feat: integrate sonner for toast notifications and enhance UI feedback
Added the sonner library for toast notifications across various components, improving user feedback for actions such as saving settings, syncing rules, and handling errors. Updated the layout to include a Toaster component for consistent notification display. Refactored alert messages in the backups, gre, and filters pages to utilize the new notification system, enhancing overall user experience.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import {
|
||||
eventListSchema,
|
||||
listEventsQuerySchema,
|
||||
type EventItem,
|
||||
type ListEventsQuery,
|
||||
} from "@/packages/contracts/src/events"
|
||||
import { requestJson } from "@/shared/api/http-client"
|
||||
|
||||
type ListEventsResponse = {
|
||||
events: unknown
|
||||
}
|
||||
|
||||
export async function listEvents(
|
||||
baseUrl: string,
|
||||
query: Partial<ListEventsQuery> = {},
|
||||
): Promise<EventItem[]> {
|
||||
const parsedQuery = listEventsQuerySchema.parse(query)
|
||||
const search = new URLSearchParams()
|
||||
search.set("limit", String(parsedQuery.limit))
|
||||
if (parsedQuery.level) search.set("level", parsedQuery.level)
|
||||
if (parsedQuery.sourceModule) search.set("sourceModule", parsedQuery.sourceModule)
|
||||
if (parsedQuery.from) search.set("from", parsedQuery.from)
|
||||
if (parsedQuery.to) search.set("to", parsedQuery.to)
|
||||
const path = `/api/events?${search.toString()}`
|
||||
const payload = await requestJson<ListEventsResponse>(baseUrl, path)
|
||||
return eventListSchema.parse(payload.events)
|
||||
}
|
||||
Reference in New Issue
Block a user