added phoneumber name address in the preference
This commit is contained in:
parent
03010314c5
commit
df6f4af53e
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 { 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,
|
||||
|
|
@ -481,51 +495,51 @@ const PreferenceList = ({ setting = false }) => {
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (userDropDown?.length > 0 && !formRef.current?.getFieldValue("userId")) {
|
||||
const adminUser = userDropDown.find(
|
||||
(user) => user.UserTypeName === "Admin"
|
||||
);
|
||||
if (userDropDown?.length > 0 && !formRef.current?.getFieldValue("userId")) {
|
||||
const adminUser = userDropDown.find(
|
||||
(user) => user.UserTypeName === "Admin"
|
||||
);
|
||||
|
||||
if (adminUser) {
|
||||
formRef.current?.setFieldsValue({
|
||||
userId: adminUser.UserId
|
||||
});
|
||||
if (adminUser) {
|
||||
formRef.current?.setFieldsValue({
|
||||
userId: adminUser.UserId
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [userDropDown]);
|
||||
}, [userDropDown]);
|
||||
const UserDropDownChange = (value) => {
|
||||
let user = userDropDown?.find((item) => item?.UserId === value);
|
||||
setSelectedUserId(user?.UserId)
|
||||
setSelectedUserId(user?.UserId)
|
||||
formRef.current?.setFieldsValue({
|
||||
userId: value,
|
||||
});
|
||||
};
|
||||
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();
|
||||
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();
|
||||
|
||||
|
||||
if (gettinguserDropDown?.data?.statusCode === 1) {
|
||||
const finaluserDropDown = gettinguserDropDown?.data?.data?.filter((value) => value.ActiveStatus === "A");
|
||||
setUserDropDown(finaluserDropDown);
|
||||
if (gettinguserDropDown?.data?.statusCode === 1) {
|
||||
const finaluserDropDown = gettinguserDropDown?.data?.data?.filter((value) => value.ActiveStatus === "A");
|
||||
setUserDropDown(finaluserDropDown);
|
||||
|
||||
if (UserType === 'Employee') {
|
||||
setSelectedUserId(UserId);
|
||||
} else {
|
||||
const adminUser = finaluserDropDown.find(
|
||||
(user) => user.UserTypeName === "Admin"
|
||||
);
|
||||
if (adminUser) {
|
||||
setSelectedUserId(adminUser.UserId);
|
||||
if (UserType === 'Employee') {
|
||||
setSelectedUserId(UserId);
|
||||
} else {
|
||||
const adminUser = finaluserDropDown.find(
|
||||
(user) => user.UserTypeName === "Admin"
|
||||
);
|
||||
if (adminUser) {
|
||||
setSelectedUserId(adminUser.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
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)
|
||||
</Checkbox>
|
||||
)}
|
||||
{allSettingsMap['estimatetitle'] !== undefined && (
|
||||
<Checkbox value="estimatetitle">
|
||||
Show “Estimate (R/W)” title
|
||||
</Checkbox>
|
||||
)}
|
||||
</Checkbox.Group>
|
||||
</Form.Item>
|
||||
)}
|
||||
{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>
|
||||
))}
|
||||
</React.Fragment>
|
||||
))}
|
||||
</Checkbox.Group>
|
||||
</Form.Item>
|
||||
)}
|
||||
</Form.Item>
|
||||
)}
|
||||
</div>
|
||||
<div className="PreferencesBTN">
|
||||
<Buttons
|
||||
|
|
|
|||
Loading…
Reference in New Issue