diff --git a/src/Contexts/GlobalStateContext.tsx b/src/Contexts/GlobalStateContext.tsx index 6015cbb..70d4eb5 100644 --- a/src/Contexts/GlobalStateContext.tsx +++ b/src/Contexts/GlobalStateContext.tsx @@ -7,6 +7,8 @@ export interface GlobalStateContextType { setIsAuthenticate: Dispatch>; isBarLoading: boolean; setIsBarLoading: Dispatch>; + userAccess: string[]; + setUserAccess: Dispatch>; } // Create the context with a default value of `undefined` const GlobalStateContext = createContext(undefined); diff --git a/src/Contexts/GlobalStateProvider.tsx b/src/Contexts/GlobalStateProvider.tsx index 82b7d9a..5228983 100644 --- a/src/Contexts/GlobalStateProvider.tsx +++ b/src/Contexts/GlobalStateProvider.tsx @@ -6,6 +6,10 @@ import GlobalStateContext from "./GlobalStateContext"; const GlobalStateProvider = ({ children }: { children: ReactNode }) => { const [isAuthenticate, setIsAuthenticate] = useState(true); const [isBarLoading, setIsBarLoading] = useState(false); // ✅ Fixed typo + const [userAccess, setUserAccess] = useState(() => { + const stored = sessionStorage.getItem('userAccess'); + return stored ? JSON.parse(stored) : []; + }); @@ -15,6 +19,8 @@ const GlobalStateProvider = ({ children }: { children: ReactNode }) => { setIsAuthenticate, isBarLoading, setIsBarLoading, // ✅ Fixed typo + userAccess, + setUserAccess }}> {children} diff --git a/src/Layouts/DefaultLayout.tsx b/src/Layouts/DefaultLayout.tsx index e1217ad..0f3cdf1 100644 --- a/src/Layouts/DefaultLayout.tsx +++ b/src/Layouts/DefaultLayout.tsx @@ -25,9 +25,13 @@ const DefaultLayout: FC<{ children: React.ReactNode }> = ({ children }) => { if (!context) { throw new Error('App must be used within a GlobalStateProvider'); } - const { setIsAuthenticate, isBarLoading } = context; + const { setIsAuthenticate, isBarLoading, userAccess } = context; const [logOutAdmin] = useLogOutMutation() + const filteredNav = nav.filter(item => + userAccess.includes('*') || !item.resourceTitle || userAccess.includes(item.resourceTitle) + ); + // Logout function const handleLogout = async () => { @@ -57,7 +61,7 @@ const DefaultLayout: FC<{ children: React.ReactNode }> = ({ children }) => { - {nav?.map(({ title, path, Icon, type, children, initPath }, index) => type === 'single' ? + {filteredNav?.map(({ title, path, Icon, type, children, initPath }, index) => type === 'single' ? {title} : diff --git a/src/Pages/Login.tsx b/src/Pages/Login.tsx index fa551c8..306a46f 100644 --- a/src/Pages/Login.tsx +++ b/src/Pages/Login.tsx @@ -34,7 +34,7 @@ const Login = () => { if (!context) { throw new Error("App must be used within a GlobalStateProvider"); } - const { setIsAuthenticate } = context; + const { setIsAuthenticate, setUserAccess } = context; const { register, handleSubmit, @@ -43,10 +43,10 @@ const Login = () => { const onSubmit = handleSubmit(async (data) => { setIsLoading(true); - // Encode Basic Auth Credentials - const username = import.meta.env.VITE_USER_NAME || ""; // Replace with actual username - const password = import.meta.env.VITE_PASSWORD || ""; // Replace with actual password - const basicAuth = `${username}:${password}`; // Encode to Base64 + + const username = import.meta.env.VITE_USER_NAME || ""; + const password = import.meta.env.VITE_PASSWORD || ""; + const basicAuth = `${username}:${password}`; try { const res = await axios.post( @@ -62,35 +62,36 @@ const Login = () => { }, } ); - console.log("============", res); + const loginData = res.data?.data; + const { principal_type_xid, role_permission } = loginData; + + const isAdmin = principal_type_xid === 1; + + const allowedTitles = isAdmin + ? ['*'] + : role_permission?.get_resource_action_link + ?.filter((link: unknown) => (link as any).is_active) + .map((link: unknown) => (link as any).app_resource.app_resource_title) ?? []; + + setIsAuthenticate(true); + setUserAccess(allowedTitles); + dispatch(setToken(String(loginData["access-token"]))); + sessionStorage.setItem('userAccess', JSON.stringify(allowedTitles)); + navigate("/dashboard"); + setIsLoading(false); - if (res.data) { - setIsAuthenticate(true); - console.log("===================================="); - console.log(res.data?.data); - console.log("===================================="); - navigate("/dashboard"); - dispatch(setToken(String(res.data?.data["access-token"]))); - } else { - console.log("===================================="); - console.log(res); - console.log("===================================="); - } } catch (error: any) { - console.log('error', error.response.data.message); - - if (error) { - toaster.create({ - title: error?.response?.data?.message, - // title: "Something Went Wrong", - type: "info", - }) - // console.log("Login failed", error?.response?.data?.message); - setIsLoading(false); - } + console.log('error', error?.response?.data?.message); + toaster.create({ + title: "Error", + description: error?.response?.data?.message || "Login failed", + type: "error", + }); + setIsLoading(false); } }); + // console.log("User Access in Context:", userAccess); return ( diff --git a/src/Pages/ManageCMS/FAQ/FAQ.tsx b/src/Pages/ManageCMS/FAQ/FAQ.tsx index c146c8a..fbee7b2 100644 --- a/src/Pages/ManageCMS/FAQ/FAQ.tsx +++ b/src/Pages/ManageCMS/FAQ/FAQ.tsx @@ -85,9 +85,21 @@ const FAQ = () => { try { await faqToggle({ id: agencyId, is_active: newStatus }).unwrap(); - refetch() + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + setTimeout(() => { + refetch(); + }, 500); } catch (error) { console.error("Error updating privacy policy:", error); + toaster.create({ + title: "Error", + description: "Someting went wrong.", + type: "error", + }); setLocalData((prevData) => prevData.map((agency) => agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency @@ -160,7 +172,7 @@ const FAQ = () => { handleDeleteFaq(selectedFaqId); } }} - /> + /> { ), Description: ( - {`${translation?.content}`.slice( - 0, - 30 - ) + "..."} + {translation?.content?.length > 30 + ? `${translation.content.slice(0, 30)}...` + : translation?.content} ), "Publish Data": formatAPIDate(agency.created_at), diff --git a/src/Pages/ManageUsers/RegisterUsers/RegisterUsers.tsx b/src/Pages/ManageUsers/RegisterUsers/RegisterUsers.tsx index e7ffd23..d954cb7 100644 --- a/src/Pages/ManageUsers/RegisterUsers/RegisterUsers.tsx +++ b/src/Pages/ManageUsers/RegisterUsers/RegisterUsers.tsx @@ -18,11 +18,13 @@ import SearchComponent from "../../../components/SearchComponent"; import AlertDailog from "../../../components/AlertDailog"; import { toaster } from "../../../components/ui/toaster"; import Delete from "../../../components/ActionIcons/Delete"; +import { delay } from "../../../components/Utils"; // import Delete from "../../../components/ActionIcons/Delete"; const tableHeadRow = [ "Sr. No", "First Name", + "Last Name", "Mobile Number", "Gender", "DOB", @@ -105,9 +107,20 @@ const RegisterUsers = () => { try { await userToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + await delay(500); refetch() } catch (error) { console.error("Error updating privacy policy:", error); + toaster.create({ + title: "Error", + description: "Someting went wrong.", + type: "error", + }); setLocalData((prevData) => prevData.map((agency) => agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency @@ -142,6 +155,7 @@ const RegisterUsers = () => { const managepost = filteredData?.flatMap((agency: UserData, index: number) => ({ "Sr. No": (currentPage - 1) * (data?.data.per_page ?? 0) + index + 1, "First Name": agency.first_name, + "Last Name": agency.last_name, "Mobile Number": agency.phone_number, "Gender": agency.gender, "DOB": agency.date_of_birth ? new Date(agency.date_of_birth).toLocaleDateString('en-GB').replace(/\//g, '-') : 'N/A', diff --git a/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx b/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx index 917c866..3779984 100644 --- a/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx +++ b/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx @@ -9,6 +9,8 @@ import { useAgencyMasterToggleMutation, useGetAgencyMasterQuery } from "../../.. import { useEffect, useState } from "react"; import SearchComponent from "../../../components/SearchComponent"; import { useDebounce } from "../../../components/Hooks/useDebounce"; +import { toaster, Toaster } from "../../../components/ui/toaster"; +import { delay } from "../../../components/Utils"; // table data @@ -65,6 +67,12 @@ const AgencyMaster = () => { ); try { await agencyMasterToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + await delay(500); refetch() } catch (error) { console.error("Error updating privacy policy:", error); @@ -73,6 +81,11 @@ const AgencyMaster = () => { agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency ) ); + toaster.create({ + title: "Error", + description: "Please try again later", + type: "error", + }); } }; @@ -120,7 +133,7 @@ const AgencyMaster = () => { size={"xs"} onChange={() => handleToggle(agency.id.toString(), Number(agency.is_active))} checked={Boolean(Number(agency.is_active))} - // disabled={isOnlyActive} + // disabled={isOnlyActive} /> @@ -199,6 +212,7 @@ const AgencyMaster = () => { isError={isError} /> + ) } diff --git a/src/Pages/MasterModule/Country/Country.tsx b/src/Pages/MasterModule/Country/Country.tsx index 41dca88..fb89bfe 100644 --- a/src/Pages/MasterModule/Country/Country.tsx +++ b/src/Pages/MasterModule/Country/Country.tsx @@ -8,6 +8,8 @@ import { CountryData, useCountryToggleMutation, useGetCountryMasterQuery } from import { useEffect, useState } from "react"; import SearchComponent from "../../../components/SearchComponent"; import { useDebounce } from "../../../components/Hooks/useDebounce"; +import { toaster, Toaster } from "../../../components/ui/toaster"; +import { delay } from "../../../components/Utils"; @@ -79,9 +81,20 @@ const Country = () => { try { await countryToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + await delay(500); refetch() } catch (error) { console.error("Error updating privacy policy:", error); + toaster.create({ + title: "Error", + description: "Please try again later.", + type: "error", + }); setLocalData((prevData) => prevData.map((agency) => agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency @@ -107,7 +120,7 @@ const Country = () => { ), })) - + return ( @@ -173,6 +186,7 @@ const Country = () => { isError={isError} /> + ) } diff --git a/src/Pages/MasterModule/DepartmentMaster/DepartmentMasterList.tsx b/src/Pages/MasterModule/DepartmentMaster/DepartmentMasterList.tsx index f69103d..e6301d3 100644 --- a/src/Pages/MasterModule/DepartmentMaster/DepartmentMasterList.tsx +++ b/src/Pages/MasterModule/DepartmentMaster/DepartmentMasterList.tsx @@ -10,6 +10,8 @@ import { useDepartmentToggleMutation, useGetDepartmentMasterQuery } from "../../ import AddDepartmentMaster from "./AddDepartmentMaster"; import EditDepartmentMaster from "./EditDepartmentMaster"; import { useDebounce } from "../../../components/Hooks/useDebounce"; +import { Toaster, toaster } from "../../../components/ui/toaster"; +import { delay } from "../../../components/Utils"; // table data @@ -58,9 +60,20 @@ const DepartmentMasterList = () => { ); try { await departmentToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + await delay(500); refetch() } catch (error) { console.error("Error updating privacy policy:", error); + toaster.create({ + title: "Error", + description: "Someting went wrong.", + type: "error", + }); setLocalData((prevData) => prevData.map((agency) => agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency @@ -142,6 +155,7 @@ const DepartmentMasterList = () => { isError={isError} /> + ) } diff --git a/src/Pages/MasterModule/IndustryMaster/IndustryMasterList.tsx b/src/Pages/MasterModule/IndustryMaster/IndustryMasterList.tsx index 8386473..b8c86da 100644 --- a/src/Pages/MasterModule/IndustryMaster/IndustryMasterList.tsx +++ b/src/Pages/MasterModule/IndustryMaster/IndustryMasterList.tsx @@ -10,6 +10,8 @@ import EditIndustryMaster from "./EditIndustryMaster"; import AddIndustryMaster from "./AddIndustryMaster"; import SearchComponent from "../../../components/SearchComponent"; import { useDebounce } from "../../../components/Hooks/useDebounce"; +import { Toaster, toaster } from "../../../components/ui/toaster"; +import { delay } from "../../../components/Utils"; // table data @@ -61,7 +63,7 @@ const IndustryMasterList = () => { const handleSearchChange = (value: string) => { setSearchTerm(value); setCurrentPage(1); - }; + }; const handlePageChange = (page: number) => { setCurrentPage(page); @@ -76,9 +78,20 @@ const IndustryMasterList = () => { ); try { await industryMasterToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + await delay(500); refetch() } catch (error) { console.error("Error updating privacy policy:", error); + toaster.create({ + title: "Error", + description: "Someting went wrong.", + type: "error", + }); setLocalData((prevData) => prevData.map((agency) => agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency @@ -160,6 +173,7 @@ const IndustryMasterList = () => { isError={isError} /> + ) } diff --git a/src/Pages/MasterModule/JobStatus/JobStatus.tsx b/src/Pages/MasterModule/JobStatus/JobStatus.tsx index c267cb8..40c01fb 100644 --- a/src/Pages/MasterModule/JobStatus/JobStatus.tsx +++ b/src/Pages/MasterModule/JobStatus/JobStatus.tsx @@ -7,8 +7,9 @@ import EditJobStatusModel from "./EditJobStatusModel"; import { useGetJobStatusQuery, useJobStatusToggleMutation } from "../../../Redux/Service/job.status"; import { useEffect, useState } from "react"; import SearchComponent from "../../../components/SearchComponent"; -import { toaster } from "../../../components/ui/toaster"; +import { toaster, Toaster } from "../../../components/ui/toaster"; import { useDebounce } from "../../../components/Hooks/useDebounce"; +import { delay } from "../../../components/Utils"; @@ -70,6 +71,12 @@ const JobStatus = () => { ); try { await jobStatusToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + await delay(500); refetch() } catch (error) { console.error("Error updating:", error); @@ -154,6 +161,7 @@ const JobStatus = () => { isError={isError} /> + ) } diff --git a/src/Pages/MasterModule/JobType/JobType.tsx b/src/Pages/MasterModule/JobType/JobType.tsx index 3e2d209..5ccd1a5 100644 --- a/src/Pages/MasterModule/JobType/JobType.tsx +++ b/src/Pages/MasterModule/JobType/JobType.tsx @@ -9,6 +9,8 @@ import EditJobeModel from "./EditJobModel"; import { JobTypeData, useGetJobTypeQuery, useJobTypeToggleMutation } from "../../../Redux/Service/job.type.service"; import { useEffect, useState } from "react"; import SearchComponent from "../../../components/SearchComponent"; +import { toaster, Toaster } from "../../../components/ui/toaster"; +import { delay } from "../../../components/Utils"; @@ -70,6 +72,12 @@ const JobType = () => { ); try { await jobTypeToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + await delay(500); refetch() } catch (error) { console.error("Error updating privacy policy:", error); @@ -78,6 +86,11 @@ const JobType = () => { agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency ) ); + toaster.create({ + title: "Error", + description: "Please try again later", + type: "error", + }); } }; @@ -144,6 +157,7 @@ const JobType = () => { onPageChange={handlePageChange} /> + ) } diff --git a/src/Pages/MasterModule/TemplateMaster/TemplateMaster.tsx b/src/Pages/MasterModule/TemplateMaster/TemplateMaster.tsx index 8e5d600..011258c 100644 --- a/src/Pages/MasterModule/TemplateMaster/TemplateMaster.tsx +++ b/src/Pages/MasterModule/TemplateMaster/TemplateMaster.tsx @@ -9,6 +9,8 @@ import EditTemplateModel from "./EditTemplateModel"; import { Template, useGetTemplateMasterQuery, useTemplateMasterToggleMutation } from "../../../Redux/Service/template.master.service"; import { useEffect, useState } from "react"; import SearchComponent from "../../../components/SearchComponent"; +import { toaster, Toaster } from "../../../components/ui/toaster"; +import { delay } from "../../../components/Utils"; const APIURL = import.meta.env.VITE_IMG_TEMPLATES @@ -72,6 +74,12 @@ const TemplateMaster = () => { ); try { await templateMasterToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); + await delay(500); refetch() } catch (error) { console.error("Error updating privacy policy:", error); @@ -80,6 +88,11 @@ const TemplateMaster = () => { agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency ) ); + toaster.create({ + title: "Error", + description: "Please try again later", + type: "error", + }); } }; @@ -124,7 +137,8 @@ const TemplateMaster = () => { ) - }}); + } + }); return ( @@ -182,6 +196,7 @@ const TemplateMaster = () => { onPageChange={handlePageChange} /> + ) } diff --git a/src/Pages/MasterModule/WorkspaceMode/WorkspaceMode.tsx b/src/Pages/MasterModule/WorkspaceMode/WorkspaceMode.tsx index 0c8f8a6..df9b8dd 100644 --- a/src/Pages/MasterModule/WorkspaceMode/WorkspaceMode.tsx +++ b/src/Pages/MasterModule/WorkspaceMode/WorkspaceMode.tsx @@ -63,12 +63,17 @@ const WorkspaceMode = () => { ); try { await workspaceToggle({ id: agencyId, is_active: newStatus }).unwrap(); + toaster.create({ + title: "Success", + description: "Status updated successfully", + type: "success", + }); refetch() } catch (error) { console.error("Error updating privacy policy:", error); toaster.create({ title: "Error", - description: "Someting went wrong.", + description: "Please try again later.", type: "error", }); setLocalData((prevData) => @@ -133,7 +138,7 @@ const WorkspaceMode = () => { }} /> {/* */} - + { height={"fit-content"} mr={2} > - {showOldPassword ? : } + {showOldPassword ? : } } > @@ -158,7 +158,7 @@ const SetNewPassword = () => { color={"#000"} mr={2} > - {showNewPassword ? : } + {showNewPassword ? : } } > diff --git a/src/Routes/Nav.ts b/src/Routes/Nav.ts index ed01aa7..1e3ebe9 100644 --- a/src/Routes/Nav.ts +++ b/src/Routes/Nav.ts @@ -1,5 +1,5 @@ -import { LuBriefcaseBusiness} from "react-icons/lu"; -import { MdHeadsetMic, MdOutlineDashboard} from "react-icons/md"; +import { LuBriefcaseBusiness } from "react-icons/lu"; +import { MdHeadsetMic, MdOutlineDashboard } from "react-icons/md"; import { GoDotFill } from "react-icons/go"; import { HiOutlinePencilSquare } from "react-icons/hi2"; import { BiUser, BiUserPin } from "react-icons/bi"; @@ -8,146 +8,156 @@ import { BsBoxes, BsPersonBadge } from "react-icons/bs"; import { AiOutlineFileText } from "react-icons/ai"; export const nav = [ - - { - title: "Dashboard", - path: "/", - Icon: MdOutlineDashboard, - type:'single' - }, - { - title: "Manage Users", - initPath: "/manage-users", - Icon: BiUserPin, - type:'multiple', - children: [ - { - title: "Register Users", - path: "/manage-users/register-users", - Icon: GoDotFill, - }, - { - title: "Deactivated Accounts", - path: "/manage-users/deactivated-accounts", - Icon: GoDotFill, - }, - ], - }, - { - title: "Manage Post", - path: "/manage-post", - Icon: HiOutlinePencilSquare, - type:'single' - }, - { - title: "Manage Sub-Admin", - path: "/sub-admin", - Icon: BiUser, - type:'single' - }, - { - title: "Manage Jobs", - path: "/manage-jobs", - Icon: LuBriefcaseBusiness, - type:'single' - }, - { - title: "Manage Groups", - path: "/manage-groups", - Icon: PiUsersThree, - type:'single' - }, - { - title: "Manage Contact Us", - path: "/manage-contact", - Icon: MdHeadsetMic , - type:'single' - }, - { - title: "Manage CMS", - initPath: "/manage-cms", - Icon: AiOutlineFileText, - type:'multiple', - children: [ - { - title: "FAQs", - path: "/manage-cms/faq", - Icon: GoDotFill, - }, - { - title: "About Us", - path: "/manage-cms/about-us", - Icon: GoDotFill, - }, - { - title: "Privacy Policy", - path: "/manage-cms/privacy-policy", - Icon: GoDotFill, - }, - { - title: "Terms And Conditions", - path: "/manage-cms/terms-conditions", - Icon: GoDotFill, - }, - // { - // title: "Privacy", - // path: "/manage-cms/privacy", - // Icon: GoDotFill, - // }, - ], - }, - { - title: "My Profile", - path: "/profile", - Icon: BsPersonBadge, - type:'single' - }, - { - title: "Master Module", - initPath: "/master-module", - Icon: BsBoxes, - type:'multiple', - children: [ - { - title: "Agency Master", - path: "/master-module/agency-master", - Icon: GoDotFill, - }, - { - title: "Template Master", - path: "/master-module/template-master", - Icon: GoDotFill, - }, - { - title: "Job Type", - path: "/master-module/job-type", - Icon: GoDotFill, - }, - { - title: "Workspace Mode", - path: "/master-module/workspace-mode", - Icon: GoDotFill, - }, - { - title: "Country", - path: "/master-module/country", - Icon: GoDotFill, - }, - { - title: "Job Status", - path: "/master-module/job-status", - Icon: GoDotFill, - }, - { - title: "Industry Master", - path: "/master-module/industry-master", - Icon: GoDotFill, - }, - { - title: "Department Master", - path: "/master-module/department-master", - Icon: GoDotFill, - }, - ], - }, - ]; \ No newline at end of file + + { + title: "Dashboard", + path: "/", + Icon: MdOutlineDashboard, + type: 'single', + resourceTitle: 'Dashboard' + }, + { + title: "Manage Users", + initPath: "/manage-users", + Icon: BiUserPin, + type: 'multiple', + resourceTitle: 'Manage Users', + children: [ + { + title: "Register Users", + path: "/manage-users/register-users", + Icon: GoDotFill, + }, + { + title: "Deactivated Accounts", + path: "/manage-users/deactivated-accounts", + Icon: GoDotFill, + }, + ], + }, + { + title: "Manage Post", + path: "/manage-post", + Icon: HiOutlinePencilSquare, + type: 'single', + resourceTitle: 'Manage Post' + }, + { + title: "Manage Sub-Admin", + path: "/sub-admin", + Icon: BiUser, + type: 'single', + resourceTitle: 'Manage Subadmin' + }, + { + title: "Manage Jobs", + path: "/manage-jobs", + Icon: LuBriefcaseBusiness, + type: 'single', + resourceTitle: 'Manage Jobs' + }, + { + title: "Manage Groups", + path: "/manage-groups", + Icon: PiUsersThree, + type: 'single', + resourceTitle: 'Manage Groups' + }, + { + title: "Manage Contact Us", + path: "/manage-contact", + Icon: MdHeadsetMic, + type: 'single', + resourceTitle: 'Manage Contact Us' + }, + { + title: "Manage CMS", + initPath: "/manage-cms", + Icon: AiOutlineFileText, + type: 'multiple', + resourceTitle: 'Manage CMS', + children: [ + { + title: "FAQs", + path: "/manage-cms/faq", + Icon: GoDotFill, + }, + { + title: "About Us", + path: "/manage-cms/about-us", + Icon: GoDotFill, + }, + { + title: "Privacy Policy", + path: "/manage-cms/privacy-policy", + Icon: GoDotFill, + }, + { + title: "Terms And Conditions", + path: "/manage-cms/terms-conditions", + Icon: GoDotFill, + }, + // { + // title: "Privacy", + // path: "/manage-cms/privacy", + // Icon: GoDotFill, + // }, + ], + }, + { + title: "My Profile", + path: "/profile", + Icon: BsPersonBadge, + type: 'single', + resourceTitle: 'My Profile' + }, + { + title: "Master Module", + initPath: "/master-module", + Icon: BsBoxes, + type: 'multiple', + resourceTitle: 'Master Module', + children: [ + { + title: "Agency Master", + path: "/master-module/agency-master", + Icon: GoDotFill, + }, + { + title: "Template Master", + path: "/master-module/template-master", + Icon: GoDotFill, + }, + { + title: "Job Type", + path: "/master-module/job-type", + Icon: GoDotFill, + }, + { + title: "Workspace Mode", + path: "/master-module/workspace-mode", + Icon: GoDotFill, + }, + { + title: "Country", + path: "/master-module/country", + Icon: GoDotFill, + }, + { + title: "Job Status", + path: "/master-module/job-status", + Icon: GoDotFill, + }, + { + title: "Industry Master", + path: "/master-module/industry-master", + Icon: GoDotFill, + }, + { + title: "Department Master", + path: "/master-module/department-master", + Icon: GoDotFill, + }, + ], + }, +]; \ No newline at end of file diff --git a/src/components/DataTable.tsx b/src/components/DataTable.tsx index ba3951c..2b5bcd8 100644 --- a/src/components/DataTable.tsx +++ b/src/components/DataTable.tsx @@ -135,23 +135,29 @@ const DataTable: React.FC = ({ key={index} bg={index % 2 === 0 ? "#fff" : "#007F3310"} > - {tableHeadRow.map((heading, colIndex) => ( - - {(() => { - const words = item[heading]?.toString().split(" ") || []; - return words.length > 5 - ? `${words.slice(0, 5).join(" ")}...` - : item[heading]; - })()} - - ))} + {tableHeadRow.map((heading, colIndex) => { + const cellContent = item[heading]; + const words = typeof cellContent === 'string' + ? cellContent.split(" ") + : cellContent?.toString().split(" ") || []; + + const truncated = words.length > 15 + ? `${words.slice(0, 15).join(" ")}...` + : cellContent; + + return ( + + {truncated} + + ); + })} ))} diff --git a/src/components/Utils.ts b/src/components/Utils.ts new file mode 100644 index 0000000..7a691e6 --- /dev/null +++ b/src/components/Utils.ts @@ -0,0 +1,3 @@ + + +export const delay = (ms: number) => new Promise(res => setTimeout(res, ms)); \ No newline at end of file