added phoneumber name address in the preference

This commit is contained in:
Tamilselvan 2026-03-30 18:36:31 +05:30
parent 03010314c5
commit df6f4af53e
2 changed files with 1946 additions and 1861 deletions

View File

@ -175,6 +175,21 @@ const Printstyle4 = ({
(setting) =>
setting?.SettingIdName?.toLowerCase() === 'estimateprintheader'
)?.SettingValue === 'Y';
const estimatebrname =
SettingData?.[0]?.SettingDtlDetails?.find(
(setting) =>
setting?.SettingIdName?.toLowerCase() === 'estimatebrname'
)?.SettingValue === 'Y';
const estimatebraddress =
SettingData?.[0]?.SettingDtlDetails?.find(
(setting) =>
setting?.SettingIdName?.toLowerCase() === 'estimatebraddress'
)?.SettingValue === 'Y';
const estimatebrphone =
SettingData?.[0]?.SettingDtlDetails?.find(
(setting) =>
setting?.SettingIdName?.toLowerCase() === 'estimatebrphone'
)?.SettingValue === 'Y';
const estimateTitle =
SettingData?.[0]?.SettingDtlDetails?.find(
(setting) => setting?.SettingIdName?.toLowerCase() === 'estimatetitle'
@ -3347,7 +3362,7 @@ const Printstyle4 = ({
width={100}
/>
) : null}
<div
{estimatebrname && <div
style={{
fontSize: '16px',
fontWeight: '600',
@ -3359,10 +3374,10 @@ const Printstyle4 = ({
}}
>
{GlobaldummyData ? 'XYZ Shop' : table2Data?.BrName}
</div>
</div>}
</div>
<div
{estimatebraddress && <div
style={{
display: 'flex',
justifyContent: 'center',
@ -3386,12 +3401,14 @@ const Printstyle4 = ({
? '-'
: '') + table2Data?.AddressDetails?.[0]?.Zip
: '')}
</div>
</div>}
{estimatebrphone && (
<div style={{ fontWeight: '500', fontSize: '10px' }}>
{' '}
Mobile : +91{' '}
{GlobaldummyData ? '986XXXXXXX' : table2Data?.BrMobile}
</div>
)}
</div>
)}
{/* <div>

View File

@ -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 { Form, Checkbox, Radio, Divider, InputNumber } from 'antd';
import { ArrowRightOutlined } from '@ant-design/icons';
@ -30,6 +30,7 @@ const PreferenceList = ({ setting = false }) => {
const { SadminuserAccess, featureaddDetails } = useAuth();
const dispatch = useDispatch();
const formRef = useRef();
const prevEstimateRef = useRef([]);
const CompId = getSession('CompId');
const BranchId = getSession('BranchId');
const AppId = getSession('AppId');
@ -157,6 +158,10 @@ const PreferenceList = ({ setting = false }) => {
...(allSettingsMap['estimatetitle']?.value === 'Y'
? ['estimatetitle']
: []),
...(allSettingsMap['estimatebrname']?.value === 'Y' ? ['estimatebrname'] : []),
...(allSettingsMap['estimatebraddress']?.value === 'Y' ? ['estimatebraddress'] : []),
...(allSettingsMap['estimatebrphone']?.value === 'Y' ? ['estimatebrphone'] : []),
],
scanlayout: allSettingsMap['scanlayout']?.value === 'Y',
verifyproduct: allSettingsMap['verifyproduct']?.value === 'Y',
@ -207,9 +212,9 @@ const PreferenceList = ({ setting = false }) => {
}
};
}, []);
useEffect(()=>{
useEffect(() => {
fetchTableData();
},[selectedUserId])
}, [selectedUserId])
useEffect(() => {
if (settingsList) {
@ -217,6 +222,8 @@ const PreferenceList = ({ setting = false }) => {
setInitialValues(built);
console.log(built, 'built');
formRef.current?.setFieldsValue(built);
prevEstimateRef.current = built.estimateSettings ?? [];
}
}, [settingsList]);
@ -311,7 +318,7 @@ const PreferenceList = ({ setting = false }) => {
};
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 res = await dispatch(getPreferenceData(data)).unwrap();
if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) {
@ -405,8 +412,15 @@ const PreferenceList = ({ setting = false }) => {
dinein: values.enabledModules,
estimation: values.enabledModules,
parking: values.enabledFeatures,
// estimateprintheader: values.estimateSettings,
// estimatebrname: values.estimatebrname,
// estimatebraddress: values.estimatebraddress,
// estimatebrphone: values.estimatebrphone,
estimateprintheader: values.estimateSettings,
estimatetitle: values.estimateSettings,
estimatebrname: values.estimateSettings,
estimatebraddress: values.estimateSettings,
estimatebrphone: values.estimateSettings,
offer: values.enabledFeatures,
whatsapp: values.pdfSendOptions,
sms: values.pdfSendOptions,
@ -492,7 +506,7 @@ const PreferenceList = ({ setting = false }) => {
});
}
}
}, [userDropDown]);
}, [userDropDown]);
const UserDropDownChange = (value) => {
let user = userDropDown?.find((item) => item?.UserId === value);
setSelectedUserId(user?.UserId)
@ -500,11 +514,11 @@ const PreferenceList = ({ setting = false }) => {
userId: value,
});
};
const userDropData = async () => {
const data ={
branchId:BranchId,
compId:CompId,
appId:AppId
const userDropData = async () => {
const data = {
branchId: BranchId,
compId: CompId,
appId: AppId
}
const gettinguserDropDown = await dispatch(getBranchUsers(data)).unwrap();
// const gettinguserDropDown = await dispatch(UserDataBasedOnBranchId(BranchId)).unwrap();
@ -525,7 +539,7 @@ const userDropData = async () => {
}
}
}
};
};
const renderCheckbox = (name, label) =>
allSettingsMap[name] !== undefined && (
@ -533,6 +547,53 @@ const userDropData = async () => {
<Checkbox>Yes</Checkbox>
</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 (
<>
@ -621,7 +682,7 @@ const userDropData = async () => {
initialValues={initialValues}
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
name="userId"
rules={[
@ -1164,26 +1225,33 @@ const userDropData = async () => {
'mobilea4',
'Prefer printing in A4/A5 on mobile?'
)}
{(allSettingsMap['estimateprintheader'] !== undefined ||
allSettingsMap['estimatetitle'] !== undefined) && (
<Form.Item
name="estimateSettings"
label="Estimate Print Settings :"
>
<Checkbox.Group>
{allSettingsMap['estimateprintheader'] !== undefined && (
<Checkbox value="estimateprintheader">
Show shop header (Name, Address, GST)
{ESTIMATE_PRINT_SETTINGS.some(({ key }) => allSettingsMap[key] !== undefined) && (
<Form.Item noStyle shouldUpdate>
{({ getFieldValue }) => (
<Form.Item name="estimateSettings" label="Estimate Print Settings :">
<Checkbox.Group onChange={(vals) => handleEstimateChange(vals, formRef)}>
{ESTIMATE_PRINT_SETTINGS
.filter(({ key }) => allSettingsMap[key] !== undefined)
.map(({ key, label, children }) => (
<React.Fragment key={key}>
<Checkbox value={key}>{label}</Checkbox>
{children.length > 0 &&
getFieldValue('estimateSettings')?.includes(key) &&
children
.filter((child) => allSettingsMap[child.key] !== undefined)
.map((child) => (
<Checkbox key={child.key} value={child.key}>
{child.label}
</Checkbox>
)}
{allSettingsMap['estimatetitle'] !== undefined && (
<Checkbox value="estimatetitle">
Show Estimate (R/W) title
</Checkbox>
)}
))}
</React.Fragment>
))}
</Checkbox.Group>
</Form.Item>
)}
</Form.Item>
)}
</div>
<div className="PreferencesBTN">
<Buttons