add char limit and toasts
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m20s
Publish Docker Image / docker (ubuntu-latest) (push) Successful in 1m11s

This commit is contained in:
Lee
2024-04-23 17:44:15 +01:00
parent 615e8cd2be
commit 43558604c0
7 changed files with 616 additions and 1 deletions

View File

@ -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`,