integrated editcollection and vew douments
This commit is contained in:
parent
0052fed1e6
commit
76df08e921
@ -4,7 +4,7 @@ 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/NewCollection";
|
import NewCollection from "./components/collections/ManageCollection";
|
||||||
|
|
||||||
const ModalProvider = () => {
|
const ModalProvider = () => {
|
||||||
const { isOpen, onClose } = useOrganizationModal();
|
const { isOpen, onClose } = useOrganizationModal();
|
||||||
|
@ -78,7 +78,7 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => {
|
|||||||
{formatUTCToLocalTime(col.createdAt)}
|
{formatUTCToLocalTime(col.createdAt)}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
align: "text-start",
|
align: "text-center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "expectedSubmittedDate",
|
key: "expectedSubmittedDate",
|
||||||
@ -91,7 +91,7 @@ const CollectionList = ({ fromDate, toDate, isPending, searchString }) => {
|
|||||||
{formatUTCToLocalTime(col.exceptedPaymentDate) ?? "-"}
|
{formatUTCToLocalTime(col.exceptedPaymentDate) ?? "-"}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
align: "text-start",
|
align: "text-center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "amount",
|
key: "amount",
|
||||||
|
@ -9,7 +9,7 @@ import moment from "moment";
|
|||||||
|
|
||||||
const Comment = ({ invoice }) => {
|
const Comment = ({ invoice }) => {
|
||||||
const {
|
const {
|
||||||
register,
|
register,reset,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useForm({
|
} = useForm({
|
||||||
@ -17,7 +17,7 @@ const Comment = ({ invoice }) => {
|
|||||||
defaultValues: { comment: "" },
|
defaultValues: { comment: "" },
|
||||||
});
|
});
|
||||||
|
|
||||||
const { mutate: AddComment, isPending } = useAddComment(() => {});
|
const { mutate: AddComment, isPending } = useAddComment(() => {reset()});
|
||||||
|
|
||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
const payload = { ...formData, invoiceId: invoice?.id };
|
const payload = { ...formData, invoiceId: invoice?.id };
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import { useModal } from "../../hooks/useAuth";
|
import { useModal } from "../../hooks/useAuth";
|
||||||
import Modal from "../common/Modal";
|
import Modal from "../common/Modal";
|
||||||
import { FormProvider, useForm } from "react-hook-form";
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
@ -8,11 +8,17 @@ import { defaultCollection, newCollection } from "./collectionSchema";
|
|||||||
import SelectMultiple from "../common/SelectMultiple";
|
import SelectMultiple from "../common/SelectMultiple";
|
||||||
import { useProjectName } from "../../hooks/useProjects";
|
import { useProjectName } from "../../hooks/useProjects";
|
||||||
import DatePicker from "../common/DatePicker";
|
import DatePicker from "../common/DatePicker";
|
||||||
import { useCreateCollection } from "../../hooks/useCollections";
|
import {
|
||||||
|
useCollection,
|
||||||
|
useCreateCollection,
|
||||||
|
useUpdateCollection,
|
||||||
|
} from "../../hooks/useCollections";
|
||||||
import { formatFileSize, localToUtc } from "../../utils/appUtils";
|
import { formatFileSize, localToUtc } from "../../utils/appUtils";
|
||||||
|
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
||||||
|
import { formatDate } from "../../utils/dateUtils";
|
||||||
|
|
||||||
const NewCollection = ({ collectionId, onClose }) => {
|
const ManageCollection = ({ collectionId, onClose }) => {
|
||||||
|
const { data, isError, isLoading, error } = useCollection(collectionId);
|
||||||
const { projectNames, projectLoading } = useProjectName();
|
const { projectNames, projectLoading } = useProjectName();
|
||||||
const methods = useForm({
|
const methods = useForm({
|
||||||
resolver: zodResolver(newCollection),
|
resolver: zodResolver(newCollection),
|
||||||
@ -28,8 +34,11 @@ const NewCollection = ({ collectionId, onClose }) => {
|
|||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = methods;
|
} = methods;
|
||||||
|
|
||||||
const { mutate: createNewCollection, isPending } = useCreateCollection(()=>{
|
const { mutate: createNewCollection, isPending } = useCreateCollection(() => {
|
||||||
handleClose()
|
handleClose();
|
||||||
|
});
|
||||||
|
const { mutate: UpdateCollection } = useUpdateCollection(() => {
|
||||||
|
handleClose();
|
||||||
});
|
});
|
||||||
|
|
||||||
const files = watch("attachments");
|
const files = watch("attachments");
|
||||||
@ -100,17 +109,58 @@ const NewCollection = ({ collectionId, onClose }) => {
|
|||||||
invoiceDate: localToUtc(formData.invoiceDate),
|
invoiceDate: localToUtc(formData.invoiceDate),
|
||||||
exceptedPaymentDate: localToUtc(formData.exceptedPaymentDate),
|
exceptedPaymentDate: localToUtc(formData.exceptedPaymentDate),
|
||||||
};
|
};
|
||||||
createNewCollection(payload);
|
|
||||||
|
if (collectionId) {
|
||||||
|
UpdateCollection({
|
||||||
|
collectionId,
|
||||||
|
payload: { ...payload, id: collectionId },
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createNewCollection(payload);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
reset(defaultCollection);
|
reset(defaultCollection);
|
||||||
onClose();
|
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,
|
||||||
|
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 (
|
return (
|
||||||
<div className="container pb-3">
|
<div className="container pb-3">
|
||||||
|
<div className="text-black fs-5 mb-2">
|
||||||
<div className="text-black fs-5 mb-2">New Collection</div>
|
{collectionId ? "Update" : "New"} Collection
|
||||||
|
</div>
|
||||||
<FormProvider {...methods}>
|
<FormProvider {...methods}>
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="p-0 text-start">
|
<form onSubmit={handleSubmit(onSubmit)} className="p-0 text-start">
|
||||||
<div className="row px-md-1 px-0">
|
<div className="row px-md-1 px-0">
|
||||||
@ -170,7 +220,6 @@ const NewCollection = ({ collectionId, onClose }) => {
|
|||||||
name="exceptedPaymentDate"
|
name="exceptedPaymentDate"
|
||||||
control={control}
|
control={control}
|
||||||
minDate={watch("invoiceDate")}
|
minDate={watch("invoiceDate")}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
{errors.exceptedPaymentDate && (
|
{errors.exceptedPaymentDate && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
@ -183,7 +232,6 @@ const NewCollection = ({ collectionId, onClose }) => {
|
|||||||
<DatePicker
|
<DatePicker
|
||||||
name="clientSubmitedDate"
|
name="clientSubmitedDate"
|
||||||
control={control}
|
control={control}
|
||||||
|
|
||||||
maxDate={new Date()}
|
maxDate={new Date()}
|
||||||
/>
|
/>
|
||||||
{errors.exceptedPaymentDate && (
|
{errors.exceptedPaymentDate && (
|
||||||
@ -282,9 +330,7 @@ const NewCollection = ({ collectionId, onClose }) => {
|
|||||||
<div
|
<div
|
||||||
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative text-black"
|
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative text-black"
|
||||||
style={{ cursor: "pointer" }}
|
style={{ cursor: "pointer" }}
|
||||||
onClick={() =>
|
onClick={() => document.getElementById("attachments").click()}
|
||||||
document.getElementById("attachments").click()
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<i className="bx bx-cloud-upload d-block bx-lg "> </i>
|
<i className="bx bx-cloud-upload d-block bx-lg "> </i>
|
||||||
<span className="text-muted d-block">
|
<span className="text-muted d-block">
|
||||||
@ -382,11 +428,7 @@ const NewCollection = ({ collectionId, onClose }) => {
|
|||||||
</form>
|
</form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NewCollection;
|
export default ManageCollection;
|
@ -9,7 +9,6 @@ const PaymentHistoryTable = ({data}) => {
|
|||||||
|
|
||||||
{data?.receivedInvoicePayments?.length > 0 && (
|
{data?.receivedInvoicePayments?.length > 0 && (
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<p className="fw-semibold fs-6">Received Payments</p>
|
|
||||||
<table className="table table-bordered mt-2">
|
<table className="table table-bordered mt-2">
|
||||||
<thead className="table-light">
|
<thead className="table-light">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -2,16 +2,23 @@ import React from "react";
|
|||||||
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
||||||
import { useCollection } from "../../hooks/useCollections";
|
import { useCollection } from "../../hooks/useCollections";
|
||||||
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
import { formatFigure } from "../../utils/appUtils";
|
import { formatFigure, getIconByFileType } from "../../utils/appUtils";
|
||||||
import Avatar from "../common/Avatar";
|
import Avatar from "../common/Avatar";
|
||||||
import PaymentHistoryTable from "./PaymentHistoryTable";
|
import PaymentHistoryTable from "./PaymentHistoryTable";
|
||||||
import Comment from "./Comment";
|
import Comment from "./Comment";
|
||||||
|
|
||||||
const ViewCollection = () => {
|
const ViewCollection = ({ onClose }) => {
|
||||||
const { viewCollection } = useCollectionContext();
|
const { viewCollection, setCollection , setDocumentView} = useCollectionContext();
|
||||||
const { data, isLoading, isError, error } = useCollection(viewCollection);
|
const { data, isLoading, isError, error } = useCollection(viewCollection);
|
||||||
|
|
||||||
|
const handleEdit = () => {
|
||||||
|
setCollection({ isOpen: true, invoiceId: viewCollection });
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
if (isLoading) return <div>isLoading...</div>;
|
if (isLoading) return <div>isLoading...</div>;
|
||||||
if (isError) return <div>{error.message}</div>;
|
if (isError) return <div>{error.message}</div>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container p-3">
|
<div className="container p-3">
|
||||||
<p className="fs-5 fw-semibold">Collection Details</p>
|
<p className="fs-5 fw-semibold">Collection Details</p>
|
||||||
@ -21,19 +28,26 @@ const ViewCollection = () => {
|
|||||||
<p className="mb-1 fs-6">{data?.title}</p>
|
<p className="mb-1 fs-6">{data?.title}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-2">
|
<div className="col-2">
|
||||||
<span class="badge bg-label-primary">
|
<span
|
||||||
|
className={`badge bg-label-${
|
||||||
|
data?.isActive ? "primary" : "danger"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
{data?.isActive ? "Active" : "Inactive"}
|
{data?.isActive ? "Active" : "Inactive"}
|
||||||
</span>
|
</span>
|
||||||
|
{!data?.receivedInvoicePayments && (<span onClick={handleEdit} className="ms-2 cursor-pointer">
|
||||||
|
<i className="bx bx-edit text-primary bx-sm"></i>
|
||||||
|
</span>)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-md-6 d-flex">
|
<div className="col-md-6 d-flex ">
|
||||||
<p className="m-0 fw-semibold me-1">Project:</p>{" "}
|
<p className="m-0 fw-semibold me-1">Project:</p>{" "}
|
||||||
{data?.project?.name}
|
{data?.project?.name}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-md-6 d-flex">
|
<div className="col-md-6 mb-3 d-flex">
|
||||||
<p className="m-0 fw-semibold me-1">Invoice Number:</p>{" "}
|
<p className="m-0 fw-semibold me-1">Invoice Number:</p>{" "}
|
||||||
{data?.invoiceNumber}
|
{data?.invoiceNumber}
|
||||||
</div>
|
</div>
|
||||||
@ -44,7 +58,7 @@ const ViewCollection = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-md-6 d-flex">
|
<div className="col-md-6 mb-3 d-flex">
|
||||||
<p className="m-0 fw-semibold me-1">Invoice Date:</p>{" "}
|
<p className="m-0 fw-semibold me-1">Invoice Date:</p>{" "}
|
||||||
{formatUTCToLocalTime(data?.invoiceDate)}
|
{formatUTCToLocalTime(data?.invoiceDate)}
|
||||||
</div>
|
</div>
|
||||||
@ -55,7 +69,7 @@ const ViewCollection = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-md-6 d-flex">
|
<div className="col-md-6 mb-3 d-flex">
|
||||||
<p className="m-0 fw-semibold me-1">Expected Payment Date:</p>{" "}
|
<p className="m-0 fw-semibold me-1">Expected Payment Date:</p>{" "}
|
||||||
{formatUTCToLocalTime(data?.exceptedPaymentDate)}
|
{formatUTCToLocalTime(data?.exceptedPaymentDate)}
|
||||||
</div>
|
</div>
|
||||||
@ -66,7 +80,7 @@ const ViewCollection = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-md-6 d-flex">
|
<div className="col-md-6 mb-3 d-flex">
|
||||||
<p className="m-0 fw-semibold me-1">Basic Amount:</p>{" "}
|
<p className="m-0 fw-semibold me-1">Basic Amount:</p>{" "}
|
||||||
{formatFigure(data?.basicAmount, {
|
{formatFigure(data?.basicAmount, {
|
||||||
type: "currency",
|
type: "currency",
|
||||||
@ -83,7 +97,7 @@ const ViewCollection = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-md-6 d-flex">
|
<div className="col-md-6 mb-3 d-flex">
|
||||||
<p className="m-0 fw-semibold me-1">Balance Amount:</p>{" "}
|
<p className="m-0 fw-semibold me-1">Balance Amount:</p>{" "}
|
||||||
{formatFigure(data?.balanceAmount, {
|
{formatFigure(data?.balanceAmount, {
|
||||||
type: "currency",
|
type: "currency",
|
||||||
@ -97,7 +111,7 @@ const ViewCollection = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-md-6 d-flex align-items-center">
|
<div className="col-md-6 mb-3 d-flex align-items-center">
|
||||||
<p className="m-0 fw-semibold">Created By:</p>{" "}
|
<p className="m-0 fw-semibold">Created By:</p>{" "}
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
<Avatar
|
<Avatar
|
||||||
@ -114,6 +128,47 @@ const ViewCollection = () => {
|
|||||||
{data?.description}
|
{data?.description}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="col-12 text-start">
|
||||||
|
<label className="form-label 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>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="container px-1 ">
|
<div className="container px-1 ">
|
||||||
{/* Tabs Navigation */}
|
{/* Tabs Navigation */}
|
||||||
@ -127,7 +182,8 @@ const ViewCollection = () => {
|
|||||||
type="button"
|
type="button"
|
||||||
role="tab"
|
role="tab"
|
||||||
>
|
>
|
||||||
Comments ({data?.comments?.length ?? '0'})
|
<i className="bx bx-message-dots bx-sm me-2"></i> Comments (
|
||||||
|
{data?.comments?.length ?? "0"})
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li className="nav-item">
|
<li className="nav-item">
|
||||||
@ -139,7 +195,7 @@ const ViewCollection = () => {
|
|||||||
type="button"
|
type="button"
|
||||||
role="tab"
|
role="tab"
|
||||||
>
|
>
|
||||||
Payments History
|
<i className="bx bx-history bx-sm me-1"></i> Payments History
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -150,8 +206,7 @@ const ViewCollection = () => {
|
|||||||
id="details"
|
id="details"
|
||||||
role="tabpanel"
|
role="tabpanel"
|
||||||
>
|
>
|
||||||
|
<Comment invoice={data} />
|
||||||
<Comment invoice={data}/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Payments History Tab Content */}
|
{/* Payments History Tab Content */}
|
||||||
|
@ -128,4 +128,22 @@ export const useAddComment = (onSuccessCallBack) => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
@ -10,10 +10,11 @@ import { isPending } from "@reduxjs/toolkit";
|
|||||||
import ConfirmModal from "../../components/common/ConfirmModal";
|
import ConfirmModal from "../../components/common/ConfirmModal";
|
||||||
import showToast from "../../services/toastService";
|
import showToast from "../../services/toastService";
|
||||||
import { useMarkedPaymentReceived } from "../../hooks/useCollections";
|
import { useMarkedPaymentReceived } from "../../hooks/useCollections";
|
||||||
import NewCollection from "../../components/collections/NewCollection";
|
|
||||||
import GlobalModel from "../../components/common/GlobalModel";
|
import GlobalModel from "../../components/common/GlobalModel";
|
||||||
import AddPayment from "../../components/collections/AddPayment";
|
import AddPayment from "../../components/collections/AddPayment";
|
||||||
import ViewCollection from "../../components/collections/ViewCollection";
|
import ViewCollection from "../../components/collections/ViewCollection";
|
||||||
|
import ManageCollection from "../../components/collections/ManageCollection";
|
||||||
|
import PreviewDocument from "../../components/Expenses/PreviewDocument";
|
||||||
|
|
||||||
const CollectionContext = createContext();
|
const CollectionContext = createContext();
|
||||||
export const useCollectionContext = () => {
|
export const useCollectionContext = () => {
|
||||||
@ -30,6 +31,10 @@ const CollectionPage = () => {
|
|||||||
isOpen: false,
|
isOpen: false,
|
||||||
invoiceId: null,
|
invoiceId: null,
|
||||||
});
|
});
|
||||||
|
const [ViewDocument, setDocumentView] = useState({
|
||||||
|
IsOpen: false,
|
||||||
|
Image: null,
|
||||||
|
});
|
||||||
const [processedPayment, setProcessedPayment] = useState(null);
|
const [processedPayment, setProcessedPayment] = useState(null);
|
||||||
const [addPayment, setAddPayment] = useState({
|
const [addPayment, setAddPayment] = useState({
|
||||||
isOpen: false,
|
isOpen: false,
|
||||||
@ -49,10 +54,12 @@ const CollectionPage = () => {
|
|||||||
|
|
||||||
const contextMassager = {
|
const contextMassager = {
|
||||||
setProcessedPayment,
|
setProcessedPayment,
|
||||||
|
setCollection,
|
||||||
setAddPayment,
|
setAddPayment,
|
||||||
addPayment,
|
addPayment,
|
||||||
setViewCollection,
|
setViewCollection,
|
||||||
viewCollection
|
viewCollection,
|
||||||
|
setDocumentView
|
||||||
};
|
};
|
||||||
const { mutate: MarkedReceived, isPending } = useMarkedPaymentReceived(() => {
|
const { mutate: MarkedReceived, isPending } = useMarkedPaymentReceived(() => {
|
||||||
setProcessedPayment(null);
|
setProcessedPayment(null);
|
||||||
@ -129,8 +136,8 @@ const CollectionPage = () => {
|
|||||||
size="lg"
|
size="lg"
|
||||||
closeModal={() => setCollection({ isOpen: false, invoiceId: null })}
|
closeModal={() => setCollection({ isOpen: false, invoiceId: null })}
|
||||||
>
|
>
|
||||||
<NewCollection
|
<ManageCollection
|
||||||
collectionId={null}
|
collectionId={makeCollection?.invoiceId ?? null}
|
||||||
onClose={() => setCollection({ isOpen: false, invoiceId: null })}
|
onClose={() => setCollection({ isOpen: false, invoiceId: null })}
|
||||||
/>
|
/>
|
||||||
</GlobalModel>
|
</GlobalModel>
|
||||||
@ -154,6 +161,16 @@ const CollectionPage = () => {
|
|||||||
</GlobalModel>
|
</GlobalModel>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{ViewDocument.IsOpen && (
|
||||||
|
<GlobalModel
|
||||||
|
isOpen
|
||||||
|
size="md"
|
||||||
|
key={ViewDocument.Image ?? "doc"}
|
||||||
|
closeModal={() => setDocumentView({ IsOpen: false, Image: null })}
|
||||||
|
>
|
||||||
|
<PreviewDocument imageUrl={ViewDocument.Image} />
|
||||||
|
</GlobalModel>)}
|
||||||
|
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
type="success"
|
type="success"
|
||||||
header="Payment Successful Received"
|
header="Payment Successful Received"
|
||||||
|
@ -4,6 +4,9 @@ import { DirectoryRepository } from "./DirectoryRepository";
|
|||||||
export const CollectionRepository = {
|
export const CollectionRepository = {
|
||||||
createNewCollection: (data) =>
|
createNewCollection: (data) =>
|
||||||
api.post(`/api/Collection/invoice/create`, 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, searchString) => {
|
getCollections: (pageSize, pageNumber,fromDate,toDate, isPending,isActive, searchString) => {
|
||||||
let url = `/api/Collection/invoice/list?pageSize=${pageSize}&pageNumber=${pageNumber}&isPending=${isPending}&isActive=${isActive}&searchString=${searchString}`;
|
let url = `/api/Collection/invoice/list?pageSize=${pageSize}&pageNumber=${pageNumber}&isPending=${isPending}&isActive=${isActive}&searchString=${searchString}`;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user