From 246abee37b669e899919e63ab7374b2a82d0668c Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Wed, 19 Nov 2025 11:23:38 +0530 Subject: [PATCH] Adding Billed To field in Manage Collection. --- .../collections/ManageCollection.jsx | 91 +++++++++++++------ .../collections/collectionSchema.jsx | 2 + 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/src/components/collections/ManageCollection.jsx b/src/components/collections/ManageCollection.jsx index 608a6c33..c0160b6b 100644 --- a/src/components/collections/ManageCollection.jsx +++ b/src/components/collections/ManageCollection.jsx @@ -16,10 +16,16 @@ import { import { formatFileSize, localToUtc } from "../../utils/appUtils"; import { useCollectionContext } from "../../pages/collections/CollectionPage"; import { formatDate } from "../../utils/dateUtils"; +import { SelectProjectField } from "../common/Forms/SelectFieldServerSide"; +import { ITEMS_PER_PAGE } from "../../utils/constants"; +import { useOrganizationsList } from "../../hooks/useOrganization"; const ManageCollection = ({ collectionId, onClose }) => { const { data, isError, isLoading, error } = useCollection(collectionId); const { projectNames, projectLoading } = useProjectName(true); + const { data: organization, isLoading: isLoadingOrganization } = + useOrganizationsList(ITEMS_PER_PAGE, 1, true); + const methods = useForm({ resolver: zodResolver(newCollection), defaultValues: defaultCollection, @@ -138,6 +144,7 @@ const ManageCollection = ({ collectionId, onClose }) => { taxAmount: data?.taxAmount, basicAmount: data?.basicAmount, description: data?.description, + billedToId: data?.billedToId, attachments: data.attachments ? data.attachments.map((doc) => ({ fileName: doc.fileName, @@ -163,36 +170,61 @@ const ManageCollection = ({ collectionId, onClose }) => {
-
- - +
+ + setValue("projectId", val, { + shouldDirty: true, + shouldValidate: true, + }) + } + /> {errors.projectId && ( - - {errors.projectId.message} - + {errors.projectId.message} )}
+ +
+ +
+ +
+ {errors?.clientId && ( + {errors.billedToId.message} + )} +
+
{errors.title && ( @@ -203,7 +235,7 @@ const ManageCollection = ({ collectionId, onClose }) => { {errors.invoiceId && ( @@ -216,7 +248,7 @@ const ManageCollection = ({ collectionId, onClose }) => { {errors.invoiceId && ( @@ -232,6 +264,7 @@ const ManageCollection = ({ collectionId, onClose }) => { name="invoiceDate" control={control} maxDate={new Date()} + size="md" /> {errors.invoiceDate && ( @@ -246,6 +279,7 @@ const ManageCollection = ({ collectionId, onClose }) => { name="exceptedPaymentDate" control={control} minDate={watch("invoiceDate")} + size="md" /> {errors.exceptedPaymentDate && ( @@ -260,6 +294,7 @@ const ManageCollection = ({ collectionId, onClose }) => { name="clientSubmitedDate" control={control} maxDate={new Date()} + size="md" /> {errors.exceptedPaymentDate && ( @@ -275,7 +310,7 @@ const ManageCollection = ({ collectionId, onClose }) => { { { diff --git a/src/components/collections/collectionSchema.jsx b/src/components/collections/collectionSchema.jsx index bb97fede..84ea806b 100644 --- a/src/components/collections/collectionSchema.jsx +++ b/src/components/collections/collectionSchema.jsx @@ -19,6 +19,7 @@ export const newCollection = z.object({ invoiceDate: z.string().min(1, { message: "Date is required" }), description: z.string().trim().optional(), clientSubmitedDate: z.string().min(1, { message: "Date is required" }), + billedToId: z.string().min(1, { message: "Date is required" }), exceptedPaymentDate: z.string().min(1, { message: "Date is required" }), invoiceNumber: z .string() @@ -75,6 +76,7 @@ export const defaultCollection = { taxAmount: "", basicAmount: "", description: "", + billedToId:"", attachments: [], };