The app said things in two places: sonner's bottom-right toasts and the custom top-centre chrome. This is the second of those, generalised — a module-level store anyone can call, drawn as a stack of frosted cards that go on their own unless raised as persistent, with room for buttons and for a message longer than a line. useCustomToast keeps its signatures, so the forty-odd call sites behind it and handleError are untouched. The component and its store are byte-identical with the portal's copy and checked by `make design-check`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
24 lines
707 B
TypeScript
24 lines
707 B
TypeScript
import { notify } from "@/lib/notificationStore"
|
|
|
|
/**
|
|
* The two things most call sites have to say.
|
|
*
|
|
* A thin front on `notify` — the description is the whole message now, since a
|
|
* card that leads with "Success!" spends its first line saying nothing. Kept as
|
|
* a hook because that is how it is called everywhere; anything needing a
|
|
* severity, a button or a persistent card calls `notify` directly.
|
|
*/
|
|
const useCustomToast = () => {
|
|
const showSuccessToast = (description: string) => {
|
|
notify(description, "success")
|
|
}
|
|
|
|
const showErrorToast = (description: string) => {
|
|
notify(description, "error")
|
|
}
|
|
|
|
return { showSuccessToast, showErrorToast }
|
|
}
|
|
|
|
export default useCustomToast
|