This commit is contained in:
@@ -18,13 +18,19 @@ const RoutesSection = ({transRoutes, copyList, sectionName, drivers, vehicles, c
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const scheduleDate = params.get('dateSchedule');
|
||||
|
||||
const normalizeCustomerType = (value) => `${value || ''}`.trim().toLowerCase().replace(/\s+/g, '_');
|
||||
const isMemberLikeType = (value) => [CUSTOMER_TYPE.MEMBER, CUSTOMER_TYPE.SELF_PAY].includes(normalizeCustomerType(value));
|
||||
const isVisitorType = (value) => normalizeCustomerType(value) === CUSTOMER_TYPE.VISITOR;
|
||||
|
||||
useEffect(() => {
|
||||
const getSeniors = () => {
|
||||
const seniors = [];
|
||||
if (transRoutes) {
|
||||
for (const transRoute of transRoutes) {
|
||||
for (const customer of transRoute.route_customer_list) {
|
||||
if (!seniors.includes(customer.customer_id) && customer.customer_pickup_status !== PICKUP_STATUS.SCHEDULE_ABSENT && customer.customer_route_status !== PERSONAL_ROUTE_STATUS.DISABLED) {
|
||||
const customerId = customer?.customer_id;
|
||||
const hasSameCustomer = seniors.some((item) => item?.customer_id === customerId);
|
||||
if (!hasSameCustomer && customer.customer_pickup_status !== PICKUP_STATUS.SCHEDULE_ABSENT && customer.customer_route_status !== PERSONAL_ROUTE_STATUS.DISABLED) {
|
||||
seniors.push(customer);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +99,7 @@ const RoutesSection = ({transRoutes, copyList, sectionName, drivers, vehicles, c
|
||||
{`${sectionName}: `} <span className="route-stats">{
|
||||
(sectionName.includes('Inbound') ||
|
||||
sectionName.includes('Outbound')) &&
|
||||
(`${seniors.filter(item => [CUSTOMER_TYPE.MEMBER, CUSTOMER_TYPE.SELF_PAY].includes(item.customer_type) && ![PERSONAL_ROUTE_STATUS.UNEXPECTED_ABSENT, PERSONAL_ROUTE_STATUS.SCHEDULED_ABSENT].includes(item?.customer_route_status))?.length} Members ${seniors.filter(item=> [CUSTOMER_TYPE.VISITOR].includes(item?.customer_type) && ![PERSONAL_ROUTE_STATUS.UNEXPECTED_ABSENT, PERSONAL_ROUTE_STATUS.SCHEDULED_ABSENT].includes(item?.customer_route_status))?.length} Visitors${sectionName.includes('Inbound') && showCheckedInText ? ` ${seniors.filter(item => item?.customer_route_status === PERSONAL_ROUTE_STATUS.IN_CENTER)?.length} checked in` : ''}`)}</span>
|
||||
(`${seniors.filter(item => isMemberLikeType(item?.customer_type) && ![PERSONAL_ROUTE_STATUS.UNEXPECTED_ABSENT, PERSONAL_ROUTE_STATUS.SCHEDULED_ABSENT].includes(item?.customer_route_status))?.length} Members ${seniors.filter(item=> isVisitorType(item?.customer_type) && ![PERSONAL_ROUTE_STATUS.UNEXPECTED_ABSENT, PERSONAL_ROUTE_STATUS.SCHEDULED_ABSENT].includes(item?.customer_route_status))?.length} Visitors${sectionName.includes('Inbound') && showCheckedInText ? ` ${seniors.filter(item => item?.customer_route_status === PERSONAL_ROUTE_STATUS.IN_CENTER)?.length} checked in` : ''}`)}</span>
|
||||
</h6>
|
||||
<div className="d-flex align-items-center" style={{ gap: '10px' }}>
|
||||
{canAddNew && (
|
||||
|
||||
Reference in New Issue
Block a user