fix: Suppression de la top bar admin [#34]

This commit is contained in:
Luc SORIGNET
2025-05-17 12:23:56 +02:00
parent f252efdef4
commit 3990d75e52
7 changed files with 152 additions and 136 deletions

View File

@ -0,0 +1,43 @@
import React, { createContext, useContext, useState, useCallback } from 'react';
import Popup from '@/components/Popup';
const PopupContext = createContext();
export const PopupProvider = ({ children }) => {
const [popupState, setPopupState] = useState({
visible: false,
message: '',
onConfirm: null,
onCancel: null,
});
const showPopup = useCallback((message, onConfirm, onCancel) => {
setPopupState({
visible: true,
message,
onConfirm: () => {
setPopupState((prev) => ({ ...prev, visible: false }));
if (onConfirm) onConfirm();
},
onCancel: () => {
setPopupState((prev) => ({ ...prev, visible: false }));
if (onCancel) onCancel();
},
});
}, []);
return (
<PopupContext.Provider value={{ showPopup }}>
<Popup
isOpen={popupState.visible}
message={popupState.message}
onConfirm={popupState.onConfirm}
onCancel={popupState.onCancel}
popupClassName="fixed z-[9999] inset-0 flex items-center justify-center"
/>
{children}
</PopupContext.Provider>
);
};
export const usePopup = () => useContext(PopupContext);