Compare commits

..

13 Commits

Author SHA1 Message Date
55ff4d5d29 Correction in UI of logo upload in Organization popup. 2025-10-14 12:04:11 +05:30
97cb357a3c Logo icon shown in organization details popup, but no option to upload logo while creating organization 2025-10-14 11:48:05 +05:30
9592108472 Removing extra margin-top on Project-details. 2025-10-13 16:35:28 +05:30
3b032b7b07 Merge pull request 'Incorrect Toggle Switch Text for Active/Inactive Employee in Project Teams' (#475) from Kartik_Bug#1455 into Issues_Oct_main_2W
Reviewed-on: #475
merged
2025-10-13 09:33:09 +00:00
b8891d403f Incorrect Toggle Switch Text for Active/Inactive Employee in Project Teams 2025-10-13 09:33:09 +00:00
01568db61c Merge pull request '“NA” Should Be Displayed When Employee Has No Email Instead of “–”' (#476) from Kartik_Bug#1451 into Issues_Oct_main_2W
Reviewed-on: #476
Merged
2025-10-13 09:32:51 +00:00
80a974e3be “NA” Should Be Displayed When Employee Has No Email Instead of “–” 2025-10-13 09:32:51 +00:00
f3e05a11d6 Merge pull request 'Adding Project and Service field in View Organization popup.' (#477) from Kartik_Task#1477 into Issues_Oct_main_2W
Reviewed-on: #477
Merged
2025-10-13 09:32:32 +00:00
222e6495a8 Adding Project and Service field in View Organization popup. 2025-10-13 09:32:32 +00:00
18a3b8a85b Merge pull request 'Filter Sidebar Should Auto-Close When Navigating to Another Page' (#478) from Kartik_Bug#1450 into Issues_Oct_main_2W
Reviewed-on: #478
merged
2025-10-13 09:32:17 +00:00
d75296ffe8 Filter Sidebar Should Auto-Close When Navigating to Another Page 2025-10-13 14:51:47 +05:30
6649cab6a2 Added cursor-not-allowed when user can delete the organization. 2025-10-13 14:16:11 +05:30
eab23389ed Correction in Projects Completion Status in this weidget data cannot be shown. 2025-10-13 12:51:42 +05:30
51 changed files with 441 additions and 2720 deletions

View File

@ -10,21 +10,7 @@
.table_header_border { .table_header_border {
border-bottom:2px solid var(--bs-table-border-color) ; border-bottom:2px solid var(--bs-table-border-color) ;
} }
.text-gary-80 {
color:var(--bs-gray-500)
}
.text-royalblue{
color: #1796e3;
}
.text-md {
font-size: 2rem;
}
.text-md-b {
font-weight: normal;
}
.text-xxs { font-size: 0.55rem; } /* 8px */ .text-xxs { font-size: 0.55rem; } /* 8px */
.text-xs { font-size: 0.75rem; } /* 12px */ .text-xs { font-size: 0.75rem; } /* 12px */
@ -294,3 +280,7 @@ font-weight: normal;
.w-8-xl{ width: 2rem; } .w-8-xl{ width: 2rem; }
.w-10-xl{ width: 2.5rem; } .w-10-xl{ width: 2.5rem; }
} }
.cursor-not-allowed{
cursor: not-allowed;
}

View File

@ -4,20 +4,17 @@ import OrganizationModal from "./components/Organization/OrganizationModal";
import { useAuthModal, useModal } from "./hooks/useAuth"; import { useAuthModal, useModal } from "./hooks/useAuth";
import SwitchTenant from "./pages/authentication/SwitchTenant"; import SwitchTenant from "./pages/authentication/SwitchTenant";
import ChangePasswordPage from "./pages/authentication/ChangePassword"; import ChangePasswordPage from "./pages/authentication/ChangePassword";
import NewCollection from "./components/collections/ManageCollection";
const ModalProvider = () => { const ModalProvider = () => {
const { isOpen, onClose } = useOrganizationModal(); const { isOpen, onClose } = useOrganizationModal();
const { isOpen: isAuthOpen } = useAuthModal(); const { isOpen: isAuthOpen } = useAuthModal();
const {isOpen:isChangePass} = useModal("ChangePassword") const {isOpen:isChangePass} = useModal("ChangePassword")
const {isOpen:isCollectionNew} = useModal("newCollection");
return ( return (
<> <>
{isOpen && <OrganizationModal />} {isOpen && <OrganizationModal />}
{isAuthOpen && <SwitchTenant />} {isAuthOpen && <SwitchTenant />}
{isChangePass && <ChangePasswordPage /> } {isChangePass && <ChangePasswordPage /> }
{isCollectionNew && <NewCollection/>}
</> </>
); );
}; };

View File

@ -126,7 +126,7 @@ const Attendance = ({ getRole, handleModalData, searchTerm, projectId, organizat
checked={ShowPending} checked={ShowPending}
onChange={(e) => setShowPending(e.target.checked)} onChange={(e) => setShowPending(e.target.checked)}
/> />
<label className="form-check-label ms-0">Show Pending</label> <label className="form-check-label ms-0">Pending Attendance</label>
</div> </div>
</div> </div>
{attLoading ? ( {attLoading ? (

View File

@ -190,7 +190,7 @@ useEffect(() => {
checked={showPending} checked={showPending}
onChange={(e) => setShowPending(e.target.checked)} onChange={(e) => setShowPending(e.target.checked)}
/> />
<label className="form-check-label ms-0">Show Pending</label> <label className="form-check-label ms-0">Pending Attendance</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -23,7 +23,7 @@ const HorizontalBarChart = ({
if (loading) { if (loading) {
return ( return (
<div className="w-full h-[380px] flex items-center justify-center bg-gray-100 rounded-xl"> <div className="w-full h-[380px] flex items-center justify-center bg-gray-100 rounded-xl">
<span className="text-gray-500 text-sm">Loading chart...</span> <span className="text-gray-500">Loading chart...</span>
{/* Replace this with a skeleton or spinner if you prefer */} {/* Replace this with a skeleton or spinner if you prefer */}
</div> </div>
); );

View File

@ -3,7 +3,8 @@ import HorizontalBarChart from "../Charts/HorizontalBarChart";
import { useProjects } from "../../hooks/useProjects"; import { useProjects } from "../../hooks/useProjects";
const ProjectCompletionChart = () => { const ProjectCompletionChart = () => {
const { projects, loading } = useProjects(); const { data: projects = [], isLoading: loading, isError, error } = useProjects();
// Bar chart logic // Bar chart logic
const projectNames = projects?.map((p) => p.name) || []; const projectNames = projects?.map((p) => p.name) || [];
@ -11,7 +12,7 @@ const ProjectCompletionChart = () => {
projects?.map((p) => { projects?.map((p) => {
const completed = p.completedWork || 0; const completed = p.completedWork || 0;
const planned = p.plannedWork || 1; const planned = p.plannedWork || 1;
const percent = (completed / planned) * 100; const percent = planned ? (completed / planned) * 100 : 0;
return Math.min(Math.round(percent), 100); return Math.min(Math.round(percent), 100);
}) || []; }) || [];

View File

@ -1,4 +1,4 @@
import React, { useState } from "react"; import React, { useEffect, useState } from "react";
import { useDocumentFilterEntities } from "../../hooks/useDocument"; import { useDocumentFilterEntities } from "../../hooks/useDocument";
import { FormProvider, useForm } from "react-hook-form"; import { FormProvider, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
@ -9,9 +9,11 @@ import {
import { DateRangePicker1 } from "../common/DateRangePicker"; import { DateRangePicker1 } from "../common/DateRangePicker";
import SelectMultiple from "../common/SelectMultiple"; import SelectMultiple from "../common/SelectMultiple";
import moment from "moment"; import moment from "moment";
import { useLocation } from "react-router-dom";
const DocumentFilterPanel = ({ entityTypeId, onApply }) => { const DocumentFilterPanel = ({ entityTypeId, onApply }) => {
const [resetKey, setResetKey] = useState(0); const [resetKey, setResetKey] = useState(0);
const location = useLocation();
const { data, isError, isLoading, error } = const { data, isError, isLoading, error } =
useDocumentFilterEntities(entityTypeId); useDocumentFilterEntities(entityTypeId);
@ -52,6 +54,13 @@ const DocumentFilterPanel = ({ entityTypeId, onApply }) => {
closePanel(); closePanel();
}; };
// Close popup when navigating to another component
useEffect(() => {
return () => {
closePanel();
};
}, []);
if (isLoading) return <div>Loading...</div>; if (isLoading) return <div>Loading...</div>;
if (isError) if (isError)
return <div>Error: {error?.message || "Something went wrong!"}</div>; return <div>Error: {error?.message || "Something went wrong!"}</div>;
@ -63,6 +72,8 @@ const DocumentFilterPanel = ({ entityTypeId, onApply }) => {
documentTag = [], documentTag = [],
} = data?.data || {}; } = data?.data || {};
return ( return (
<FormProvider {...methods}> <FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)}> <form onSubmit={handleSubmit(onSubmit)}>
@ -73,8 +84,7 @@ const DocumentFilterPanel = ({ entityTypeId, onApply }) => {
<div className="d-inline-flex border rounded-pill overflow-hidden shadow-none"> <div className="d-inline-flex border rounded-pill overflow-hidden shadow-none">
<button <button
type="button" type="button"
className={`btn px-2 py-1 rounded-0 text-tiny ${ className={`btn px-2 py-1 rounded-0 text-tiny ${isUploadedAt ? "active btn-secondary text-white" : ""
isUploadedAt ? "active btn-secondary text-white" : ""
}`} }`}
onClick={() => setValue("isUploadedAt", true)} onClick={() => setValue("isUploadedAt", true)}
> >
@ -82,8 +92,7 @@ const DocumentFilterPanel = ({ entityTypeId, onApply }) => {
</button> </button>
<button <button
type="button" type="button"
className={`btn px-2 py-1 rounded-0 text-tiny ${ className={`btn px-2 py-1 rounded-0 text-tiny ${!isUploadedAt ? "active btn-secondary text-white" : ""
!isUploadedAt ? "active btn-secondary text-white" : ""
}`} }`}
onClick={() => setValue("isUploadedAt", false)} onClick={() => setValue("isUploadedAt", false)}
> >

View File

@ -144,12 +144,12 @@ const Documents = ({ Document_Entity, Entity }) => {
<span className="switch-off"></span> <span className="switch-off"></span>
</span> </span>
<span className="switch-label"> <span className="switch-label">
{isActive ? "Active" : "In-Active"} {isActive ? "Active Document" : "In-Active Document"}
</span> </span>
</label> </label>
</div> </div>
<div className="col-6 col-md-6 col-lg-8 text-end"> <div className="col-12 col-md-6 col-lg-8 text-end">
{(isSelf || canUploadDocument) && ( {(isSelf || canUploadDocument) && (
<button <button
className="btn btn-sm btn-primary me-3" className="btn btn-sm btn-primary me-3"

View File

@ -51,7 +51,6 @@ const EmpAttendance = () => {
new Date(b?.checkInTime).getTime() - new Date(a?.checkInTime).getTime() new Date(b?.checkInTime).getTime() - new Date(a?.checkInTime).getTime()
); );
console.log(sorted);
const { currentPage, totalPages, currentItems, paginate } = usePagination( const { currentPage, totalPages, currentItems, paginate } = usePagination(
sorted, sorted,

View File

@ -1,53 +1,27 @@
import { useState } from "react"; import { useState } from 'react';
const PreviewDocument = ({ imageUrl }) => { const PreviewDocument = ({ imageUrl }) => {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [rotation, setRotation] = useState(0);
return ( return (
<> <div className="d-flex justify-content-center align-items-center" style={{ minHeight: "50vh" }}>
<div className="d-flex justify-content-start">
<i
className="bx bx-rotate-right cursor-pointer"
onClick={() => setRotation((prev) => prev + 90)}
></i>
</div>
<div
className="d-flex flex-column justify-content-center align-items-center"
style={{ minHeight: "60%" }}
>
{loading && ( {loading && (
<div className="text-secondary text-center mb-2">Loading...</div> <div className="text-secondary text-center mb-2">
Loading...
</div>
)} )}
<div className="mb-3 d-flex justify-content-center align-items-center">
<img <img
src={imageUrl} src={imageUrl}
alt="Full View" alt="Full View"
className="img-fluid" className="img-fluid"
style={{ style={{
maxHeight: "80vh", maxHeight: "100vh",
objectFit: "contain", objectFit: "contain",
display: loading ? "none" : "block", display: loading ? "none" : "block",
transform: `rotate(${rotation}deg)`,
transition: "transform 0.3s ease",
}} }}
onLoad={() => setLoading(false)} onLoad={() => setLoading(false)}
/> />
</div> </div>
<div className="d-flex justify-content-center gap-2">
<button
className="btn btn-outline-secondary"
onClick={() => setRotation(0)}
title="Reset Rotation"
>
<i className="bx bx-reset"></i> Reset
</button>
</div>
</div>
</>
); );
}; };

View File

@ -34,8 +34,6 @@ const Header = () => {
const isDashboardPath = const isDashboardPath =
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname); /^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
const isProjectPath = /^\/projects$/.test(location.pathname); const isProjectPath = /^\/projects$/.test(location.pathname);
const isCollectionPath =
/^\/collection$/.test(location.pathname) || /^\/$/.test(location.pathname);
const showProjectDropdown = (pathname) => { const showProjectDropdown = (pathname) => {
const isDirectoryPath = /^\/directory$/.test(pathname); const isDirectoryPath = /^\/directory$/.test(pathname);
@ -218,7 +216,7 @@ const Header = () => {
className="dropdown-menu" className="dropdown-menu"
style={{ overflow: "auto", maxHeight: "300px" }} style={{ overflow: "auto", maxHeight: "300px" }}
> >
{(isDashboardPath|| isCollectionPath) &&( {isDashboardPath && (
<li> <li>
<button <button
className="dropdown-item" className="dropdown-item"

View File

@ -1,4 +1,4 @@
import React, { useEffect } from "react"; import React, { useEffect, useState } from "react";
import { FormProvider, useForm } from "react-hook-form"; import { FormProvider, useForm } from "react-hook-form";
import { import {
useCreateOrganization, useCreateOrganization,
@ -14,6 +14,7 @@ import Label from "../common/Label";
import { useGlobalServices } from "../../hooks/masterHook/useMaster"; import { useGlobalServices } from "../../hooks/masterHook/useMaster";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import SelectMultiple from "../common/SelectMultiple"; import SelectMultiple from "../common/SelectMultiple";
import { LogoUpload } from "../Tenant/LogoUpload";
const ManagOrg = () => { const ManagOrg = () => {
const { data: service, isLoading } = useGlobalServices(); const { data: service, isLoading } = useGlobalServices();
@ -31,10 +32,14 @@ const ManagOrg = () => {
defaultValues: defaultOrganizationValues, defaultValues: defaultOrganizationValues,
}); });
const [logoPreview, setLogoPreview] = useState(null);
const [logoName, setLogoName] = useState("");
const { const {
handleSubmit, handleSubmit,
register, register,
reset, reset,
getValues,
formState: { errors }, formState: { errors },
} = method; } = method;
@ -62,6 +67,7 @@ const ManagOrg = () => {
email: organization.email || "", email: organization.email || "",
serviceIds: organization.services?.map((s) => s.id) || [], serviceIds: organization.services?.map((s) => s.id) || [],
address: organization.address || "", address: organization.address || "",
logoImage: organization.logoImage || "",
}); });
} }
}, [organization, reset, service?.data]); }, [organization, reset, service?.data]);
@ -93,6 +99,14 @@ const ManagOrg = () => {
} }
onOpen({ startStep: 2 }); onOpen({ startStep: 2 });
}; };
useEffect(() => {
const logoImage = getValues("logoImage");
if (logoImage) {
setLogoPreview(logoImage);
setLogoName("Uploaded Logo");
}
}, [getValues]);
return ( return (
<FormProvider {...method}> <FormProvider {...method}>
<form className="form" onSubmit={handleSubmit(onSubmit)}> <form className="form" onSubmit={handleSubmit(onSubmit)}>
@ -176,6 +190,17 @@ const ManagOrg = () => {
)} )}
</div> </div>
<div className="col-sm-12 text-start mt-2">
<Label htmlFor="logoImage" required>Logo Image</Label>
<LogoUpload
preview={logoPreview}
setPreview={setLogoPreview}
fileName={logoName}
setFileName={setLogoName}
/>
</div>
<div className="d-flex justify-content-between gap-2 my-2"> <div className="d-flex justify-content-between gap-2 my-2">
<button <button
type="button" type="button"

View File

@ -13,6 +13,7 @@ export const organizationSchema = z.object({
.regex(phoneRegex, { message: "Invalid phone number" }), .regex(phoneRegex, { message: "Invalid phone number" }),
contactPerson: z.string().min(1, { message: "Person name required" }), contactPerson: z.string().min(1, { message: "Person name required" }),
address: z.string().min(1, { message: "Address is required!" }), address: z.string().min(1, { message: "Address is required!" }),
logoImage: z.string().min(1, { message: "Logo is required!" }),
email: z email: z
.string().trim() .string().trim()
.min(1, { message: "Email is required" }) .min(1, { message: "Email is required" })
@ -28,6 +29,7 @@ export const defaultOrganizationValues = {
contactPerson: "", contactPerson: "",
address: "", address: "",
email: "", email: "",
logoImage:"",
serviceIds: [], serviceIds: [],
}; };

View File

@ -131,7 +131,7 @@ const OrganizationsList = ({searchText}) => {
<div className="d-flex justify-content-center gap-2"> <div className="d-flex justify-content-center gap-2">
<i className="bx bx-show text-primary cursor-pointer" onClick={()=>onOpen({startStep:5,orgData:org.id,flowType:"view"})}></i> <i className="bx bx-show text-primary cursor-pointer" onClick={()=>onOpen({startStep:5,orgData:org.id,flowType:"view"})}></i>
<i className="bx bx-edit text-secondary cursor-pointer" onClick={()=>onOpen({startStep:4,orgData:org,flowType:"edit"})}></i> <i className="bx bx-edit text-secondary cursor-pointer" onClick={()=>onOpen({startStep:4,orgData:org,flowType:"edit"})}></i>
<i className="bx bx-trash text-danger cursor-pointer"></i> <i className="bx bx-trash text-danger cursor-not-allowed"></i>
</div> </div>
</td> </td>
</tr> </tr>

View File

@ -22,8 +22,7 @@ const VieworgDataanization = ({ orgId }) => {
</div> </div>
<div className="text-end"> <div className="text-end">
<span <span
className={`badge bg-label-${ className={`badge bg-label-${data?.isActive ? "primary" : "secondary"
data?.isActive ? "primary" : "secondary"
} `} } `}
> >
{data?.isActive ? "Active" : "In-Active"}{" "} {data?.isActive ? "Active" : "In-Active"}{" "}
@ -105,9 +104,101 @@ const VieworgDataanization = ({ orgId }) => {
<div className="text-muted text-start">{data?.address}</div> <div className="text-muted text-start">{data?.address}</div>
</div> </div>
</div> </div>
<div className="d-flex text-secondary mb-2"> <div className="col-12 mb-3">
{" "} <div
<i className="bx bx-sm bx-briefcase me-1" /> Projects And Services className="d-flex justify-content-between align-items-center text-secondary mb-2 cursor-pointer"
data-bs-toggle="collapse"
data-bs-target="#collapse-projects-services"
aria-expanded="false"
>
<div>
<i className="bx bx-sm bx-briefcase me-1" /> Projects
</div>
<i className="bx bx-chevron-down me-2"></i>
</div>
{/* remove "show" from className */}
<div id="collapse-projects-services" className="collapse">
{data?.projects && data.projects.length > 0 ? (
data.projects
.reduce((acc, curr) => {
const projectId = curr.project.id;
if (!acc.find((p) => p.id === projectId)) {
acc.push(curr.project);
}
return acc;
}, [])
.map((project) => (
<div key={project.id} className="mb-2 rounded p-2">
<div
className="d-flex justify-content-between align-items-center cursor-pointer"
data-bs-toggle="collapse"
data-bs-target={`#collapse-${project.id}`}
aria-expanded="false"
>
<label className="form-label fw-semibold">
<i className="bx bx-buildings me-2"></i>
{project.name}
</label>
<i className="bx bx-chevron-down"></i>
</div>
<div id={`collapse-${project.id}`} className="collapse mt-2 ps-5">
{data.projects
.filter((p) => p.project.id === project.id)
.map((p) => (
<div key={p.service.id} className="mb-1 text-muted">
<i className="bx bx-wrench me-2"></i>
{p.service.name}
</div>
))}
</div>
</div>
))
) : (
<div className="text-muted fst-italic ps-2">No projects available</div>
)}
</div>
</div>
{/* Services Section */}
<div className="col-12 mb-3">
<div
className="d-flex justify-content-between align-items-center text-secondary mb-2 cursor-pointer"
data-bs-toggle="collapse"
data-bs-target="#collapse-services"
aria-expanded="false"
>
<div>
<i className="bx bx-sm bx-cog me-1" /> Services
</div>
<i className="bx bx-chevron-down me-2"></i>
</div>
{/* collapse is closed initially */}
<div id="collapse-services" className="collapse">
{data?.services && data.services.length > 0 ? (
<div className="row">
{data.services.map((service) => (
<div key={service.id} className="col-md-12 mb-3">
<div className="card h-100 shadow-sm border-0">
<div className="card-body">
<h6 className="fw-semibold mb-1">
<i className="bx bx-wrench me-1"></i>
{service.name}
</h6>
<p className="text-muted small mb-0">
{service.description || "No description available."}
</p>
</div>
</div>
</div>
))}
</div>
) : (
<div className="text-muted fst-italic ps-2">No services available</div>
)}
</div>
</div> </div>
</div> </div>
); );

View File

@ -201,7 +201,7 @@ const Teams = () => {
className="form-check-label ms-2" className="form-check-label ms-2"
htmlFor="activeEmployeeSwitch" htmlFor="activeEmployeeSwitch"
> >
{activeEmployee ? "Active Employees" : "Include Inactive Employees"} {activeEmployee ? "Active Employees" : "In-active Employees"}
</label> </label>
</div> </div>
</div> </div>

View File

@ -45,7 +45,7 @@ export const LogoUpload = ({ preview, setPreview, fileName, setFileName }) => {
return ( return (
<div className="col-sm-12 mb-3"> <div className="col-sm-12 mb-3">
<div <div
className="border border-secondary border-dashed rounded p-2 text-center position-relative" className="border border-secondary text-black border-dashed rounded p-2 text-center position-relative"
style={{ cursor: "pointer" }} style={{ cursor: "pointer" }}
onClick={() => document.getElementById("logoImageInput")?.click()} onClick={() => document.getElementById("logoImageInput")?.click()}
> >

View File

@ -1,266 +0,0 @@
import { zodResolver } from "@hookform/resolvers/zod";
import React, { useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
import { defaultPayment, paymentSchema } from "./collectionSchema";
import Label from "../common/Label";
import DatePicker from "../common/DatePicker";
import { formatDate } from "date-fns";
import { useCollectionContext } from "../../pages/collections/CollectionPage";
import { useAddPayment, useCollection } from "../../hooks/useCollections";
import { formatFigure, localToUtc } from "../../utils/appUtils";
import { formatUTCToLocalTime } from "../../utils/dateUtils";
import Avatar from "../common/Avatar";
import { PaymentHistorySkeleton } from "./CollectionSkeleton";
import { usePaymentAjustmentHead } from "../../hooks/masterHook/useMaster";
const AddPayment = ({ onClose }) => {
const { addPayment } = useCollectionContext();
const { data, isLoading, isError, error } = useCollection(
addPayment?.invoiceId
);
const {
data: paymentTypes,
isLoading: isPaymentTypeLoading,
isError: isPaymentTypeError,
error: paymentError,
} = usePaymentAjustmentHead(true);
const methods = useForm({
resolver: zodResolver(paymentSchema),
defaultValues: defaultPayment,
});
const {
control,
register,
handleSubmit,
reset,
formState: { errors },
} = methods;
const { mutate: AddPayment, isPending } = useAddPayment(() => {
handleClose();
});
const onSubmit = (formData) => {
const payload = {
...formData,
paymentReceivedDate: localToUtc(formData.paymentReceivedDate),
invoiceId: addPayment.invoiceId,
};
AddPayment(payload);
};
const handleClose = (formData) => {
reset(defaultPayment);
};
return (
<div className="container pb-3">
<div className="text-black fs-5 mb-2">Add Payment</div>
<FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)} className="p-0 text-start">
<div className="row px-md-1 px-0">
<div className="col-12 col-md-6 mb-2">
<Label required>TransanctionId</Label>
<input
type="text"
className="form-control form-control-sm"
{...register("transactionId")}
/>
{errors.transactionId && (
<small className="danger-text">
{errors.transactionId.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label required>Transaction Date </Label>
<DatePicker
name="paymentReceivedDate"
control={control}
minDate={
data?.clientSubmitedDate
? new Date(
new Date(data?.clientSubmitedDate).setDate(
new Date(data?.clientSubmitedDate).getDate() + 1
)
)
: null
}
maxDate={new Date()}
/>
{errors.paymentReceivedDate && (
<small className="danger-text">
{errors.paymentReceivedDate.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label
htmlFor="paymentAdjustmentHeadId"
className="form-label"
required
>
Payment Adjustment Head
</Label>
<select
className="form-select form-select-sm "
{...register("paymentAdjustmentHeadId")}
>
{isPaymentTypeLoading ? (
<option>Loading..</option>
) : (
<>
<option value="">Select Payment Head</option>
{paymentTypes?.data
?.sort((a, b) => a.name.localeCompare(b.name))
?.map((type) => (
<option key={type.id} value={type.id}>
{type.name}
</option>
))}
</>
)}
</select>
{errors.paymentAdjustmentHeadId && (
<small className="danger-text">
{errors.paymentAdjustmentHeadId.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label htmlFor="amount" className="form-label" required>
Amount
</Label>
<input
type="number"
id="amount"
className="form-control form-control-sm"
min="1"
step="0.01"
inputMode="decimal"
{...register("amount", { valueAsNumber: true })}
/>
{errors.amount && (
<small className="danger-text">{errors.amount.message}</small>
)}
</div>
<div className="col-12 mb-2">
<Label htmlFor="comment" className="form-label" required>
Comment
</Label>
<textarea
id="comment"
className="form-control form-control-sm"
{...register("comment")}
/>
{errors.comment && (
<small className="danger-text">{errors.comment.message}</small>
)}
</div>
<div className="d-flex justify-content-end gap-3">
{" "}
<button
type="reset"
className="btn btn-label-secondary btn-sm mt-3"
onClick={() => {
handleClose();
onClose();
}}
disabled={isPending}
>
Cancel
</button>
<button
type="submit"
className="btn btn-primary btn-sm mt-3"
disabled={isPending}
>
{isPending ? "Please Wait..." : "Submit"}
</button>
</div>
</div>
</form>
</FormProvider>
{isLoading ? (
<PaymentHistorySkeleton />
) : (
data?.receivedInvoicePayments?.length > 0 && (
<div className="mt-1 text-start">
<div className="mb-2 text-secondry fs-6">
<i className="bx bx-history bx-sm me-1"></i>History
</div>
<div className="row text-start mx-2">
{data.receivedInvoicePayments
.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
.map((payment, index) => (
<div className="col-12 mb-2" key={payment.id}>
<div className=" p-2 border-start border-warning">
<div className="row">
<div className="col-12 col-md-6 d-flex justify-content-between align-items-center ">
<div>
<small className="fw-semibold me-1">
Transaction Date:
</small>{" "}
{formatUTCToLocalTime(payment.paymentReceivedDate)}
</div>
<span className="fs-semibold d-block d-md-none">
{formatFigure(payment.amount, {
type: "currency",
currency: "INR",
})}
</span>
</div>
<div className="col-12 col-md-6 mb-0 d-flex align-items-center m-0">
<small className="fw-semibold me-2">
Updated By:
</small>{" "}
<Avatar
size="xs"
firstName={payment?.createdBy?.firstName}
lastName={payment?.createdBy?.lastName}
/>{" "}
{payment?.createdBy?.firstName}{" "}
{payment.createdBy?.lastName}
</div>
</div>
<div className="row">
<div className="col-12 col-md-6">
<p className="mb-1">
<small className="fw-semibold">
Transaction ID:
</small>{" "}
{payment.transactionId}
</p>
</div>
<div className="col-12 ">
<div className="d-flex justify-content-between">
<span>{payment?.paymentAdjustmentHead?.name}</span>
<span className="fs-semibold d-none d-md-block">
{formatFigure(payment.amount, {
type: "currency",
currency: "INR",
})}
</span>
</div>
<p className="text-tiny m-0 mt-1">
{payment?.comment}
</p>
</div>
</div>
</div>
</div>
))}
</div>
</div>
)
)}
</div>
);
};
export default AddPayment;

View File

@ -1,296 +0,0 @@
import React, { useState } from "react";
import { useCollections } from "../../hooks/useCollections";
import {
ADDPAYMENT_COLLECTION,
ADMIN_COLLECTION,
CREATE_COLLECTION,
EDIT_COLLECTION,
ITEMS_PER_PAGE,
VIEW_COLLECTION,
} from "../../utils/constants";
import { formatFigure, localToUtc, useDebounce } from "../../utils/appUtils";
import { formatUTCToLocalTime } from "../../utils/dateUtils";
import Pagination from "../common/Pagination";
import { useCollectionContext } from "../../pages/collections/CollectionPage";
import { CollectionTableSkeleton } from "./CollectionSkeleton";
import { useSelectedProject } from "../../slices/apiDataManager";
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
const CollectionList = ({ fromDate, toDate, isPending, searchString }) => {
const [currentPage, setCurrentPage] = useState(1);
const isAdmin = useHasUserPermission(ADMIN_COLLECTION);
const canAddPayment = useHasUserPermission(ADDPAYMENT_COLLECTION);
const canViewCollection = useHasUserPermission(VIEW_COLLECTION);
const canEditCollection = useHasUserPermission(EDIT_COLLECTION);
const canCreate = useHasUserPermission(CREATE_COLLECTION);
const selectedProject = useSelectedProject();
const searchDebounce = useDebounce(searchString, 500);
const { data, isLoading, isError, error } = useCollections(
ITEMS_PER_PAGE,
currentPage,
localToUtc(fromDate),
localToUtc(toDate),
isPending,
true,
selectedProject,
searchDebounce
);
const { setProcessedPayment, setAddPayment, setViewCollection } =
useCollectionContext();
const paginate = (page) => {
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
setCurrentPage(page);
}
};
const collectionColumns = [
{
key: "invoiceDate",
label: "Invoice Date",
getValue: (col) => (
<span
className="text-truncate d-inline-block"
style={{ maxWidth: "200px" }}
>
{formatUTCToLocalTime(col.invoiceDate)}
</span>
),
align: "text-start",
},
{
key: "invoiceId",
label: "Invoice No",
getValue: (col) => (
<span
className="text-truncate d-inline-block"
style={{ maxWidth: "200px" }}
>
{col?.invoiceNumber ?? "-"}
</span>
),
align: "text-start",
},
{
key: "project",
label: "Project",
getValue: (col) => (
<span
className="text-truncate d-inline-block"
style={{ maxWidth: "200px" }}
>
{col?.project?.name ?? "-"}
</span>
),
align: "text-start",
},
{
key: "submittedDate",
label: "Submission Date",
getValue: (col) => (
<span
className="text-truncate d-inline-block"
style={{ maxWidth: "200px" }}
>
{formatUTCToLocalTime(col.createdAt)}
</span>
),
align: "text-center",
},
{
key: "expectedSubmittedDate",
label: "Expected Payment Date",
getValue: (col) => (
<span
className="text-truncate d-inline-block"
style={{ maxWidth: "200px" }}
>
{formatUTCToLocalTime(col.exceptedPaymentDate) ?? "-"}
</span>
),
align: "text-center",
},
{
key: "amount",
label: "Total Amount",
getValue: (col) => (
<span
className="text-truncate d-inline-block"
style={{ maxWidth: "200px" }}
>
{formatFigure(col?.basicAmount + col?.taxAmount, {
type: "currency",
currency: "INR",
}) ?? 0}
</span>
),
align: "text-end",
},
{
key: "balance",
label: "Balance",
getValue: (col) => (
<span
className="text-truncate d-inline-block py-3"
style={{ maxWidth: "200px" }}
>
{formatFigure(col?.balanceAmount, {
type: "currency",
currency: "INR",
}) ?? 0}
</span>
),
align: "text-end",
},
];
if (isLoading) return <CollectionTableSkeleton />;
if (isError) return <p>{error.message}</p>;
return (
<div className="card ">
<div
className="card-datatable table-responsive page-min-h"
id="horizontal-example"
>
<div className="dataTables_wrapper no-footer mx-5 pb-2">
<table className="table dataTable text-nowrap">
<thead>
<tr className="table_header_border">
{collectionColumns.map((col) => (
<th key={col.key} className={col.align}>
{col.label}
</th>
))}
{(isAdmin ||
canAddPayment ||
canViewCollection ||
canEditCollection ||
canCreate) && <th>Action</th>}
</tr>
</thead>
<tbody>
{Array.isArray(data?.data) && data.data.length > 0 ? (
data.data.map((row, i) => (
<tr key={i}>
{collectionColumns.map((col) => (
<td key={col.key} className={col.align}>
{col.getValue(row)}
</td>
))}
{(isAdmin ||
canAddPayment ||
canViewCollection ||
canEditCollection ||
canCreate) && (
<td
className="sticky-action-column text-center"
style={{ padding: "12px 8px" }}
>
<div className="dropdown z-2">
<button
type="button"
className="btn btn-icon btn-text-secondary rounded-pill dropdown-toggle hide-arrow p-0"
data-bs-toggle="dropdown"
aria-expanded="false"
>
<i
className="bx bx-dots-vertical-rounded bx-sm text-muted"
data-bs-toggle="tooltip"
data-bs-offset="0,8"
data-bs-placement="top"
data-bs-custom-class="tooltip-dark"
title="More Action"
></i>
</button>
<ul className="dropdown-menu dropdown-menu-end">
{/* View */}
<li>
<a
className="dropdown-item cursor-pointer"
onClick={() => setViewCollection(row.id)}
>
<i className="bx bx-show me-2 text-primary"></i>
<span>View</span>
</a>
</li>
{/* Only if not completed */}
{!row?.markAsCompleted && (
<>
{/* Add Payment */}
{(isAdmin || canAddPayment) && (
<li>
<a
className="dropdown-item cursor-pointer"
onClick={() =>
setAddPayment({
isOpen: true,
invoiceId: row.id,
})
}
>
<i className="bx bx-wallet me-2 text-warning"></i>
<span>Add Payment</span>
</a>
</li>
)}
{/* Mark Payment */}
{isAdmin && (
<li>
<a
className="dropdown-item cursor-pointer"
onClick={() =>
setProcessedPayment({
isOpen: true,
invoiceId: row.id,
})
}
>
<i className="bx bx-check-circle me-2 text-success"></i>
<span>Mark Payment</span>
</a>
</li>
)}
</>
)}
</ul>
</div>
</td>
)}
</tr>
))
) : (
<tr style={{ height: "200px" }}>
<td
colSpan={collectionColumns.length + 1}
className="text-center border-0 align-middle"
>
No Collections Found
</td>
</tr>
)}
</tbody>
</table>
{data?.data?.length > 0 && (
<div className="d-flex justify-content-start mt-2">
<Pagination
currentPage={currentPage}
totalPages={data?.totalPages}
onPageChange={paginate}
/>
</div>
)}
</div>
</div>
</div>
);
};
export default CollectionList;

View File

@ -1,211 +0,0 @@
import React from "react";
const SkeletonLine = ({ height = 20, width = "100%", className = "" }) => (
<div
className={`skeleton mb-2 ${className}`}
style={{
height,
width,
}}
></div>
);
export const PaymentHistorySkeleton = ({ count = 2 }) => {
return (
<div className="row text-start">
{[...Array(count)].map((_, idx) => (
<div className="col-12 mb-2" key={idx}>
<div className="p-2 border-start border-warning">
{/* Top Row: Date + Amount */}
<div className="d-flex justify-content-between align-items-center">
<SkeletonLine width="150px" height={18} /> {/* Date */}
<SkeletonLine width="100px" height={18} /> {/* Amount */}
</div>
<div className="row mt-1">
{/* Transaction ID */}
<div className="col-12 col-md-6">
<SkeletonLine width="80%" height={16} />
</div>
{/* Received By (Avatar + Name) */}
<div className="col-12 col-md-6 d-flex align-items-center gap-2">
<SkeletonLine
width="30px"
height={30}
className="rounded-circle"
/>{" "}
{/* Avatar */}
<SkeletonLine width="120px" height={16} /> {/* Name */}
</div>
</div>
</div>
</div>
))}
</div>
);
};
export const CollectionDetailsSkeleton = () => {
return (
<div className="container p-3">
{/* Title */}
<SkeletonLine height={24} width="200px" className="mx-auto" />
{/* Header Row */}
<div className="row mb-3 px-1">
<div className="col-10">
<SkeletonLine height={20} />
</div>
<div className="col-2 d-flex justify-content-end">
<SkeletonLine height={20} width="60px" />
</div>
</div>
{/* Project */}
<div className="row mb-3">
<div className="col-md-6">
<SkeletonLine width="60%" />
</div>
</div>
{/* Invoice & E-Invoice */}
<div className="row mb-3">
<div className="col-md-6">
<SkeletonLine />
</div>
<div className="col-md-6">
<SkeletonLine />
</div>
</div>
{/* Invoice Date & Client Submitted */}
<div className="row mb-3">
<div className="col-md-6">
<SkeletonLine />
</div>
<div className="col-md-6">
<SkeletonLine />
</div>
</div>
{/* Expected Payment & Mark as Completed */}
<div className="row mb-3">
<div className="col-md-6">
<SkeletonLine />
</div>
<div className="col-md-6">
<SkeletonLine width="40%" />
</div>
</div>
{/* Basic & Tax Amount */}
<div className="row mb-3">
<div className="col-md-6">
<SkeletonLine />
</div>
<div className="col-md-6">
<SkeletonLine />
</div>
</div>
{/* Balance & Created At */}
<div className="row mb-3">
<div className="col-md-6">
<SkeletonLine />
</div>
<div className="col-md-6">
<SkeletonLine />
</div>
</div>
{/* Created By */}
<div className="row mb-3">
<div className="col-md-6 d-flex align-items-center">
<SkeletonLine
width="40px"
height={40}
className="me-2 rounded-circle"
/>
<SkeletonLine width="100px" />
</div>
</div>
{/* Description */}
<div className="row mb-3">
<div className="col-12">
<SkeletonLine height={50} />
</div>
</div>
{/* Attachments */}
<div className="row mb-3">
<div className="col-12 d-flex gap-2 flex-wrap">
{[...Array(3)].map((_, idx) => (
<SkeletonLine key={idx} height={60} width="80px" />
))}
</div>
</div>
{/* Tabs */}
<div className="row mb-2">
<div className="col-12 d-flex gap-2">
<SkeletonLine height={35} width="120px" />
<SkeletonLine height={35} width="150px" />
</div>
</div>
{/* Tab Content (Comments / Payments) */}
<SkeletonLine height={200} />
</div>
);
};
export const CollectionTableSkeleton = () => {
const columnCount = 8;
return (
<div className="card ">
<div
className="card-datatable table-responsive page-min-h"
id="horizontal-example"
>
<div className="dataTables_wrapper no-footer mx-5 pb-2">
<table className="table dataTable text-nowrap">
<thead>
<tr >
{[...Array(columnCount - 1)].map((_, i) => (
<th key={i}>
<SkeletonLine height={15} width="80px" />
</th>
))}
<th className="d-flex justify-content-center">
<SkeletonLine height={16} width="40px" />
</th>
</tr>
</thead>
<tbody>
{[...Array(8)].map((_, rowIdx) => (
<tr key={rowIdx}>
{[...Array(columnCount - 1)].map((_, colIdx) => (
<td key={colIdx}>
<SkeletonLine height={33} />
</td>
))}
<td className="d-flex justify-content-center">
<SkeletonLine height={16} width="20px" />
</td>
</tr>
))}
</tbody>
</table>
{/* Pagination Skeleton */}
<div className="d-flex justify-content-end mt-2">
<SkeletonLine height={30} width="200px" />
</div>
</div>
</div>
</div>
);
};

View File

@ -1,85 +0,0 @@
import { zodResolver } from "@hookform/resolvers/zod";
import React from "react";
import { useForm } from "react-hook-form";
import { CommentSchema } from "./collectionSchema";
import { useAddComment } from "../../hooks/useCollections";
import Avatar from "../common/Avatar";
import { formatUTCToLocalTime } from "../../utils/dateUtils";
import moment from "moment";
const Comment = ({ invoice }) => {
const {
register,
reset,
handleSubmit,
formState: { errors },
} = useForm({
resolver: zodResolver(CommentSchema),
defaultValues: { comment: "" },
});
const { mutate: AddComment, isPending } = useAddComment(() => {
reset();
});
const onSubmit = (formData) => {
const payload = { ...formData, invoiceId: invoice?.id };
AddComment(payload);
};
return (
<div className="row pt-1 px-2">
<form onSubmit={handleSubmit(onSubmit)}>
<div className="col-12">
<textarea
className="form-control "
rows={3}
{...register("comment")}
/>
{errors.comment && (
<small className="danger-text">{errors.comment.message}</small>
)}
</div>
<div className="d-flex justify-content-end p-2">
<button
className="btn btn-sm btn-primary"
type="submit"
disabled={isPending}
>
{isPending ? "Please wait..." : "Submit"}
</button>
</div>
</form>
{invoice?.comments?.length > 0 ? (
invoice.comments.map((comment, index) => (
<div
className="border-start border-primary ps-1 py-2 mb-3"
key={comment.id || index}
>
<div className="d-flex justify-content-between align-items-center mb-1">
<div className="d-flex align-items-center">
<Avatar
size="xs"
firstName={comment?.createdBy?.firstName}
lastName={comment?.createdBy?.lastName}
/>
<span className="ms-1 fw-semibold">
{comment?.createdBy?.firstName} {comment?.createdBy?.lastName}
</span>
</div>
<small className="text-secondary">
{moment.utc(comment?.createdAt).local().fromNow()}
</small>
</div>
<div className="ms-9"> <p className="mb-1">{comment?.comment}</p></div>
</div>
))
) : (
<div className="text-center py-2"> <p className="text-muted">No comments yet.</p></div>
)}
</div>
);
};
export default Comment;

View File

@ -1,445 +0,0 @@
import React, { useEffect } from "react";
import { useModal } from "../../hooks/useAuth";
import Modal from "../common/Modal";
import { FormProvider, useForm } from "react-hook-form";
import Label from "../common/Label";
import { zodResolver } from "@hookform/resolvers/zod";
import { defaultCollection, newCollection } from "./collectionSchema";
import SelectMultiple from "../common/SelectMultiple";
import { useProjectName } from "../../hooks/useProjects";
import DatePicker from "../common/DatePicker";
import {
useCollection,
useCreateCollection,
useUpdateCollection,
} from "../../hooks/useCollections";
import { formatFileSize, localToUtc } from "../../utils/appUtils";
import { useCollectionContext } from "../../pages/collections/CollectionPage";
import { formatDate } from "../../utils/dateUtils";
const ManageCollection = ({ collectionId, onClose }) => {
const { data, isError, isLoading, error } = useCollection(collectionId);
const { projectNames, projectLoading } = useProjectName(true);
const methods = useForm({
resolver: zodResolver(newCollection),
defaultValues: defaultCollection,
});
const {
control,
watch,
register,
setValue,
handleSubmit,
reset,
formState: { errors },
} = methods;
const { mutate: createNewCollection, isPending } = useCreateCollection(() => {
handleClose();
});
const { mutate: UpdateCollection } = useUpdateCollection(() => {
handleClose();
});
const files = watch("attachments");
const onFileChange = async (e) => {
const newFiles = Array.from(e.target.files);
if (newFiles.length === 0) return;
const existingFiles = watch("attachments") || [];
const parsedFiles = await Promise.all(
newFiles.map(async (file) => {
const base64Data = await toBase64(file);
return {
fileName: file.name,
base64Data,
contentType: file.type,
fileSize: file.size,
description: "",
isActive: true,
};
})
);
const combinedFiles = [
...existingFiles,
...parsedFiles.filter(
(newFile) =>
!existingFiles.some(
(f) =>
f.fileName === newFile.fileName && f.fileSize === newFile.fileSize
)
),
];
setValue("attachments", combinedFiles, {
shouldDirty: true,
shouldValidate: true,
});
};
const toBase64 = (file) =>
new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result.split(",")[1]);
reader.onerror = (error) => reject(error);
});
const removeFile = (index) => {
if (collectionId) {
const newFiles = files.map((file, i) => {
if (file.documentId !== index) return file;
return {
...file,
isActive: false,
};
});
setValue("attachments", newFiles, { shouldValidate: true });
} else {
const newFiles = files.filter((_, i) => i !== index);
setValue("attachments", newFiles, { shouldValidate: true });
}
};
const onSubmit = (formData) => {
const payload = {
...formData,
clientSubmitedDate: localToUtc(formData.clientSubmitedDate),
invoiceDate: localToUtc(formData.invoiceDate),
exceptedPaymentDate: localToUtc(formData.exceptedPaymentDate),
};
if (collectionId) {
UpdateCollection({
collectionId,
payload: { ...payload, id: collectionId },
});
} else {
createNewCollection(payload);
}
};
const handleClose = () => {
reset(defaultCollection);
onClose();
};
useEffect(() => {
if (data && collectionId) {
reset({
projectId: data?.project?.id,
invoiceNumber: data?.invoiceNumber,
eInvoiceNumber: data?.eInvoiceNumber,
title: data?.title,
clientSubmitedDate: formatDate(data?.clientSubmitedDate),
invoiceDate: formatDate(data?.invoiceDate),
exceptedPaymentDate: formatDate(data?.exceptedPaymentDate),
taxAmount: data?.taxAmount,
basicAmount: data?.basicAmount,
description: data?.description,
attachments: data.attachments
? data.attachments.map((doc) => ({
fileName: doc.fileName,
base64Data: null,
contentType: doc.contentType,
documentId: doc.documentId,
fileSize: 0,
description: "",
preSignedUrl: doc.preSignedUrl,
isActive: doc.isActive ?? true,
}))
: [],
});
}
}, [data]);
if (isLoading) return <div>Loading....</div>;
if (isError) return <div>{error.message}</div>;
return (
<div className="container pb-3">
<div className="text-black fs-5 mb-2">
{collectionId ? "Update" : "New"} Collection
</div>
<FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)} className="p-0 text-start">
<div className="row px-md-1 px-0">
<div className="col-12 col-md-6 mb-2">
<Label className="form-label" required>
Select Project
</Label>
<select
className="form-select form-select-sm"
{...register("projectId")}
>
<option value="">Select Project</option>
{projectLoading ? (
<option>Loading...</option>
) : (
projectNames?.map((project) => (
<option key={project.id} value={project.id}>
{project.name}
</option>
))
)}
</select>
{errors.projectId && (
<small className="danger-text">
{errors.projectId.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label required>Title</Label>
<input
type="text"
className="form-control form-control-sm"
{...register("title")}
/>
{errors.title && (
<small className="danger-text">{errors.title.message}</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label required>Invoice Number</Label>
<input
type="text"
className="form-control form-control-sm"
{...register("invoiceNumber")}
/>
{errors.invoiceId && (
<small className="danger-text">
{errors.invoiceId.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label required>E-Invoice Number</Label>
<input
type="text"
className="form-control form-control-sm"
{...register("eInvoiceNumber")}
/>
{errors.invoiceId && (
<small className="danger-text">
{errors.invoiceId.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label required>Invoice Date</Label>
<DatePicker
name="invoiceDate"
control={control}
maxDate={new Date()}
/>
{errors.invoiceDate && (
<small className="danger-text">
{errors.invoiceDate.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label required>Expected Payment Date</Label>
<DatePicker
name="exceptedPaymentDate"
control={control}
minDate={watch("invoiceDate")}
/>
{errors.exceptedPaymentDate && (
<small className="danger-text">
{errors.exceptedPaymentDate.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label required>Submission Date (Client)</Label>
<DatePicker
name="clientSubmitedDate"
control={control}
maxDate={new Date()}
/>
{errors.exceptedPaymentDate && (
<small className="danger-text">
{errors.exceptedPaymentDate.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label htmlFor="basicAmount" className="form-label" required>
Basic Amount
</Label>
<input
type="number"
id="basicAmount"
className="form-control form-control-sm"
min="1"
step="0.01"
inputMode="decimal"
{...register("basicAmount", { valueAsNumber: true })}
/>
{errors.basicAmount && (
<small className="danger-text">
{errors.basicAmount.message}
</small>
)}
</div>
<div className="col-12 col-md-6 mb-2">
<Label htmlFor="taxAmount" className="form-label" required>
Tax Amount
</Label>
<input
type="number"
id="taxAmount"
className="form-control form-control-sm"
min="1"
step="0.01"
inputMode="decimal"
{...register("taxAmount", { valueAsNumber: true })}
/>
{errors.taxAmount && (
<small className="danger-text">
{errors.taxAmount.message}
</small>
)}
</div>
<div className="col-12 my-2 text-start mb-2">
<div className="col-md-12">
<Label htmlFor="description" className="form-label" required>
Description
</Label>
<textarea
id="description"
className="form-control form-control-sm"
{...register("description")}
rows="2"
></textarea>
{errors.description && (
<small className="danger-text">
{errors.description.message}
</small>
)}
</div>
</div>
<div className="col-12">
<Label className="form-label" required>
Upload Bill{" "}
</Label>
<div
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative text-black"
style={{ cursor: "pointer" }}
onClick={() => document.getElementById("attachments").click()}
>
<i className="bx bx-cloud-upload d-block bx-lg "> </i>
<span className="text-muted d-block">
Click to select or click here to browse
</span>
<small className="text-muted">
(PDF, JPG, PNG,Doc,docx,xls,xlsx max 5MB)
</small>
<input
type="file"
id="attachments"
accept="
.pdf,
.doc,
.docx,
.xls,
.xlsx,
.jpg,
.jpeg,
.png
"
multiple
style={{ display: "none" }}
{...register("attachments")}
onChange={(e) => {
onFileChange(e);
e.target.value = "";
}}
/>
</div>
{errors.attachments && (
<small className="danger-text">
{errors.attachments.message}
</small>
)}
{files.length > 0 && (
<div className="d-block">
{files
.filter((file) => {
if (collectionId) {
return file.isActive;
}
return true;
})
.map((file, idx) => (
<a
key={idx}
className="d-flex justify-content-between text-start p-1"
href={file.preSignedUrl || "#"}
target="_blank"
rel="noopener noreferrer"
>
<div>
<span className="mb-0 text-secondary small d-block">
{file.fileName}
</span>
<span className="text-body-secondary small d-block">
{file.fileSize ? formatFileSize(file.fileSize) : ""}
</span>
</div>
<i
className="bx bx-trash bx-sm cursor-pointer text-danger"
onClick={(e) => {
e.preventDefault();
removeFile(collectionId ? file.documentId : idx);
}}
></i>
</a>
))}
</div>
)}
{Array.isArray(errors.attachments) &&
errors.attachments.map((fileError, index) => (
<div key={index} className="danger-text small mt-1">
{
(fileError?.fileSize?.message ||
fileError?.contentType?.message ||
fileError?.base64Data?.message,
fileError?.documentId?.message)
}
</div>
))}
</div>
<div className="d-flex justify-content-end gap-3">
{" "}
<button
type="reset"
className="btn btn-label-secondary btn-sm mt-3"
onClick={handleClose}
disabled={isPending}
>
Cancel
</button>
<button
type="submit"
className="btn btn-primary btn-sm mt-3"
disabled={isPending}
>
{isPending ? "Please Wait..." : "Submit"}
</button>
</div>
</div>
</form>
</FormProvider>
</div>
);
};
export default ManageCollection;

View File

@ -1,53 +0,0 @@
import React from 'react'
import { formatUTCToLocalTime } from '../../utils/dateUtils'
import { formatFigure } from '../../utils/appUtils'
import Avatar from '../common/Avatar'
const PaymentHistoryTable = ({data}) => {
return (
<div>
{data?.receivedInvoicePayments?.length > 0 ? (
<div className="pt-1 data-tabe table-responsive">
<table className="table table-bordered table-responsive mt-2">
<thead className="table-light">
<tr>
<th className="text-center">Sr.No</th>
<th className="text-center">Transaction ID</th>
<th className="text-center"> Received Date</th>
<th className="text-center"> Payment Adjustment-Head</th>
<th className="text-center">Amount</th>
<th className="text-center">Updated By</th>
</tr>
</thead>
<tbody>
{data.receivedInvoicePayments.map((payment, index) => (
<tr key={payment.id}>
<td className="text-center">{index + 1}</td>
<td ><span className="mx-2">{payment.transactionId}</span></td>
<td className="text-center">{formatUTCToLocalTime(payment.paymentReceivedDate)}</td>
<td className="text-start">{payment?.paymentAdjustmentHead?.name ?? "--"}</td>
<td className="text-end">
<span className="px-1">{formatFigure(payment.amount, {
type: "currency",
currency: "INR",
})}</span>
</td>
<td>
<div className="d-flex align-items-center mx-2 py-1">
{payment.createdBy?.firstName}{" "}
{payment.createdBy?.lastName}
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
):(<div className='text-center py-2'><p>No History</p></div>)}
</div>
)
}
export default PaymentHistoryTable

View File

@ -1,258 +0,0 @@
import React, { useState } from "react";
import { useCollectionContext } from "../../pages/collections/CollectionPage";
import { useCollection } from "../../hooks/useCollections";
import { formatUTCToLocalTime } from "../../utils/dateUtils";
import { formatFigure, getIconByFileType } from "../../utils/appUtils";
import Avatar from "../common/Avatar";
import PaymentHistoryTable from "./PaymentHistoryTable";
import Comment from "./Comment";
import { CollectionDetailsSkeleton } from "./CollectionSkeleton";
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
import { ADMIN_COLLECTION, EDIT_COLLECTION } from "../../utils/constants";
const ViewCollection = ({ onClose }) => {
const [activeTab, setActiveTab] = useState("payments");
const isAdmin = useHasUserPermission(ADMIN_COLLECTION);
const canEditCollection = useHasUserPermission(EDIT_COLLECTION);
const { viewCollection, setCollection, setDocumentView } =
useCollectionContext();
const { data, isLoading, isError, error } = useCollection(viewCollection);
const handleEdit = () => {
setCollection({ isOpen: true, invoiceId: viewCollection });
onClose();
};
if (isLoading) return <CollectionDetailsSkeleton />;
if (isError) return <div>{error.message}</div>;
return (
<div className="container p-3">
<p className="fs-5 fw-semibold">Collection Details</p>
<div className="row text-start ">
<div className="col-12 mb-3 d-flex justify-content-between">
<div className="d-flex">
<label
className=" me-2 mb-0 fw-semibold"
style={{ minWidth: "130px" }}
>
Project :
</label>
<div className="text-muted">{data?.project?.name}</div>
</div>
<div>
{" "}
<span
className={`badge bg-label-${
data?.isActive ? "primary" : "danger"
}`}
>
{data?.isActive ? "Active" : "Inactive"}
</span>
{(isAdmin || canEditCollection) &&
!data?.receivedInvoicePayments && (
<span onClick={handleEdit} className="ms-2 cursor-pointer">
<i className="bx bx-edit text-primary bx-sm"></i>
</span>
)}
</div>
</div>
<div className="col-md-6">
<div className="row mb-2 text-wrap">
<div className="col-4 fw-semibold">Title :</div>
<div className="col-8 text-wrap">{data?.title}</div>
</div>
</div>
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">Invoice Number:</div>
<div className="col-8">{data?.invoiceNumber}</div>
</div>
</div>
{/* Row 2: E-Invoice Number + Project */}
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">E-Invoice Number:</div>
<div className="col-8">{data?.eInvoiceNumber}</div>
</div>
</div>
{/* Row 3: Invoice Date + Client Submitted Date */}
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">Invoice Date:</div>
<div className="col-8">
{formatUTCToLocalTime(data?.invoiceDate)}
</div>
</div>
</div>
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">Client Submission Date:</div>
<div className="col-8">
{formatUTCToLocalTime(data?.clientSubmitedDate)}
</div>
</div>
</div>
{/* Row 4: Expected Payment Date + Mark as Completed */}
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">Expected Payment Date:</div>
<div className="col-8">
{formatUTCToLocalTime(data?.exceptedPaymentDate)}
</div>
</div>
</div>
{/* Row 5: Basic Amount + Tax Amount */}
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">Basic Amount :</div>
<div className="col-8">
{formatFigure(data?.basicAmount, {
type: "currency",
currency: "INR",
})}
</div>
</div>
</div>
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">Tax Amount :</div>
<div className="col-8">
{formatFigure(data?.taxAmount, {
type: "currency",
currency: "INR",
})}
</div>
</div>
</div>
{/* Row 6: Balance Amount + Created At */}
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">Balance Amount :</div>
<div className="col-8">
{formatFigure(data?.balanceAmount, {
type: "currency",
currency: "INR",
})}
</div>
</div>
</div>
<div className="col-md-6">
<div className="row mb-4 align-items-end">
<div className="col-4 fw-semibold">Created At :</div>
<div className="col-8">{formatUTCToLocalTime(data?.createdAt)}</div>
</div>
</div>
{/* Row 7: Created By */}
<div className="col-md-6">
<div className="row mb-4 align-items-center">
<div className="col-4 fw-semibold">Created By :</div>
<div className="col-8 d-flex align-items-center">
<Avatar
size="xs"
firstName={data.createdBy?.firstName}
lastName={data.createdBy?.lastName}
/>
<span className="ms-1 text-muted">
{data?.createdBy?.firstName} {data?.createdBy?.lastName}
</span>
</div>
</div>
</div>
{/* Description */}
<div className="col-12 my-1 mb-2">
<div className=" me-2 mb-0 fw-semibold">Description :</div>
<div className="text-muted">{data?.description}</div>
</div>
<div className="col-12 text-start">
<label className=" me-2 mb-2 fw-semibold">Attachment :</label>
<div className="d-flex flex-wrap gap-2">
{data?.attachments?.map((doc) => {
const isImage = doc.contentType?.includes("image");
return (
<div
key={doc.documentId}
className="border rounded hover-scale p-2 d-flex flex-column align-items-center"
style={{
width: "80px",
cursor: isImage ? "pointer" : "default",
}}
onClick={() => {
if (isImage) {
setDocumentView({
IsOpen: true,
Image: doc.preSignedUrl,
});
}
}}
>
<i
className={`bx ${getIconByFileType(doc.contentType)}`}
style={{ fontSize: "30px" }}
></i>
<small
className="text-center text-tiny text-truncate w-100"
title={doc.fileName}
>
{doc.fileName}
</small>
</div>
);
}) ?? "No Attachment"}
</div>
</div>
<div className="container px-1">
{/* Tabs Navigation */}
<ul className="nav nav-tabs" role="tablist">
<li className="nav-item">
<button
className={`nav-link ${
activeTab === "payments" ? "active" : ""
}`}
onClick={() => setActiveTab("payments")}
type="button"
>
<i className="bx bx-history bx-sm me-1"></i> Payments History
</button>
</li>
<li className="nav-item">
<button
className={`nav-link ${
activeTab === "details" ? "active" : ""
}`}
onClick={() => setActiveTab("details")}
type="button"
>
<i className="bx bx-message-dots bx-sm me-2"></i> Comments (
{data?.comments?.length ?? "0"})
</button>
</li>
</ul>
{/* Tab Content */}
<div className="tab-content px-1 py-0 border-top-0">
{activeTab === "payments" && (
<div className="tab-pane fade show active">
<PaymentHistoryTable data={data} />
</div>
)}
{activeTab === "details" && (
<div className="tab-pane fade show active">
<Comment invoice={data} />
</div>
)}
</div>
</div>
</div>
</div>
);
};
export default ViewCollection;

View File

@ -1,101 +0,0 @@
import { z } from "zod";
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
const ALLOWED_TYPES = [
"application/pdf",
"application/doc",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"image/png",
"image/jpg",
"image/jpeg",
"application/vnd.ms-excel",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
];
export const newCollection = z.object({
title: z.string().trim().min(1, { message: "Title is required" }),
projectId: z.string().trim().min(1, { message: "Project is required" }),
invoiceDate: z.string().min(1, { message: "Date is required" }),
description: z.string().trim().optional(),
clientSubmitedDate: z.string().min(1, { message: "Date is required" }),
exceptedPaymentDate: z.string().min(1, { message: "Date is required" }),
invoiceNumber: z
.string()
.trim()
.min(1, { message: "Invoice is required" })
.max(17, { message: "Invalid Number" }),
eInvoiceNumber: z
.string()
.trim()
.min(1, { message: "E-Invoice No is required" }),
taxAmount: z.coerce
.number({
invalid_type_error: "Amount is required and must be a number",
})
.min(1, "Amount must be Enter")
.refine((val) => /^\d+(\.\d{1,2})?$/.test(val.toString()), {
message: "Amount must have at most 2 decimal places",
}),
basicAmount: z.coerce
.number({
invalid_type_error: "Amount is required and must be a number",
})
.min(1, "Amount must be Enter")
.refine((val) => /^\d+(\.\d{1,2})?$/.test(val.toString()), {
message: "Amount must have at most 2 decimal places",
}),
attachments: z
.array(
z.object({
fileName: z.string().min(1, { message: "Filename is required" }),
base64Data: z.string().nullable(),
contentType: z.string().refine((val) => ALLOWED_TYPES.includes(val), {
message: "Only PDF, PNG, JPG, or JPEG files are allowed",
}),
documentId: z.string().optional(),
fileSize: z.number().max(MAX_FILE_SIZE, {
message: "File size must be less than or equal to 5MB",
}),
description: z.string().optional(),
isActive: z.boolean().default(true),
})
)
.nonempty({ message: "At least one file attachment is required" }),
});
export const defaultCollection = {
projectId: "",
invoiceNumber: " ",
eInvoiceNumber: "",
title: "",
clientSubmitedDate: null,
invoiceDate: null,
exceptedPaymentDate: null,
taxAmount: "",
basicAmount: "",
description: "",
attachments: [],
};
export const paymentSchema = z.object({
paymentReceivedDate: z.string().min(1, { message: "Date is required" }),
transactionId: z.string().min(1, "Transaction ID is required"),
amount: z.number().min(1, "Amount must be greater than zero"),
comment:z.string().min(1,{message:"Comment required"}),
paymentAdjustmentHeadId:z.string().min(1,{message:"Payment Type required"})
});
// Default Value
export const defaultPayment = {
paymentReceivedDate: null,
transactionId: "",
amount: 0,
comment:"",
paymentAdjustmentHeadId:""
};
export const CommentSchema = z.object({
comment:z.string().min(1,{message:"Comment required"})
})

View File

@ -1,22 +0,0 @@
import React from "react";
import Breadcrumb from "./Breadcrumb";
const AccessDenied = ({data}) => {
return (
<div className="container-fluid">
<Breadcrumb
data={data}
/>
<div className="card text-center py-1">
<i className="fa-solid fa-triangle-exclamation fs-5" />
<p>
Access Denied: You don't have permission to perform this action !
</p>
</div>
</div>
);
};
export default AccessDenied;

View File

@ -51,7 +51,7 @@ const Avatar = ({ firstName, lastName, size = "sm", classAvatar }) => {
return ( return (
<div className="avatar-wrapper p-1"> <div className="avatar-wrapper p-1">
<div className={`avatar avatar-${size} ${classAvatar}`}> <div className={`avatar avatar-${size} me-2 ${classAvatar}`}>
<span className={`avatar-initial rounded-circle ${bgClass}`}> <span className={`avatar-initial rounded-circle ${bgClass}`}>
{generateAvatarText(firstName, lastName)} {generateAvatarText(firstName, lastName)}
</span> </span>

View File

@ -13,18 +13,19 @@ const ConfirmModal = ({
if (!isOpen) return null; if (!isOpen) return null;
const TypeofIcon = () => { const TypeofIcon = () => {
switch (type) { if (type === "delete") {
case "delete": return (
return <i className="bx bx-x-circle text-danger" style={{ fontSize: "60px" }}></i>; <i
case "success": className="bx bx-x-circle text-danger"
return <i className="bx bx-check-circle text-success" style={{ fontSize: "60px" }}></i>; style={{ fontSize: "60px" }}
case "warning": ></i>
return <i className="bx bx-error-circle text-warning" style={{ fontSize: "60px" }}></i>; );
default:
return null;
} }
return null;
}; };
const modalSize = type === "delete" ? "sm" : "md";
return ( return (
<div <div
className="modal fade show" className="modal fade show"
@ -32,7 +33,7 @@ const ConfirmModal = ({
role="dialog" role="dialog"
aria-modal="true" aria-modal="true"
> >
<div className="modal-dialog modal-sm modal-dialog-top"> <div className={`modal-dialog modal-${modalSize} modal-dialog-top`}>
<div className="modal-content"> <div className="modal-content">
<div className="modal-body py-1 px-2"> <div className="modal-body py-1 px-2">
<div className="d-flex justify-content-between mb-4 pt-2"> <div className="d-flex justify-content-between mb-4 pt-2">
@ -46,10 +47,8 @@ const ConfirmModal = ({
</div> </div>
<div className="row"> <div className="row">
<div className="col-4 col-sm-3 d-flex justify-content-center align-items-start"> <div className="col-4 col-sm-2">{TypeofIcon()}</div>
{TypeofIcon()} <div className="col-8 col-sm-10 py-sm-2 py-1 text-sm-start">
</div>
<div className="col-8 col-sm-9 py-sm-2 py-1 text-sm-start">
<span className="fs-6">{message}</span> <span className="fs-6">{message}</span>
<div className="d-flex justify-content-end mt-4"> <div className="d-flex justify-content-end mt-4">
<button <button
@ -60,7 +59,7 @@ const ConfirmModal = ({
{loading ? "Please Wait..." : "Yes"} {loading ? "Please Wait..." : "Yes"}
</button> </button>
<button <button
className="btn btn-secondary ms-3 btn-sm" className="btn btn-secondary ms-4 btn-sm"
onClick={onClose} onClick={onClose}
disabled={loading} disabled={loading}
> >
@ -69,7 +68,6 @@ const ConfirmModal = ({
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -88,6 +88,7 @@ export default DateRangePicker;
export const DateRangePicker1 = ({ export const DateRangePicker1 = ({
startField = "startDate", startField = "startDate",
endField = "endDate", endField = "endDate",
@ -97,7 +98,6 @@ export const DateRangePicker1 = ({
resetSignal, resetSignal,
defaultRange = true, defaultRange = true,
maxDate = null, maxDate = null,
howManyDay = 6,
...rest ...rest
}) => { }) => {
const inputRef = useRef(null); const inputRef = useRef(null);
@ -107,13 +107,12 @@ export const DateRangePicker1 = ({
field: { ref }, field: { ref },
} = useController({ name: startField, control }); } = useController({ name: startField, control });
// Apply default range
const applyDefaultDates = () => { const applyDefaultDates = () => {
const today = new Date(); const today = new Date();
const past = new Date(today.getTime()); const past = new Date();
past.setDate(today.getDate() - howManyDay); past.setDate(today.getDate() - 6);
const format = (d) => window.flatpickr.formatDate(d, "d-m-Y"); const format = (d) => flatpickr.formatDate(d, "d-m-Y");
const formattedStart = format(past); const formattedStart = format(past);
const formattedEnd = format(today); const formattedEnd = format(today);
@ -128,11 +127,7 @@ export const DateRangePicker1 = ({
useEffect(() => { useEffect(() => {
if (!inputRef.current || inputRef.current._flatpickr) return; if (!inputRef.current || inputRef.current._flatpickr) return;
if (defaultRange && !getValues(startField) && !getValues(endField)) { const instance = flatpickr(inputRef.current, {
applyDefaultDates();
}
const instance = window.flatpickr(inputRef.current, {
mode: "range", mode: "range",
dateFormat: "d-m-Y", dateFormat: "d-m-Y",
allowInput: allowText, allowInput: allowText,
@ -140,7 +135,7 @@ export const DateRangePicker1 = ({
onChange: (selectedDates) => { onChange: (selectedDates) => {
if (selectedDates.length === 2) { if (selectedDates.length === 2) {
const [start, end] = selectedDates; const [start, end] = selectedDates;
const format = (d) => window.flatpickr.formatDate(d, "d-m-Y"); const format = (d) => flatpickr.formatDate(d, "d-m-Y");
setValue(startField, format(start), { shouldValidate: true }); setValue(startField, format(start), { shouldValidate: true });
setValue(endField, format(end), { shouldValidate: true }); setValue(endField, format(end), { shouldValidate: true });
} else { } else {
@ -153,10 +148,12 @@ export const DateRangePicker1 = ({
const currentStart = getValues(startField); const currentStart = getValues(startField);
const currentEnd = getValues(endField); const currentEnd = getValues(endField);
if (currentStart && currentEnd) { if (defaultRange && !currentStart && !currentEnd) {
applyDefaultDates();
} else if (currentStart && currentEnd) {
instance.setDate([ instance.setDate([
window.flatpickr.parseDate(currentStart, "d-m-Y"), flatpickr.parseDate(currentStart, "d-m-Y"),
window.flatpickr.parseDate(currentEnd, "d-m-Y"), flatpickr.parseDate(currentEnd, "d-m-Y"),
]); ]);
} }
@ -178,6 +175,7 @@ export const DateRangePicker1 = ({
} }
}, [resetSignal, defaultRange, setValue, startField, endField]); }, [resetSignal, defaultRange, setValue, startField, endField]);
const start = getValues(startField); const start = getValues(startField);
const end = getValues(endField); const end = getValues(endField);
const formattedValue = start && end ? `${start} To ${end}` : ""; const formattedValue = start && end ? `${start} To ${end}` : "";
@ -188,7 +186,7 @@ export const DateRangePicker1 = ({
type="text" type="text"
className="form-control form-control-sm" className="form-control form-control-sm"
placeholder={placeholder} placeholder={placeholder}
value={formattedValue} defaultValue={formattedValue}
ref={(el) => { ref={(el) => {
inputRef.current = el; inputRef.current = el;
ref(el); ref(el);

View File

@ -16,10 +16,10 @@ import ManageDocumentCategory from "./ManageDocumentCategory";
import ManageDocumentType from "./ManageDocumentType"; import ManageDocumentType from "./ManageDocumentType";
import ManageServices from "./Services/ManageServices"; import ManageServices from "./Services/ManageServices";
import ServiceGroups from "./Services/ServicesGroups"; import ServiceGroups from "./Services/ServicesGroups";
import ManagePaymentHead from "./paymentAdjustmentHead/ManagePaymentHead";
const MasterModal = ({ modaldata, closeModal }) => { const MasterModal = ({ modaldata, closeModal }) => {
if (!modaldata?.modalType || modaldata.modalType === "delete") { if (!modaldata?.modalType || modaldata.modalType === "delete") {
return null; return null;
} }
@ -58,17 +58,21 @@ const MasterModal = ({ modaldata, closeModal }) => {
"Edit-Document Type": ( "Edit-Document Type": (
<ManageDocumentType data={item} onClose={closeModal} /> <ManageDocumentType data={item} onClose={closeModal} />
), ),
Services: <ManageServices onClose={closeModal} />, "Services": (
"Edit-Services": <ManageServices data={item} onClose={closeModal} />, <ManageServices onClose={closeModal} />
"Manage-Services": <ServiceGroups service={item} onClose={closeModal} />, ),
"Payment Adjustment Head": <ManagePaymentHead onClose={closeModal} />, "Edit-Services": (
"Edit-Payment Adjustment Head": <ManagePaymentHead data={item} onClose={closeModal} /> <ManageServices data={item} onClose={closeModal} />
),
"Manage-Services": (
<ServiceGroups service={item} onClose={closeModal}/>
),
}; };
return ( return (
<div className="p-2 p-md-1"> <div className="p-2 p-md-1">
<div className="text-center"> <div className="text-center">
<p className="fs-5 fw-semibold">{`${(masterType, " ", modalType)}`}</p> <p className="fs-5 fw-semibold" >{`${masterType, " ", modalType}`}</p>
</div> </div>
{ modalComponents[modalType] || null} { modalComponents[modalType] || null}
</div> </div>

View File

@ -1,107 +0,0 @@
import React, { useEffect } from "react";
import { z } from "zod";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import Label from "../../common/Label";
import { useCreatePaymentAjustmentHead, useUpdatePaymentAjustmentHead } from "../../../hooks/masterHook/useMaster";
export const simpleFormSchema = z.object({
name: z.string().min(1, "Name is required"),
description: z.string().min(1, "Description is required"),
});
const ManagePaymentHead = ({ data, onClose }) => {
const {
register,
handleSubmit,
reset,
formState: { errors },
} = useForm({
resolver: zodResolver(simpleFormSchema),
defaultValues: {
name: "",
description: "",
},
});
const {mutate:CreateAjustmentHead,isPending} = useCreatePaymentAjustmentHead(()=>{
handleClose?.()
});
const {mutate:UpdateAjustmentHead,isPending:isUpdating} = useUpdatePaymentAjustmentHead(()=>{
handleClose?.()
})
const onSubmit = (formData) => {
if(data){
let id = data?.id;
const payload = {
...formData,
id:id,
}
UpdateAjustmentHead({id:id,payload:payload})
}else{
let payload={
...formData
}
CreateAjustmentHead(payload)
}
};
useEffect(() => {
if (data) {
reset({
name: data.name,
description: data.description,
});
}
}, [data]);
const handleClose = () => {
reset();
onClose();
};
return (
<div className="row text-start">
<form onSubmit={handleSubmit(onSubmit)} className="p-4">
<div className="mb-3">
<Label htmlFor="name" required>
Name
</Label>
<input
type="text"
{...register("name")}
className={`form-control ${errors.name ? "is-invalid" : ""}`}
/>
{errors.name && (
<div className="invalid-feedback">{errors.name.message}</div>
)}
</div>
<div className="mb-3">
<Label htmlFor="description" required>
Description
</Label>
<textarea
{...register("description")}
className={`form-control ${errors.description ? "is-invalid" : ""}`}
/>
{errors.description && (
<div className="invalid-feedback">{errors.description.message}</div>
)}
</div>
<div className="d-flex flex-row justify-content-end gap-2">
<button
className="btn btn-sm btn-label-secondary"
onClick={handleClose} disabled={isUpdating || isPending}
>
Cancel
</button>
<button type="submit" className="btn btn-sm btn-primary" disabled={isUpdating || isPending}>
{isPending || isUpdating ? "Please Wait" :data ? "Update":"Submit"}
</button>
</div>
</form>
</div>
);
};
export default ManagePaymentHead;

View File

@ -10,14 +10,6 @@ import {
} from "@tanstack/react-query"; } from "@tanstack/react-query";
import showToast from "../../services/toastService"; import showToast from "../../services/toastService";
export const usePaymentAjustmentHead = (isActive) => {
return useQuery({
queryKey: ["paymentType",isActive],
queryFn: async () => await MasterRespository.getPaymentAdjustmentHead(isActive),
});
};
export const useServices = () => { export const useServices = () => {
return useQuery({ return useQuery({
queryKey: ["services"], queryKey: ["services"],
@ -38,6 +30,7 @@ export const useActivitiesByGroups = (groupId) => {
queryFn: async () => await MasterRespository.getActivitesByGroup(groupId), queryFn: async () => await MasterRespository.getActivitesByGroup(groupId),
enabled: !!groupId, enabled: !!groupId,
}); });
}; };
export const useGlobalServices = () => { export const useGlobalServices = () => {
@ -303,8 +296,6 @@ const fetchMasterData = async (masterType) => {
return (await MasterRespository.getDocumentTypes()).data; return (await MasterRespository.getDocumentTypes()).data;
case "Document Category": case "Document Category":
return (await MasterRespository.getDocumentCategories()).data; return (await MasterRespository.getDocumentCategories()).data;
case "Payment Adjustment Head":
return (await MasterRespository.getPaymentAdjustmentHead(true)).data;
case "Status": case "Status":
return [ return [
{ {
@ -457,6 +448,8 @@ export const useUpdateApplicationRole = (onSuccessCallback) => {
}); });
}; };
//-----Create work Category------------------------------- //-----Create work Category-------------------------------
export const useCreateWorkCategory = (onSuccessCallback) => { export const useCreateWorkCategory = (onSuccessCallback) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -710,11 +703,13 @@ export const useCreateService = (onSuccessCallback) => {
return useMutation({ return useMutation({
mutationFn: async (payload) => { mutationFn: async (payload) => {
const resp = await MasterRespository.createService(payload); const resp = await MasterRespository.createService(payload);
return resp.data; return resp.data;
}, },
onSuccess: (data) => { onSuccess: (data) => {
queryClient.invalidateQueries({ queryKey: ["masterData", "Services"] }); queryClient.invalidateQueries({ queryKey: ["masterData", "Services"] });
showToast(data?.message || "Service added successfully", "success"); showToast(data?.message || "Service added successfully", "success");
@ -722,12 +717,8 @@ export const useCreateService = (onSuccessCallback) => {
if (onSuccessCallback) onSuccessCallback(data?.data); if (onSuccessCallback) onSuccessCallback(data?.data);
}, },
onError: (error) => { onError: (error) => {
showToast(
error?.response?.data?.message || showToast( error?.response?.data?.message || error?.message || "Something went wrong", "error");
error?.message ||
"Something went wrong",
"error"
);
}, },
}); });
}; };
@ -750,12 +741,7 @@ export const useUpdateService = (onSuccessCallback) => {
if (onSuccessCallback) onSuccessCallback(data); if (onSuccessCallback) onSuccessCallback(data);
}, },
onError: (error) => { onError: (error) => {
showToast( showToast(error?.response?.data?.message || error?.message || "Something went wrong", "error");
error?.response?.data?.message ||
error?.message ||
"Something went wrong",
"error"
);
}, },
}); });
}; };
@ -773,22 +759,15 @@ export const useCreateActivityGroup = (onSuccessCallback) => {
queryKey: ["groups"], queryKey: ["groups"],
}); });
showToast( showToast( data?.message ||
data?.message || data?.response?.data?.message || "Activity Group created successfully.",
data?.response?.data?.message ||
"Activity Group created successfully.",
"success" "success"
); );
if (onSuccessCallback) onSuccessCallback(data); if (onSuccessCallback) onSuccessCallback(data);
}, },
onError: (error) => { onError: (error) => {
showToast( showToast(error?.response?.data?.message || error?.message || "Something went wrong", "error");
error?.response?.data?.message ||
error?.message ||
"Something went wrong",
"error"
);
}, },
}); });
}; };
@ -807,8 +786,7 @@ export const useUpdateActivityGroup = (onSuccessCallback) => {
showToast( showToast(
data?.message || data?.message ||
data?.response?.data?.message || data?.response?.data?.message|| "Activity Group Updated successfully.",
"Activity Group Updated successfully.",
"success" "success"
); );
@ -834,12 +812,7 @@ export const useCreateActivity = (onSuccessCallback) => {
if (onSuccessCallback) onSuccessCallback(data); if (onSuccessCallback) onSuccessCallback(data);
}, },
onError: (error) => { onError: (error) => {
showToast( showToast(error?.response?.data?.message || error?.message || "Something went wrong", "error");
error?.response?.data?.message ||
error?.message ||
"Something went wrong",
"error"
);
}, },
}); });
}; };
@ -861,12 +834,7 @@ export const useUpdateActivity = (onSuccessCallback) => {
if (onSuccessCallback) onSuccessCallback(data); if (onSuccessCallback) onSuccessCallback(data);
}, },
onError: (error) => { onError: (error) => {
showToast( showToast(error?.response?.data?.message || error?.message || "Something went wrong", "error");
error?.response?.data?.message ||
error?.message ||
"Something went wrong",
"error"
);
}, },
}); });
}; };
@ -1000,52 +968,7 @@ export const useUpdateDocumentType = (onSuccessCallback) => {
}, },
}); });
}; };
// ------------------------------x-x--------x-x------------------------------------ // -Delete Master --------
// ==============================Payment Adjustment Head =============================
export const useCreatePaymentAjustmentHead = (onSuccessCallback) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (payload) => {
const resp = await MasterRespository.createPaymentAjustmentHead(payload);
return resp.data;
},
onSuccess: (data) => {
queryClient.invalidateQueries({
queryKey: ["masterData", "Payment Adjustment Head"],
});
showToast("Payment Ajustment Head successfully", "success");
if (onSuccessCallback) onSuccessCallback(data);
},
onError: (error) => {
showToast(error.message || "Something went wrong", "error");
},
});
};
export const useUpdatePaymentAjustmentHead = (onSuccessCallback) => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({ id, payload }) => {
const resp = await MasterRespository.updatePaymentAjustmentHead(id, payload);
return resp.data;
},
onSuccess: (data) => {
queryClient.invalidateQueries({
queryKey: ["masterData", "Payment Adjustment Head"],
});
showToast("Payment Ajustment Head Updated successfully", "success");
if (onSuccessCallback) onSuccessCallback(data);
},
onError: (error) => {
showToast(error.message || "Something went wrong", "error");
},
});
};
// ====================x=x====================x=x==================================
// --------Delete Master --------
export const useDeleteMasterItem = () => { export const useDeleteMasterItem = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -1078,12 +1001,14 @@ export const useDeleteMasterItem = () => {
}); });
}; };
export const useDeleteServiceGroup =()=>{ export const useDeleteServiceGroup =()=>{
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation({ return useMutation({
mutationFn: async (id)=>await MasterRespository.deleteActivityGroup(id), mutationFn: async (id)=>await MasterRespository.deleteActivityGroup(id),
onSuccess: ({_,variable}) => { onSuccess: ({_,variable}) => {
queryClient.invalidateQueries({ queryKey: ["groups"] }); queryClient.invalidateQueries({ queryKey: ["groups"] });
showToast(`Group deleted successfully.`, "success"); showToast(`Group deleted successfully.`, "success");
@ -1097,13 +1022,15 @@ export const useDeleteServiceGroup = () => {
showToast(message, "error"); showToast(message, "error");
}, },
}); });
}; }
export const useDeleteActivity =()=>{ export const useDeleteActivity =()=>{
const queryClient = useQueryClient(); const queryClient = useQueryClient();
return useMutation({ return useMutation({
mutationFn: async (id)=>await MasterRespository.deleteActivity(id), mutationFn: async (id)=>await MasterRespository.deleteActivity(id),
onSuccess: ({_,variable}) => { onSuccess: ({_,variable}) => {
queryClient.invalidateQueries({ queryKey: ["activties"] }); queryClient.invalidateQueries({ queryKey: ["activties"] });
showToast(`Acivity deleted successfully.`, "success"); showToast(`Acivity deleted successfully.`, "success");
@ -1117,4 +1044,4 @@ export const useDeleteActivity = () => {
showToast(message, "error"); showToast(message, "error");
}, },
}); });
}; }

View File

@ -32,16 +32,6 @@ export const useModal = (modalType) => {
return { isOpen, onOpen, onClose, onToggle }; return { isOpen, onOpen, onClose, onToggle };
}; };
export const useSubscription = (frequency) => {
return useQuery({
queryKey: ["subscriptionPlans", frequency],
queryFn: async () => {
debugger
const resp = await AuthRepository.getSubscription(frequency);
return resp.data;
},
});
};
// -------------------APIHook------------------------------------- // -------------------APIHook-------------------------------------
@ -95,8 +85,8 @@ export const useAuthModal = () => {
export const useLogout = () => { export const useLogout = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const naviget = useNavigate(); const naviget = useNavigate()
const dispatch = useDispatch(); const dispatch = useDispatch()
return useMutation({ return useMutation({
mutationFn: async () => { mutationFn: async () => {
@ -109,12 +99,12 @@ export const useLogout = () => {
}, },
onSuccess: (data) => { onSuccess: (data) => {
queryClient.clear(); queryClient.clear()
removeSession(); removeSession();
dispatch(cacheProfileData(null)); dispatch(cacheProfileData(null))
// window.location.href = "/auth/login"; // window.location.href = "/auth/login";
naviget("/auth/login", { replace: true }); naviget("/auth/login",{replace:true})
if (onSuccessCallBack) onSuccessCallBack(); if (onSuccessCallBack) onSuccessCallBack();
}, },

View File

@ -1,152 +0,0 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { CollectionRepository } from "../repositories/ColllectionRepository";
import showToast from "../services/toastService";
export const useCollections = (
pageSize,
pageNumber,
fromDate,
toDate,
isPending,
isActive,
projectId,
searchString
) => {
return useQuery({
queryKey: [
"collections",
pageSize,
pageNumber,
fromDate,
toDate,
isPending,
isActive,
projectId,
searchString,
],
queryFn: async () => {
const response = await CollectionRepository.getCollections(
pageSize,
pageNumber,
fromDate,
toDate,
isPending,
isActive,
projectId,
searchString
);
return response.data;
},
keepPreviousData: true,
staleTime: 1000 * 60 * 1,
});
};
export const useCollection =(collectionId)=>{
return useQuery({
queryKey:["collection",collectionId],
queryFn:async()=> {
const resp = await CollectionRepository.getCollection(collectionId);
return resp.data
},
enabled:!!collectionId
})
}
// =========================Mutation======================
export const useCreateCollection = (onSuccessCallBack) => {
const clinent = useQueryClient();
return useMutation({
mutationFn: async (payload) =>
await CollectionRepository.createNewCollection(payload),
onSuccess: (_, variables) => {
showToast("New Collection created Successfully", "success");
clinent.invalidateQueries({ queryKey: ["collections"] });
if (onSuccessCallBack) onSuccessCallBack();
},
onError: (error) => {
showToast(
error.response.data.message || error.message || "Something Went wrong"
);
},
});
};
export const useMarkedPaymentReceived = (onSuccessCallBack) => {
const client = useQueryClient();
return useMutation({
mutationFn: async (payload) =>
await CollectionRepository.markPaymentReceived(payload),
onSuccess: async () => {
client.invalidateQueries({ queryKey: ["collections"] });
showToast("Payment Received marked Successfully", "success");
if (onSuccessCallBack) onSuccessCallBack();
},
onError: (error) => {
showToast(
error.response.data.message || error.message || "Something Went wrong"
);
},
});
};
export const useAddPayment = (onSuccessCallBack) => {
const client = useQueryClient();
return useMutation({
mutationFn: (payload) => CollectionRepository.makeReceivePayment(payload),
onSuccess: () => {
client.invalidateQueries({ queryKey: ["collections"] });
client.invalidateQueries({ queryKey: ["collection"] });
showToast("Payment Received marked Successfully", "success");
if (onSuccessCallBack) onSuccessCallBack();
},
onError: (error) => {
showToast(
error?.response?.data?.message || error.message || "Something Went wrong"
);
},
});
};
export const useAddComment = (onSuccessCallBack) => {
const client = useQueryClient();
return useMutation({
mutationFn: (payload) => CollectionRepository.addComment(payload),
onSuccess: () => {
client.invalidateQueries({ queryKey: ["collections"] });
client.invalidateQueries({ queryKey: ["collection"] });
showToast("Comment Successfully", "success");
if (onSuccessCallBack) onSuccessCallBack();
},
onError: (error) => {
showToast(
error?.response?.data?.message || error.message || "Something Went wrong"
);
},
});
};
export const useUpdateCollection =(onSuccessCallBack)=>{
const client = useQueryClient();
return useMutation({
mutationFn:async({collectionId,payload})=> await CollectionRepository.updateCollection(collectionId,payload),
onSuccess: () => {
client.invalidateQueries({ queryKey: ["collections"] });
client.invalidateQueries({ queryKey: ["collection"] });
showToast("Collection Updated Successfully", "success");
if (onSuccessCallBack) onSuccessCallBack();
},
onError: (error) => {
showToast(
error?.response?.data?.message || error.message || "Something Went wrong"
);
},
})
}

View File

@ -153,7 +153,7 @@ export const useProjectsAllocationByEmployee = (employeeId) => {
return { projectList, loading: isLoading, error, refetch }; return { projectList, loading: isLoading, error, refetch };
}; };
export const useProjectName = (provideAll=false) => { export const useProjectName = () => {
const { const {
data = [], data = [],
isLoading, isLoading,
@ -161,9 +161,9 @@ export const useProjectName = (provideAll=false) => {
refetch, refetch,
isError, isError,
} = useQuery({ } = useQuery({
queryKey: ["basicProjectNameList",provideAll], queryKey: ["basicProjectNameList"],
queryFn: async () => { queryFn: async () => {
const res = await ProjectRepository.projectNameList(provideAll); const res = await ProjectRepository.projectNameList();
return res.data || res; return res.data || res;
}, },
onError: (error) => { onError: (error) => {

View File

@ -1,5 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import React from "react"; import React, { useEffect } from "react";
import { FormProvider, useForm } from "react-hook-form"; import { FormProvider, useForm } from "react-hook-form";
import { import {
contactsFilter, contactsFilter,
@ -8,11 +8,14 @@ import {
import { useContactFilter } from "../../hooks/useDirectory"; import { useContactFilter } from "../../hooks/useDirectory";
import { ExpenseFilterSkeleton } from "../../components/Expenses/ExpenseSkeleton"; import { ExpenseFilterSkeleton } from "../../components/Expenses/ExpenseSkeleton";
import SelectMultiple from "../../components/common/SelectMultiple"; import SelectMultiple from "../../components/common/SelectMultiple";
import { useLocation } from "react-router-dom";
const ContactFilterPanel = ({ onApply, clearFilter }) => { const ContactFilterPanel = ({ onApply, clearFilter }) => {
const { data, isError, isLoading, error, isFetched, isFetching } = const { data, isError, isLoading, error, isFetched, isFetching } =
useContactFilter(); useContactFilter();
const location = useLocation();
const methods = useForm({ const methods = useForm({
resolver: zodResolver(contactsFilter), resolver: zodResolver(contactsFilter),
defaultValues: defaultContactFilter, defaultValues: defaultContactFilter,
@ -35,9 +38,19 @@ const ContactFilterPanel = ({ onApply, clearFilter }) => {
closePanel(); closePanel();
}; };
useEffect(() => {
return () => {
closePanel();
};
}, []);
if (isLoading || isFetching) return <ExpenseFilterSkeleton />; if (isLoading || isFetching) return <ExpenseFilterSkeleton />;
if (isError && isFetched) if (isError && isFetched)
return <div>Something went wrong Here- {error.message} </div>; return <div>Something went wrong Here- {error.message} </div>;
return ( return (
<FormProvider {...methods}> <FormProvider {...methods}>
<form onSubmit={handleSubmit(onSubmit)} className="p-2 text-start"> <form onSubmit={handleSubmit(onSubmit)} className="p-2 text-start">

View File

@ -139,8 +139,7 @@ export default function DirectoryPage({ IsPage = true, projectId = null }) {
<ul className="nav nav-tabs"> <ul className="nav nav-tabs">
<li className="nav-item cursor-pointer"> <li className="nav-item cursor-pointer">
<a <a
className={`nav-link ${ className={`nav-link ${activeTab === "notes" ? "active" : ""
activeTab === "notes" ? "active" : ""
} fs-6`} } fs-6`}
onClick={(e) => handleTabClick("notes", e)} onClick={(e) => handleTabClick("notes", e)}
> >
@ -150,8 +149,7 @@ export default function DirectoryPage({ IsPage = true, projectId = null }) {
</li> </li>
<li className="nav-item cursor-pointer"> <li className="nav-item cursor-pointer">
<a <a
className={`nav-link ${ className={`nav-link ${activeTab === "contacts" ? "active" : ""
activeTab === "contacts" ? "active" : ""
} fs-6`} } fs-6`}
onClick={(e) => handleTabClick("contacts", e)} onClick={(e) => handleTabClick("contacts", e)}
> >
@ -190,23 +188,21 @@ export default function DirectoryPage({ IsPage = true, projectId = null }) {
/> />
</div> </div>
<button <button
className={`btn btn-sm p-1 ${ className={`btn btn-sm p-1 ${gridView ? " btn-primary" : " btn-outline-primary"
!gridView ? "btn-primary" : "btn-outline-primary" }`}
onClick={() => setGridView(true)}
>
<i className="bx bx-grid-alt"></i>
</button>
<button
className={`btn btn-sm p-1 ${!gridView ? "btn-primary" : "btn-outline-primary"
}`} }`}
onClick={() => setGridView(false)} onClick={() => setGridView(false)}
> >
<i className="bx bx-list-ul"></i> <i className="bx bx-list-ul"></i>
</button> </button>
<button <div className="form-check form-switch d-flex align-items-end d-none d-md-flex">
className={`btn btn-sm p-1 ${
gridView ? " btn-primary" : " btn-outline-primary"
}`}
onClick={() => setGridView(true)}
>
<i className="bx bx-grid-alt"></i>
</button>
<div className="form-check form-switch d-flex align-items-center d-none d-md-flex">
<input <input
type="checkbox" type="checkbox"
className="form-check-input" className="form-check-input"
@ -219,32 +215,14 @@ export default function DirectoryPage({ IsPage = true, projectId = null }) {
className="form-check-label ms-2" className="form-check-label ms-2"
htmlFor="inactiveEmployeesCheckbox" htmlFor="inactiveEmployeesCheckbox"
> >
{showActive ? "Active" : "Inactive"} Contacts {showActive ? "Active" : "In-active"} Contacts
</label> </label>
</div> </div>
</div> </div>
</div> </div>
)} )}
</div> </div>
<div className="col-12 col-md-2 d-flex justify-content-end align-items-center gap-2"> <div className="col-12 col-md-2 d-flex justify-content-end align-items-center gap-2">
<div className={`form-check form-switch d-flex align-items-center ${activeTab === "contacts" ? " d-flex d-md-none m-0":"d-none" }`}>
<input
type="checkbox"
className="form-check-input"
role="switch"
id="inactiveEmployeesCheckbox"
checked={showActive}
onChange={(e) => setShowActive(e.target.checked)}
/>
<label
className="form-check-label ms-2"
htmlFor="inactiveEmployeesCheckbox"
>
{showActive ? "Active" : "Inactive"} Contacts
</label>
</div>
<div className=" btn-group"> <div className=" btn-group">
<button <button
className="btn btn-sm btn-label-secondary dropdown-toggle" className="btn btn-sm btn-label-secondary dropdown-toggle"
@ -266,7 +244,6 @@ export default function DirectoryPage({ IsPage = true, projectId = null }) {
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import React from "react"; import React, { useEffect } from "react";
import { FormProvider, useForm } from "react-hook-form"; import { FormProvider, useForm } from "react-hook-form";
import { import {
defaultNotesFilter, defaultNotesFilter,
@ -8,11 +8,18 @@ import {
import { useContactFilter, useNoteFilter } from "../../hooks/useDirectory"; import { useContactFilter, useNoteFilter } from "../../hooks/useDirectory";
import { ExpenseFilterSkeleton } from "../../components/Expenses/ExpenseSkeleton"; import { ExpenseFilterSkeleton } from "../../components/Expenses/ExpenseSkeleton";
import SelectMultiple from "../../components/common/SelectMultiple"; import SelectMultiple from "../../components/common/SelectMultiple";
import { useLocation } from "react-router-dom";
const NoteFilterPanel = ({ onApply, clearFilter }) => { const NoteFilterPanel = ({ onApply, clearFilter }) => {
const { data, isError, isLoading, error, isFetched, isFetching } = const { data, isError, isLoading, error, isFetched, isFetching } =
useNoteFilter(); useNoteFilter();
useEffect(() => {
return () => {
closePanel();
};
}, []);
const methods = useForm({ const methods = useForm({
resolver: zodResolver(notesFilter), resolver: zodResolver(notesFilter),
defaultValues: defaultNotesFilter, defaultValues: defaultNotesFilter,

View File

@ -206,8 +206,8 @@ const LandingPage = () => {
navigation={false} navigation={false}
modules={[EffectFlip, Autoplay, Pagination, Navigation]} modules={[EffectFlip, Autoplay, Pagination, Navigation]}
className="mySwiper" className="mySwiper"
onSlideChange={() => {}} onSlideChange={() => console.log("slide change")}
onSwiper={(swiper) => {}} onSwiper={(swiper) => console.log(swiper)}
> >
<SwiperSlide> <SwiperSlide>
<SwaperSlideContent <SwaperSlideContent

View File

@ -2,28 +2,37 @@ import React, { useState, useEffect } from "react";
import axios from "axios"; import axios from "axios";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import PlanCardSkeleton from "./PlanCardSkeleton"; import PlanCardSkeleton from "./PlanCardSkeleton";
import { useSubscription } from "../../hooks/useAuth";
const SubscriptionPlans = () => { const SubscriptionPlans = () => {
const [plans, setPlans] = useState([]); const [plans, setPlans] = useState([]);
const [frequency, setFrequency] = useState(1); const [frequency, setFrequency] = useState(1);
const { data, isLoading, isError, error } = useSubscription(frequency);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
useEffect(() => {
const fetchPlans = async () => {
try {
setLoading(true);
const res = await axios.get(
`http://localhost:5032/api/market/list/subscription-plan?frequency=${frequency}`,
{ headers: { "Content-Type": "application/json" } }
);
setPlans(res.data?.data || []);
} catch (err) {
console.error("Error fetching plans:", err);
} finally {
setLoading(false);
}
};
fetchPlans();
}, [frequency]);
const frequencyLabel = (freq) => { const frequencyLabel = (freq) => {
switch (freq) { switch (freq) {
case 0: case 0: return "1 mo";
return "1 mo"; case 1: return "3 mo";
case 1: case 2: return "6 mo";
return "3 mo"; case 3: return "1 yr";
case 2: default: return "mo";
return "6 mo";
case 3:
return "1 yr";
default:
return "mo";
} }
}; };
@ -32,49 +41,38 @@ const SubscriptionPlans = () => {
{/* Frequency Switcher */} {/* Frequency Switcher */}
<div className="text-center mb-4"> <div className="text-center mb-4">
<div className="btn-group" role="group" aria-label="Plan frequency"> <div className="btn-group" role="group" aria-label="Plan frequency">
{["Monthly", "Quarterly", "Half-Yearly", "Yearly"].map( {["Monthly", "Quarterly", "Half-Yearly", "Yearly"].map((label, idx) => (
(label, idx) => (
<button <button
key={idx} key={idx}
type="button" type="button"
className={`btn btn-${ className={`btn btn-${frequency === idx ? "primary" : "outline-secondary"}`}
frequency === idx ? "primary" : "outline-secondary"
}`}
onClick={() => setFrequency(idx)} onClick={() => setFrequency(idx)}
> >
{label} {label}
</button> </button>
) ))}
)}
</div> </div>
</div> </div>
{/* Cards */} {/* Cards */}
<div className="row g-4 mt-10"> <div className="row g-4 mt-10">
{isLoading ? ( {loading ? (
// Show 3 skeletons // Show 3 skeletons
<> <>
<PlanCardSkeleton /> <PlanCardSkeleton />
<PlanCardSkeleton /> <PlanCardSkeleton />
<PlanCardSkeleton /> <PlanCardSkeleton />
</> </>
) : data.length === 0 ? ( ) : plans.length === 0 ? (
<div className="text-center">No plans found</div> <div className="text-center">No plans found</div>
) : isError ? (
<div className="text-start bg-light">
<p>{error.message}</p>
<p>{error.name}</p>
</div>
) : ( ) : (
data.map((plan) => ( plans.map((plan) => (
<div key={plan.id} className="col-xl-4 col-lg-6 col-md-6"> <div key={plan.id} className="col-xl-4 col-lg-6 col-md-6">
<div className="card h-100 shadow-lg border-0 p-3 text-center p-10"> <div className="card h-100 shadow-lg border-0 p-3 text-center p-10">
{/* Header */} {/* Header */}
<div className="mb-3"> <div className="mb-3">
<i className="bx bxs-package text-primary fs-1 mb-2"></i> <i className="bx bxs-package text-primary fs-1 mb-2"></i>
<p className="card-title fs-3 fw-bold mb-1"> <p className="card-title fs-3 fw-bold mb-1">{plan.planName}</p>
{plan.planName}
</p>
<p className="text-muted mb-0 fs-5">{plan.description}</p> <p className="text-muted mb-0 fs-5">{plan.description}</p>
</div> </div>
@ -82,9 +80,7 @@ const SubscriptionPlans = () => {
<div className="mb-3"> <div className="mb-3">
<h4 className="fw-semibold mt-auto mb-0 fs-3"> <h4 className="fw-semibold mt-auto mb-0 fs-3">
{plan.currency?.symbol} {plan.price} {plan.currency?.symbol} {plan.price}
<small className="text-muted ms-1"> <small className="text-muted ms-1">/ {frequencyLabel(frequency)}</small>
/ {frequencyLabel(frequency)}
</small>
</h4> </h4>
</div> </div>
@ -137,6 +133,7 @@ const SubscriptionPlans = () => {
)) ))
)} )}
</div> </div>
</div> </div>
); );
}; };

View File

@ -1,223 +0,0 @@
import React, { createContext, useContext, useState } from "react";
import moment from "moment";
import Breadcrumb from "../../components/common/Breadcrumb";
import CollectionList from "../../components/collections/CollectionList";
import { useModal } from "../../hooks/useAuth";
import { FormProvider, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { DateRangePicker1 } from "../../components/common/DateRangePicker";
import { isPending } from "@reduxjs/toolkit";
import ConfirmModal from "../../components/common/ConfirmModal";
import showToast from "../../services/toastService";
import { useMarkedPaymentReceived } from "../../hooks/useCollections";
import GlobalModel from "../../components/common/GlobalModel";
import AddPayment from "../../components/collections/AddPayment";
import ViewCollection from "../../components/collections/ViewCollection";
import ManageCollection from "../../components/collections/ManageCollection";
import PreviewDocument from "../../components/Expenses/PreviewDocument";
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
import {
ADDPAYMENT_COLLECTION,
ADMIN_COLLECTION,
CREATE_COLLECTION,
EDIT_COLLECTION,
VIEW_COLLECTION,
} from "../../utils/constants";
import AccessDenied from "../../components/common/AccessDenied";
const CollectionContext = createContext();
export const useCollectionContext = () => {
const context = useContext(CollectionContext);
if (!context) {
window.location = "/dashboard";
showToast("Out of Context Happend inside Collection Context", "warning");
}
return context;
};
const CollectionPage = () => {
const [viewCollection, setViewCollection] = useState(null);
const [makeCollection, setCollection] = useState({
isOpen: false,
invoiceId: null,
});
const [ViewDocument, setDocumentView] = useState({
IsOpen: false,
Image: null,
});
const [processedPayment, setProcessedPayment] = useState(null);
const [addPayment, setAddPayment] = useState({
isOpen: false,
invoiceId: null,
});
const [showPending, setShowPending] = useState(false);
const [searchText, setSearchText] = useState("");
const isAdmin = useHasUserPermission(ADMIN_COLLECTION);
const canViewCollection = useHasUserPermission(VIEW_COLLECTION);
const canCreate = useHasUserPermission(CREATE_COLLECTION);
const canEditCollection = useHasUserPermission(EDIT_COLLECTION);
const canAddPayment = useHasUserPermission(ADDPAYMENT_COLLECTION);
const methods = useForm({
defaultValues: {
fromDate: moment().subtract(180, "days").format("DD-MM-YYYY"),
toDate: moment().format("DD-MM-YYYY"),
},
});
const { watch } = methods;
const [fromDate, toDate] = watch(["fromDate", "toDate"]);
const handleToggleActive = (e) => setShowPending(e.target.checked);
const contextMassager = {
setProcessedPayment,
setCollection,
setAddPayment,
addPayment,
setViewCollection,
viewCollection,
setDocumentView,
};
const { mutate: MarkedReceived, isPending } = useMarkedPaymentReceived(() => {
setProcessedPayment(null);
});
const handleMarkedPayment = (payload) => {
MarkedReceived(payload);
};
if (isAdmin === undefined ||
canAddPayment === undefined ||
canEditCollection === undefined ||
canViewCollection === undefined ||
canCreate === undefined
) {
return <div className="text-center py-5">Checking access...</div>;
}
if (!isAdmin && !canAddPayment && !canEditCollection && !canViewCollection && !canCreate) {
return <AccessDenied data={[{ label: "Home", link: "/" }, { label: "Collection" }]} />;
}
return (
<CollectionContext.Provider value={contextMassager}>
<div className="container-fluid">
<Breadcrumb
data={[{ label: "Home", link: "/" }, { label: "Collection" }]}
/>
<div className="card my-3 py-2 px-sm-4 px-0">
<div className="row px-3">
<div className="col-12 col-md-3 mb-1">
<FormProvider {...methods}>
<DateRangePicker1 howManyDay={180} />
</FormProvider>
</div>
<div className="col-12 col-md-3 d-flex align-items-center gap-2 ">
<div className="form-check form-switch text-start align-items-center">
<input
type="checkbox"
className="form-check-input"
role="switch"
id="inactiveEmployeesCheckbox"
checked={showPending}
onChange={(e) => setShowPending(e.target.checked)}
/>
<label
className="form-check-label ms-0"
htmlFor="inactiveEmployeesCheckbox"
>
Show Pending
</label>
</div>
</div>
<div className="col-12 col-md-6 d-flex justify-content-end gap-4">
<div className=" w-md-auto">
{" "}
<input
type="search"
value={searchText}
onChange={(e) => setSearchText(e.target.value)}
placeholder="search Collection"
className="form-control form-control-sm"
/>
</div>
{ (canCreate || isAdmin) && (
<button
className="btn btn-sm btn-primary"
type="button"
onClick={() => setCollection({ isOpen: true, invoiceId: null })}
>
<i className="bx bx-plus-circle me-2"></i>
<span className="d-none d-md-inline-block">Add New Collection</span>
</button>
)}
</div>
</div>
</div>
<CollectionList
fromDate={fromDate}
toDate={toDate}
isPending={showPending}
searchString={searchText}
/>
{makeCollection.isOpen && (
<GlobalModel
isOpen={makeCollection.isOpen}
size="lg"
closeModal={() => setCollection({ isOpen: false, invoiceId: null })}
>
<ManageCollection
collectionId={makeCollection?.invoiceId ?? null}
onClose={() => setCollection({ isOpen: false, invoiceId: null })}
/>
</GlobalModel>
)}
{addPayment.isOpen && (
<GlobalModel
size="lg"
isOpen={addPayment.isOpen}
closeModal={() => setAddPayment({ isOpen: false, invoiceId: null })}
>
<AddPayment
onClose={() => setAddPayment({ isOpen: false, invoiceId: null })}
/>
</GlobalModel>
)}
{viewCollection && (
<GlobalModel
size="lg"
isOpen={viewCollection}
closeModal={() => setViewCollection(null)}
>
<ViewCollection onClose={() => setViewCollection(null)} />
</GlobalModel>
)}
{ViewDocument.IsOpen && (
<GlobalModel
isOpen
size="md"
key={ViewDocument.Image ?? "doc"}
closeModal={() => setDocumentView({ IsOpen: false, Image: null })}
>
<PreviewDocument imageUrl={ViewDocument.Image} />
</GlobalModel>
)}
<ConfirmModal
type="success"
header="Payment Successful Received"
message="Payment has been recored successfully."
isOpen={processedPayment?.isOpen}
loading={isPending}
onSubmit={() => handleMarkedPayment(processedPayment?.invoiceId)}
onClose={() => setProcessedPayment(null)}
/>
</div>
</CollectionContext.Provider>
);
};
export default CollectionPage;

View File

@ -176,11 +176,9 @@ const EmployeeList = () => {
useEffect(() => { useEffect(() => {
if (!loading && Array.isArray(employees)) { if (!loading && Array.isArray(employees)) {
const sorted = [...employees].sort((a, b) => { const sorted = [...employees].sort((a, b) => {
const nameA = `${a.firstName || ""}${a.middleName || ""}${ const nameA = `${a.firstName || ""}${a.middleName || ""}${a.lastName || ""
a.lastName || ""
}`.toLowerCase(); }`.toLowerCase();
const nameB = `${b.firstName || ""}${b.middleName || ""}${ const nameB = `${b.firstName || ""}${b.middleName || ""}${b.lastName || ""
b.lastName || ""
}`.toLowerCase(); }`.toLowerCase();
return nameA?.localeCompare(nameB); return nameA?.localeCompare(nameB);
}); });
@ -258,8 +256,7 @@ const EmployeeList = () => {
? "Suspend Employee" ? "Suspend Employee"
: "Reactivate Employee" : "Reactivate Employee"
} }
message={`Are you sure you want to ${ message={`Are you sure you want to ${selectedEmpFordelete?.isActive ? "suspend" : "reactivate"
selectedEmpFordelete?.isActive ? "suspend" : "reactivate"
} this employee?`} } this employee?`}
onSubmit={(id) => onSubmit={(id) =>
suspendEmployee({ suspendEmployee({
@ -309,7 +306,7 @@ const EmployeeList = () => {
className="form-check-label ms-0" className="form-check-label ms-0"
htmlFor="inactiveEmployeesCheckbox" htmlFor="inactiveEmployeesCheckbox"
> >
Show Inactive Employees In-active Employees
</label> </label>
</div> </div>
</div> </div>
@ -471,8 +468,7 @@ const EmployeeList = () => {
Status Status
</th> </th>
<th <th
className={`sorting_disabled ${ className={`sorting_disabled ${!Manage_Employee && "d-none"
!Manage_Employee && "d-none"
}`} }`}
rowSpan="1" rowSpan="1"
colSpan="1" colSpan="1"
@ -549,11 +545,10 @@ const EmployeeList = () => {
{item.email} {item.email}
</span> </span>
) : ( ) : (
<span className="text-truncate text-italic"> <span className="d-block text-start text-muted fst-italic">NA</span>
-
</span>
)} )}
</td> </td>
<td className="text-start d-none d-sm-table-cell"> <td className="text-start d-none d-sm-table-cell">
<span className="text-truncate"> <span className="text-truncate">
<i className="bx bxs-phone-call text-primary me-2"></i> <i className="bx bxs-phone-call text-primary me-2"></i>
@ -568,8 +563,13 @@ const EmployeeList = () => {
</td> </td>
<td className="d-none d-md-table-cell"> <td className="d-none d-md-table-cell">
{moment(item.joiningDate)?.format("DD-MMM-YYYY")} {item.joiningDate ? (
moment(item.joiningDate).format("DD-MMM-YYYY")
) : (
<span className="d-block text-center text-muted fst-italic">NA</span>
)}
</td> </td>
<td> <td>
{showInactive ? ( {showInactive ? (
<span <span

View File

@ -77,7 +77,7 @@ const ProjectDetails = () => {
<AboutProject /> <AboutProject />
<ProjectOverview project={projectId} /> <ProjectOverview project={projectId} />
</div> </div>
<div className="col-lg-8 col-md-7 mt-5"> <div className="col-lg-8 col-md-7 mt-2">
<ProjectProgressChart ShowAllProject="false" DefaultRange="1M" /> <ProjectProgressChart ShowAllProject="false" DefaultRange="1M" />
<div className="mt-5"> <div className="mt-5">
<AttendanceOverview /> <AttendanceOverview />

View File

@ -10,7 +10,6 @@ const AuthRepository = {
verifyOTP: (data) => api.postPublic("/api/auth/login-otp", data), verifyOTP: (data) => api.postPublic("/api/auth/login-otp", data),
register: (data) => api.postPublic("/api/auth/register", data), register: (data) => api.postPublic("/api/auth/register", data),
sendMail: (data) => api.postPublic("/api/auth/sendmail", data), sendMail: (data) => api.postPublic("/api/auth/sendmail", data),
getSubscription:(frequency)=> api.getPublic(`/api/market/list/subscription-plan?frequency=${frequency}`),
// Protected routes (require auth token) // Protected routes (require auth token)
logout: (data) => api.post("/api/auth/logout", data), logout: (data) => api.post("/api/auth/logout", data),
@ -20,8 +19,6 @@ const AuthRepository = {
selectTenant: (tenantId) => api.post(`/api/Auth/select-tenant/${tenantId}`), selectTenant: (tenantId) => api.post(`/api/Auth/select-tenant/${tenantId}`),
getTenantList: () => api.get("/api/Auth/get/user/tenants"), getTenantList: () => api.get("/api/Auth/get/user/tenants"),
//
}; };
export default AuthRepository; export default AuthRepository;

View File

@ -1,29 +0,0 @@
import { api } from "../utils/axiosClient";
import { DirectoryRepository } from "./DirectoryRepository";
export const CollectionRepository = {
createNewCollection: (data) =>
api.post(`/api/Collection/invoice/create`, data),
updateCollection:(id,data)=>{
api.put(`/api/Collection/invoice/edit/${id}`,data)
},
getCollections: (pageSize, pageNumber,fromDate,toDate, isPending,isActive,projectId, searchString) => {
let url = `/api/Collection/invoice/list?pageSize=${pageSize}&pageNumber=${pageNumber}&isPending=${isPending}&isActive=${isActive}&searchString=${searchString}`;
const params = [];
if (fromDate) params.push(`fromDate=${fromDate}`);
if (toDate) params.push(`toDate=${toDate}`);
if(projectId) params.push(`projectId=${projectId}`)
if (params.length > 0) {
url += `&${params.join("&")}`;
}
return api.get(url);
},
makeReceivePayment:(data)=> api.post(`/api/Collection/invoice/payment/received`,data),
markPaymentReceived:(invoiceId)=>api.put(`/api/Collection/invoice/marked/completed/${invoiceId}`),
getCollection:(id)=>api.get(`/api/Collection/invoice/details/${id}`),
addComment:(data)=>api.post(`/api/Collection/invoice/add/comment`,data)
};

View File

@ -58,7 +58,6 @@ export const MasterRespository = {
"Document Type": (id) => api.delete(`/api/Master/document-type/delete/${id}`), "Document Type": (id) => api.delete(`/api/Master/document-type/delete/${id}`),
"Document Category": (id) => "Document Category": (id) =>
api.delete(`/api/Master/document-category/delete/${id}`), api.delete(`/api/Master/document-category/delete/${id}`),
"Payment Adjustment Head":(id,isActive)=>api.delete(`/api/Master/payment-adjustment-head/delete/${id}`,(isActive=false)),
getWorkCategory: () => api.get(`/api/master/work-categories`), getWorkCategory: () => api.get(`/api/master/work-categories`),
createWorkCategory: (data) => api.post(`/api/master/work-category`, data), createWorkCategory: (data) => api.post(`/api/master/work-category`, data),
@ -125,15 +124,10 @@ export const MasterRespository = {
api.put(`/api/Master/activity-group/edit/${serviceId}`, data), api.put(`/api/Master/activity-group/edit/${serviceId}`, data),
getActivitesByGroup: (activityGroupId) => getActivitesByGroup: (activityGroupId) =>
api.get(`api/master/activities?activityGroupId=${activityGroupId}`), api.get(`api/master/activities?activityGroupId=${activityGroupId}`),
deleteActivityGroup: (id) => deleteActivityGroup:(id)=>api.delete(`/api/Master/activity-group/delete/${id}`),
api.delete(`/api/Master/activity-group/delete/${id}`),
deleteActivity:(id)=>api.delete(`/api/Master/activity/delete/${id}`), deleteActivity:(id)=>api.delete(`/api/Master/activity/delete/${id}`),
getOrganizationType: () => api.get("/api/Master/organization-type/list"), getOrganizationType: () => api.get("/api/Master/organization-type/list"),
getPaymentAdjustmentHead: (isActive) =>
api.get(`/api/Master/payment-adjustment-head/list?isActive=${isActive}`),
createPaymentAjustmentHead:(data)=>api.post(`/api/Master/payment-adjustment-head`, data),
updatePaymentAjustmentHead:(id,data)=>api.put(`/api/Master/payment-adjustment-head/edit/${id}`, data)
}; };

View File

@ -40,7 +40,7 @@ const ProjectRepository = {
api.get(`/api/project/allocation-histery/${id}`), api.get(`/api/project/allocation-histery/${id}`),
updateProjectsByEmployee: (id, data) => updateProjectsByEmployee: (id, data) =>
api.post(`/api/project/assign-projects/${id}`, data), api.post(`/api/project/assign-projects/${id}`, data),
projectNameList: (provideAll) => api.get(`/api/project/list/basic?provideAll=${provideAll}`), projectNameList: () => api.get("/api/project/list/basic"),
getProjectDetails: (id) => api.get(`/api/project/details/${id}`), getProjectDetails: (id) => api.get(`/api/project/details/${id}`),

View File

@ -53,7 +53,6 @@ import DailyProgrssReport from "../pages/DailyProgressReport/DailyProgrssReport"
import ProjectPage from "../pages/project/ProjectPage"; import ProjectPage from "../pages/project/ProjectPage";
import { ComingSoonPage } from "../pages/Misc/ComingSoonPage"; import { ComingSoonPage } from "../pages/Misc/ComingSoonPage";
import ImageGalleryPage from "../pages/Gallary/ImageGallaryPage"; import ImageGalleryPage from "../pages/Gallary/ImageGallaryPage";
import CollectionPage from "../pages/collections/CollectionPage";
const router = createBrowserRouter( const router = createBrowserRouter(
[ [
{ {
@ -96,7 +95,6 @@ const router = createBrowserRouter(
{ path: "/activities/reports", element: <Reports /> }, { path: "/activities/reports", element: <Reports /> },
{ path: "/gallary", element: <ImageGalleryPage /> }, { path: "/gallary", element: <ImageGalleryPage /> },
{ path: "/expenses", element: <ExpensePage /> }, { path: "/expenses", element: <ExpensePage /> },
{ path: "/collection", element: <CollectionPage /> },
{ path: "/masters", element: <MasterPage /> }, { path: "/masters", element: <MasterPage /> },
{ path: "/tenants", element: <TenantPage /> }, { path: "/tenants", element: <TenantPage /> },
{ path: "/tenants/new-tenant", element: <CreateTenant /> }, { path: "/tenants/new-tenant", element: <CreateTenant /> },

View File

@ -113,7 +113,7 @@ export const formatFigure = (
type = "number", type = "number",
currency = "INR", currency = "INR",
locale = "en-US", locale = "en-US",
notation = "standard", // standard or compact notation = "compact",
compactDisplay = "short", compactDisplay = "short",
minimumFractionDigits = 0, minimumFractionDigits = 0,
maximumFractionDigits = 2, maximumFractionDigits = 2,

View File

@ -72,9 +72,7 @@ axiosClient.interceptors.response.use(
if (status === 401 && !isRefreshRequest) { if (status === 401 && !isRefreshRequest) {
originalRequest._retry = true; originalRequest._retry = true;
const refreshToken = const refreshToken = localStorage.getItem("refreshToken") || sessionStorage.getItem("refreshToken");
localStorage.getItem("refreshToken") ||
sessionStorage.getItem("refreshToken");
if ( if (
!refreshToken || !refreshToken ||
@ -89,9 +87,7 @@ axiosClient.interceptors.response.use(
try { try {
// Refresh token call // Refresh token call
const res = await axiosClient.post("/api/Auth/refresh-token", { const res = await axiosClient.post("/api/Auth/refresh-token", {
token: token: localStorage.getItem("jwtToken") || sessionStorage.getItem("jwtToken"),
localStorage.getItem("jwtToken") ||
sessionStorage.getItem("jwtToken"),
refreshToken, refreshToken,
}); });
@ -148,11 +144,6 @@ export const api = {
headers: { ...customHeaders }, headers: { ...customHeaders },
authRequired: false, authRequired: false,
}), }),
getPublic: (url, data = {}, customHeaders = {}) =>
apiRequest("get", url, data, {
headers: { ...customHeaders },
authRequired: false,
}),
// Authenticated routes // Authenticated routes
get: (url, params = {}, customHeaders = {}) => get: (url, params = {}, customHeaders = {}) =>

View File

@ -3,6 +3,7 @@ export const DURATION_TIME = 10; // minutes
export const ITEMS_PER_PAGE = 20; export const ITEMS_PER_PAGE = 20;
export const OTP_EXPIRY_SECONDS = 300; // OTP time export const OTP_EXPIRY_SECONDS = 300; // OTP time
export const BASE_URL = process.env.VITE_BASE_URL; export const BASE_URL = process.env.VITE_BASE_URL;
// export const BASE_URL = "https://api.marcoaiot.com"; // export const BASE_URL = "https://api.marcoaiot.com";
@ -49,7 +50,7 @@ export const DIRECTORY_ADMIN = "4286a13b-bb40-4879-8c6d-18e9e393beda";
export const DIRECTORY_MANAGER = "62668630-13ce-4f52-a0f0-db38af2230c5"; export const DIRECTORY_MANAGER = "62668630-13ce-4f52-a0f0-db38af2230c5";
export const DIRECTORY_USER = "0f919170-92d4-4337-abd3-49b66fc871bb"; export const DIRECTORY_USER = "0f919170-92d4-4337-abd3-49b66fc871bb";
// ========================Finance=========================================================
// -----------------------Expense---------------------------------------- // -----------------------Expense----------------------------------------
export const VIEW_SELF_EXPENSE = "385be49f-8fde-440e-bdbc-3dffeb8dd116"; export const VIEW_SELF_EXPENSE = "385be49f-8fde-440e-bdbc-3dffeb8dd116";
@ -65,16 +66,6 @@ export const PROCESS_EXPENSE = "ea5a1529-4ee8-4828-80ea-0e23c9d4dd11";
export const EXPENSE_MANAGE = "ea5a1529-4ee8-4828-80ea-0e23c9d4dd11"; export const EXPENSE_MANAGE = "ea5a1529-4ee8-4828-80ea-0e23c9d4dd11";
// --------------------------------Collection----------------------------
export const ADMIN_COLLECTION = "dbf17591-09fe-4c93-9e1a-12db8f5cc5de";
export const VIEW_COLLECTION = "c8d7eea5-4033-4aad-9ebe-76de49896830";
export const CREATE_COLLECTION = "b93141fd-dbd3-4051-8f57-bf25d18e3555";
export const EDIT_COLLECTION = "455187b4-fef1-41f9-b3d0-025d0b6302c3";
export const ADDPAYMENT_COLLECTION = "061d9ccd-85b4-4cb0-be06-2f9f32cebb72";
// ==========================================================================================
export const EXPENSE_REJECTEDBY = [ export const EXPENSE_REJECTEDBY = [
"d1ee5eec-24b6-4364-8673-a8f859c60729", "d1ee5eec-24b6-4364-8673-a8f859c60729",
"965eda62-7907-4963-b4a1-657fb0b2724b", "965eda62-7907-4963-b4a1-657fb0b2724b",
@ -155,3 +146,4 @@ export const PROJECT_STATUS = [
}, },
]; ];
export const DEFAULT_EMPTY_STATUS_ID = "00000000-0000-0000-0000-000000000000"; export const DEFAULT_EMPTY_STATUS_ID = "00000000-0000-0000-0000-000000000000";