56 lines
1.6 KiB
TypeScript
56 lines
1.6 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>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
if (actionData.success) {
|
||
|
|
return (
|
||
|
|
<div className="rounded-md bg-emerald-500/15 px-4 py-3 text-sm text-emerald-700 dark:text-emerald-300">
|
||
|
|
{actionData.message ?? "Settings updated successfully."}
|
||
|
|
</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;
|
||
|
|
}
|