diff --git a/src/App.tsx b/src/App.tsx index 8ad23207..5499dba1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,3 +1,4 @@ +import { DireProvider } from "./Context/DireContext"; import AppRoutes from "./router/AppRoutes"; import { ToastContainer } from "react-toastify"; @@ -5,8 +6,13 @@ import { ToastContainer } from "react-toastify"; const App = () => { return (
- - + + + + + + +
); diff --git a/src/Context/DireContext.jsx b/src/Context/DireContext.jsx new file mode 100644 index 00000000..a8e842e9 --- /dev/null +++ b/src/Context/DireContext.jsx @@ -0,0 +1,21 @@ +import React, { createContext, useContext, useState } from "react"; + +const DireContext = createContext(undefined); + +export const DireProvider = ({ children }) => { + const [dirActions, setDirActions] = useState([]); + + return ( + + {children} + + ); +}; + +export const useDir = () => { + const context = useContext(DireContext); + if (!context) { + throw new Error("useDir must be used within a "); + } + return context; +}; diff --git a/src/components/Directory/CardViewDirectory.jsx b/src/components/Directory/CardViewDirectory.jsx index 1dc16cec..33fcad6f 100644 --- a/src/components/Directory/CardViewDirectory.jsx +++ b/src/components/Directory/CardViewDirectory.jsx @@ -3,6 +3,7 @@ import Avatar from "../common/Avatar"; import { getBucketNameById } from "./DirectoryUtils"; import { useBuckets } from "../../hooks/useDirectory"; import { getPhoneIcon } from "./DirectoryUtils"; +import { useDir } from "../../Context/DireContext"; const CardViewDirectory = ({ IsActive, contact, @@ -11,8 +12,10 @@ const CardViewDirectory = ({ setOpen_contact, setIsOpenModalNote, IsDeleted, + restore, }) => { const { buckets } = useBuckets(); + const { dirActions, setDirActions } = useDir(); return (
{" "} - {contact.name} + {contact.name}
-
- -
+ + + Modify + + +
  • + IsDeleted(contact.id)} + > + + Delete + +
  • + +
    + )} + {!IsActive && ( + { + setDirActions({ action: false, id: contact.id }); + restore(contact.id); + }} + > + )}