From b413c2cb5da3da6c9f94123eccdd470a40b49009 Mon Sep 17 00:00:00 2001 From: Vijesh Shetty Date: Mon, 17 Jun 2024 10:20:02 +0530 Subject: [PATCH] fix home page bug --- app/page.tsx | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index de3c614..103253d 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -14,6 +14,7 @@ import { useEffect, useState } from "react"; import { publicLinkType } from "@/interfaces/types"; import parsePublicRecords from "@/lib/actions/parsePublicRecords"; import { GitHubLogoIcon } from "@radix-ui/react-icons"; +import { HTTP_STATUS } from "@/lib/constants"; export default function Home() { const router = useRouter(); @@ -47,6 +48,21 @@ export default function Home() { form.append("long_url", long_url); const response = await createPublicUrl(form); + if(response.status == HTTP_STATUS.BAD_REQUEST){ + toast({ + title: "URL is not valid", + variant:"destructive" + }); + setLongurlInput(""); + return; + } else if(response.status == HTTP_STATUS.INTERNAL_SERVER_ERROR){ + toast({ + title: "Error while shortening the link", + variant:"destructive" + }); + return; + } + toast({ title: "Short link generated successfully!!", description: "The link is valid only for 2hrs!!", @@ -101,17 +117,7 @@ export default function Home() { className="mt-6" />
- {publicLinks.map((link) => ( - - ))} - {loading? ( -
- - -
- ) : ( -
- )} + {publicLinks.map((link)=>)}