diff --git a/src/hooks/useProductsSets.js b/src/hooks/useProductsSets.js index 1900465..6b79b7a 100644 --- a/src/hooks/useProductsSets.js +++ b/src/hooks/useProductsSets.js @@ -141,11 +141,10 @@ export const useNewProductRecord = () => { 'duration_unit': 'h', 'open_weekdays': ['1', '2', '3', '4', '5', '6', '7'], 'recommends_rate': 0, - 'dept': '', 'dept_id': 0, 'dept_name': '', 'display_to_c': 0, - 'km': undefined, + 'km': 0, 'city_id': 0, 'city_name': '', 'open_hours': '', @@ -156,7 +155,7 @@ export const useNewProductRecord = () => { lgc_details: [ { 'title': '', - 'description': '', + 'descriptions': '', 'lgc': 1, 'id': '', }, diff --git a/src/views/products/Detail/ProductInfo.jsx b/src/views/products/Detail/ProductInfo.jsx index 1d3172c..81713cd 100644 --- a/src/views/products/Detail/ProductInfo.jsx +++ b/src/views/products/Detail/ProductInfo.jsx @@ -59,11 +59,11 @@ const ProductInfo = ({ ...props }) => { // "lastedit_changed": "", }; const copyFields = pick(editingProduct.info, ['product_type_id']); // 'title', - const readyToSubInfo = { ...copyNewProduct.info, ...editingProduct.info, ...values.info, ...copyFields, type: copyFields.product_type_id, ...poster }; - readyToSubInfo.dept = Number(readyToSubInfo.dept); + const readyToSubInfo = { ...copyNewProduct.info, ...editingProduct.info, title: editingProduct.info.product_title, ...values.info, ...copyFields, ...poster }; // console.log('onSave', editingProduct.info, readyToSubInfo); + /** lgc_details */ - const prevLgcDetailsMapped = editingProduct.lgc_details.reduce((r, c) => ({ ...r, [c.lgc]: { ...c, description: c.descriptions } }), {}); + const prevLgcDetailsMapped = editingProduct.lgc_details.reduce((r, c) => ({ ...r, [c.lgc]: c }), {}); const mergedLgc = { ...prevLgcDetailsMapped, ...values.lgc_details_mapped }; // console.log(values); diff --git a/src/views/products/Detail/ProductInfoForm.jsx b/src/views/products/Detail/ProductInfoForm.jsx index f7dff06..65bbc2e 100644 --- a/src/views/products/Detail/ProductInfoForm.jsx +++ b/src/views/products/Detail/ProductInfoForm.jsx @@ -367,7 +367,7 @@ const formValuesMapper = (values) => { { key: 'city_id', transform: (value) => value?.value || value?.key || '' }, { key: 'city_name', transform: (value) => value?.label || '' }, ], - 'dept': { key: 'dept', transform: (value) => (typeof value === 'string' ? value : value?.value || value?.key || '') }, + 'dept': { key: 'dept_id', transform: (value) => (typeof value === 'string' ? value : value?.value || value?.key || '') }, 'open_weekdays': { key: 'open_weekdays', transform: (value) => (Array.isArray(value) ? value.join(',') : value) }, 'recommends_rate': { key: 'recommends_rate', transform: (value) => (typeof value === 'string' ? value : value?.value || value?.key || '') }, // 'lgc_details': [ @@ -392,7 +392,7 @@ const formValuesMapper = (values) => { transform: (value) => { const valueArr = Object.values(value) .filter((_v) => !isEmpty(_v)) - .map((e) => ({ title: '', ...e, description: e.description || '' })); + .map((e) => ({ title: '', ...e, descriptions: e.descriptions || '' })); return valueArr; }, }, @@ -401,7 +401,7 @@ const formValuesMapper = (values) => { transform: (value) => { const valueArr = Object.values(value) .filter((_v) => !isEmpty(_v)) - .map((e) => ({ title: '', ...e, description: e.description || '' })); + .map((e) => ({ title: '', ...e, descriptions: e.descriptions || '' })); return valueArr.reduce((r, c) => ({ ...r, [c.lgc]: c }), {}); }, }, @@ -409,7 +409,7 @@ const formValuesMapper = (values) => { 'product_title': { key: 'title' }, }; let dest = {}; - const { city, product_title, ...omittedValue } = values; + const { city, dept, product_title, ...omittedValue } = values; dest = { ...omittedValue, ...objectMapper(values, destinationObject) }; for (const key in dest) { if (Object.prototype.hasOwnProperty.call(dest, key)) { diff --git a/src/views/products/Detail/ProductInfoLgc.jsx b/src/views/products/Detail/ProductInfoLgc.jsx index 2b6a595..9a8c13a 100644 --- a/src/views/products/Detail/ProductInfoLgc.jsx +++ b/src/views/products/Detail/ProductInfoLgc.jsx @@ -36,7 +36,7 @@ const ProductInfoLgc = ({ editable, formInstance, ...props }) => { disabled={!editable} /> -