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(() => {
|
||||
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]);
|
||||
}
|
||||
}, [purchaseId, data, reset]);
|
||||
@ -78,8 +84,7 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
|
||||
setActiveTab((prev) => Math.max(prev - 1, 0));
|
||||
};
|
||||
|
||||
const { mutate: CreateInvoice, isPending } =
|
||||
useCreatePurchaseInvoice(() => {
|
||||
const { mutate: CreateInvoice, isPending } = useCreatePurchaseInvoice(() => {
|
||||
reset();
|
||||
onClose();
|
||||
});
|
||||
@ -149,9 +154,7 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
|
||||
|
||||
<span className="bs-stepper-label">
|
||||
<span className="bs-stepper-title">{step.name}</span>
|
||||
<span className="bs-stepper-subtitle">
|
||||
{step.subtitle}
|
||||
</span>
|
||||
<span className="bs-stepper-subtitle">{step.subtitle}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
@ -225,4 +228,3 @@ const ManagePurchase = ({ onClose, purchaseId }) => {
|
||||
};
|
||||
|
||||
export default ManagePurchase;
|
||||
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
import React from "react";
|
||||
import { AppFormController, useAppFormContext } from "../../hooks/appHooks/useAppForm";
|
||||
import {
|
||||
AppFormController,
|
||||
useAppFormContext,
|
||||
} from "../../hooks/appHooks/useAppForm";
|
||||
import Label from "../common/Label";
|
||||
import DatePicker from "../common/DatePicker";
|
||||
import {
|
||||
SelectFieldSearch,
|
||||
SelectProjectField,
|
||||
} 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";
|
||||
|
||||
const PurchasePartyDetails = () => {
|
||||
@ -18,7 +25,6 @@ const PurchasePartyDetails = () => {
|
||||
formState: { errors },
|
||||
} = useAppFormContext();
|
||||
|
||||
|
||||
return (
|
||||
<div className="row g-2 text-start">
|
||||
{/* Title */}
|
||||
@ -61,35 +67,27 @@ const PurchasePartyDetails = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Organization */}
|
||||
<div className="col-12 col-md-6">
|
||||
|
||||
|
||||
<AppFormController
|
||||
name="organizationId"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<SelectFieldSearch
|
||||
{...field}
|
||||
label="Organization"
|
||||
placeholder="Select Organization"
|
||||
required
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
valueKey="id"
|
||||
labelKey="name"
|
||||
useFetchHook={useGlobaleOrganizations}
|
||||
hookParams={[ITEMS_PER_PAGE,1]}
|
||||
errors={errors?.organizationId}
|
||||
hookParams={[ITEMS_PER_PAGE, 1]}
|
||||
error={errors?.organizationId?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
{/* Supplier */}
|
||||
<div className="col-12 col-md-6">
|
||||
|
||||
|
||||
<AppFormController
|
||||
name="supplierId"
|
||||
control={control}
|
||||
@ -103,16 +101,13 @@ const PurchasePartyDetails = () => {
|
||||
valueKey="id"
|
||||
labelKey="name"
|
||||
useFetchHook={useGlobaleOrganizations}
|
||||
hookParams={[ITEMS_PER_PAGE,1]}
|
||||
hookParams={[ITEMS_PER_PAGE, 1]}
|
||||
errors={errors.supplierId}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{/* Billing Address */}
|
||||
<div className="col-12 col-md-6">
|
||||
<Label htmlFor="billingAddress">Billing Address</Label>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user