feat(dashboard): add share button with clipboard fallback
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { useState, useEffect } from "react"
|
||||
import { format, eachDayOfInterval, isSameDay } from "date-fns"
|
||||
import { de, enUS } from "date-fns/locale"
|
||||
import { CalendarIcon, User, Home, X, Info, Utensils, Trash2, Check } from "lucide-react"
|
||||
import { CalendarIcon, User, Home, X, Info, Utensils, Trash2, Check, Share2 } from "lucide-react"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
@@ -220,6 +220,25 @@ export function PlanDashboard({ plan, dict, settingsDict, lang }: PlanDashboardP
|
||||
dict={settingsDict}
|
||||
lang={lang}
|
||||
/>
|
||||
<Button variant="outline" size="sm" onClick={() => {
|
||||
if (navigator.share) {
|
||||
navigator.share({
|
||||
title: plan.title,
|
||||
text: dict.shareTitle,
|
||||
url: window.location.href,
|
||||
}).catch(() => {
|
||||
// Fallback if share fails / is cancelled
|
||||
navigator.clipboard.writeText(window.location.href)
|
||||
toast.success(dict.copySuccess)
|
||||
})
|
||||
} else {
|
||||
navigator.clipboard.writeText(window.location.href)
|
||||
toast.success(dict.copySuccess)
|
||||
}
|
||||
}}>
|
||||
<Share2 className="w-4 h-4 mr-2" />
|
||||
{dict.share}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user