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>
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
"instructionsTitle": "Katzenpflege-Anleitungen",
|
||||
"export": "Exportieren",
|
||||
"settings": "Einstellungen",
|
||||
"share": "Teilen",
|
||||
"shareTitle": "Plan teilen",
|
||||
"copySuccess": "Link kopiert!",
|
||||
"shareError": "Fehler beim Teilen.",
|
||||
"feeding": "Füttern",
|
||||
"litter": "Klo reinigen",
|
||||
"ownerHome": "Besitzer zu Hause",
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
"instructionsTitle": "Cat Care Instructions",
|
||||
"export": "Export",
|
||||
"settings": "Settings",
|
||||
"share": "Share",
|
||||
"shareTitle": "Share Plan",
|
||||
"copySuccess": "Link copied to clipboard!",
|
||||
"shareError": "Could not share plan.",
|
||||
"feeding": "Feeding",
|
||||
"litter": "Clean litter",
|
||||
"ownerHome": "Owner Home",
|
||||
|
||||
Reference in New Issue
Block a user