fixed project, supplier and Organization filed fullfied whenevr open for update
This commit is contained in:
parent
9234253c97
commit
e0789cda3a
@ -54,7 +54,13 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (purchaseId && data) {
|
if (purchaseId && data) {
|
||||||
reset(data);
|
reset({
|
||||||
|
...data,
|
||||||
|
title: data.title,
|
||||||
|
projectId: data.project.id,
|
||||||
|
organizationId: data.organization.id,
|
||||||
|
supplierId: data.supplier.id,
|
||||||
|
});
|
||||||
setCompletedTabs([0, 1, 2]);
|
setCompletedTabs([0, 1, 2]);
|
||||||
}
|
}
|
||||||
}, [purchaseId, data, reset]);
|
}, [purchaseId, data, reset]);
|
||||||
@ -78,11 +84,10 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
|
|||||||
setActiveTab((prev) => Math.max(prev - 1, 0));
|
setActiveTab((prev) => Math.max(prev - 1, 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
const { mutate: CreateInvoice, isPending } =
|
const { mutate: CreateInvoice, isPending } = useCreatePurchaseInvoice(() => {
|
||||||
useCreatePurchaseInvoice(() => {
|
reset();
|
||||||
reset();
|
onClose();
|
||||||
onClose();
|
});
|
||||||
});
|
|
||||||
|
|
||||||
const { mutate: updatePurchase, isPending: isUpdating } =
|
const { mutate: updatePurchase, isPending: isUpdating } =
|
||||||
useUpdatePurchaseInvoice(() => {
|
useUpdatePurchaseInvoice(() => {
|
||||||
@ -149,9 +154,7 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
|
|||||||
|
|
||||||
<span className="bs-stepper-label">
|
<span className="bs-stepper-label">
|
||||||
<span className="bs-stepper-title">{step.name}</span>
|
<span className="bs-stepper-title">{step.name}</span>
|
||||||
<span className="bs-stepper-subtitle">
|
<span className="bs-stepper-subtitle">{step.subtitle}</span>
|
||||||
{step.subtitle}
|
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -225,4 +228,3 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default ManagePurchase;
|
export default ManagePurchase;
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,19 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { AppFormController, useAppFormContext } from "../../hooks/appHooks/useAppForm";
|
import {
|
||||||
|
AppFormController,
|
||||||
|
useAppFormContext,
|
||||||
|
} from "../../hooks/appHooks/useAppForm";
|
||||||
import Label from "../common/Label";
|
import Label from "../common/Label";
|
||||||
import DatePicker from "../common/DatePicker";
|
import DatePicker from "../common/DatePicker";
|
||||||
import {
|
import {
|
||||||
SelectFieldSearch,
|
SelectFieldSearch,
|
||||||
SelectProjectField,
|
SelectProjectField,
|
||||||
} from "../common/Forms/SelectFieldServerSide";
|
} from "../common/Forms/SelectFieldServerSide";
|
||||||
import { useGlobaleOrganizations, useOrganization, useOrganizationsList } from "../../hooks/useOrganization";
|
import {
|
||||||
|
useGlobaleOrganizations,
|
||||||
|
useOrganization,
|
||||||
|
useOrganizationsList,
|
||||||
|
} from "../../hooks/useOrganization";
|
||||||
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||||
|
|
||||||
const PurchasePartyDetails = () => {
|
const PurchasePartyDetails = () => {
|
||||||
@ -18,7 +25,6 @@ const PurchasePartyDetails = () => {
|
|||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useAppFormContext();
|
} = useAppFormContext();
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="row g-2 text-start">
|
<div className="row g-2 text-start">
|
||||||
{/* Title */}
|
{/* Title */}
|
||||||
@ -61,35 +67,27 @@ const PurchasePartyDetails = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Organization */}
|
|
||||||
<div className="col-12 col-md-6">
|
<div className="col-12 col-md-6">
|
||||||
|
|
||||||
|
|
||||||
<AppFormController
|
<AppFormController
|
||||||
name="organizationId"
|
name="organizationId"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<SelectFieldSearch
|
<SelectFieldSearch
|
||||||
|
{...field}
|
||||||
label="Organization"
|
label="Organization"
|
||||||
placeholder="Select Organization"
|
placeholder="Select Organization"
|
||||||
required
|
required
|
||||||
value={field.value}
|
|
||||||
onChange={field.onChange}
|
|
||||||
valueKey="id"
|
valueKey="id"
|
||||||
labelKey="name"
|
labelKey="name"
|
||||||
useFetchHook={useGlobaleOrganizations}
|
useFetchHook={useGlobaleOrganizations}
|
||||||
hookParams={[ITEMS_PER_PAGE,1]}
|
hookParams={[ITEMS_PER_PAGE, 1]}
|
||||||
errors={errors?.organizationId}
|
error={errors?.organizationId?.message}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Supplier */}
|
|
||||||
<div className="col-12 col-md-6">
|
<div className="col-12 col-md-6">
|
||||||
|
|
||||||
|
|
||||||
<AppFormController
|
<AppFormController
|
||||||
name="supplierId"
|
name="supplierId"
|
||||||
control={control}
|
control={control}
|
||||||
@ -103,16 +101,13 @@ const PurchasePartyDetails = () => {
|
|||||||
valueKey="id"
|
valueKey="id"
|
||||||
labelKey="name"
|
labelKey="name"
|
||||||
useFetchHook={useGlobaleOrganizations}
|
useFetchHook={useGlobaleOrganizations}
|
||||||
hookParams={[ITEMS_PER_PAGE,1]}
|
hookParams={[ITEMS_PER_PAGE, 1]}
|
||||||
errors={errors.supplierId}
|
errors={errors.supplierId}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Billing Address */}
|
|
||||||
<div className="col-12 col-md-6">
|
<div className="col-12 col-md-6">
|
||||||
<Label htmlFor="billingAddress">Billing Address</Label>
|
<Label htmlFor="billingAddress">Billing Address</Label>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user