Files
web/apps/scandic-web/components/MyPages/ProfilingConsent/Alert/AlertContext.tsx
Matilda Landström 26f3b5bdd0 Merged in feat/LOY-484-consent-alert (pull request #3184)
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)
2025-11-26 12:13:04 +00:00

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)