Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
2.0 kB ยท 72 lines
TSX
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273import type { ExternalToast } from "sonner";import { toast } from "sonner";
type ToastType = | "default" | "description" | "success" | "warning" | "info" | "error" | "promise";
const config = { error: { type: "error", title: "Something went wrong", description: "Please try again", action: { label: "Discord", onClick: () => { if (typeof window === "undefined") return; window.open("/discord", "_blank"); }, }, }, "unique-slug": { type: "warning", title: "Slug is already taken", description: "Please select another slug. Every slug is unique.", }, success: { type: "success", title: "Success" }, deleted: { type: "success", title: "Deleted successfully" }, // TODO: we are not informing the user besides the visual changes when an entry has been deleted removed: { type: "success", title: "Removed successfully" }, saved: { type: "success", title: "Saved successfully" }, "test-error": { type: "error", title: "Connection Failed", description: "Please enter a correct URL", }, "test-warning-empty-url": { type: "warning", title: "URL is Empty", description: "Please enter a valid, non-empty URL", }, "test-success": { type: "success", title: "Connection Established", },} as const;
const _config: Record< string, Pick<ExternalToast, "action" | "description"> & { type: ToastType; title: string; }> = config;
type ToastAction = keyof typeof config;
export function toastAction(action: ToastAction) { const { title, type, ...props } = _config[action];
if (type === "default") return toast(title, props); if (type === "success") return toast.success(title, props); if (type === "error") return toast.error(title, props); if (type === "warning") return toast.warning(title, props); if (type === "description") return toast.message(title, props); if (type === "info") return toast.info(title, props);}
export { toast };