add char limit and toasts
This commit is contained in:
@ -3,8 +3,10 @@
|
||||
import { ReactElement, useState } from "react";
|
||||
import { ActionMenu } from "@/app/components/action-menu";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { useToast } from "@/app/components/ui/use-toast";
|
||||
|
||||
export default function Home(): ReactElement {
|
||||
const { toast } = useToast();
|
||||
const [value, setValue] = useState("");
|
||||
|
||||
/**
|
||||
@ -16,6 +18,15 @@ export default function Home(): ReactElement {
|
||||
return;
|
||||
}
|
||||
|
||||
// Limit the paste size to 400,000 characters
|
||||
if (value.length > 400_000) {
|
||||
toast({
|
||||
title: "Paste",
|
||||
description: "Pastes can't be longer than 400,000 characters",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Upload the paste to the server
|
||||
const response = await fetch(
|
||||
`${process.env.NEXT_PUBLIC_API_ENDPOINT}/upload`,
|
||||
|
Reference in New Issue
Block a user