Commishes now stay on the settings page when saving, with a Sonner toast confirming the save rather than being navigated to the league homepage. https://claude.ai/code/session_01PewdKxVfAbqasJbmk2UGw4
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
export type SettingsActionData =
|
|
| {
|
|
section?: string;
|
|
error?: string;
|
|
testSuccess?: boolean;
|
|
success?: boolean;
|
|
message?: string;
|
|
}
|
|
| undefined;
|
|
|
|
export function SettingsMessage({ actionData }: { actionData: SettingsActionData }) {
|
|
if (!actionData) return null;
|
|
if (actionData.section === "draft-order") return null;
|
|
if (actionData.error) {
|
|
return (
|
|
<div className="rounded-md bg-destructive/15 px-4 py-3 text-sm text-destructive">
|
|
{actionData.error}
|
|
</div>
|
|
);
|
|
}
|
|
if (actionData.testSuccess) {
|
|
return (
|
|
<div className="rounded-md bg-emerald-500/15 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-300">
|
|
Test notification sent to Discord.
|
|
</div>
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export function DraftOrderMessage({ actionData }: { actionData: SettingsActionData }) {
|
|
if (!actionData || actionData.section !== "draft-order") return null;
|
|
if (actionData.error) {
|
|
return (
|
|
<div className="rounded-md bg-destructive/15 px-4 py-3 text-sm text-destructive">
|
|
{actionData.error}
|
|
</div>
|
|
);
|
|
}
|
|
if (actionData.success && actionData.message) {
|
|
return (
|
|
<div className="rounded-md bg-emerald-500/15 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-300">
|
|
{actionData.message}
|
|
</div>
|
|
);
|
|
}
|
|
return null;
|
|
}
|