docs: add a need help button (#8069)
* docs: add a need help button * change github issue link * responsive fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import React, { createContext, useContext, useReducer } from "react"
|
||||
import React, { createContext, useContext, useMemo, useReducer } from "react"
|
||||
import { NotificationItemProps, NotificationContainer } from "@/components"
|
||||
import uuid from "react-uuid"
|
||||
|
||||
@@ -69,15 +69,27 @@ const NotificationContext = createContext<NotificationContextType | null>(null)
|
||||
|
||||
export type NotificationProviderProps = {
|
||||
children?: React.ReactNode
|
||||
initial?: NotificationItemType[]
|
||||
}
|
||||
|
||||
export const NotificationProvider = ({
|
||||
children,
|
||||
initial = [],
|
||||
}: NotificationProviderProps) => {
|
||||
const [notifications, dispatch] = useReducer(notificationReducer, [])
|
||||
|
||||
const generateId = () => uuid()
|
||||
|
||||
const normalizedInitial = useMemo(() => {
|
||||
return initial.map((notif) => ({
|
||||
id: generateId(),
|
||||
...notif,
|
||||
}))
|
||||
}, [initial])
|
||||
|
||||
const [notifications, dispatch] = useReducer(
|
||||
notificationReducer,
|
||||
normalizedInitial
|
||||
)
|
||||
|
||||
const addNotification = (notification: NotificationItemType) => {
|
||||
if (!notification.id) {
|
||||
notification.id = generateId()
|
||||
|
||||
Reference in New Issue
Block a user