Skip to content

Commit

Permalink
fix home page bug
Browse files Browse the repository at this point in the history
  • Loading branch information
VijeshVS committed Jun 17, 2024
1 parent 90e6ca6 commit b413c2c
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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!!",
Expand Down Expand Up @@ -101,17 +117,7 @@ export default function Home() {
className="mt-6"
/>
<div className="mt-6">
{publicLinks.map((link) => (
<LinkCardComponent key={link.shortUrl} publicLink={link} />
))}
{loading? (
<div>
<LinkCardSkeleton />
<LinkCardSkeleton />
</div>
) : (
<div></div>
)}
{publicLinks.map((link)=><LinkCardComponent key={link.shortUrl} publicLink={link} />)}
<div className="mt-6 flex justify-center">
<Card className="w-fit max-w-[500px] flex items-center">
<CardContent className="mt-4 flex">
Expand Down

0 comments on commit b413c2c

Please sign in to comment.