From 21a378039c04aa3b421b814eb70534c41b4325de Mon Sep 17 00:00:00 2001 From: Lixian Zhou Date: Thu, 12 Mar 2026 15:05:16 -0400 Subject: [PATCH] fix --- .../src/components/customers/CustomersList.js | 27 +++++----- .../dashboard/DashboardCustomersList.js | 53 +++++++++++++------ client/src/components/seating/Seating.js | 7 +-- .../trans-routes/BreakfastSection.js | 10 ++-- .../components/trans-routes/LunchSection.js | 10 ++-- .../src/components/trans-routes/MealStatus.js | 6 ++- .../trans-routes/PersonnelInfoTable.js | 15 ++++-- .../trans-routes/RoutesDashboard.js | 8 +-- .../components/trans-routes/SnackSection.js | 10 ++-- client/src/components/vehicles/VehicleList.js | 12 +++-- client/src/services/AuthService.js | 8 +++ 11 files changed, 105 insertions(+), 61 deletions(-) diff --git a/client/src/components/customers/CustomersList.js b/client/src/components/customers/CustomersList.js index 1d6ca60..eaabce1 100644 --- a/client/src/components/customers/CustomersList.js +++ b/client/src/components/customers/CustomersList.js @@ -30,6 +30,7 @@ const CustomersList = () => { }; const getVisibleColumnsByPermission = (columnList = []) => { return columnList.filter((column) => { + if (column.key === 'name') return true; const mappedTab = CUSTOMER_LIST_COLUMN_TAB_MAP[column.key]; if (!mappedTab) return true; return AuthService.canViewCustomerTab(mappedTab); @@ -82,18 +83,20 @@ const CustomersList = () => { {AuthService.canCreateCustomer() && } - ({ - ...customer, - address: customer?.address1 || customer?.address2 || customer?.address3 || customer?.address4 || customer?.address5, - phone: customer?.phone || customer?.home_phone || customer?.mobile_phone, - tags: customer?.tags?.join(', ') - }))} - filename="customers" - show={showExportDropdown} - onToggle={onExportToggle} - /> + {AuthService.canExportCustomerReport() && ( + ({ + ...customer, + address: customer?.address1 || customer?.address2 || customer?.address3 || customer?.address4 || customer?.address5, + phone: customer?.phone || customer?.home_phone || customer?.mobile_phone, + tags: customer?.tags?.join(', ') + }))} + filename="customers" + show={showExportDropdown} + onToggle={onExportToggle} + /> + )} ); diff --git a/client/src/components/dashboard/DashboardCustomersList.js b/client/src/components/dashboard/DashboardCustomersList.js index b328b58..0a5d313 100644 --- a/client/src/components/dashboard/DashboardCustomersList.js +++ b/client/src/components/dashboard/DashboardCustomersList.js @@ -27,11 +27,30 @@ const DashboardCustomersList = ({ additionalButtons, showBreadcrumb = false, tit }; const getVisibleColumnsByPermission = (columnList = []) => { return columnList.filter((column) => { + if (column.key === 'name') return true; const mappedTab = CUSTOMER_LIST_COLUMN_TAB_MAP[column.key]; if (!mappedTab) return true; return AuthService.canViewCustomerTab(mappedTab); }); }; + const CUSTOMER_FILTER_TAB_MAP = { + customerType: 'careServices', + programType: 'personalInfo', + paySource: 'personalInfo', + transportationType: 'careServices', + eyesOn: 'medicalInsurance' + }; + const canViewFilterControl = (filterKey) => { + const mappedTab = CUSTOMER_FILTER_TAB_MAP[filterKey]; + if (!mappedTab) return true; + return AuthService.canViewCustomerTab(mappedTab); + }; + const visibleCustomerTypeFilter = canViewFilterControl('customerType'); + const visibleProgramTypeFilter = canViewFilterControl('programType'); + const visiblePaySourceFilter = canViewFilterControl('paySource'); + const visibleTransportationTypeFilter = canViewFilterControl('transportationType'); + const visibleEyesOnFilter = canViewFilterControl('eyesOn'); + const hasVisibleFilters = visibleCustomerTypeFilter || visibleProgramTypeFilter || visiblePaySourceFilter || visibleTransportationTypeFilter || visibleEyesOnFilter; const navigate = useNavigate(); const dispatch = useDispatch(); const site = EventsService.site; @@ -192,23 +211,23 @@ const DashboardCustomersList = ({ additionalButtons, showBreadcrumb = false, tit filtered = filtered.filter(item => item.status === 'active' && item.type !== CUSTOMER_TYPE.TRANSFERRED && item.type !== CUSTOMER_TYPE.DECEASED && item.type !== CUSTOMER_TYPE.DISCHARGED); } - if (customerTypeFilter) { + if (customerTypeFilter && visibleCustomerTypeFilter) { filtered = filtered.filter((item) => (item?.type || '') === customerTypeFilter); } - if (programTypeFilter) { + if (programTypeFilter && visibleProgramTypeFilter) { filtered = filtered.filter((item) => (item?.program || '') === programTypeFilter); } - if (paySourceFilter) { + if (paySourceFilter && visiblePaySourceFilter) { filtered = filtered.filter((item) => (item?.pay_source || '') === paySourceFilter); } - if (transportationTypeFilter) { + if (transportationTypeFilter && visibleTransportationTypeFilter) { filtered = filtered.filter((item) => (item?.transportation_type || '') === transportationTypeFilter); } - if (eyesOnFilter) { + if (eyesOnFilter && visibleEyesOnFilter) { filtered = filtered.filter((item) => { const normalized = `${item?.eyes_on || (item?.disability ? YES_NO.YES : '')}`.toLowerCase(); return normalized === eyesOnFilter; @@ -411,7 +430,7 @@ const DashboardCustomersList = ({ additionalButtons, showBreadcrumb = false, tit >
Filter By
-
+ {visibleCustomerTypeFilter &&
Customer Type
-
-
+
} + {visibleProgramTypeFilter &&
Program Type
-
+
}
-
+ {visiblePaySourceFilter &&
Pay Source
-
-
+
} + {visibleTransportationTypeFilter &&
Tranportation Type
-
+
}
-
+ {visibleEyesOnFilter &&
Eyes-On
-
+
}
@@ -504,7 +523,7 @@ const DashboardCustomersList = ({ additionalButtons, showBreadcrumb = false, tit
setKeyword(e.currentTarget.value)} /> - Filter - + } { + const canManageSeatingChart = AuthService.canEditSeatingChart(); // OLD ROW-BASED INITIAL VALUE - COMMENTED OUT // const initialValue = { // rows: [{ @@ -973,7 +974,7 @@ const Seating = () => {
-
+ {canManageSeatingChart &&
Manage Seating Chart
{/* */} @@ -1284,7 +1285,7 @@ const Seating = () => { currentLabels.map((item) =>
{item.label_name}
) }
-
+
} )} diff --git a/client/src/components/trans-routes/BreakfastSection.js b/client/src/components/trans-routes/BreakfastSection.js index 9852cca..f638820 100644 --- a/client/src/components/trans-routes/BreakfastSection.js +++ b/client/src/components/trans-routes/BreakfastSection.js @@ -3,7 +3,7 @@ import { TransRoutesService } from "../../services"; import moment from 'moment'; -const BreakfastSection = ({transRoutes, breakfastRecords, sectionName, confimHasBreakfast, removeBreakfastRecord, selectedDate, refreshRecords}) => { +const BreakfastSection = ({transRoutes, breakfastRecords, sectionName, confimHasBreakfast, removeBreakfastRecord, selectedDate, refreshRecords, canEdit = false}) => { const [customers, setCustomers] = useState([]); const createBreakfastForAll = async () => { @@ -40,7 +40,7 @@ const BreakfastSection = ({transRoutes, breakfastRecords, sectionName, confimHas return ( <>
{sectionName} {` (${customers?.length})`}
- {customers?.some(c => !c.has_breakfast) && (
)} + {canEdit && customers?.some(c => !c.has_breakfast) && (
)}
@@ -48,7 +48,7 @@ const BreakfastSection = ({transRoutes, breakfastRecords, sectionName, confimHas - + {canEdit && } @@ -57,10 +57,10 @@ const BreakfastSection = ({transRoutes, breakfastRecords, sectionName, confimHas - + } )) } diff --git a/client/src/components/trans-routes/LunchSection.js b/client/src/components/trans-routes/LunchSection.js index 961f8b9..8e22636 100644 --- a/client/src/components/trans-routes/LunchSection.js +++ b/client/src/components/trans-routes/LunchSection.js @@ -3,7 +3,7 @@ import { TransRoutesService } from "../../services"; import moment from 'moment'; -const LunchSection = ({transRoutes, lunchRecords, sectionName, confirmHasLunch, removeLunchRecord, selectedDate, refreshRecords}) => { +const LunchSection = ({transRoutes, lunchRecords, sectionName, confirmHasLunch, removeLunchRecord, selectedDate, refreshRecords, canEdit = false}) => { const [customers, setCustomers] = useState([]); const createLunchForAll = async () => { @@ -40,7 +40,7 @@ const LunchSection = ({transRoutes, lunchRecords, sectionName, confirmHasLunch, return ( <>
{sectionName} {` (${customers?.length})`}
- {customers?.some(c => !c.has_lunch) && (
)} + {canEdit && customers?.some(c => !c.has_lunch) && (
)}
Name Has Breakfast TodayChange Breakfast StatusChange Breakfast Status
{customer?.customer_name} {customer?.has_breakfast ? 'Yes': 'No'} + {canEdit && {!customer?.has_breakfast && } {customer?.has_breakfast && } -
@@ -48,7 +48,7 @@ const LunchSection = ({transRoutes, lunchRecords, sectionName, confirmHasLunch, - + {canEdit && } @@ -57,10 +57,10 @@ const LunchSection = ({transRoutes, lunchRecords, sectionName, confirmHasLunch, - + } )) } diff --git a/client/src/components/trans-routes/MealStatus.js b/client/src/components/trans-routes/MealStatus.js index ba73a48..346b75b 100644 --- a/client/src/components/trans-routes/MealStatus.js +++ b/client/src/components/trans-routes/MealStatus.js @@ -1,5 +1,5 @@ import React, { useEffect, useState, useCallback } from "react"; -import { TransRoutesService } from "../../services"; +import { AuthService, TransRoutesService } from "../../services"; import BreakfastSection from './BreakfastSection'; import LunchSection from "./LunchSection"; import SnackSection from "./SnackSection"; @@ -7,6 +7,7 @@ import { Breadcrumb } from "react-bootstrap"; import moment from 'moment'; const MealStatus = () => { + const canEditMealStatus = AuthService.canEditMealStatus(); const [selectedDate, setSelectedDate] = useState(new Date()); const [allRoutes, setAllRoutes] = useState([]); const [breakfastRecords, setBreakfastRecords] = useState([]); @@ -169,6 +170,7 @@ const MealStatus = () => { breakfastRecords={breakfastRecords} confimHasBreakfast={confimHasBreakfast} removeBreakfastRecord={removeBreakfastRecord} + canEdit={canEditMealStatus} sectionName={'Breakfast Info'} selectedDate={selectedDate} refreshRecords={fetchAllData} @@ -180,6 +182,7 @@ const MealStatus = () => { lunchRecords={lunchRecords} confirmHasLunch={confirmHasLunch} removeLunchRecord={removeLunchRecord} + canEdit={canEditMealStatus} sectionName={'Lunch Info'} selectedDate={selectedDate} refreshRecords={fetchAllData} @@ -191,6 +194,7 @@ const MealStatus = () => { snackRecords={snackRecords} confirmHasSnack={confirmHasSnack} removeSnackRecord={removeSnackRecord} + canEdit={canEditMealStatus} sectionName={'Snack Info'} selectedDate={selectedDate} refreshRecords={fetchAllData} diff --git a/client/src/components/trans-routes/PersonnelInfoTable.js b/client/src/components/trans-routes/PersonnelInfoTable.js index d36c119..534bcf4 100644 --- a/client/src/components/trans-routes/PersonnelInfoTable.js +++ b/client/src/components/trans-routes/PersonnelInfoTable.js @@ -4,7 +4,7 @@ import { CUSTOMER_TYPE_TEXT, PERSONAL_ROUTE_STATUS, PERSONAL_ROUTE_STATUS_TEXT, import { Modal, Button } from "react-bootstrap"; import { transRoutesSlice } from "./../../store"; import { CSVLink } from "react-csv"; -import { ReportService, CustomerService } from "../../services"; +import { ReportService, CustomerService, AuthService } from "../../services"; import TimePicker from 'react-time-picker'; import 'react-time-picker/dist/TimePicker.css'; import moment from 'moment'; @@ -18,6 +18,7 @@ const PersonnelInfoTable = ({transRoutes, showCompletedInfo, customerTableId, routeTypeFilter, customerTypeFilter, onRouteUpdated = null }) => { + const canExportRouteReport = AuthService.canExportTransportationScheduleReport(); const [show, setShow] = useState(false); const [showGroupEditor, setShowGroupEditor] = useState(false); const [showBulkUpdateModal, setShowBulkUpdateModal] = useState(false); @@ -695,10 +696,14 @@ const PersonnelInfoTable = ({transRoutes, showCompletedInfo, )} {showGroupInfo && (
- - Generate Route Reports - - + {canExportRouteReport && ( + <> + + Generate Route Reports + + + + )}
diff --git a/client/src/components/trans-routes/RoutesDashboard.js b/client/src/components/trans-routes/RoutesDashboard.js index da21b10..5c69a27 100644 --- a/client/src/components/trans-routes/RoutesDashboard.js +++ b/client/src/components/trans-routes/RoutesDashboard.js @@ -2003,9 +2003,11 @@ const RoutesDashboard = () => { { currentTab === 'allRoutesOverview' && <> { !showCopyDateTargetLoading && <> - + {AuthService.canExportTransportationScheduleReport() && ( + + )} { +const SnackSection = ({transRoutes, snackRecords, sectionName, confirmHasSnack, removeSnackRecord, selectedDate, refreshRecords, canEdit = false}) => { const [customers, setCustomers] = useState([]); const createSnackForAll = async () => { @@ -40,7 +40,7 @@ const SnackSection = ({transRoutes, snackRecords, sectionName, confirmHasSnack, return ( <>
{sectionName} {` (${customers?.length})`}
- {customers?.some(c => !c.has_snack) && (
)} + {canEdit && customers?.some(c => !c.has_snack) && (
)}
Name Has Lunch TodayChange Lunch StatusChange Lunch Status
{customer?.customer_name} {customer?.has_lunch ? 'Yes': 'No'} + {canEdit && {!customer?.has_lunch && } {customer?.has_lunch && } -
@@ -48,7 +48,7 @@ const SnackSection = ({transRoutes, snackRecords, sectionName, confirmHasSnack, - + {canEdit && } @@ -57,10 +57,10 @@ const SnackSection = ({transRoutes, snackRecords, sectionName, confirmHasSnack, - + } )) } diff --git a/client/src/components/vehicles/VehicleList.js b/client/src/components/vehicles/VehicleList.js index c5148f7..98b633b 100644 --- a/client/src/components/vehicles/VehicleList.js +++ b/client/src/components/vehicles/VehicleList.js @@ -384,11 +384,13 @@ const VehicleList = () => { {AuthService.canAddVehicle() && } - + {AuthService.canExportVehicleReport() && ( + + )} diff --git a/client/src/services/AuthService.js b/client/src/services/AuthService.js index 1ac8038..a542018 100644 --- a/client/src/services/AuthService.js +++ b/client/src/services/AuthService.js @@ -221,6 +221,8 @@ const canViewMealStatus = () => { ]); } +const canEditMealStatus = () => hasPermission('Edit_Meal Status'); + const canViewSeatingChart = () => { return hasAnyPermission([ 'View_Seating Chart', @@ -228,6 +230,10 @@ const canViewSeatingChart = () => { ]); } +const canEditSeatingChart = () => { + return hasPermission('Edit_Seating Chart'); +} + const canViewLobby = () => { return canViewMealStatus() || canViewSeatingChart(); } @@ -373,7 +379,9 @@ export const AuthService = { canViewMedicalEvents, canEditMedicalEvents, canViewMealStatus, + canEditMealStatus, canViewSeatingChart, + canEditSeatingChart, canViewLobby, isAdmin, canCreateOrEditDrivers,
Name Has Snack TodayChange Snack StatusChange Snack Status
{customer?.customer_name} {customer?.has_snack ? 'Yes': 'No'} + {canEdit && {!customer?.has_snack && } {customer?.has_snack && } -