Compare commits
No commits in common. "521d46bdeeaa88393be7d4eaf4206093e9d0b8c6" and "047e563505632736383e0955b3d59d83fa9e22a6" have entirely different histories.
521d46bdee
...
047e563505
@ -16,16 +16,10 @@ import {
|
|||||||
import { formatFileSize, localToUtc } from "../../utils/appUtils";
|
import { formatFileSize, localToUtc } from "../../utils/appUtils";
|
||||||
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
||||||
import { formatDate } from "../../utils/dateUtils";
|
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 ManageCollection = ({ collectionId, onClose }) => {
|
||||||
const { data, isError, isLoading, error } = useCollection(collectionId);
|
const { data, isError, isLoading, error } = useCollection(collectionId);
|
||||||
const { projectNames, projectLoading } = useProjectName(true);
|
const { projectNames, projectLoading } = useProjectName(true);
|
||||||
const { data: organization, isLoading: isLoadingOrganization } =
|
|
||||||
useOrganizationsList(ITEMS_PER_PAGE, 1, true);
|
|
||||||
|
|
||||||
const methods = useForm({
|
const methods = useForm({
|
||||||
resolver: zodResolver(newCollection),
|
resolver: zodResolver(newCollection),
|
||||||
defaultValues: defaultCollection,
|
defaultValues: defaultCollection,
|
||||||
@ -144,7 +138,6 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
taxAmount: data?.taxAmount,
|
taxAmount: data?.taxAmount,
|
||||||
basicAmount: data?.basicAmount,
|
basicAmount: data?.basicAmount,
|
||||||
description: data?.description,
|
description: data?.description,
|
||||||
billedToId: data?.billedToId,
|
|
||||||
attachments: data.attachments
|
attachments: data.attachments
|
||||||
? data.attachments.map((doc) => ({
|
? data.attachments.map((doc) => ({
|
||||||
fileName: doc.fileName,
|
fileName: doc.fileName,
|
||||||
@ -171,60 +164,35 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
<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">
|
||||||
<div className="col-12 col-md-6 mb-2">
|
<div className="col-12 col-md-6 mb-2">
|
||||||
<SelectProjectField
|
<Label className="form-label" required>
|
||||||
label="Project"
|
Select Project
|
||||||
required
|
|
||||||
placeholder="Select Project"
|
|
||||||
value={watch("projectId")}
|
|
||||||
onChange={(val) =>
|
|
||||||
setValue("projectId", val, {
|
|
||||||
shouldDirty: true,
|
|
||||||
shouldValidate: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
{errors.projectId && (
|
|
||||||
<small className="danger-text">{errors.projectId.message}</small>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-12 col-md-6 mb-2">
|
|
||||||
<Label htmlFor="name" required>
|
|
||||||
Bill To
|
|
||||||
</Label>
|
</Label>
|
||||||
<div className="d-flex align-items-center gap-2">
|
|
||||||
<select
|
<select
|
||||||
className="select2 form-select form-select flex-grow-1"
|
className="form-select form-select-sm"
|
||||||
aria-label="Default select example"
|
{...register("projectId")}
|
||||||
{...register("billedToId", {
|
|
||||||
required: "Client is required",
|
|
||||||
valueAsNumber: false,
|
|
||||||
})}
|
|
||||||
>
|
>
|
||||||
{isLoading ? (
|
<option value="">Select Project</option>
|
||||||
|
{projectLoading ? (
|
||||||
<option>Loading...</option>
|
<option>Loading...</option>
|
||||||
) : (
|
) : (
|
||||||
<>
|
projectNames?.map((project) => (
|
||||||
<option value="">Select Client</option>
|
<option key={project.id} value={project.id}>
|
||||||
{organization?.data?.map((org) => (
|
{project.name}
|
||||||
<option key={org.id} value={org.id}>
|
|
||||||
{org.name}
|
|
||||||
</option>
|
</option>
|
||||||
))}
|
))
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
{errors.projectId && (
|
||||||
{errors?.clientId && (
|
<small className="danger-text">
|
||||||
<span className="danger-text">{errors.billedToId.message}</span>
|
{errors.projectId.message}
|
||||||
|
</small>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 col-md-6 mb-2">
|
<div className="col-12 col-md-6 mb-2">
|
||||||
<Label required>Title</Label>
|
<Label required>Title</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control form-control"
|
className="form-control form-control-sm"
|
||||||
{...register("title")}
|
{...register("title")}
|
||||||
/>
|
/>
|
||||||
{errors.title && (
|
{errors.title && (
|
||||||
@ -235,7 +203,7 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
<Label required>Invoice Number</Label>
|
<Label required>Invoice Number</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control form-control"
|
className="form-control form-control-sm"
|
||||||
{...register("invoiceNumber")}
|
{...register("invoiceNumber")}
|
||||||
/>
|
/>
|
||||||
{errors.invoiceId && (
|
{errors.invoiceId && (
|
||||||
@ -248,7 +216,7 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
<Label required>E-Invoice Number</Label>
|
<Label required>E-Invoice Number</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control form-control"
|
className="form-control form-control-sm"
|
||||||
{...register("eInvoiceNumber")}
|
{...register("eInvoiceNumber")}
|
||||||
/>
|
/>
|
||||||
{errors.invoiceId && (
|
{errors.invoiceId && (
|
||||||
@ -264,7 +232,6 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
name="invoiceDate"
|
name="invoiceDate"
|
||||||
control={control}
|
control={control}
|
||||||
maxDate={new Date()}
|
maxDate={new Date()}
|
||||||
size="md"
|
|
||||||
/>
|
/>
|
||||||
{errors.invoiceDate && (
|
{errors.invoiceDate && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
@ -279,7 +246,6 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
name="exceptedPaymentDate"
|
name="exceptedPaymentDate"
|
||||||
control={control}
|
control={control}
|
||||||
minDate={watch("invoiceDate")}
|
minDate={watch("invoiceDate")}
|
||||||
size="md"
|
|
||||||
/>
|
/>
|
||||||
{errors.exceptedPaymentDate && (
|
{errors.exceptedPaymentDate && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
@ -294,7 +260,6 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
name="clientSubmitedDate"
|
name="clientSubmitedDate"
|
||||||
control={control}
|
control={control}
|
||||||
maxDate={new Date()}
|
maxDate={new Date()}
|
||||||
size="md"
|
|
||||||
/>
|
/>
|
||||||
{errors.exceptedPaymentDate && (
|
{errors.exceptedPaymentDate && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
@ -310,7 +275,7 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="basicAmount"
|
id="basicAmount"
|
||||||
className="form-control form-control"
|
className="form-control form-control-sm"
|
||||||
min="1"
|
min="1"
|
||||||
step="0.01"
|
step="0.01"
|
||||||
inputMode="decimal"
|
inputMode="decimal"
|
||||||
@ -329,7 +294,7 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
id="taxAmount"
|
id="taxAmount"
|
||||||
className="form-control form-control"
|
className="form-control form-control-sm"
|
||||||
min="1"
|
min="1"
|
||||||
step="0.01"
|
step="0.01"
|
||||||
inputMode="decimal"
|
inputMode="decimal"
|
||||||
@ -348,7 +313,7 @@ const ManageCollection = ({ collectionId, onClose }) => {
|
|||||||
</Label>
|
</Label>
|
||||||
<textarea
|
<textarea
|
||||||
id="description"
|
id="description"
|
||||||
className="form-control form-control"
|
className="form-control form-control-sm"
|
||||||
{...register("description")}
|
{...register("description")}
|
||||||
rows="2"
|
rows="2"
|
||||||
></textarea>
|
></textarea>
|
||||||
|
|||||||
@ -19,7 +19,6 @@ export const newCollection = z.object({
|
|||||||
invoiceDate: z.string().min(1, { message: "Date is required" }),
|
invoiceDate: z.string().min(1, { message: "Date is required" }),
|
||||||
description: z.string().trim().optional(),
|
description: z.string().trim().optional(),
|
||||||
clientSubmitedDate: z.string().min(1, { message: "Date is required" }),
|
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" }),
|
exceptedPaymentDate: z.string().min(1, { message: "Date is required" }),
|
||||||
invoiceNumber: z
|
invoiceNumber: z
|
||||||
.string()
|
.string()
|
||||||
@ -76,7 +75,6 @@ export const defaultCollection = {
|
|||||||
taxAmount: "",
|
taxAmount: "",
|
||||||
basicAmount: "",
|
basicAmount: "",
|
||||||
description: "",
|
description: "",
|
||||||
billedToId:"",
|
|
||||||
attachments: [],
|
attachments: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user