import React from "react";
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 { ITEMS_PER_PAGE } from "../../utils/constants";
const PurchasePartyDetails = () => {
const {
register,
control,
setValue,
watch,
formState: { errors },
} = useAppFormContext();
const hasNumber = !! watch('proformaInvoiceNumber');
const hasAmount =
watch("proformaInvoiceAmount") !== null && watch("proformaInvoiceAmount") > 0;
const hasDate = !!watch("proformaInvoiceDate");
// If any one field is filled → all must be valid
const anyField = hasNumber || hasAmount || hasDate;
return (
{/* Title */}
{errors?.title && (
{errors.title.message}
)}
{/* Project ID */}
setValue("projectId", val, {
shouldDirty: true,
shouldValidate: true,
})
}
errors={errors}
/>
{errors?.billingAddress && (
{errors.billingAddress.message}
)}
{errors?.shippingAddress && (
{errors.shippingAddress.message}
)}
{/* Purchase Order Number */}
{errors?.purchaseOrderNumber && (
{errors.purchaseOrderNumber.message}
)}
{/* Purchase Order Date */}
{errors?.purchaseOrderDate && (
{errors.purchaseOrderDate.message}
)}
{/* Proforma Invoice */}
{errors?.proformaInvoiceNumber && (
{errors.proformaInvoiceNumber.message}
)}
{errors?.proformaInvoiceAmount && (
{errors.proformaInvoiceAmount.message}
)}
{errors?.proformaInvoiceDate && (
{errors.proformaInvoiceDate.message}
)}
);
};
export default PurchasePartyDetails;