1- import { useState , useCallback } from 'react' ;
21import { useMutation , useQuery , useQueryClient } from '@tanstack/react-query' ;
3- import { toast } from 'sonner' ;
42import { Copy , Trash2 , RefreshCw , Link , Eye , EyeOff } from 'lucide-react' ;
5- import {
6- Dialog ,
7- DialogContent ,
8- DialogHeader ,
9- DialogTitle ,
10- } from '@/components/ui/dialog' ;
3+ import { useState , useCallback } from 'react' ;
4+ import { toast } from 'sonner' ;
5+
116import { Button } from '@/components/ui/button' ;
7+ import { Dialog , DialogContent , DialogHeader , DialogTitle } from '@/components/ui/dialog' ;
128import { Input } from '@/components/ui/input' ;
139import { Label } from '@/components/ui/label' ;
1410import { Switch } from '@/components/ui/switch' ;
15- import {
16- createShareLink ,
17- getShareLink ,
18- revokeShareLink ,
19- } from '@/services/api/shareLinkService' ;
20- import type { CreateShareLinkRequest } from '@/types/shareLink' ;
2111import { ApiError } from '@/services/api/apiClient' ;
12+ import { createShareLink , getShareLink , revokeShareLink } from '@/services/api/shareLinkService' ;
13+ import type { CreateShareLinkRequest } from '@/types/shareLink' ;
2214
2315interface ShareDialogProps {
2416 entryId : string ;
@@ -76,17 +68,20 @@ export function ShareDialog({ entryId, open, onOpenChange }: ShareDialogProps) {
7668 createMutation . mutate ( req ) ;
7769 } , [ useExpiry , expiresAt , usePassword , password , createMutation ] ) ;
7870
79- const handleCopy = useCallback ( async ( token ?: string ) => {
80- const t = token ?? createdToken ;
81- if ( ! t ) return ;
82- const url = `${ window . location . origin } /share/${ encodeURIComponent ( t ) } ` ;
83- try {
84- await navigator . clipboard . writeText ( url ) ;
85- toast . success ( 'Link copied to clipboard' ) ;
86- } catch {
87- toast . error ( 'Failed to copy to clipboard' ) ;
88- }
89- } , [ createdToken ] ) ;
71+ const handleCopy = useCallback (
72+ async ( token ?: string ) => {
73+ const t = token ?? createdToken ;
74+ if ( ! t ) return ;
75+ const url = `${ window . location . origin } /share/${ encodeURIComponent ( t ) } ` ;
76+ try {
77+ await navigator . clipboard . writeText ( url ) ;
78+ toast . success ( 'Link copied to clipboard' ) ;
79+ } catch {
80+ toast . error ( 'Failed to copy to clipboard' ) ;
81+ }
82+ } ,
83+ [ createdToken ]
84+ ) ;
9085
9186 const existingLink = linkQuery . data ;
9287 const hasLink = ! ! existingLink && ! linkQuery . error ;
@@ -185,11 +180,7 @@ export function ShareDialog({ entryId, open, onOpenChange }: ShareDialogProps) {
185180 < div >
186181 < Label className = "text-xs text-muted-foreground mb-1.5 block" > Share URL</ Label >
187182 < div className = "flex gap-2" >
188- < Input
189- readOnly
190- value = { shareUrl ?? '' }
191- className = "text-xs font-mono"
192- />
183+ < Input readOnly value = { shareUrl ?? '' } className = "text-xs font-mono" />
193184 < Button variant = "outline" size = "icon" onClick = { ( ) => handleCopy ( ) } >
194185 < Copy className = "h-4 w-4" />
195186 </ Button >
@@ -221,11 +212,7 @@ export function ShareDialog({ entryId, open, onOpenChange }: ShareDialogProps) {
221212 < Label htmlFor = "use-expiry" className = "text-sm" >
222213 Set expiration
223214 </ Label >
224- < Switch
225- id = "use-expiry"
226- checked = { useExpiry }
227- onCheckedChange = { setUseExpiry }
228- />
215+ < Switch id = "use-expiry" checked = { useExpiry } onCheckedChange = { setUseExpiry } />
229216 </ div >
230217 { useExpiry && (
231218 < Input
@@ -240,11 +227,7 @@ export function ShareDialog({ entryId, open, onOpenChange }: ShareDialogProps) {
240227 < Label htmlFor = "use-password" className = "text-sm" >
241228 Password protect
242229 </ Label >
243- < Switch
244- id = "use-password"
245- checked = { usePassword }
246- onCheckedChange = { setUsePassword }
247- />
230+ < Switch id = "use-password" checked = { usePassword } onCheckedChange = { setUsePassword } />
248231 </ div >
249232 { usePassword && (
250233 < >
0 commit comments