Skip to content

Commit

Permalink
quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VijeshVS committed Jun 2, 2024
1 parent 77085d9 commit f0a6322
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/app/(dashboard)/links/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default function Page(params : any) {
<Copy size={15} className="mr-2" />
Copy
</Button>
<LinkShareDialog link={fetchLink}>
<LinkShareDialog shortCode={shortCode} link={fetchLink}>
<Button variant="outline" className="ml-2">
<Share2 size={15} className="mr-2" />
Share
Expand Down Expand Up @@ -143,7 +143,7 @@ export default function Page(params : any) {
<Button onClick={()=>{copyToClipboard(shortLink)}} variant="outline">
<Copy size={15} />
</Button>
<LinkShareDialog link={fetchLink}>
<LinkShareDialog shortCode={shortCode} link={fetchLink}>
<Button variant="outline" className="ml-2">
<Share2 size={15} />
</Button>
Expand Down
9 changes: 8 additions & 1 deletion app/app/(dashboard)/links/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ export default function CreatePage() {
description: "Please try again",
variant: "destructive",
});
} else {
}else if (res.status == HTTP_STATUS.CONFLICT) {
toast({
title: "The short code has already been in use",
description:"Please try different shortcode",
variant:"destructive"
})
}
else{
toast({
title: "Error while shortening the link",
description: "Please try again",
Expand Down
4 changes: 2 additions & 2 deletions components/CardComponents/LinkCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function LinkCard({
<Copy size={15} className="mr-2" />
Copy
</Button>
<LinkShareDialog link={link}>
<LinkShareDialog shortCode={shortCode} link={link}>
<Button variant="outline" className="ml-2">
<Share2 size={15} className="mr-2" />
Share
Expand Down Expand Up @@ -106,7 +106,7 @@ export function LinkCard({
<Button onClick={()=>{copyToClipboard(shortLink)}} variant="outline">
<Copy size={15} />
</Button>
<LinkShareDialog link={link}>
<LinkShareDialog shortCode={shortCode} link={link}>
<Button variant="outline" className="ml-2">
<Share2 size={15} />
</Button>
Expand Down
7 changes: 4 additions & 3 deletions components/DialogComponents/LinkShareDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import {
import { TwitterLogoIcon } from "@radix-ui/react-icons"
import { linkType } from "@/interfaces/types"

export function LinkShareDialog({children,link}:{
export function LinkShareDialog({children,link,shortCode}:{
children : React.ReactNode,
link: linkType
link: linkType,
shortCode: string
}) {

const REDIRECT_URL:string = process.env.REDIRECT_URL || "https://eurl.dev";
const shortLink:string = `${REDIRECT_URL}/${link.short_code}`
const shortLink:string = `${REDIRECT_URL}/${shortCode}`

function copyToClipboard(){
navigator.clipboard.writeText(shortLink);
Expand Down

0 comments on commit f0a6322

Please sign in to comment.