feat: add shared overview and harden frontend session state (#407)

This commit is contained in:
Daniel Volz
2026-03-10 06:26:03 +01:00
committed by GitHub
parent 733fe2f38a
commit 105eb7bc0d
37 changed files with 3281 additions and 1138 deletions
+66
View File
@@ -4,6 +4,7 @@
*/
import { Check, Copy, Link2, X } from "lucide-react";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
export interface ShareDialogProps {
@@ -40,8 +41,49 @@ export function ShareDialog({
onCopyShareLink,
}: ShareDialogProps) {
const { t } = useTranslation();
const [overviewCopied, setOverviewCopied] = useState(false);
const closeLabel = t("common.close");
const copyLabel = shareCopied ? t("share.copied") : t("share.copyLink");
const overviewCopyLabel = overviewCopied ? t("share.copied") : t("share.copyOverviewLink");
const overviewLink = shareLink ? `${shareLink}/overview` : null;
useEffect(() => {
if (!shareLink) {
setOverviewCopied(false);
}
}, [shareLink]);
const copyOverviewLink = async () => {
if (!overviewLink) return;
const markCopied = () => {
setOverviewCopied(true);
setTimeout(() => setOverviewCopied(false), 2000);
};
if (navigator.clipboard?.writeText) {
try {
await navigator.clipboard.writeText(overviewLink);
markCopied();
return;
} catch {
// Fall back to textarea-based copy.
}
}
const textarea = document.createElement("textarea");
textarea.value = overviewLink;
textarea.style.position = "fixed";
textarea.style.opacity = "0";
document.body.appendChild(textarea);
textarea.select();
try {
document.execCommand("copy");
markCopied();
} finally {
document.body.removeChild(textarea);
}
};
// ESC is handled by the global handler in App.tsx to avoid double history.back()
@@ -91,6 +133,7 @@ export function ShareDialog({
return (
<div className="share-dialog-result">
<p className="share-success">{t("share.linkGenerated")}</p>
<p className="share-link-label">{t("share.scheduleLink")}</p>
<div className="share-link-box">
<input
type="text"
@@ -109,13 +152,34 @@ export function ShareDialog({
{shareCopied ? <Check size={18} aria-hidden="true" /> : <Copy size={18} aria-hidden="true" />}
</button>
</div>
<p className="share-link-label">{t("share.overviewLink")}</p>
<div className="share-link-box">
<input
type="text"
value={overviewLink ?? ""}
readOnly
className="share-link-input"
onClick={(e) => (e.target as HTMLInputElement).select()}
/>
<button
type="button"
className="btn-copy icon-only tooltip-trigger"
onClick={copyOverviewLink}
aria-label={overviewCopyLabel}
data-tooltip={overviewCopyLabel}
>
{overviewCopied ? <Check size={18} aria-hidden="true" /> : <Copy size={18} aria-hidden="true" />}
</button>
</div>
{shareCopied && <span className="share-copied-hint">{t("share.copied")}</span>}
{overviewCopied && <span className="share-copied-hint">{t("share.copied")}</span>}
<div className="share-dialog-footer">
<button
className="ghost"
onClick={() => {
onShareLinkChange(null);
onShareCopiedChange(false);
setOverviewCopied(false);
}}
>
{t("share.generateAnother")}
@@ -131,6 +195,7 @@ export function ShareDialog({
<label htmlFor="share-person-select">{t("share.selectPerson")}</label>
<select
id="share-person-select"
className="select-field"
value={shareSelectedPerson}
onChange={(e) => onShareSelectedPersonChange(e.target.value)}
>
@@ -146,6 +211,7 @@ export function ShareDialog({
<label htmlFor="share-period-select">{t("share.selectPeriod")}</label>
<select
id="share-period-select"
className="select-field"
value={shareSelectedDays}
onChange={(e) => onShareSelectedDaysChange(Number(e.target.value))}
>