feat: update label

This commit is contained in:
Henry
2024-08-27 23:34:52 +01:00
parent 2adcac85a4
commit 583256a46b
6 changed files with 145 additions and 38 deletions

View File

@@ -2,9 +2,10 @@ import { createContext, useContext, useState } from "react";
type ModalContextType = {
isOpen: boolean;
openModal: (contentType: string) => void;
openModal: (contentType: string, entityId?: string) => void;
closeModal: () => void;
modalContentType: string;
entityId: string;
};
interface Props {
@@ -15,11 +16,13 @@ const ModalContext = createContext<ModalContextType | undefined>(undefined);
export const ModalProvider: React.FC<Props> = ({ children }) => {
const [isOpen, setIsOpen] = useState(false);
const [entityId, setEntityId] = useState("");
const [modalContentType, setModalContentType] = useState("");
const openModal = (contentType: string) => {
const openModal = (contentType: string, entityId?: string) => {
setIsOpen(true);
setModalContentType(contentType);
if (entityId) setEntityId(entityId);
};
const closeModal = () => {
@@ -28,7 +31,7 @@ export const ModalProvider: React.FC<Props> = ({ children }) => {
return (
<ModalContext.Provider
value={{ isOpen, openModal, closeModal, modalContentType }}
value={{ isOpen, openModal, closeModal, modalContentType, entityId }}
>
{children}
</ModalContext.Provider>