client given cr fixed
This commit is contained in:
parent
367d15d065
commit
da34c59a90
@ -602,32 +602,28 @@ React.useEffect(() => {
|
|||||||
value={info.establishmentName}
|
value={info.establishmentName}
|
||||||
onChange={handleFieldChange('establishmentName')}
|
onChange={handleFieldChange('establishmentName')}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
<Field
|
{/* <Field
|
||||||
label="Permanent Factory Code(PFC)"
|
label="Permanent Factory Code(PFC)"
|
||||||
placeholder="Enter Permanent Factory Code"
|
placeholder="Enter Permanent Factory Code"
|
||||||
value={info.permanentFactoryCode}
|
value={info.permanentFactoryCode}
|
||||||
onChange={handleFieldChange('permanentFactoryCode')}
|
onChange={handleFieldChange('permanentFactoryCode')}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
|
/> */}
|
||||||
/>
|
{/* <Field
|
||||||
<Field
|
|
||||||
label="Business Register Industry Code"
|
label="Business Register Industry Code"
|
||||||
placeholder="Enter Industry Code"
|
placeholder="Enter Industry Code"
|
||||||
value={info.industryCode}
|
value={info.industryCode}
|
||||||
onChange={handleFieldChange('industryCode')}
|
onChange={handleFieldChange('industryCode')}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
|
/> */}
|
||||||
/>
|
{/* <Field
|
||||||
<Field
|
|
||||||
label="License Number"
|
label="License Number"
|
||||||
placeholder="Enter License Number"
|
placeholder="Enter License Number"
|
||||||
value={info.licenseNumber}
|
value={info.licenseNumber}
|
||||||
onChange={handleFieldChange('licenseNumber')}
|
onChange={handleFieldChange('licenseNumber')}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
|
/> */}
|
||||||
/>
|
|
||||||
{/* Email field is hidden but data remains in form state */}
|
{/* Email field is hidden but data remains in form state */}
|
||||||
<Field
|
<Field
|
||||||
label="ISIC Code"
|
label="ISIC Code"
|
||||||
@ -635,7 +631,6 @@ React.useEffect(() => {
|
|||||||
value={info.isicCode}
|
value={info.isicCode}
|
||||||
onChange={handleFieldChange('isicCode')}
|
onChange={handleFieldChange('isicCode')}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
<Field
|
<Field
|
||||||
label="Emirate"
|
label="Emirate"
|
||||||
|
|||||||
@ -410,6 +410,7 @@ const ProductData = ({
|
|||||||
const [isLoadingProducts, setIsLoadingProducts] = React.useState(false);
|
const [isLoadingProducts, setIsLoadingProducts] = React.useState(false);
|
||||||
const [productsError, setProductsError] = React.useState('');
|
const [productsError, setProductsError] = React.useState('');
|
||||||
const [showDraftSaved, setShowDraftSaved] = React.useState(false);
|
const [showDraftSaved, setShowDraftSaved] = React.useState(false);
|
||||||
|
const [deletedProducts, setDeletedProducts] = React.useState([]);
|
||||||
const MAX_PRODUCTS = maxProducts;
|
const MAX_PRODUCTS = maxProducts;
|
||||||
// Remove the unused state variables since we'll use the props directly
|
// Remove the unused state variables since we'll use the props directly
|
||||||
const [unitOptions, setUnitOptions] = React.useState([]);
|
const [unitOptions, setUnitOptions] = React.useState([]);
|
||||||
@ -737,6 +738,56 @@ const existingProduct = currentSubmission.products?.find(p =>
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add deleted products with is_active: false if we're in draft edit mode
|
||||||
|
if (location.state?.isEdit && deletedProducts.length > 0) {
|
||||||
|
const deletedFormattedProducts = deletedProducts.map(product => {
|
||||||
|
const selectedProduct = productOptions.find(p => p.value === product.product);
|
||||||
|
const existingProduct = currentSubmission.products?.find(p =>
|
||||||
|
p.product_id === (selectedProduct?.product_id || product.product_id) ||
|
||||||
|
p.product?.id === (selectedProduct?.product_id || product.product_id)
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
id: existingProduct?.id || 0,
|
||||||
|
product_id: selectedProduct?.product_id || product.product_id || null,
|
||||||
|
unit_id: product.unit?.toString() || '0',
|
||||||
|
annual_installed_capacity: product.capacity || '0',
|
||||||
|
previous_quantity_period_one: product.octQuantity || '0',
|
||||||
|
previous_quantity_period_two: product.novQuantity || '0',
|
||||||
|
previous_quantity_period_three: product.decQuantity || '0',
|
||||||
|
previous_cost_period_one: product.octCost || '0',
|
||||||
|
previous_cost_period_two: product.novCost || '0',
|
||||||
|
previous_cost_period_three: product.decCost || '0',
|
||||||
|
current_quantity_period_one: product.janQuantity || '0',
|
||||||
|
current_quantity_period_two: product.febQuantity || '0',
|
||||||
|
current_quantity_period_three: product.marQuantity || '0',
|
||||||
|
current_cost_period_one: product.janCost || '0',
|
||||||
|
current_cost_period_two: product.febCost || '0',
|
||||||
|
current_cost_period_three: product.marCost || '0',
|
||||||
|
forecast_quantity_period_one: product.aprQuantity || '0',
|
||||||
|
forecast_quantity_period_two: product.mayQuantity || '0',
|
||||||
|
forecast_quantity_period_three: product.junQuantity || '0',
|
||||||
|
forecast_cost_period_one: product.aprCost || '0',
|
||||||
|
forecast_cost_period_two: product.mayCost || '0',
|
||||||
|
forecast_cost_period_three: product.junCost || '0',
|
||||||
|
previous_quantity: product.octQuantity || '0',
|
||||||
|
previous_cost: product.octCost || '0',
|
||||||
|
current_quantity: product.novQuantity || '0',
|
||||||
|
current_cost: product.novCost || '0',
|
||||||
|
forecast_quantity: product.decQuantity || '0',
|
||||||
|
forecast_cost: product.decCost || '0',
|
||||||
|
variation_reason_master_id: product.variationReason || '0',
|
||||||
|
other_variation_reason: product.otherVariationReason || '0',
|
||||||
|
zero_target_reason_master_id: product.zeroTargetReason || '0',
|
||||||
|
other_zero_target_reason: product.otherZeroTargetReason || '0',
|
||||||
|
remarks: product.remarks || remarks || '',
|
||||||
|
is_active: false // Mark as inactive
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Combine active and deleted products
|
||||||
|
formattedProducts.push(...deletedFormattedProducts);
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare the complete payload with values from currentSubmission
|
// Prepare the complete payload with values from currentSubmission
|
||||||
const payload = {
|
const payload = {
|
||||||
establishment_id: establishmentId,
|
establishment_id: establishmentId,
|
||||||
@ -1284,6 +1335,11 @@ useEffect(() => {
|
|||||||
const productToRemove = products.find(p => p.id === id);
|
const productToRemove = products.find(p => p.id === id);
|
||||||
onProductsChange(products.filter((p) => p.id !== id));
|
onProductsChange(products.filter((p) => p.id !== id));
|
||||||
|
|
||||||
|
// Track deleted products if we're in draft edit mode
|
||||||
|
if (location.state?.isEdit && productToRemove) {
|
||||||
|
setDeletedProducts(prev => [...prev, productToRemove]);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove the product ID from selectedProductIds if it exists
|
// Remove the product ID from selectedProductIds if it exists
|
||||||
if (productToRemove?.product) {
|
if (productToRemove?.product) {
|
||||||
setSelectedProductIds(prev => prev.filter(pid => pid !== productToRemove.product));
|
setSelectedProductIds(prev => prev.filter(pid => pid !== productToRemove.product));
|
||||||
|
|||||||
@ -680,7 +680,7 @@ const CompanyProfile = () => {
|
|||||||
2: [
|
2: [
|
||||||
{ field: 'contactName', label: 'Name' },
|
{ field: 'contactName', label: 'Name' },
|
||||||
{ field: 'contactAddress', label: 'Address' },
|
{ field: 'contactAddress', label: 'Address' },
|
||||||
{ field: 'contactCityTown', label: 'City/Town' },
|
// { field: 'contactCityTown', label: 'City/Town' },
|
||||||
{ field: 'contactEmirate', label: 'Emirate' },
|
{ field: 'contactEmirate', label: 'Emirate' },
|
||||||
{ field: 'contactMobileNumber', label: 'Mobile Number' },
|
{ field: 'contactMobileNumber', label: 'Mobile Number' },
|
||||||
{ field: 'contactEmail', label: 'Email' },
|
{ field: 'contactEmail', label: 'Email' },
|
||||||
@ -1127,8 +1127,8 @@ const CompanyProfile = () => {
|
|||||||
options={contactCityOptions}
|
options={contactCityOptions}
|
||||||
placeholder="Select City/Town"
|
placeholder="Select City/Town"
|
||||||
width="100%"
|
width="100%"
|
||||||
required
|
// required
|
||||||
error={fieldErrors.contactCityTown}
|
// error={fieldErrors.contactCityTown}
|
||||||
readOnly={modalMode === 'view'}
|
readOnly={modalMode === 'view'}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
|
|||||||
@ -131,7 +131,7 @@ const EditCompanyProfile = () => {
|
|||||||
{ field: 'contactName', label: 'Name' },
|
{ field: 'contactName', label: 'Name' },
|
||||||
// { field: 'contactAddress', label: 'Address' },
|
// { field: 'contactAddress', label: 'Address' },
|
||||||
{ field: 'contactEmirate', label: 'Emirate' },
|
{ field: 'contactEmirate', label: 'Emirate' },
|
||||||
{ field: 'contactCityTown', label: 'City/Town' },
|
// { field: 'contactCityTown', label: 'City/Town' },
|
||||||
{ field: 'contactEmail', label: 'Email' },
|
{ field: 'contactEmail', label: 'Email' },
|
||||||
],
|
],
|
||||||
3: [
|
3: [
|
||||||
@ -699,16 +699,17 @@ const EditCompanyProfile = () => {
|
|||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<h4 className="text-[16px] font-semibold text-[#232528]">Details</h4>
|
<h4 className="text-[16px] font-semibold text-[#232528]">Details</h4>
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||||
<TextField
|
{/* <TextField
|
||||||
label="Permanent Factory Code"
|
label="Permanent Factory Code"
|
||||||
|
type="hidden"
|
||||||
value={form.permanentFactoryCode || ""}
|
value={form.permanentFactoryCode || ""}
|
||||||
onChange={(e) => handleFormChange("permanentFactoryCode", e.target.value)}
|
onChange={(e) => handleFormChange("permanentFactoryCode", e.target.value)}
|
||||||
placeholder="Enter Factory Code"
|
placeholder="Enter Factory Code"
|
||||||
width="100%"
|
width="100%"
|
||||||
// required
|
// required
|
||||||
error={fieldErrors.permanentFactoryCode}
|
error={fieldErrors.permanentFactoryCode}
|
||||||
/>
|
/> */}
|
||||||
<TextField
|
{/* <TextField
|
||||||
label="Unique License Number"
|
label="Unique License Number"
|
||||||
value={form.uniqueLicenseNumber || ""}
|
value={form.uniqueLicenseNumber || ""}
|
||||||
onChange={(e) => handleFormChange("uniqueLicenseNumber", e.target.value)}
|
onChange={(e) => handleFormChange("uniqueLicenseNumber", e.target.value)}
|
||||||
@ -716,8 +717,8 @@ const EditCompanyProfile = () => {
|
|||||||
width="100%"
|
width="100%"
|
||||||
required
|
required
|
||||||
error={fieldErrors.uniqueLicenseNumber}
|
error={fieldErrors.uniqueLicenseNumber}
|
||||||
/>
|
/> */}
|
||||||
<TextField
|
{/* <TextField
|
||||||
label="Industry Code (Business Register)"
|
label="Industry Code (Business Register)"
|
||||||
value={form.industryCodeBusiness || ""}
|
value={form.industryCodeBusiness || ""}
|
||||||
onChange={(e) => handleFormChange("industryCodeBusiness", e.target.value)}
|
onChange={(e) => handleFormChange("industryCodeBusiness", e.target.value)}
|
||||||
@ -725,7 +726,7 @@ const EditCompanyProfile = () => {
|
|||||||
width="100%"
|
width="100%"
|
||||||
// required
|
// required
|
||||||
error={fieldErrors.industryCodeBusiness}
|
error={fieldErrors.industryCodeBusiness}
|
||||||
/>
|
/> */}
|
||||||
<div className="whitespace-nowrap">
|
<div className="whitespace-nowrap">
|
||||||
<TextField
|
<TextField
|
||||||
label="Industry Code (Current Production)"
|
label="Industry Code (Current Production)"
|
||||||
@ -738,7 +739,7 @@ const EditCompanyProfile = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-full">
|
<div className="col-span-full">
|
||||||
<TextField
|
{/* <TextField
|
||||||
label="Description of Industry"
|
label="Description of Industry"
|
||||||
value={form.industryDescription || ""}
|
value={form.industryDescription || ""}
|
||||||
onChange={(e) => handleFormChange("industryDescription", e.target.value)}
|
onChange={(e) => handleFormChange("industryDescription", e.target.value)}
|
||||||
@ -746,7 +747,7 @@ const EditCompanyProfile = () => {
|
|||||||
width="100%"
|
width="100%"
|
||||||
multiline
|
multiline
|
||||||
rows={3}
|
rows={3}
|
||||||
/>
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
{form.industryCodeBusiness && form.industryCodeBusiness !== form.industryCodeCurrent && (
|
{form.industryCodeBusiness && form.industryCodeBusiness !== form.industryCodeCurrent && (
|
||||||
<div className="col-span-full">
|
<div className="col-span-full">
|
||||||
@ -782,6 +783,7 @@ const EditCompanyProfile = () => {
|
|||||||
width="100%"
|
width="100%"
|
||||||
required
|
required
|
||||||
error={fieldErrors.contactName}
|
error={fieldErrors.contactName}
|
||||||
|
readOnly
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
label="Address"
|
label="Address"
|
||||||
@ -790,6 +792,7 @@ const EditCompanyProfile = () => {
|
|||||||
placeholder="Enter Address"
|
placeholder="Enter Address"
|
||||||
width="100%"
|
width="100%"
|
||||||
// required
|
// required
|
||||||
|
readOnly
|
||||||
error={fieldErrors.contactAddress}
|
error={fieldErrors.contactAddress}
|
||||||
/>
|
/>
|
||||||
<SelectField
|
<SelectField
|
||||||
@ -808,6 +811,7 @@ const EditCompanyProfile = () => {
|
|||||||
placeholder="Select Emirate"
|
placeholder="Select Emirate"
|
||||||
width="100%"
|
width="100%"
|
||||||
required
|
required
|
||||||
|
readOnly
|
||||||
error={fieldErrors.contactEmirate}
|
error={fieldErrors.contactEmirate}
|
||||||
/>
|
/>
|
||||||
<SelectField
|
<SelectField
|
||||||
@ -824,7 +828,7 @@ const EditCompanyProfile = () => {
|
|||||||
}))}
|
}))}
|
||||||
placeholder={form.contactEmirate ? (isLoadingCities ? "Loading cities..." : "Select City/Town") : "Select emirate first"}
|
placeholder={form.contactEmirate ? (isLoadingCities ? "Loading cities..." : "Select City/Town") : "Select emirate first"}
|
||||||
width="100%"
|
width="100%"
|
||||||
required
|
// required
|
||||||
disabled={!form.contactEmirate || isLoadingCities}
|
disabled={!form.contactEmirate || isLoadingCities}
|
||||||
error={fieldErrors.contactCityTown}
|
error={fieldErrors.contactCityTown}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user