@@ -92,8 +92,6 @@ export interface CapCardProps extends PropsWithChildren {
9292 sharedCapCard ?: boolean ;
9393 isSelected ?: boolean ;
9494 onSelectToggle ?: ( ) => void ;
95- customDomain ?: string | null ;
96- domainVerified ?: boolean ;
9795 hideSharedStatus ?: boolean ;
9896 anyCapSelected ?: boolean ;
9997 isDeleting ?: boolean ;
@@ -110,13 +108,15 @@ export const CapCard = ({
110108 isLoadingAnalytics,
111109 sharedCapCard = false ,
112110 hideSharedStatus = false ,
113- customDomain,
114- domainVerified,
115111 isSelected = false ,
116112 onSelectToggle,
117113 anyCapSelected = false ,
118114 isDeleting = false ,
119115} : CapCardProps ) => {
116+ const { activeOrganization } = useDashboardContext ( ) ;
117+ const customDomain = activeOrganization ?. organization . customDomain ;
118+ const domainVerified = activeOrganization ?. organization . domainVerified ;
119+
120120 const [ isSharingDialogOpen , setIsSharingDialogOpen ] = useState ( false ) ;
121121 const [ isPasswordDialogOpen , setIsPasswordDialogOpen ] = useState ( false ) ;
122122 const [ isDropdownOpen , setIsDropdownOpen ] = useState ( false ) ;
@@ -294,6 +294,18 @@ export const CapCard = ({
294294 }
295295 } ;
296296
297+ const copyLinkHandler = ( ) => {
298+ handleCopy (
299+ NODE_ENV === "development"
300+ ? `${ webUrl } /s/${ cap . id } `
301+ : buildEnv . NEXT_PUBLIC_IS_CAP && customDomain && domainVerified
302+ ? `https://${ customDomain } /s/${ cap . id } `
303+ : buildEnv . NEXT_PUBLIC_IS_CAP && ! customDomain && ! domainVerified
304+ ? `https://cap.link/${ cap . id } `
305+ : `${ webUrl } /s/${ cap . id } ` ,
306+ ) ;
307+ } ;
308+
297309 return (
298310 < >
299311 < SharingDialog
@@ -376,45 +388,31 @@ export const CapCard = ({
376388 tooltipContent = "Copy link"
377389 onClick = { ( e ) => {
378390 e . stopPropagation ( ) ;
379- handleCopy (
380- NODE_ENV === "development"
381- ? `${ webUrl } /s/${ cap . id } `
382- : buildEnv . NEXT_PUBLIC_IS_CAP &&
383- customDomain &&
384- domainVerified
385- ? `https://${ customDomain } /s/${ cap . id } `
386- : buildEnv . NEXT_PUBLIC_IS_CAP &&
387- ! customDomain &&
388- ! domainVerified
389- ? `https://cap.link/${ cap . id } `
390- : `${ webUrl } /s/${ cap . id } ` ,
391- ) ;
391+ copyLinkHandler ( ) ;
392392 } }
393393 className = "delay-0"
394394 icon = {
395- < >
396- { ! copyPressed ? (
397- < FontAwesomeIcon
398- className = "text-gray-12 size-4"
399- icon = { faLink }
400- />
401- ) : (
402- < svg
403- xmlns = "http://www.w3.org/2000/svg"
404- width = "24"
405- height = "24"
406- viewBox = "0 0 24 24"
407- fill = "none"
408- stroke = "currentColor"
409- strokeWidth = "2"
410- strokeLinecap = "round"
411- strokeLinejoin = "round"
412- className = "text-gray-12 size-5 svgpathanimation"
413- >
414- < path d = "M20 6 9 17l-5-5" />
415- </ svg >
416- ) }
417- </ >
395+ ! copyPressed ? (
396+ < FontAwesomeIcon
397+ className = "text-gray-12 size-4"
398+ icon = { faLink }
399+ />
400+ ) : (
401+ < svg
402+ xmlns = "http://www.w3.org/2000/svg"
403+ width = "24"
404+ height = "24"
405+ viewBox = "0 0 24 24"
406+ fill = "none"
407+ stroke = "currentColor"
408+ strokeWidth = "2"
409+ strokeLinecap = "round"
410+ strokeLinejoin = "round"
411+ className = "text-gray-12 size-5 svgpathanimation"
412+ >
413+ < path d = "M20 6 9 17l-5-5" />
414+ </ svg >
415+ )
418416 }
419417 />
420418 ) }
@@ -448,17 +446,7 @@ export const CapCard = ({
448446 < DropdownMenuItem
449447 onClick = { ( e ) => {
450448 e . stopPropagation ( ) ;
451- handleCopy (
452- buildEnv . NEXT_PUBLIC_IS_CAP &&
453- NODE_ENV === "production" &&
454- customDomain &&
455- domainVerified
456- ? `https://${ customDomain } /s/${ cap . id } `
457- : buildEnv . NEXT_PUBLIC_IS_CAP &&
458- NODE_ENV === "production"
459- ? `https://cap.link/${ cap . id } `
460- : `${ location . origin } /s/${ cap . id } ` ,
461- ) ;
449+ copyLinkHandler ( ) ;
462450 toast . success ( "Link copied to clipboard" ) ;
463451 } }
464452 className = "flex gap-2 items-center rounded-lg"
0 commit comments