feat(LOY-484): Change toast to alert for Profiling Consent * feat(LOY-484): change toast to alert using context * refactor(LOY-484): remove uneccesary code * chore(LOY-484): small UI fixes Approved-by: Chuma Mcphoy (We Ahead)
31 lines
825 B
TypeScript
31 lines
825 B
TypeScript
"use client"
|
|
import { createContext, type ReactNode, useContext, useState } from "react"
|
|
|
|
import type { AlertTypeEnum } from "@scandic-hotels/common/constants/alert"
|
|
|
|
type AlertType = AlertTypeEnum.Success | AlertTypeEnum.Alarm
|
|
|
|
const ProfilingConsentAlertContext = createContext<{
|
|
alertType: AlertType | null
|
|
setAlertType: (data: AlertType | null) => void
|
|
}>({
|
|
alertType: null,
|
|
setAlertType: () => {},
|
|
})
|
|
|
|
export function ProfilingConsentAlertProvider({
|
|
children,
|
|
}: {
|
|
children: ReactNode
|
|
}) {
|
|
const [alertType, setAlertType] = useState<AlertType | null>(null)
|
|
return (
|
|
<ProfilingConsentAlertContext.Provider value={{ alertType, setAlertType }}>
|
|
{children}
|
|
</ProfilingConsentAlertContext.Provider>
|
|
)
|
|
}
|
|
|
|
export const useProfilingConsentAlert = () =>
|
|
useContext(ProfilingConsentAlertContext)
|