docs: add a need help button (#8069)

* docs: add a need help button

* change github issue link

* responsive fixes
This commit is contained in:
Shahed Nasser
2024-07-11 10:29:13 +03:00
committed by GitHub
parent f460348280
commit a8df528c65
23 changed files with 219 additions and 107 deletions
@@ -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()