diff --git a/src/Pages/Preference/PreferenceList.jsx b/src/Pages/Preference/PreferenceList.jsx index e056ba1..c38e2a4 100644 --- a/src/Pages/Preference/PreferenceList.jsx +++ b/src/Pages/Preference/PreferenceList.jsx @@ -20,6 +20,7 @@ import { getSession } from '../../Services/Others.js'; import { useAuth } from '../../AuthContext.jsx'; import { ApplicationPreferences } from '../../Features/BrachLogin/BranchLogin.js'; import './PreferenceList.scss'; +import { InputField } from '../../Components/Forms/InputField.jsx'; const PreferenceList = () => { const { SadminuserAccess, featureaddDetails } = useAuth(); @@ -57,8 +58,8 @@ const PreferenceList = () => { const settingsList = tableValue[0]?.SettingDtlDetails ?? preferenceConfigs; const allSettingsMap = {}; - settingsList?.forEach(({ SettingIdName, SettingValue, SettingCount, SettingTime }) => { - allSettingsMap[SettingIdName?.toLowerCase()] = { value: SettingValue, count: SettingCount, time: SettingTime?.split(' ')?.[0] }; + settingsList?.forEach(({ SettingIdName, SettingValue, SettingCount, SettingTime,Comments }) => { + allSettingsMap[SettingIdName?.toLowerCase()] = { value: SettingValue, count: SettingCount, time: SettingTime?.split(' ')?.[0], comments: Comments }; }); console.log(featureaddDetails, 'featureaddDetails'); @@ -83,7 +84,9 @@ const PreferenceList = () => { stockselection: allSettingsMap['stockselection']?.value === 'Y', weightasquantity: allSettingsMap['weightasquantity']?.value === 'Y', expiredselection: allSettingsMap['expiredselection']?.value === 'Y', - 'sales mode': allSettingsMap['sales mode']?.value === 'Y', + salesmode: allSettingsMap['sales mode']?.value === 'Y', + retailshortname: allSettingsMap['retailshortname']?.comments || 'RT', + wholesaleshortname: allSettingsMap['wholesaleshortname']?.comments || 'WS', billitemsorder: allSettingsMap['billitemsorder']?.value === 'Y', preorderpricechange: allSettingsMap['preorderpricechange']?.value === 'Y', quantityrestriction: allSettingsMap['overalllimit']?.value === 'Y' || allSettingsMap['itemwiselimit']?.value === 'Y', @@ -301,6 +304,10 @@ const PreferenceList = () => { const handleSubmit = async () => { const values = formRef.current.getFieldsValue(); + const salesMode = values.salesmode; + console.log("Sales Mode:", values.salesmode); +console.log("Retail Short Name:", values.retailshortname); +console.log("Wholesale Short Name:", values.wholesaleshortname); const settings = settingsList || []; console.log(values, 'values'); const updatedSettings = settings.map((setting) => { @@ -317,7 +324,8 @@ const PreferenceList = () => { stockselection: values.stockselection, weightasquantity: values.weightasquantity, expiredselection: values.expiredselection, - 'sales mode': values?.['sales mode'], + 'sales mode': values?.['salesmode'], + billitemsorder: values.billitemsorder, preorderpricechange: values.preorderpricechange, tokenonly: values.tokenonly, @@ -363,19 +371,38 @@ const PreferenceList = () => { ? boolValues[key] : (arrayValues[key]?.includes(key) ?? false); - return { - ConfigName: setting.SettingIdName, - SettingId: setting.SettingId, - Comments: setting.Comments || 'Enter Comment', - SettingValue: isChecked ? 'Y' : 'N', - SettingCount: ((key === 'overalllimit' || key === 'itemwiselimit') && isChecked) ? parseFloat(values.maxquantity) || null : null, - SettingTime: - ((key === "hours" && isChecked) - ? ((parseFloat(values.maxtime) * 60)?.toFixed(2) + ' ' + 'Minutes' || null) - : (key === "minutes" && isChecked) - ? (parseFloat(values.maxtime)?.toFixed(2) + ' ' + 'Minutes' || null) - : null), - }; + return { + ConfigName: setting.SettingIdName, + SettingId: setting.SettingId, + + Comments: + key === "retailshortname" + ? values.retailshortname || "" + : key === "wholesaleshortname" + ? values.wholesaleshortname || "" + : setting.Comments || "Enter Comment", + + SettingValue: + key === "retailshortname" || key === "wholesaleshortname" + ? salesMode + ? "Y" + : "N" + : isChecked + ? "Y" + : "N", + + SettingCount: + (key === "overalllimit" || key === "itemwiselimit") && isChecked + ? parseFloat(values.maxquantity) || null + : null, + + SettingTime: + key === "hours" && isChecked + ? (parseFloat(values.maxtime) * 60).toFixed(2) + " Minutes" + : key === "minutes" && isChecked + ? parseFloat(values.maxtime).toFixed(2) + " Minutes" + : null, +}; }); const payload = { @@ -713,7 +740,53 @@ const PreferenceList = () => { {renderCheckbox('stockselection', 'Enable stock selection?')} {renderCheckbox('weightasquantity', 'Use Weight as Quantity?')} {renderCheckbox('expiredselection', 'Show product expiry date?')} - {renderCheckbox('sales mode', 'Retail or Wholesale mode?')} + {/* {renderCheckbox('sales mode', 'Retail or Wholesale mode?')} */} + {(allSettingsMap['sales mode'] !== undefined ) && ( + <> +