Added new fields in api in HScode and Establishmesnts
This commit is contained in:
parent
3bcd609ce3
commit
7e1bafe2fd
@ -199,6 +199,7 @@ const createEmptyProfile = () => ({
|
|||||||
contactCountryCode: '',
|
contactCountryCode: '',
|
||||||
contactMobileNumber: '',
|
contactMobileNumber: '',
|
||||||
contactEmail: '',
|
contactEmail: '',
|
||||||
|
zone: '',
|
||||||
contactWebsite: '',
|
contactWebsite: '',
|
||||||
// Corporate / head office contact details
|
// Corporate / head office contact details
|
||||||
corporateSameAs: true,
|
corporateSameAs: true,
|
||||||
@ -1182,8 +1183,8 @@ const CompanyProfile = () => {
|
|||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
label="Zone (Area name)"
|
label="Zone (Area name)"
|
||||||
value={form.contactZone || ''}
|
value={form.zone || ''}
|
||||||
onChange={handleFormChange('contactZone')}
|
onChange={handleFormChange('zone')}
|
||||||
placeholder="Enter zone"
|
placeholder="Enter zone"
|
||||||
width="100%"
|
width="100%"
|
||||||
readOnly={modalMode === 'view'}
|
readOnly={modalMode === 'view'}
|
||||||
@ -2120,6 +2121,7 @@ const displayedRows = sortedProfiles.map((item) => {
|
|||||||
contactCityTown: establishmentCityName || base.contactCityTown,
|
contactCityTown: establishmentCityName || base.contactCityTown,
|
||||||
contactCityTownId: item?.establishment_city_town_id ? String(item.establishment_city_town_id) : null,
|
contactCityTownId: item?.establishment_city_town_id ? String(item.establishment_city_town_id) : null,
|
||||||
contactEmirate: establishmentEmirateName,
|
contactEmirate: establishmentEmirateName,
|
||||||
|
zone: item?.zone ?? '',
|
||||||
contactEmirateId: item?.establishment_emirate_id ? String(item.establishment_emirate_id) : '',
|
contactEmirateId: item?.establishment_emirate_id ? String(item.establishment_emirate_id) : '',
|
||||||
products: Array.isArray(item?.products) ? item.products : [],
|
products: Array.isArray(item?.products) ? item.products : [],
|
||||||
productCount: item?.product_count ?? 0,
|
productCount: item?.product_count ?? 0,
|
||||||
@ -2884,6 +2886,7 @@ const handleView = async (id) => {
|
|||||||
establishment_mobile_number: form.contactMobileNumber || '',
|
establishment_mobile_number: form.contactMobileNumber || '',
|
||||||
establishment_contact_email: form.contactEmail || '',
|
establishment_contact_email: form.contactEmail || '',
|
||||||
establishment_website: form.contactWebsite || '',
|
establishment_website: form.contactWebsite || '',
|
||||||
|
zone: form.zone || '',
|
||||||
corporate_same_as_establishment: Boolean(form.corporateSameAs),
|
corporate_same_as_establishment: Boolean(form.corporateSameAs),
|
||||||
corporate_name: form.corporateName || '',
|
corporate_name: form.corporateName || '',
|
||||||
corporate_address: form.corporateAddress || '',
|
corporate_address: form.corporateAddress || '',
|
||||||
@ -2919,6 +2922,7 @@ const handleView = async (id) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
console.log('API Payload for creation:', apiPayload);
|
||||||
const apiResponse = await createEstablishment(apiPayload);
|
const apiResponse = await createEstablishment(apiPayload);
|
||||||
const successMessage = apiResponse?.message || 'Establishment added successfully.';
|
const successMessage = apiResponse?.message || 'Establishment added successfully.';
|
||||||
showToast('success', successMessage);
|
showToast('success', successMessage);
|
||||||
@ -2994,6 +2998,7 @@ const handleView = async (id) => {
|
|||||||
establishment_mobile_number: form.contactMobileNumber || '',
|
establishment_mobile_number: form.contactMobileNumber || '',
|
||||||
establishment_contact_email: form.contactEmail || '',
|
establishment_contact_email: form.contactEmail || '',
|
||||||
establishment_website: form.contactWebsite || '',
|
establishment_website: form.contactWebsite || '',
|
||||||
|
zone: form.zone || '',
|
||||||
corporate_same_as_establishment: Boolean(form.corporateSameAs),
|
corporate_same_as_establishment: Boolean(form.corporateSameAs),
|
||||||
corporate_name: form.corporateName || '',
|
corporate_name: form.corporateName || '',
|
||||||
corporate_address: form.corporateAddress || '',
|
corporate_address: form.corporateAddress || '',
|
||||||
|
|||||||
@ -685,6 +685,7 @@ const IsicHsCodes = () => {
|
|||||||
description: product.hs_description || '',
|
description: product.hs_description || '',
|
||||||
unit: product.unit_id ? String(product.unit_id) : '',
|
unit: product.unit_id ? String(product.unit_id) : '',
|
||||||
status: product.is_active ? 'Active' : 'Inactive',
|
status: product.is_active ? 'Active' : 'Inactive',
|
||||||
|
weight: product.weight_in_ib || '',
|
||||||
createdBy: selected.createdBy,
|
createdBy: selected.createdBy,
|
||||||
createdOn: selected.createdOn || new Date(product.created_at).toLocaleDateString('en-GB'),
|
createdOn: selected.createdOn || new Date(product.created_at).toLocaleDateString('en-GB'),
|
||||||
updated: selected.updated || (product.updated_at ? new Date(product.updated_at).toLocaleDateString('en-GB') : '')
|
updated: selected.updated || (product.updated_at ? new Date(product.updated_at).toLocaleDateString('en-GB') : '')
|
||||||
@ -727,6 +728,7 @@ const IsicHsCodes = () => {
|
|||||||
description: productData.hs_description || '',
|
description: productData.hs_description || '',
|
||||||
unit: productData.unit_id ? String(productData.unit_id) : '',
|
unit: productData.unit_id ? String(productData.unit_id) : '',
|
||||||
status: productData.is_active ? 'Active' : 'Inactive',
|
status: productData.is_active ? 'Active' : 'Inactive',
|
||||||
|
weight: productData.weight_in_ib || '',
|
||||||
};
|
};
|
||||||
setForm(formData);
|
setForm(formData);
|
||||||
setEditingRow(index);
|
setEditingRow(index);
|
||||||
@ -1000,6 +1002,7 @@ const handleExportCSV = () => {
|
|||||||
product_name: form.product,
|
product_name: form.product,
|
||||||
hs_description: form.description || '',
|
hs_description: form.description || '',
|
||||||
unit_id: form.unit ? parseInt(form.unit) : null,
|
unit_id: form.unit ? parseInt(form.unit) : null,
|
||||||
|
weight_in_ib:form.weight ? parseFloat(form.weight) : null,
|
||||||
// Preserve the original created_by value for updates, or use current user for new records
|
// Preserve the original created_by value for updates, or use current user for new records
|
||||||
created_by: modalMode === 'edit' ? (existingProduct?.created_by || userProfile?.id) : (userProfile?.id || null)
|
created_by: modalMode === 'edit' ? (existingProduct?.created_by || userProfile?.id) : (userProfile?.id || null)
|
||||||
};
|
};
|
||||||
@ -1038,6 +1041,7 @@ const handleExportCSV = () => {
|
|||||||
unit: selectedUnit ? selectedUnit.label : existingProduct?.unit || 'N/A',
|
unit: selectedUnit ? selectedUnit.label : existingProduct?.unit || 'N/A',
|
||||||
unit_id: form.unit ? parseInt(form.unit) : existingProduct?.unit_id || null,
|
unit_id: form.unit ? parseInt(form.unit) : existingProduct?.unit_id || null,
|
||||||
updated: new Date().toLocaleDateString('en-GB'),
|
updated: new Date().toLocaleDateString('en-GB'),
|
||||||
|
weight_in_ib: form.weight ? form.weight: existingProduct?.weight_in_ib || null,
|
||||||
// Explicitly preserve these fields to ensure they don't get cleared
|
// Explicitly preserve these fields to ensure they don't get cleared
|
||||||
estimatedMapped: existingProduct?.estimatedMapped || 0,
|
estimatedMapped: existingProduct?.estimatedMapped || 0,
|
||||||
createdBy: existingProduct?.createdBy || '-',
|
createdBy: existingProduct?.createdBy || '-',
|
||||||
@ -1062,10 +1066,10 @@ const handleExportCSV = () => {
|
|||||||
|
|
||||||
// Show success message and reload the page after a short delay
|
// Show success message and reload the page after a short delay
|
||||||
setToast({ show: true, message: 'Product updated successfully!', type: 'success' });
|
setToast({ show: true, message: 'Product updated successfully!', type: 'success' });
|
||||||
closeModal();
|
// closeModal();
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
window.location.reload();
|
// window.location.reload();
|
||||||
}, 1000);
|
// }, 1000);
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating product:', error);
|
console.error('Error updating product:', error);
|
||||||
@ -1088,6 +1092,7 @@ const handleExportCSV = () => {
|
|||||||
description: form.description || '',
|
description: form.description || '',
|
||||||
unit: selectedUnit ? selectedUnit.label : 'N/A',
|
unit: selectedUnit ? selectedUnit.label : 'N/A',
|
||||||
unit_id: form.unit ? parseInt(form.unit) : null,
|
unit_id: form.unit ? parseInt(form.unit) : null,
|
||||||
|
weight_in_ib: form.weight ? parseFloat(form.weight) : null,
|
||||||
estimatedMapped: 0,
|
estimatedMapped: 0,
|
||||||
createdBy: userProfile?.name || 'System',
|
createdBy: userProfile?.name || 'System',
|
||||||
createdById: userProfile?.id || null,
|
createdById: userProfile?.id || null,
|
||||||
@ -1180,6 +1185,7 @@ const handleExportCSV = () => {
|
|||||||
description: product.hs_description || '',
|
description: product.hs_description || '',
|
||||||
// unit: product.unit?.uom || 'N/A',
|
// unit: product.unit?.uom || 'N/A',
|
||||||
unit: product.unit?.uom ?? '',
|
unit: product.unit?.uom ?? '',
|
||||||
|
weight: product.weight_in_ib || '',
|
||||||
|
|
||||||
estimatedMapped: 0,
|
estimatedMapped: 0,
|
||||||
createdBy: creatorName,
|
createdBy: creatorName,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user