21 lines
695 B
TypeScript
21 lines
695 B
TypeScript
// src/contexts/ModalContext.ts
|
|
import { createContext } from 'react';
|
|
|
|
/**
|
|
* Defines the names of all modals used in the application.
|
|
* Using a type ensures consistency and prevents typos.
|
|
*/
|
|
export type ModalType = 'profile' | 'voiceAssistant' | 'whatsNew' | 'correctionTool';
|
|
|
|
/**
|
|
* Defines the shape of the context that will be provided to consumers.
|
|
*/
|
|
export interface ModalContextType {
|
|
openModal: (modal: ModalType) => void;
|
|
closeModal: (modal: ModalType) => void;
|
|
isModalOpen: (modal: ModalType) => boolean;
|
|
}
|
|
|
|
// Create the context with a default value (which should not be used directly).
|
|
export const ModalContext = createContext<ModalContextType | undefined>(undefined);
|