feat(dashboard): add share button with clipboard fallback
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
import { useState, useEffect } from "react"
|
import { useState, useEffect } from "react"
|
||||||
import { format, eachDayOfInterval, isSameDay } from "date-fns"
|
import { format, eachDayOfInterval, isSameDay } from "date-fns"
|
||||||
import { de, enUS } from "date-fns/locale"
|
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 { toast } from "sonner"
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
@@ -220,6 +220,25 @@ export function PlanDashboard({ plan, dict, settingsDict, lang }: PlanDashboardP
|
|||||||
dict={settingsDict}
|
dict={settingsDict}
|
||||||
lang={lang}
|
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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,10 @@
|
|||||||
"instructionsTitle": "Katzenpflege-Anleitungen",
|
"instructionsTitle": "Katzenpflege-Anleitungen",
|
||||||
"export": "Exportieren",
|
"export": "Exportieren",
|
||||||
"settings": "Einstellungen",
|
"settings": "Einstellungen",
|
||||||
|
"share": "Teilen",
|
||||||
|
"shareTitle": "Plan teilen",
|
||||||
|
"copySuccess": "Link kopiert!",
|
||||||
|
"shareError": "Fehler beim Teilen.",
|
||||||
"feeding": "Füttern",
|
"feeding": "Füttern",
|
||||||
"litter": "Klo reinigen",
|
"litter": "Klo reinigen",
|
||||||
"ownerHome": "Besitzer zu Hause",
|
"ownerHome": "Besitzer zu Hause",
|
||||||
|
|||||||
@@ -38,6 +38,10 @@
|
|||||||
"instructionsTitle": "Cat Care Instructions",
|
"instructionsTitle": "Cat Care Instructions",
|
||||||
"export": "Export",
|
"export": "Export",
|
||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
|
"share": "Share",
|
||||||
|
"shareTitle": "Share Plan",
|
||||||
|
"copySuccess": "Link copied to clipboard!",
|
||||||
|
"shareError": "Could not share plan.",
|
||||||
"feeding": "Feeding",
|
"feeding": "Feeding",
|
||||||
"litter": "Clean litter",
|
"litter": "Clean litter",
|
||||||
"ownerHome": "Owner Home",
|
"ownerHome": "Owner Home",
|
||||||
|
|||||||
Reference in New Issue
Block a user