Merge pull request 'prefarance-task' (#283) from prefarance-task into main
Reviewed-on: Pozomind/pozo-retail-app#283
This commit is contained in:
commit
69b93e6be3
|
|
@ -216,6 +216,7 @@ const AppRoutes = () => {
|
||||||
onClose={handleCancel}
|
onClose={handleCancel}
|
||||||
onPayNow={handlePay}
|
onPayNow={handlePay}
|
||||||
onContinueWithCredits={freeExtend}
|
onContinueWithCredits={freeExtend}
|
||||||
|
setExtendModel={setExtendModel}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export const gettableData = createAsyncThunk(
|
||||||
data?.BranchId != undefined
|
data?.BranchId != undefined
|
||||||
) {
|
) {
|
||||||
return await axiosRetailInstanceData.get(
|
return await axiosRetailInstanceData.get(
|
||||||
`/Settings?appId=${data?.AppId}&compId=${data?.CompId}&branchId=${data?.BranchId}`
|
`/Settings?appId=${data?.AppId}&compId=${data?.CompId}&branchId=${data?.BranchId}&userId=${data?.UserId}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,15 @@ export const getBranchBasedUserList = createAsyncThunk(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getBranchUsers = createAsyncThunk(
|
||||||
|
'user/getBranchUsers',
|
||||||
|
async (data) => {
|
||||||
|
if (data?.branchId != null && data?.branchId != undefined && data?.compId != null && data?.compId != undefined && data?.appId != null && data?.appId != undefined) {
|
||||||
|
return await axiosCommonInstanceData.get(`/User?branchId=${data?.branchId}&compId=${data?.compId}&appId=${data?.appId}&userType=UE`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
userData: [],
|
userData: [],
|
||||||
branchBasedUserData: [],
|
branchBasedUserData: [],
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,14 @@ import { ApplicationPreferences } from '../../Features/BrachLogin/BranchLogin.js
|
||||||
import './PreferenceList.scss';
|
import './PreferenceList.scss';
|
||||||
import { InputField } from '../../Components/Forms/InputField.jsx';
|
import { InputField } from '../../Components/Forms/InputField.jsx';
|
||||||
import { changePreferenceData } from '../../Features/BookingScreen/BookingData/BookingData.js';
|
import { changePreferenceData } from '../../Features/BookingScreen/BookingData/BookingData.js';
|
||||||
|
import { DropDowns } from '../../Components/Forms/DropDown.jsx';
|
||||||
|
import { getBranchUsers } from '../../Features/UserAccount/userData.js';
|
||||||
|
import { UserDataBasedOnBranchId } from '../../Features/Reports/Reports.js';
|
||||||
|
|
||||||
const PreferenceList = ({ setting = false }) => {
|
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 CompId = getSession('CompId');
|
const CompId = getSession('CompId');
|
||||||
const BranchId = getSession('BranchId');
|
const BranchId = getSession('BranchId');
|
||||||
const AppId = getSession('AppId');
|
const AppId = getSession('AppId');
|
||||||
|
|
@ -42,8 +44,10 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
const [activeSection, setActiveSection] = useState('general');
|
const [activeSection, setActiveSection] = useState('general');
|
||||||
const [empData, setEmpData] = useState();
|
const [empData, setEmpData] = useState();
|
||||||
const [preferenceConfigs, setPreferenceConfigs] = useState([]);
|
const [preferenceConfigs, setPreferenceConfigs] = useState([]);
|
||||||
|
const [selectedUserId, setSelectedUserId] = useState([]);
|
||||||
|
|
||||||
const [addnewAccess, setAddNewAccess] = useState(true);
|
const [addnewAccess, setAddNewAccess] = useState(true);
|
||||||
|
const [userDropDown, setUserDropDown] = useState();
|
||||||
|
|
||||||
const tableValue = useSelector(settingDataSelector);
|
const tableValue = useSelector(settingDataSelector);
|
||||||
const appPreferences = useSelector(ApplicationPreferences);
|
const appPreferences = useSelector(ApplicationPreferences);
|
||||||
|
|
@ -73,6 +77,7 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
console.log(featureaddDetails, 'featureaddDetails');
|
console.log(featureaddDetails, 'featureaddDetails');
|
||||||
|
|
||||||
const buildInitialValues = () => ({
|
const buildInitialValues = () => ({
|
||||||
|
userId: selectedUserId,
|
||||||
dashboard: allSettingsMap['dashboard']?.value === 'Y',
|
dashboard: allSettingsMap['dashboard']?.value === 'Y',
|
||||||
shortcutkeys: allSettingsMap['shortcutkeys']?.value === 'Y',
|
shortcutkeys: allSettingsMap['shortcutkeys']?.value === 'Y',
|
||||||
autoreceivestock: allSettingsMap['autoreceivestock']?.value === 'Y',
|
autoreceivestock: allSettingsMap['autoreceivestock']?.value === 'Y',
|
||||||
|
|
@ -188,7 +193,7 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
fetchTableData();
|
userDropData()
|
||||||
|
|
||||||
const centerPageSub = document.querySelector('.centerPageSub');
|
const centerPageSub = document.querySelector('.centerPageSub');
|
||||||
if (centerPageSub) {
|
if (centerPageSub) {
|
||||||
|
|
@ -201,6 +206,9 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
useEffect(()=>{
|
||||||
|
fetchTableData();
|
||||||
|
},[selectedUserId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (settingsList) {
|
if (settingsList) {
|
||||||
|
|
@ -302,7 +310,7 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchTableData = async () => {
|
const fetchTableData = async () => {
|
||||||
const res = await dispatch(gettableData({ CompId, BranchId, AppId })).unwrap();
|
const res = await dispatch(gettableData({ CompId, BranchId, AppId,UserId:selectedUserId })).unwrap();
|
||||||
if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) {
|
if (res?.data?.statusCode === 1 && res?.data?.data?.length > 0) {
|
||||||
await dispatch(changePreferenceData(res?.data?.data));
|
await dispatch(changePreferenceData(res?.data?.data));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -342,7 +350,7 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
const values = formRef.current.getFieldsValue();
|
const values = formRef.current.getFieldsValue();
|
||||||
const salesMode = values.salesmode;
|
const salesMode = values.salesmode;
|
||||||
console.log('Sales Mode:', values.salesmode);
|
console.log('Sales Mode:', values);
|
||||||
console.log('Retail Short Name:', values.retailshortname);
|
console.log('Retail Short Name:', values.retailshortname);
|
||||||
console.log('Wholesale Short Name:', values.wholesaleshortname);
|
console.log('Wholesale Short Name:', values.wholesaleshortname);
|
||||||
const settings = settingsList || [];
|
const settings = settingsList || [];
|
||||||
|
|
@ -453,8 +461,9 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
BranchId,
|
BranchId,
|
||||||
CreatedBy: UserId,
|
CreatedBy: UserId,
|
||||||
AppId,
|
AppId,
|
||||||
|
userId: UserType === 'Employee' ? UserId : values.userId,
|
||||||
SettingDtlDetails: updatedSettings,
|
SettingDtlDetails: updatedSettings,
|
||||||
};
|
};;
|
||||||
const response = await dispatch(postPreferenceAppNames(payload)).unwrap();
|
const response = await dispatch(postPreferenceAppNames(payload)).unwrap();
|
||||||
|
|
||||||
if (response?.data?.statusCode === 1) {
|
if (response?.data?.statusCode === 1) {
|
||||||
|
|
@ -467,6 +476,56 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (userDropDown?.length > 0 && !formRef.current?.getFieldValue("userId")) {
|
||||||
|
const adminUser = userDropDown.find(
|
||||||
|
(user) => user.UserTypeName === "Admin"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (adminUser) {
|
||||||
|
formRef.current?.setFieldsValue({
|
||||||
|
userId: adminUser.UserId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [userDropDown]);
|
||||||
|
const UserDropDownChange = (value) => {
|
||||||
|
let user = userDropDown?.find((item) => item?.UserId === value);
|
||||||
|
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();
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const renderCheckbox = (name, label) =>
|
const renderCheckbox = (name, label) =>
|
||||||
allSettingsMap[name] !== undefined && (
|
allSettingsMap[name] !== undefined && (
|
||||||
<Form.Item name={name} label={label} valuePropName="checked">
|
<Form.Item name={name} label={label} valuePropName="checked">
|
||||||
|
|
@ -561,6 +620,27 @@ const PreferenceList = ({ setting = false }) => {
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
className="preferences-list"
|
className="preferences-list"
|
||||||
>
|
>
|
||||||
|
{(UserType === 'Admin' || UserType === 'Super Admin' || UserType === 'Super Admin User')&& ( <span>
|
||||||
|
<Form.Item
|
||||||
|
name="userId"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: 'Please select a User',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<DropDowns
|
||||||
|
label={<label className="required">Users</label>}
|
||||||
|
valueData={formRef.current?.getFieldValue("userId")}
|
||||||
|
options={userDropDown?.map((option) => ({
|
||||||
|
label: option?.UserName || option?.MobileNo,
|
||||||
|
value: option?.UserId,
|
||||||
|
}))}
|
||||||
|
onChangeFunction={(value, option) => UserDropDownChange(value, option)}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</span>)}
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import { WaiterNames } from '../../../Features/Reports/Reports';
|
||||||
import { Messages } from '../../../Components/Notifications/Messages';
|
import { Messages } from '../../../Components/Notifications/Messages';
|
||||||
import FormHeader from '../../PageComponents/FormHeader';
|
import FormHeader from '../../PageComponents/FormHeader';
|
||||||
import { changeBreadCrumb } from '../../../Features/AppPage/CenterPage';
|
import { changeBreadCrumb } from '../../../Features/AppPage/CenterPage';
|
||||||
|
const { RangePicker } = DatePicker;
|
||||||
|
|
||||||
const subDirectory = import.meta.env.BASE_URL;
|
const subDirectory = import.meta.env.BASE_URL;
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
@ -229,11 +230,9 @@ const TipAmountSettlementList = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Set today's date for fromDate and toDate in the form
|
|
||||||
const today = dayjs();
|
const today = dayjs();
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
fromDate: today,
|
dateRange: [today, today],
|
||||||
toDate: today,
|
|
||||||
});
|
});
|
||||||
dispatch(changeBreadCrumb({ items: items }));
|
dispatch(changeBreadCrumb({ items: items }));
|
||||||
fetchData();
|
fetchData();
|
||||||
|
|
@ -287,9 +286,9 @@ const TipAmountSettlementList = () => {
|
||||||
if (values.Employee && values.Employee !== 'all') {
|
if (values.Employee && values.Employee !== 'all') {
|
||||||
filtered = filtered.filter((item) => item.Employee === values.Employee);
|
filtered = filtered.filter((item) => item.Employee === values.Employee);
|
||||||
}
|
}
|
||||||
if (values.fromDate && values.toDate) {
|
if (values.dateRange && values.dateRange.length === 2) {
|
||||||
const from = dayjs(values.fromDate).startOf('day');
|
const from = dayjs(values.dateRange[0]).startOf('day');
|
||||||
const to = dayjs(values.toDate).endOf('day');
|
const to = dayjs(values.dateRange[1]).endOf('day');
|
||||||
filtered = filtered.filter((item) => {
|
filtered = filtered.filter((item) => {
|
||||||
const itemDate = dayjs(item.Date, 'DD/MM/YYYY');
|
const itemDate = dayjs(item.Date, 'DD/MM/YYYY');
|
||||||
return itemDate.isSameOrAfter(from) && itemDate.isSameOrBefore(to);
|
return itemDate.isSameOrAfter(from) && itemDate.isSameOrBefore(to);
|
||||||
|
|
@ -307,7 +306,14 @@ const TipAmountSettlementList = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFinish = async (values) => {
|
const onFinish = async (values) => {
|
||||||
const { Employee, fromDate, toDate, ...restValues } = values;
|
const { Employee, dateRange, ...restValues } = values;
|
||||||
|
let fromDate = null;
|
||||||
|
let toDate = null;
|
||||||
|
if (dateRange && dateRange.length === 2) {
|
||||||
|
fromDate = dateRange[0];
|
||||||
|
toDate = dateRange[1];
|
||||||
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
CompId,
|
CompId,
|
||||||
BranchId,
|
BranchId,
|
||||||
|
|
@ -320,18 +326,19 @@ const TipAmountSettlementList = () => {
|
||||||
: {}),
|
: {}),
|
||||||
};
|
};
|
||||||
let response;
|
let response;
|
||||||
Employee !== 'all'
|
if (Employee !== 'all') {
|
||||||
? (response = await dispatch(getTipAmountSettlementList(data)).unwrap())
|
response = await dispatch(getTipAmountSettlementList(data)).unwrap();
|
||||||
: (response = await dispatch(
|
} else {
|
||||||
getAllTipAmountSettlementList(data)
|
response = await dispatch(getAllTipAmountSettlementList(data)).unwrap();
|
||||||
).unwrap());
|
}
|
||||||
|
|
||||||
if (response?.data?.statusCode === 1) {
|
if (response?.data?.statusCode === 1) {
|
||||||
setTableData(response?.data?.data?.[0]?.WaiterDetails);
|
setTableData(response?.data?.data?.[0]?.WaiterDetails);
|
||||||
const StatusValue = form.getFieldValue('status') === 'toBe' ? 'N' : 'Y';
|
const StatusValue = form.getFieldValue('status') === 'toBe' ? 'N' : 'Y';
|
||||||
|
|
||||||
const employees = response?.data?.data?.[0]?.WaiterDetails ?? [];
|
const employees = response?.data?.data?.[0]?.WaiterDetails ?? [];
|
||||||
|
|
||||||
const data =
|
const hasData =
|
||||||
employees?.some(
|
employees?.some(
|
||||||
(E) =>
|
(E) =>
|
||||||
(StatusValue == 'N' &&
|
(StatusValue == 'N' &&
|
||||||
|
|
@ -340,11 +347,10 @@ const TipAmountSettlementList = () => {
|
||||||
E?.TipsDetails?.some((e) => e?.IsSettled == 'Y'))
|
E?.TipsDetails?.some((e) => e?.IsSettled == 'Y'))
|
||||||
) ?? false;
|
) ?? false;
|
||||||
|
|
||||||
if (data) {
|
if (hasData) {
|
||||||
setMessageType('success');
|
setMessageType('success');
|
||||||
setMessageData(response?.data?.response);
|
setMessageData(response?.data?.response);
|
||||||
}
|
} else {
|
||||||
if (!data) {
|
|
||||||
setMessageType('error');
|
setMessageType('error');
|
||||||
setMessageData('No data Found');
|
setMessageData('No data Found');
|
||||||
}
|
}
|
||||||
|
|
@ -490,36 +496,19 @@ const TipAmountSettlementList = () => {
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Col>
|
<Col>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="fromDate"
|
name="dateRange"
|
||||||
label="From Date"
|
label="Date Range"
|
||||||
style={{ marginBottom: '8px' }}
|
style={{ marginBottom: '8px' }}
|
||||||
rules={[{ message: 'Please select from date' }]}
|
rules={[{ type: 'array', required: true, message: 'Please select date range' }]}
|
||||||
>
|
>
|
||||||
<DatePicker
|
<RangePicker
|
||||||
format="DD/MM/YYYY"
|
format="DD-MM-YYYY"
|
||||||
style={{ width: 140 }}
|
allowClear
|
||||||
disabledDate={(current) =>
|
disabledDate={(current) => current && current > dayjs()}
|
||||||
current && current > dayjs().endOf('day')
|
placeholder={["From Date", "To Date"]}
|
||||||
}
|
style={{ width: 280 }}
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
</Col>
|
|
||||||
<Col>
|
|
||||||
<Form.Item
|
|
||||||
name="toDate"
|
|
||||||
label="To Date"
|
|
||||||
style={{ marginBottom: '8px' }}
|
|
||||||
rules={[{ message: 'Please select to date' }]}
|
|
||||||
>
|
|
||||||
<DatePicker
|
|
||||||
format="DD/MM/YYYY"
|
|
||||||
style={{ width: 140 }}
|
|
||||||
disabledDate={(current) =>
|
|
||||||
current && current > dayjs().endOf('day')
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ const useSubscriptionManager = (sessionData, logout) => {
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
}, [sessionData]);
|
}, [sessionData]);
|
||||||
|
|
||||||
return { remainingDays, handleCancel, handlePay, freeExtend, extendModel };
|
return { remainingDays, handleCancel, handlePay, freeExtend, extendModel,setExtendModel };
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useSubscriptionManager;
|
export default useSubscriptionManager;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue