Merge pull request 'remove readmefile' (#328) from poorinima_print4_style into main
Reviewed-on: Pozomind/pozo-retail-app#328
This commit is contained in:
commit
02843b1990
File diff suppressed because it is too large
Load Diff
|
|
@ -1,4 +1,4 @@
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
import { Form, Checkbox, Radio, Divider, InputNumber } from 'antd';
|
import { Form, Checkbox, Radio, Divider, InputNumber } from 'antd';
|
||||||
import { ArrowRightOutlined } from '@ant-design/icons';
|
import { ArrowRightOutlined } from '@ant-design/icons';
|
||||||
|
|
@ -30,6 +30,7 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
const { SadminuserAccess, featureaddDetails } = useAuth();
|
const { SadminuserAccess, featureaddDetails } = useAuth();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const formRef = useRef();
|
const formRef = useRef();
|
||||||
|
const prevEstimateRef = useRef([]);
|
||||||
const CompId = getSession('CompId');
|
const CompId = getSession('CompId');
|
||||||
const BranchId = getSession('BranchId');
|
const BranchId = getSession('BranchId');
|
||||||
const AppId = getSession('AppId');
|
const AppId = getSession('AppId');
|
||||||
|
|
@ -157,6 +158,10 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
...(allSettingsMap['estimatetitle']?.value === 'Y'
|
...(allSettingsMap['estimatetitle']?.value === 'Y'
|
||||||
? ['estimatetitle']
|
? ['estimatetitle']
|
||||||
: []),
|
: []),
|
||||||
|
...(allSettingsMap['estimatebrname']?.value === 'Y' ? ['estimatebrname'] : []),
|
||||||
|
...(allSettingsMap['estimatebraddress']?.value === 'Y' ? ['estimatebraddress'] : []),
|
||||||
|
...(allSettingsMap['estimatebrphone']?.value === 'Y' ? ['estimatebrphone'] : []),
|
||||||
|
|
||||||
],
|
],
|
||||||
scanlayout: allSettingsMap['scanlayout']?.value === 'Y',
|
scanlayout: allSettingsMap['scanlayout']?.value === 'Y',
|
||||||
verifyproduct: allSettingsMap['verifyproduct']?.value === 'Y',
|
verifyproduct: allSettingsMap['verifyproduct']?.value === 'Y',
|
||||||
|
|
@ -207,9 +212,9 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
useEffect(()=>{
|
useEffect(() => {
|
||||||
fetchTableData();
|
fetchTableData();
|
||||||
},[selectedUserId])
|
}, [selectedUserId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (settingsList) {
|
if (settingsList) {
|
||||||
|
|
@ -217,6 +222,8 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
setInitialValues(built);
|
setInitialValues(built);
|
||||||
console.log(built, 'built');
|
console.log(built, 'built');
|
||||||
formRef.current?.setFieldsValue(built);
|
formRef.current?.setFieldsValue(built);
|
||||||
|
prevEstimateRef.current = built.estimateSettings ?? [];
|
||||||
|
|
||||||
}
|
}
|
||||||
}, [settingsList]);
|
}, [settingsList]);
|
||||||
|
|
||||||
|
|
@ -311,7 +318,7 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchTableData = async () => {
|
const fetchTableData = async () => {
|
||||||
const res = await dispatch(gettableData({ CompId, BranchId, AppId,UserId:selectedUserId })).unwrap();
|
const res = await dispatch(gettableData({ CompId, BranchId, AppId, UserId: selectedUserId })).unwrap();
|
||||||
const data = { CompId, BranchId, AppId, UserId: selectedUserId };
|
const data = { CompId, BranchId, AppId, UserId: selectedUserId };
|
||||||
// const res = await dispatch(getPreferenceData(data)).unwrap();
|
// const res = await dispatch(getPreferenceData(data)).unwrap();
|
||||||
if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) {
|
if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) {
|
||||||
|
|
@ -405,8 +412,15 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
dinein: values.enabledModules,
|
dinein: values.enabledModules,
|
||||||
estimation: values.enabledModules,
|
estimation: values.enabledModules,
|
||||||
parking: values.enabledFeatures,
|
parking: values.enabledFeatures,
|
||||||
|
// estimateprintheader: values.estimateSettings,
|
||||||
|
// estimatebrname: values.estimatebrname,
|
||||||
|
// estimatebraddress: values.estimatebraddress,
|
||||||
|
// estimatebrphone: values.estimatebrphone,
|
||||||
estimateprintheader: values.estimateSettings,
|
estimateprintheader: values.estimateSettings,
|
||||||
estimatetitle: values.estimateSettings,
|
estimatetitle: values.estimateSettings,
|
||||||
|
estimatebrname: values.estimateSettings,
|
||||||
|
estimatebraddress: values.estimateSettings,
|
||||||
|
estimatebrphone: values.estimateSettings,
|
||||||
offer: values.enabledFeatures,
|
offer: values.enabledFeatures,
|
||||||
whatsapp: values.pdfSendOptions,
|
whatsapp: values.pdfSendOptions,
|
||||||
sms: values.pdfSendOptions,
|
sms: values.pdfSendOptions,
|
||||||
|
|
@ -481,51 +495,51 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (userDropDown?.length > 0 && !formRef.current?.getFieldValue("userId")) {
|
if (userDropDown?.length > 0 && !formRef.current?.getFieldValue("userId")) {
|
||||||
const adminUser = userDropDown.find(
|
const adminUser = userDropDown.find(
|
||||||
(user) => user.UserTypeName === "Admin"
|
(user) => user.UserTypeName === "Admin"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (adminUser) {
|
if (adminUser) {
|
||||||
formRef.current?.setFieldsValue({
|
formRef.current?.setFieldsValue({
|
||||||
userId: adminUser.UserId
|
userId: adminUser.UserId
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}, [userDropDown]);
|
||||||
}, [userDropDown]);
|
|
||||||
const UserDropDownChange = (value) => {
|
const UserDropDownChange = (value) => {
|
||||||
let user = userDropDown?.find((item) => item?.UserId === value);
|
let user = userDropDown?.find((item) => item?.UserId === value);
|
||||||
setSelectedUserId(user?.UserId)
|
setSelectedUserId(user?.UserId)
|
||||||
formRef.current?.setFieldsValue({
|
formRef.current?.setFieldsValue({
|
||||||
userId: value,
|
userId: value,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const userDropData = async () => {
|
const userDropData = async () => {
|
||||||
const data ={
|
const data = {
|
||||||
branchId:BranchId,
|
branchId: BranchId,
|
||||||
compId:CompId,
|
compId: CompId,
|
||||||
appId:AppId
|
appId: AppId
|
||||||
}
|
}
|
||||||
const gettinguserDropDown = await dispatch(getBranchUsers(data)).unwrap();
|
const gettinguserDropDown = await dispatch(getBranchUsers(data)).unwrap();
|
||||||
// const gettinguserDropDown = await dispatch(UserDataBasedOnBranchId(BranchId)).unwrap();
|
// const gettinguserDropDown = await dispatch(UserDataBasedOnBranchId(BranchId)).unwrap();
|
||||||
|
|
||||||
|
|
||||||
if (gettinguserDropDown?.data?.statusCode === 1) {
|
if (gettinguserDropDown?.data?.statusCode === 1) {
|
||||||
const finaluserDropDown = gettinguserDropDown?.data?.data?.filter((value) => value.ActiveStatus === "A");
|
const finaluserDropDown = gettinguserDropDown?.data?.data?.filter((value) => value.ActiveStatus === "A");
|
||||||
setUserDropDown(finaluserDropDown);
|
setUserDropDown(finaluserDropDown);
|
||||||
|
|
||||||
if (UserType === 'Employee') {
|
if (UserType === 'Employee') {
|
||||||
setSelectedUserId(UserId);
|
setSelectedUserId(UserId);
|
||||||
} else {
|
} else {
|
||||||
const adminUser = finaluserDropDown.find(
|
const adminUser = finaluserDropDown.find(
|
||||||
(user) => user.UserTypeName === "Admin"
|
(user) => user.UserTypeName === "Admin"
|
||||||
);
|
);
|
||||||
if (adminUser) {
|
if (adminUser) {
|
||||||
setSelectedUserId(adminUser.UserId);
|
setSelectedUserId(adminUser.UserId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const renderCheckbox = (name, label) =>
|
const renderCheckbox = (name, label) =>
|
||||||
allSettingsMap[name] !== undefined && (
|
allSettingsMap[name] !== undefined && (
|
||||||
|
|
@ -533,6 +547,53 @@ const userDropData = async () => {
|
||||||
<Checkbox>Yes</Checkbox>
|
<Checkbox>Yes</Checkbox>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
);
|
);
|
||||||
|
const ESTIMATE_PRINT_SETTINGS = [
|
||||||
|
{
|
||||||
|
key: 'estimateprintheader',
|
||||||
|
label: 'Show shop header',
|
||||||
|
children: [
|
||||||
|
{ key: 'estimatebrname', label: 'name' },
|
||||||
|
{ key: 'estimatebraddress', label: 'address' },
|
||||||
|
{ key: 'estimatebrphone', label: 'phone number' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'estimatetitle',
|
||||||
|
label: 'Show "Estimate" title',
|
||||||
|
children: [],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const handleEstimateChange = (checkedValues) => {
|
||||||
|
const prev = prevEstimateRef.current;
|
||||||
|
let updated = [...checkedValues];
|
||||||
|
|
||||||
|
ESTIMATE_PRINT_SETTINGS.forEach(({ key, children }) => {
|
||||||
|
if (!children.length) return;
|
||||||
|
|
||||||
|
const childKeys = children
|
||||||
|
.filter((c) => allSettingsMap[c.key] !== undefined)
|
||||||
|
.map((c) => c.key);
|
||||||
|
|
||||||
|
const parentJustChecked = checkedValues.includes(key) && !prev.includes(key);
|
||||||
|
|
||||||
|
// Parent just checked → add all children
|
||||||
|
if (parentJustChecked) {
|
||||||
|
updated = [...new Set([...updated, ...childKeys])];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate AFTER updated may have changed above ✅
|
||||||
|
const anyChildChecked = childKeys.some((c) => updated.includes(c));
|
||||||
|
|
||||||
|
// All children removed → remove parent
|
||||||
|
if (updated.includes(key) && !anyChildChecked) { // ✅ uses variable, no duplicate
|
||||||
|
updated = updated.filter((v) => v !== key);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
prevEstimateRef.current = updated;
|
||||||
|
formRef.current?.setFieldValue('estimateSettings', updated);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -621,7 +682,7 @@ const userDropData = async () => {
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
className="preferences-list"
|
className="preferences-list"
|
||||||
>
|
>
|
||||||
{(UserType === 'Admin' || UserType === 'Super Admin' || UserType === 'Super Admin User')&& ( <span>
|
{(UserType === 'Admin' || UserType === 'Super Admin' || UserType === 'Super Admin User') && (<span>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="userId"
|
name="userId"
|
||||||
rules={[
|
rules={[
|
||||||
|
|
@ -1164,26 +1225,33 @@ const userDropData = async () => {
|
||||||
'mobilea4',
|
'mobilea4',
|
||||||
'Prefer printing in A4/A5 on mobile?'
|
'Prefer printing in A4/A5 on mobile?'
|
||||||
)}
|
)}
|
||||||
{(allSettingsMap['estimateprintheader'] !== undefined ||
|
{ESTIMATE_PRINT_SETTINGS.some(({ key }) => allSettingsMap[key] !== undefined) && (
|
||||||
allSettingsMap['estimatetitle'] !== undefined) && (
|
<Form.Item noStyle shouldUpdate>
|
||||||
<Form.Item
|
{({ getFieldValue }) => (
|
||||||
name="estimateSettings"
|
<Form.Item name="estimateSettings" label="Estimate Print Settings :">
|
||||||
label="Estimate Print Settings :"
|
<Checkbox.Group onChange={(vals) => handleEstimateChange(vals, formRef)}>
|
||||||
>
|
{ESTIMATE_PRINT_SETTINGS
|
||||||
<Checkbox.Group>
|
.filter(({ key }) => allSettingsMap[key] !== undefined)
|
||||||
{allSettingsMap['estimateprintheader'] !== undefined && (
|
.map(({ key, label, children }) => (
|
||||||
<Checkbox value="estimateprintheader">
|
<React.Fragment key={key}>
|
||||||
Show shop header (Name, Address, GST)
|
<Checkbox value={key}>{label}</Checkbox>
|
||||||
</Checkbox>
|
|
||||||
)}
|
{children.length > 0 &&
|
||||||
{allSettingsMap['estimatetitle'] !== undefined && (
|
getFieldValue('estimateSettings')?.includes(key) &&
|
||||||
<Checkbox value="estimatetitle">
|
children
|
||||||
Show “Estimate (R/W)” title
|
.filter((child) => allSettingsMap[child.key] !== undefined)
|
||||||
</Checkbox>
|
.map((child) => (
|
||||||
)}
|
<Checkbox key={child.key} value={child.key}>
|
||||||
</Checkbox.Group>
|
{child.label}
|
||||||
</Form.Item>
|
</Checkbox>
|
||||||
)}
|
))}
|
||||||
|
</React.Fragment>
|
||||||
|
))}
|
||||||
|
</Checkbox.Group>
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="PreferencesBTN">
|
<div className="PreferencesBTN">
|
||||||
<Buttons
|
<Buttons
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue