set Directory page for project

This commit is contained in:
pramod mahajan 2025-09-10 20:35:48 +05:30
parent d6de8cbfc1
commit 4741025dcb
3 changed files with 15 additions and 12 deletions

View File

@ -12,14 +12,14 @@ import ListViewContact from "../../components/Directory/ListViewContact";
import { CardViewContactSkeleton, ListViewContactSkeleton } from "../../components/Directory/DirectoryPageSkeleton"; import { CardViewContactSkeleton, ListViewContactSkeleton } from "../../components/Directory/DirectoryPageSkeleton";
const ContactsPage = ({ searchText }) => { const ContactsPage = ({projectId ,searchText }) => {
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const [filters, setFilter] = useState(defaultContactFilter); const [filters, setFilter] = useState(defaultContactFilter);
const debouncedSearch = useDebounce(searchText, 500); const debouncedSearch = useDebounce(searchText, 500);
const { showActive, gridView } = useDirectoryContext(); const { showActive, gridView } = useDirectoryContext();
const { data, isError, isLoading, error } = useContactList( const { data, isError, isLoading, error } = useContactList(
showActive, showActive,
null, projectId,
ITEMS_PER_PAGE, ITEMS_PER_PAGE,
currentPage, currentPage,
filters, filters,

View File

@ -32,7 +32,7 @@ export const useDirectoryContext = () => {
} }
return context; return context;
}; };
export default function DirectoryPage({ IsPage = true, projectId }) { export default function DirectoryPage({ IsPage = true, projectId=null }) {
const [searchContact, setsearchContact] = useState(""); const [searchContact, setsearchContact] = useState("");
const [searchNote, setSearchNote] = useState(""); const [searchNote, setSearchNote] = useState("");
const [activeTab, setActiveTab] = useState("notes"); const [activeTab, setActiveTab] = useState("notes");
@ -94,13 +94,13 @@ export default function DirectoryPage({ IsPage = true, projectId }) {
return ( return (
<> <>
<DirectoryContext.Provider value={contextValues}> <DirectoryContext.Provider value={contextValues}>
<div className="container-fluid"> <div className={`${IsPage ? "container-fluid":""}`}>
<Breadcrumb {IsPage && ( <Breadcrumb
data={[ data={[
{ label: "Home", link: "/dashboard" }, { label: "Home", link: "/dashboard" },
{ label: "Directory", link: null }, { label: "Directory", link: null },
]} ]}
></Breadcrumb> ></Breadcrumb>)}
<div className="card"> <div className="card">
<div className="d-flex justify-content-between align-items-center mb-1 px-2"> <div className="d-flex justify-content-between align-items-center mb-1 px-2">
<ul className="nav nav-tabs"> <ul className="nav nav-tabs">
@ -188,7 +188,7 @@ export default function DirectoryPage({ IsPage = true, projectId }) {
<i className="bx bx-grid-alt"></i> <i className="bx bx-grid-alt"></i>
</button> </button>
</div> </div>
<div className="form-check form-switch text-start m-0 ms-5"> <div className="form-check form-switch d-flex align-items-center ms-4">
<input <input
type="checkbox" type="checkbox"
className="form-check-input" className="form-check-input"
@ -197,8 +197,11 @@ export default function DirectoryPage({ IsPage = true, projectId }) {
checked={showActive} checked={showActive}
onChange={(e) => setShowActive(e.target.checked)} onChange={(e) => setShowActive(e.target.checked)}
/> />
<label className="form-check-label ms-0"> <label
{showActive ? "In-ACtive":"Active" } className="form-check-label ms-2"
htmlFor="inactiveEmployeesCheckbox"
>
{showActive ? "Inactive" : "Active"}
</label> </label>
</div> </div>
</div> </div>
@ -211,10 +214,10 @@ export default function DirectoryPage({ IsPage = true, projectId }) {
<div> <div>
<Suspense fallback={<MainDirectoryPageSkeleton />}> <Suspense fallback={<MainDirectoryPageSkeleton />}>
{activeTab === "notes" && ( {activeTab === "notes" && (
<NotesPage projectId={null} searchText={searchNote} /> <NotesPage projectId={projectId} searchText={searchNote} />
)} )}
{activeTab === "contacts" && ( {activeTab === "contacts" && (
<ContactsPage searchText={searchContact} /> <ContactsPage projectId={projectId} searchText={searchContact} />
)} )}
</Suspense> </Suspense>
</div> </div>

View File

@ -56,7 +56,7 @@ export const DirectoryRepository = {
const payloadJsonString = JSON.stringify(filter); const payloadJsonString = JSON.stringify(filter);
return api.get( return api.get(
`/api/directory/notes?` + `/api/directory/notes?` +
(projectId ? `projectId=${projectId}` : "&") + (projectId ? `projectId=${projectId}&` : "&") +
`pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${encodeURIComponent( `pageSize=${pageSize}&pageNumber=${pageNumber}&filter=${encodeURIComponent(
payloadJsonString payloadJsonString
)}&searchString=${encodeURIComponent(searchString)}` )}&searchString=${encodeURIComponent(searchString)}`