added float button
This commit is contained in:
parent
16389bf102
commit
eb6d4e413d
@ -18,6 +18,7 @@ import ConfirmModal from "../../components/common/ConfirmModal";
|
|||||||
import DirectoryListTableHeader from "./DirectoryListTableHeader";
|
import DirectoryListTableHeader from "./DirectoryListTableHeader";
|
||||||
import DirectoryPageHeader from "./DirectoryPageHeader";
|
import DirectoryPageHeader from "./DirectoryPageHeader";
|
||||||
import ManageBucket from "../../components/Directory/ManageBucket";
|
import ManageBucket from "../../components/Directory/ManageBucket";
|
||||||
|
import {useFab} from "../../Context/FabContext";
|
||||||
|
|
||||||
const Directory = () =>
|
const Directory = () =>
|
||||||
{
|
{
|
||||||
@ -36,11 +37,12 @@ const Directory = () =>
|
|||||||
const [openBucketModal,setOpenBucketModal] = useState(false)
|
const [openBucketModal,setOpenBucketModal] = useState(false)
|
||||||
|
|
||||||
const [tempSelectedBucketIds, setTempSelectedBucketIds] = useState([]);
|
const [tempSelectedBucketIds, setTempSelectedBucketIds] = useState([]);
|
||||||
const [tempSelectedCategoryIds, setTempSelectedCategoryIds] = useState([]);
|
const [ tempSelectedCategoryIds, setTempSelectedCategoryIds ] = useState( [] );
|
||||||
|
const {setActions} = useFab()
|
||||||
|
|
||||||
const { contacts, loading } = useDirectory(IsActive);
|
const { contacts, loading , refetch} = useDirectory(IsActive);
|
||||||
const { contactCategory, loading: contactCategoryLoading } =
|
const { contactCategory, loading: contactCategoryLoading } =
|
||||||
useContactCategory();
|
useContactCategory();
|
||||||
const {buckets} = useBuckets();
|
const {buckets} = useBuckets();
|
||||||
|
|
||||||
const submitContact = async (data) => {
|
const submitContact = async (data) => {
|
||||||
@ -56,15 +58,17 @@ const Directory = () =>
|
|||||||
);
|
);
|
||||||
showToast("Contact updated successfully", "success");
|
showToast("Contact updated successfully", "success");
|
||||||
setIsOpenModal(false);
|
setIsOpenModal(false);
|
||||||
setSelectedContact(null);
|
setSelectedContact( null );
|
||||||
} else {
|
} else {
|
||||||
response = await DirectoryRepository.CreateContact(data);
|
response = await DirectoryRepository.CreateContact(data);
|
||||||
updatedContacts = [...contacts_cache, response.data];
|
updatedContacts = [...contacts_cache, response.data];
|
||||||
showToast("Contact created successfully", "success");
|
showToast("Contact created successfully", "success");
|
||||||
setIsOpenModal(false);
|
setIsOpenModal(false);
|
||||||
}
|
}
|
||||||
cacheData("Contacts", {data:updatedContacts,isActive:IsActive});
|
|
||||||
setContactList(updatedContacts);
|
// cacheData("Contacts", {data:updatedContacts,isActive:IsActive});
|
||||||
|
// setContactList(updatedContacts);
|
||||||
|
refetch()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const msg =
|
const msg =
|
||||||
error.response?.data?.message ||
|
error.response?.data?.message ||
|
||||||
@ -80,7 +84,7 @@ const Directory = () =>
|
|||||||
const contacts_cache = getCachedData("contacts")?.data || [];
|
const contacts_cache = getCachedData("contacts")?.data || [];
|
||||||
|
|
||||||
const response = await DirectoryRepository.DeleteContact(deleteContact);
|
const response = await DirectoryRepository.DeleteContact(deleteContact);
|
||||||
const updatedContacts = ContactList.filter((c) => c.id !== deleteContact);
|
const updatedContacts = ContactList.filter( ( c ) => c.id !== deleteContact );
|
||||||
setContactList(updatedContacts);
|
setContactList(updatedContacts);
|
||||||
cacheData("Contacts", {data:updatedContacts,isActive:IsActive});
|
cacheData("Contacts", {data:updatedContacts,isActive:IsActive});
|
||||||
showToast("Contact deleted successfully", "success");
|
showToast("Contact deleted successfully", "success");
|
||||||
@ -155,7 +159,7 @@ const Directory = () =>
|
|||||||
|
|
||||||
return matchesSearch && matchesCategory && matchesBucket;
|
return matchesSearch && matchesCategory && matchesBucket;
|
||||||
}).sort((a, b) => a.name.localeCompare(b.name));
|
}).sort((a, b) => a.name.localeCompare(b.name));
|
||||||
}, [ContactList, searchText, selectedCategoryIds, selectedBucketIds]);
|
}, [ContactList, searchText, selectedCategoryIds, selectedBucketIds,selectedContact]);
|
||||||
|
|
||||||
const applyFilter = () => {
|
const applyFilter = () => {
|
||||||
setSelectedBucketIds(tempSelectedBucketIds);
|
setSelectedBucketIds(tempSelectedBucketIds);
|
||||||
@ -192,8 +196,30 @@ const Directory = () =>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setActions([
|
||||||
|
{
|
||||||
|
label: "New Contact",
|
||||||
|
icon: "bx bx-plus-circle",
|
||||||
|
color: "warning",
|
||||||
|
onClick: () => setIsOpenModal(true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Manage Bucket",
|
||||||
|
icon: "fa-solid fa-bucket fs-5 ",
|
||||||
|
color: "primary",
|
||||||
|
onClick: () => setOpenBucketModal(true),
|
||||||
|
},
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
return () => setActions([]); // Clean up
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container-xxl flex-grow-1 container-p-y">
|
<div className="container-xxl flex-grow-1 container-p-y">
|
||||||
|
|
||||||
<Breadcrumb
|
<Breadcrumb
|
||||||
data={[
|
data={[
|
||||||
{ label: "Home", link: "/dashboard" },
|
{ label: "Home", link: "/dashboard" },
|
||||||
@ -333,6 +359,8 @@ const Directory = () =>
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{!loading && currentItems < ITEMS_PER_PAGE && (
|
{!loading && currentItems < ITEMS_PER_PAGE && (
|
||||||
<nav aria-label="Page ">
|
<nav aria-label="Page ">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user