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: '',
|
||||
contactMobileNumber: '',
|
||||
contactEmail: '',
|
||||
zone: '',
|
||||
contactWebsite: '',
|
||||
// Corporate / head office contact details
|
||||
corporateSameAs: true,
|
||||
@ -1182,8 +1183,8 @@ const CompanyProfile = () => {
|
||||
/>
|
||||
<TextField
|
||||
label="Zone (Area name)"
|
||||
value={form.contactZone || ''}
|
||||
onChange={handleFormChange('contactZone')}
|
||||
value={form.zone || ''}
|
||||
onChange={handleFormChange('zone')}
|
||||
placeholder="Enter zone"
|
||||
width="100%"
|
||||
readOnly={modalMode === 'view'}
|
||||
@ -2120,6 +2121,7 @@ const displayedRows = sortedProfiles.map((item) => {
|
||||
contactCityTown: establishmentCityName || base.contactCityTown,
|
||||
contactCityTownId: item?.establishment_city_town_id ? String(item.establishment_city_town_id) : null,
|
||||
contactEmirate: establishmentEmirateName,
|
||||
zone: item?.zone ?? '',
|
||||
contactEmirateId: item?.establishment_emirate_id ? String(item.establishment_emirate_id) : '',
|
||||
products: Array.isArray(item?.products) ? item.products : [],
|
||||
productCount: item?.product_count ?? 0,
|
||||
@ -2884,6 +2886,7 @@ const handleView = async (id) => {
|
||||
establishment_mobile_number: form.contactMobileNumber || '',
|
||||
establishment_contact_email: form.contactEmail || '',
|
||||
establishment_website: form.contactWebsite || '',
|
||||
zone: form.zone || '',
|
||||
corporate_same_as_establishment: Boolean(form.corporateSameAs),
|
||||
corporate_name: form.corporateName || '',
|
||||
corporate_address: form.corporateAddress || '',
|
||||
@ -2919,6 +2922,7 @@ const handleView = async (id) => {
|
||||
};
|
||||
|
||||
try {
|
||||
console.log('API Payload for creation:', apiPayload);
|
||||
const apiResponse = await createEstablishment(apiPayload);
|
||||
const successMessage = apiResponse?.message || 'Establishment added successfully.';
|
||||
showToast('success', successMessage);
|
||||
@ -2994,6 +2998,7 @@ const handleView = async (id) => {
|
||||
establishment_mobile_number: form.contactMobileNumber || '',
|
||||
establishment_contact_email: form.contactEmail || '',
|
||||
establishment_website: form.contactWebsite || '',
|
||||
zone: form.zone || '',
|
||||
corporate_same_as_establishment: Boolean(form.corporateSameAs),
|
||||
corporate_name: form.corporateName || '',
|
||||
corporate_address: form.corporateAddress || '',
|
||||
|
||||
@ -685,6 +685,7 @@ const IsicHsCodes = () => {
|
||||
description: product.hs_description || '',
|
||||
unit: product.unit_id ? String(product.unit_id) : '',
|
||||
status: product.is_active ? 'Active' : 'Inactive',
|
||||
weight: product.weight_in_ib || '',
|
||||
createdBy: selected.createdBy,
|
||||
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') : '')
|
||||
@ -727,6 +728,7 @@ const IsicHsCodes = () => {
|
||||
description: productData.hs_description || '',
|
||||
unit: productData.unit_id ? String(productData.unit_id) : '',
|
||||
status: productData.is_active ? 'Active' : 'Inactive',
|
||||
weight: productData.weight_in_ib || '',
|
||||
};
|
||||
setForm(formData);
|
||||
setEditingRow(index);
|
||||
@ -1000,6 +1002,7 @@ const handleExportCSV = () => {
|
||||
product_name: form.product,
|
||||
hs_description: form.description || '',
|
||||
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
|
||||
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_id: form.unit ? parseInt(form.unit) : existingProduct?.unit_id || null,
|
||||
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
|
||||
estimatedMapped: existingProduct?.estimatedMapped || 0,
|
||||
createdBy: existingProduct?.createdBy || '-',
|
||||
@ -1062,10 +1066,10 @@ const handleExportCSV = () => {
|
||||
|
||||
// Show success message and reload the page after a short delay
|
||||
setToast({ show: true, message: 'Product updated successfully!', type: 'success' });
|
||||
closeModal();
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
// closeModal();
|
||||
// setTimeout(() => {
|
||||
// window.location.reload();
|
||||
// }, 1000);
|
||||
return;
|
||||
} catch (error) {
|
||||
console.error('Error updating product:', error);
|
||||
@ -1088,6 +1092,7 @@ const handleExportCSV = () => {
|
||||
description: form.description || '',
|
||||
unit: selectedUnit ? selectedUnit.label : 'N/A',
|
||||
unit_id: form.unit ? parseInt(form.unit) : null,
|
||||
weight_in_ib: form.weight ? parseFloat(form.weight) : null,
|
||||
estimatedMapped: 0,
|
||||
createdBy: userProfile?.name || 'System',
|
||||
createdById: userProfile?.id || null,
|
||||
@ -1180,6 +1185,7 @@ const handleExportCSV = () => {
|
||||
description: product.hs_description || '',
|
||||
// unit: product.unit?.uom || 'N/A',
|
||||
unit: product.unit?.uom ?? '',
|
||||
weight: product.weight_in_ib || '',
|
||||
|
||||
estimatedMapped: 0,
|
||||
createdBy: creatorName,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user