diff --git a/client/src/components/time-ticket-list/time-ticket-list.component.jsx b/client/src/components/time-ticket-list/time-ticket-list.component.jsx index 11ec514fe..b7265ca2b 100644 --- a/client/src/components/time-ticket-list/time-ticket-list.component.jsx +++ b/client/src/components/time-ticket-list/time-ticket-list.component.jsx @@ -12,7 +12,7 @@ import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter"; import { onlyUnique } from "../../utils/arrayHelper"; import dayjs from "../../utils/day"; import { alphaSort, dateSort } from "../../utils/sorters"; -import RbacWrapper, { HasRbacAccess } from "../rbac-wrapper/rbac-wrapper.component"; +import { HasRbacAccess } from "../rbac-wrapper/rbac-wrapper.component"; import TimeTicketEnterButton from "../time-ticket-enter-button/time-ticket-enter-button.component"; const mapStateToProps = createStructuredSelector({ @@ -52,6 +52,10 @@ export function TimeTicketList({ splitKey: bodyshop.imexshopid }); + const canEditCommittedTimeTickets = HasRbacAccess({ bodyshop, authLevel, action: "timetickets:editcommitted" }); + const canEditTimeTickets = HasRbacAccess({ bodyshop, authLevel, action: "timetickets:edit" }); + const canEditShiftTickets = HasRbacAccess({ bodyshop, authLevel, action: "timetickets:shiftedit" }); + const totals = useMemo(() => { if (timetickets) return timetickets.reduce( @@ -65,6 +69,18 @@ export function TimeTicketList({ return { productivehrs: 0, actualhrs: 0 }; }, [timetickets]); + const isDisabled = (record) => { + if (disabled === true || !record.id) return true; + + const isShiftTicket = !record.ciecacode; + const isCommitted = record.committed_at; + if (isShiftTicket) { + return !(canEditShiftTickets && (!isCommitted || canEditCommittedTimeTickets)); + } + + return !(canEditTimeTickets && (!isCommitted || canEditCommittedTimeTickets)); + }; + const columns = [ ...(Enhanced_Payroll.treatment === "on" ? [ @@ -241,59 +257,16 @@ export function TimeTicketList({ )} {!techConsole && ( - { - return
; + - - - - + + )} )