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}
|
||||
onPayNow={handlePay}
|
||||
onContinueWithCredits={freeExtend}
|
||||
setExtendModel={setExtendModel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export const gettableData = createAsyncThunk(
|
|||
data?.BranchId != undefined
|
||||
) {
|
||||
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 = {
|
||||
userData: [],
|
||||
branchBasedUserData: [],
|
||||
|
|
|
|||
|
|
@ -22,12 +22,14 @@ import { ApplicationPreferences } from '../../Features/BrachLogin/BranchLogin.js
|
|||
import './PreferenceList.scss';
|
||||
import { InputField } from '../../Components/Forms/InputField.jsx';
|
||||
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 { SadminuserAccess, featureaddDetails } = useAuth();
|
||||
const dispatch = useDispatch();
|
||||
const formRef = useRef();
|
||||
|
||||
const CompId = getSession('CompId');
|
||||
const BranchId = getSession('BranchId');
|
||||
const AppId = getSession('AppId');
|
||||
|
|
@ -42,8 +44,10 @@ const PreferenceList = ({ setting = false }) => {
|
|||
const [activeSection, setActiveSection] = useState('general');
|
||||
const [empData, setEmpData] = useState();
|
||||
const [preferenceConfigs, setPreferenceConfigs] = useState([]);
|
||||
const [selectedUserId, setSelectedUserId] = useState([]);
|
||||
|
||||
const [addnewAccess, setAddNewAccess] = useState(true);
|
||||
const [userDropDown, setUserDropDown] = useState();
|
||||
|
||||
const tableValue = useSelector(settingDataSelector);
|
||||
const appPreferences = useSelector(ApplicationPreferences);
|
||||
|
|
@ -73,6 +77,7 @@ const PreferenceList = ({ setting = false }) => {
|
|||
console.log(featureaddDetails, 'featureaddDetails');
|
||||
|
||||
const buildInitialValues = () => ({
|
||||
userId: selectedUserId,
|
||||
dashboard: allSettingsMap['dashboard']?.value === 'Y',
|
||||
shortcutkeys: allSettingsMap['shortcutkeys']?.value === 'Y',
|
||||
autoreceivestock: allSettingsMap['autoreceivestock']?.value === 'Y',
|
||||
|
|
@ -188,7 +193,7 @@ const PreferenceList = ({ setting = false }) => {
|
|||
],
|
||||
})
|
||||
);
|
||||
fetchTableData();
|
||||
userDropData()
|
||||
|
||||
const centerPageSub = document.querySelector('.centerPageSub');
|
||||
if (centerPageSub) {
|
||||
|
|
@ -201,6 +206,9 @@ const PreferenceList = ({ setting = false }) => {
|
|||
}
|
||||
};
|
||||
}, []);
|
||||
useEffect(()=>{
|
||||
fetchTableData();
|
||||
},[selectedUserId])
|
||||
|
||||
useEffect(() => {
|
||||
if (settingsList) {
|
||||
|
|
@ -302,7 +310,7 @@ const PreferenceList = ({ setting = false }) => {
|
|||
};
|
||||
|
||||
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) {
|
||||
await dispatch(changePreferenceData(res?.data?.data));
|
||||
} else {
|
||||
|
|
@ -342,7 +350,7 @@ const PreferenceList = ({ setting = false }) => {
|
|||
const handleSubmit = async () => {
|
||||
const values = formRef.current.getFieldsValue();
|
||||
const salesMode = values.salesmode;
|
||||
console.log('Sales Mode:', values.salesmode);
|
||||
console.log('Sales Mode:', values);
|
||||
console.log('Retail Short Name:', values.retailshortname);
|
||||
console.log('Wholesale Short Name:', values.wholesaleshortname);
|
||||
const settings = settingsList || [];
|
||||
|
|
@ -453,8 +461,9 @@ const PreferenceList = ({ setting = false }) => {
|
|||
BranchId,
|
||||
CreatedBy: UserId,
|
||||
AppId,
|
||||
userId: UserType === 'Employee' ? UserId : values.userId,
|
||||
SettingDtlDetails: updatedSettings,
|
||||
};
|
||||
};;
|
||||
const response = await dispatch(postPreferenceAppNames(payload)).unwrap();
|
||||
|
||||
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) =>
|
||||
allSettingsMap[name] !== undefined && (
|
||||
<Form.Item name={name} label={label} valuePropName="checked">
|
||||
|
|
@ -561,6 +620,27 @@ const PreferenceList = ({ setting = false }) => {
|
|||
initialValues={initialValues}
|
||||
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
|
||||
style={{
|
||||
backgroundColor:
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import { WaiterNames } from '../../../Features/Reports/Reports';
|
|||
import { Messages } from '../../../Components/Notifications/Messages';
|
||||
import FormHeader from '../../PageComponents/FormHeader';
|
||||
import { changeBreadCrumb } from '../../../Features/AppPage/CenterPage';
|
||||
const { RangePicker } = DatePicker;
|
||||
|
||||
const subDirectory = import.meta.env.BASE_URL;
|
||||
const { Option } = Select;
|
||||
|
|
@ -229,11 +230,9 @@ const TipAmountSettlementList = () => {
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
// Set today's date for fromDate and toDate in the form
|
||||
const today = dayjs();
|
||||
form.setFieldsValue({
|
||||
fromDate: today,
|
||||
toDate: today,
|
||||
dateRange: [today, today],
|
||||
});
|
||||
dispatch(changeBreadCrumb({ items: items }));
|
||||
fetchData();
|
||||
|
|
@ -287,9 +286,9 @@ const TipAmountSettlementList = () => {
|
|||
if (values.Employee && values.Employee !== 'all') {
|
||||
filtered = filtered.filter((item) => item.Employee === values.Employee);
|
||||
}
|
||||
if (values.fromDate && values.toDate) {
|
||||
const from = dayjs(values.fromDate).startOf('day');
|
||||
const to = dayjs(values.toDate).endOf('day');
|
||||
if (values.dateRange && values.dateRange.length === 2) {
|
||||
const from = dayjs(values.dateRange[0]).startOf('day');
|
||||
const to = dayjs(values.dateRange[1]).endOf('day');
|
||||
filtered = filtered.filter((item) => {
|
||||
const itemDate = dayjs(item.Date, 'DD/MM/YYYY');
|
||||
return itemDate.isSameOrAfter(from) && itemDate.isSameOrBefore(to);
|
||||
|
|
@ -307,7 +306,14 @@ const TipAmountSettlementList = () => {
|
|||
};
|
||||
|
||||
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 = {
|
||||
CompId,
|
||||
BranchId,
|
||||
|
|
@ -320,18 +326,19 @@ const TipAmountSettlementList = () => {
|
|||
: {}),
|
||||
};
|
||||
let response;
|
||||
Employee !== 'all'
|
||||
? (response = await dispatch(getTipAmountSettlementList(data)).unwrap())
|
||||
: (response = await dispatch(
|
||||
getAllTipAmountSettlementList(data)
|
||||
).unwrap());
|
||||
if (Employee !== 'all') {
|
||||
response = await dispatch(getTipAmountSettlementList(data)).unwrap();
|
||||
} else {
|
||||
response = await dispatch(getAllTipAmountSettlementList(data)).unwrap();
|
||||
}
|
||||
|
||||
if (response?.data?.statusCode === 1) {
|
||||
setTableData(response?.data?.data?.[0]?.WaiterDetails);
|
||||
const StatusValue = form.getFieldValue('status') === 'toBe' ? 'N' : 'Y';
|
||||
|
||||
const employees = response?.data?.data?.[0]?.WaiterDetails ?? [];
|
||||
|
||||
const data =
|
||||
const hasData =
|
||||
employees?.some(
|
||||
(E) =>
|
||||
(StatusValue == 'N' &&
|
||||
|
|
@ -340,11 +347,10 @@ const TipAmountSettlementList = () => {
|
|||
E?.TipsDetails?.some((e) => e?.IsSettled == 'Y'))
|
||||
) ?? false;
|
||||
|
||||
if (data) {
|
||||
if (hasData) {
|
||||
setMessageType('success');
|
||||
setMessageData(response?.data?.response);
|
||||
}
|
||||
if (!data) {
|
||||
} else {
|
||||
setMessageType('error');
|
||||
setMessageData('No data Found');
|
||||
}
|
||||
|
|
@ -490,36 +496,19 @@ const TipAmountSettlementList = () => {
|
|||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
|
||||
<Col>
|
||||
<Form.Item
|
||||
name="fromDate"
|
||||
label="From Date"
|
||||
name="dateRange"
|
||||
label="Date Range"
|
||||
style={{ marginBottom: '8px' }}
|
||||
rules={[{ message: 'Please select from date' }]}
|
||||
rules={[{ type: 'array', required: true, message: 'Please select date range' }]}
|
||||
>
|
||||
<DatePicker
|
||||
format="DD/MM/YYYY"
|
||||
style={{ width: 140 }}
|
||||
disabledDate={(current) =>
|
||||
current && current > dayjs().endOf('day')
|
||||
}
|
||||
/>
|
||||
</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')
|
||||
}
|
||||
<RangePicker
|
||||
format="DD-MM-YYYY"
|
||||
allowClear
|
||||
disabledDate={(current) => current && current > dayjs()}
|
||||
placeholder={["From Date", "To Date"]}
|
||||
style={{ width: 280 }}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ const useSubscriptionManager = (sessionData, logout) => {
|
|||
return () => clearInterval(interval);
|
||||
}, [sessionData]);
|
||||
|
||||
return { remainingDays, handleCancel, handlePay, freeExtend, extendModel };
|
||||
return { remainingDays, handleCancel, handlePay, freeExtend, extendModel,setExtendModel };
|
||||
};
|
||||
|
||||
export default useSubscriptionManager;
|
||||
|
|
|
|||
Loading…
Reference in New Issue