Replace sonner toasts with one top-centre notification stack
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`.
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
import { toast } from "sonner"
|
||||
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) => {
|
||||
toast.success("Success!", {
|
||||
description,
|
||||
})
|
||||
notify(description, "success")
|
||||
}
|
||||
|
||||
const showErrorToast = (description: string) => {
|
||||
toast.error("Something went wrong!", {
|
||||
description,
|
||||
})
|
||||
notify(description, "error")
|
||||
}
|
||||
|
||||
return { showSuccessToast, showErrorToast }
|
||||
|
||||
Reference in New Issue
Block a user