11<script setup lang="ts">
2+ import type { Judge } from ' @/types/bench' ;
3+
4+ const props = defineProps <{
5+ judge: Judge
6+ }>()
7+
8+ const judge = props .judge
9+
210const showCopiedFeedback = ref (false )
311
4- const copyProfileLink = () => {
12+ const shareProfile = async () => {
513 const url = window .location .href
6- navigator .clipboard .writeText (url )
7- showCopiedFeedback .value = true
8- setTimeout (() => {
9- showCopiedFeedback .value = false
10- }, 2000 )
14+ const title = ' Judge Profile'
15+
16+ if (navigator .share ) {
17+ try {
18+ await navigator .share ({
19+ title ,
20+ url ,
21+ })
22+ } catch (err ) {
23+ // User cancelled or share failed
24+ console .error (' Error sharing:' , err )
25+ }
26+ } else {
27+ // Fallback to copy
28+ navigator .clipboard .writeText (url )
29+ showCopiedFeedback .value = true
30+ setTimeout (() => {
31+ showCopiedFeedback .value = false
32+ }, 2000 )
33+ }
1134}
1235 </script >
1336
@@ -30,11 +53,11 @@ const copyProfileLink = () => {
3053 <button
3154 type =" button"
3255 class =" hidden text-sm/6 font-semibold text-gray-900 sm:block"
33- @click =" copyProfileLink "
56+ @click =" shareProfile "
3457 >
35- {{ showCopiedFeedback ? 'Copied!' : 'Copy Profile Link ' }}
58+ {{ showCopiedFeedback ? 'Copied!' : 'Share Profile' }}
3659 </button >
37- <router-link to =" /review" class =" hidden text-sm/6 font-semibold text-gray-900 sm:block" >Write Review</router-link >
60+ <router-link : to =" ` /review/judge/${judge.id}` " class =" hidden text-sm/6 font-semibold text-gray-900 sm:block" >Write Review</router-link >
3861 <a href =" #" class =" rounded-md bg-gray-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-gray-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-600" >Follow</a >
3962
4063 <div class =" relative sm:hidden" >
@@ -46,7 +69,7 @@ const copyProfileLink = () => {
4669 </button >
4770
4871 <div class =" absolute right-0 z-10 mt-0.5 w-32 origin-top-right rounded-md bg-white py-2 shadow-lg ring-1 ring-gray-900/5 focus:outline-none" role =" menu" aria-orientation =" vertical" aria-labelledby =" more-menu-button" tabindex =" -1" >
49- <button type =" button" class =" block w-full px-3 py-1 text-left text-sm/6 text-gray-900" role =" menuitem" tabindex =" -1" id =" more-menu-item-0" >Share Profile</button >
72+ <button type =" button" class =" block w-full px-3 py-1 text-left text-sm/6 text-gray-900" role =" menuitem" tabindex =" -1" id =" more-menu-item-0" @click = " shareProfile " >Share Profile</button >
5073 <router-link to =" /review" class =" block px-3 py-1 text-sm/6 text-gray-900" role =" menuitem" tabindex =" -1" id =" more-menu-item-1" >Write Review</router-link >
5174 </div >
5275 </div >
0 commit comments