Merge pull request 'FIX #238 Dynamic Retail and wholesale value in preference' (#239) from DynamicnameforRW into main
Reviewed-on: Pozomind/pozo-retail-app#239
This commit is contained in:
commit
75c156b7b8
|
|
@ -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) => {
|
||||
|
|
@ -318,6 +325,7 @@ const PreferenceList = () => {
|
|||
weightasquantity: values.weightasquantity,
|
||||
expiredselection: values.expiredselection,
|
||||
'sales mode': values?.['salesmode'],
|
||||
|
||||
billitemsorder: values.billitemsorder,
|
||||
preorderpricechange: values.preorderpricechange,
|
||||
tokenonly: values.tokenonly,
|
||||
|
|
@ -366,15 +374,34 @@ const PreferenceList = () => {
|
|||
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,
|
||||
|
||||
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' || null)
|
||||
: (key === "minutes" && isChecked)
|
||||
? (parseFloat(values.maxtime)?.toFixed(2) + ' ' + 'Minutes' || null)
|
||||
: null),
|
||||
key === "hours" && isChecked
|
||||
? (parseFloat(values.maxtime) * 60).toFixed(2) + " Minutes"
|
||||
: key === "minutes" && isChecked
|
||||
? parseFloat(values.maxtime).toFixed(2) + " Minutes"
|
||||
: null,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
@ -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 ) && (
|
||||
<>
|
||||
<Form.Item
|
||||
name="salesmode"
|
||||
label="Retail or Wholesale mode?"
|
||||
valuePropName="checked"
|
||||
>
|
||||
<Checkbox>Yes</Checkbox>
|
||||
</Form.Item>
|
||||
</>
|
||||
)}
|
||||
<Form.Item
|
||||
noStyle
|
||||
shouldUpdate={(prev, curr) => prev.salesmode !== curr.salesmode}
|
||||
>
|
||||
{({ getFieldValue }) =>
|
||||
getFieldValue('salesmode') && (
|
||||
<>
|
||||
<Form.Item
|
||||
name="retailshortname"
|
||||
label="Retail Short Name"
|
||||
|
||||
rules={[
|
||||
{ required: true, message: "Please enter Retail Short Name" },
|
||||
]}
|
||||
>
|
||||
<InputField placeholder="Enter Retail Short Name" style={{ width: 250 }} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="wholesaleshortname"
|
||||
label="Wholesale Short Name"
|
||||
|
||||
rules={[
|
||||
{ required: true, message: "Please enter Wholesale Short Name" },
|
||||
]}
|
||||
>
|
||||
<InputField
|
||||
placeholder="Enter Wholesale Short Name"
|
||||
style={{ width: 250 }}
|
||||
/>
|
||||
</Form.Item>
|
||||
</>
|
||||
)
|
||||
}
|
||||
</Form.Item>
|
||||
{renderCheckbox(
|
||||
'billitemsorder',
|
||||
'Show selected items first in Order Summary?'
|
||||
|
|
|
|||
Loading…
Reference in New Issue