diff --git a/src/components/assignments_checklist/assignments_checklist.styles.tsx b/src/components/assignments_checklist/assignments_checklist.styles.tsx index cacb988f95..a5818e2f13 100644 --- a/src/components/assignments_checklist/assignments_checklist.styles.tsx +++ b/src/components/assignments_checklist/assignments_checklist.styles.tsx @@ -1,26 +1,18 @@ -import { FC } from 'react'; -import { - Box, - Checkbox, - CheckboxProps, - FormControlLabel, - Typography, -} from '@mui/material'; +import { Box, Checkbox, FormControlLabel, Typography } from '@mui/material'; import { styled } from '@mui/system'; -export const HeaderBox = styled(Box)<{ disabled: boolean }>(({ disabled }) => ({ +export const HeaderBox = styled(Box)({ display: 'flex', flexDirection: 'row', alignItems: 'center', borderRadius: 'var(--radius-s, 4px)', - opacity: disabled && '24%', -})); +}) as unknown as typeof Box; export const StyledContentBox = styled(Box)({ display: 'flex', flexDirection: 'column', gap: '8px', -}); +}) as unknown as typeof Box; export const StyledTypography = styled(Typography)({ color: 'var(--always-white)', @@ -29,14 +21,14 @@ export const StyledTypography = styled(Typography)({ lineHeight: '20px', marginTop: '4px', marginBottom: '4px', -}); +}) as unknown as typeof Typography; export const ChildrenBox = styled(Box)({ display: 'flex', flexDirection: 'column', paddingLeft: '8px', paddingRight: '8px', -}); +}) as unknown as typeof Box; export const StyledFormControlLabel = styled(FormControlLabel)({ marginLeft: '4px', @@ -47,11 +39,11 @@ export const StyledFormControlLabel = styled(FormControlLabel)({ '& .MuiFormControlLabel-label.Mui-disabled': { color: 'var(--always-white)', }, -}); +}) as unknown as typeof FormControlLabel; -export const StyledCheckbox: FC = styled(Checkbox)({ +export const StyledCheckbox = styled(Checkbox)({ padding: 0, '& svg': { color: 'var(--always-white)', }, -}); +}) as unknown as typeof Checkbox; diff --git a/src/components/assignments_checklist/index.tsx b/src/components/assignments_checklist/index.tsx index ba83f6c36d..98372acbff 100644 --- a/src/components/assignments_checklist/index.tsx +++ b/src/components/assignments_checklist/index.tsx @@ -118,8 +118,8 @@ export const AssignmentCheckList = ({ sx={{ background: `var(--${color})`, minHeight: '32px', + opacity: disabled && '24%', }} - disabled={disabled} > {header}} diff --git a/src/components/select/index.styles.tsx b/src/components/select/index.styles.tsx index ccf0cdb4c2..1e10a2574b 100644 --- a/src/components/select/index.styles.tsx +++ b/src/components/select/index.styles.tsx @@ -1,13 +1,15 @@ -import { styled } from '@mui/system'; -import { Select } from '@mui/material'; +import { Select, styled } from '@mui/material'; -const SelectStyled = styled(Select)({ +export const SelectStyled = styled(Select)({ '.MuiSelect-select p': { overflow: 'hidden', textOverflow: 'ellipsis', }, '.MuiSelect-icon': { color: 'var(--black)', + '&.Mui-disabled': { + color: 'var(--accent-200)', + }, }, '.MuiOutlinedInput-notchedOutline': { borderColor: 'var(--accent-350)', @@ -29,6 +31,4 @@ const SelectStyled = styled(Select)({ borderColor: 'var(--accent-200)', }, }, -}); - -export default SelectStyled; +}) as unknown as typeof Select; diff --git a/src/components/select/index.tsx b/src/components/select/index.tsx index 9ca05adcb2..9a602aca4a 100644 --- a/src/components/select/index.tsx +++ b/src/components/select/index.tsx @@ -1,7 +1,6 @@ -import { FormControl, InputLabel } from '@mui/material'; -import { Theme } from '@mui/material/styles/createTheme'; +import { FormControl, InputLabel, Theme } from '@mui/material'; +import { SelectStyled } from './index.styles'; import { SelectPropsType } from './index.types'; -import SelectStyled from './index.styles'; /** * Custom select component. @@ -11,7 +10,7 @@ import SelectStyled from './index.styles'; */ const Select = (props: SelectPropsType) => { return ( - + { '&.Mui-focused': { color: 'var(--accent-main)' }, '&[data-shrink=false]': { top: `-8px` }, marginTop: '2px', + '&.Mui-disabled': { color: 'var(--accent-200)' }, }} > {props.label} diff --git a/src/components/timefield/index.tsx b/src/components/timefield/index.tsx index 0a4cbec216..3bd0fb418f 100644 --- a/src/components/timefield/index.tsx +++ b/src/components/timefield/index.tsx @@ -22,9 +22,12 @@ const TimeField = (props: TimeFieldProps) => { className: props.className, inputMode: 'numeric', pattern: '[0-9]*', - style: { + sx: { color: - props.value === '0:00' ? 'var(--accent-350)' : 'var(--black)', + props.value.length === 0 || props.value === '0:00' + ? 'var(--accent-350)' + : 'var(--black)', + '&::placeholder': { opacity: 1 }, }, }, }} diff --git a/src/features/congregation/app_access/user_add/person_select/index.tsx b/src/features/congregation/app_access/user_add/person_select/index.tsx index db1dcde588..d10c4ca2c8 100644 --- a/src/features/congregation/app_access/user_add/person_select/index.tsx +++ b/src/features/congregation/app_access/user_add/person_select/index.tsx @@ -88,7 +88,7 @@ const PersonSelect = (props: PersonSelectType) => { )} option.person_name} diff --git a/src/features/congregation/field_service_groups/group_members/index.tsx b/src/features/congregation/field_service_groups/group_members/index.tsx index f7990c756e..ca564b3219 100644 --- a/src/features/congregation/field_service_groups/group_members/index.tsx +++ b/src/features/congregation/field_service_groups/group_members/index.tsx @@ -16,6 +16,8 @@ const GroupMembers = (props: GroupMembersProps) => { members, handleDragChange, handleRemove, + handleInputChange, + inputValue, } = useGroupMembers(props); return ( @@ -47,7 +49,8 @@ const GroupMembers = (props: GroupMembersProps) => { option.person_uid === value?.person_uid } value={null} - inputValue={''} + inputValue={inputValue} + onInputChange={(_, value) => handleInputChange(value)} onChange={(e, value: UsersOption) => handleAddPublisher(value)} renderOption={(props, option) => ( { const groups = useRecoilValue(fieldGroupsState); const [members, setMembers] = useState([]); + const [inputValue, setInputValue] = useState(''); const other_groups_members = useMemo(() => { const otherGroups = groups.filter( @@ -80,7 +81,11 @@ const useGroupMembers = ({ group, onChange }: GroupMembersProps) => { return lastIndex; }; + const handleInputChange = (value: string) => setInputValue(value); + const handleAddPublisher = (value: UsersOption) => { + setInputValue(''); + const newGroup = structuredClone(group); const index = getIndex(); @@ -173,6 +178,8 @@ const useGroupMembers = ({ group, onChange }: GroupMembersProps) => { members, handleDragChange, handleRemove, + handleInputChange, + inputValue, }; }; diff --git a/src/features/ministry/report/ministry_timer/add_time_dialog/useAddTimeDialog.tsx b/src/features/ministry/report/ministry_timer/add_time_dialog/useAddTimeDialog.tsx index 0705235304..ff438105d7 100644 --- a/src/features/ministry/report/ministry_timer/add_time_dialog/useAddTimeDialog.tsx +++ b/src/features/ministry/report/ministry_timer/add_time_dialog/useAddTimeDialog.tsx @@ -16,10 +16,7 @@ const useAddTimeDialog = ({ onAdd, onClose }: AddTimeDialogProps) => { if (!report) return 0; - if (report.report_data.hours.field_service.length === 0) return 0; - - const [hours, minutes] = report.report_data.hours.field_service.split(':'); - return +hours * 3600 + +minutes * 60; + return report.report_data.timer.value; }, [reports, today]); const [value, setValue] = useState(initialValue); diff --git a/src/features/ministry/report/ministry_timer/useMinistryTimer.tsx b/src/features/ministry/report/ministry_timer/useMinistryTimer.tsx index 534be7dbdf..376632a4dd 100644 --- a/src/features/ministry/report/ministry_timer/useMinistryTimer.tsx +++ b/src/features/ministry/report/ministry_timer/useMinistryTimer.tsx @@ -42,19 +42,8 @@ const useMinistryTimer = () => { return timer.value; } - if (!todayReport) return 0; - - if (todayReport?.report_data.hours.field_service.length === 0) return 0; - - if (todayReport?.report_data.hours.field_service.length > 0) { - const [hours, minutes] = - todayReport.report_data.hours.field_service.split(':'); - - const seconds = +hours * 3600 + +minutes * 60; - - return seconds; - } - }, [timer, todayReport]); + return 0; + }, [timer]); const timerState = useMemo(() => { return timer.state; @@ -99,6 +88,7 @@ const useMinistryTimer = () => { const handleStop = async () => { const report = structuredClone(todayReport); + report.report_data.timer.state = 'not_started'; report.report_data.timer.value = 0; report.report_data.timer.start = 0; @@ -108,7 +98,18 @@ const useMinistryTimer = () => { if (hours > 0 || minutes > 0) { const draftReport = structuredClone(report); - draftReport.report_data.hours.field_service = `${hours}:${String(minutes).padStart(2, '0')}`; + const current = draftReport.report_data.hours.field_service; + const [prevHours, prevMinutes] = current.split(':').map(Number); + + let newHours = prevHours + hours; + let newMinutes = (prevMinutes || 0) + minutes; + + if (newMinutes >= 60) { + newHours++; + newMinutes = newMinutes - 60; + } + + draftReport.report_data.hours.field_service = `${newHours}:${String(newMinutes).padStart(2, '0')}`; await handleSaveDailyFieldServiceReport(draftReport); @@ -146,15 +147,6 @@ const useMinistryTimer = () => { const handleCloseSlider = () => setSliderOpen(false); const handleTimeAdded = async (value: number) => { - // Convert seconds to hours, minutes, and seconds - const seconds = value % 60; - - const minutesTotal = (value - seconds) / 60; - const minutes = minutesTotal % 60; - - const hoursTotal = value - seconds - minutes * 60; - const hours = hoursTotal / 3600; - setTime(value); let report: UserFieldServiceDailyReportType; @@ -172,7 +164,6 @@ const useMinistryTimer = () => { report.report_data.timer.value = value; report.report_data.timer.state = 'started'; report.report_data.timer.start = Date.now(); - report.report_data.hours.field_service = `${hours}:${String(minutes).padStart(2, '0')}`; report.report_data.updatedAt = new Date().toISOString(); await handleSaveDailyFieldServiceReport(report); diff --git a/src/features/ministry/report/report_form_dialog/service_time/useServiceTime.tsx b/src/features/ministry/report/report_form_dialog/service_time/useServiceTime.tsx index bdea23c38b..68b1660006 100644 --- a/src/features/ministry/report/report_form_dialog/service_time/useServiceTime.tsx +++ b/src/features/ministry/report/report_form_dialog/service_time/useServiceTime.tsx @@ -8,7 +8,6 @@ import { ServiceTimeProps } from './index.types'; import { personIsEnrollmentActive } from '@services/app/persons'; import { handleSaveDailyFieldServiceReport } from '@services/app/user_field_service_reports'; import { hoursCreditsEnabledState } from '@states/settings'; -import { formatDate } from '@services/dateformat'; import useMinistryDailyRecord from '@features/ministry/hooks/useMinistryDailyRecord'; const useServiceTime = ({ onClose }: ServiceTimeProps) => { @@ -28,10 +27,6 @@ const useServiceTime = ({ onClose }: ServiceTimeProps) => { const { hours, bibleStudies, hoursCredit } = useMinistryDailyRecord(currentReport); - const today = useMemo(() => { - return formatDate(new Date(), 'yyyy/MM/dd'); - }, []); - const monthReport = useMemo(() => { if (!currentReport) return; @@ -121,18 +116,6 @@ const useServiceTime = ({ onClose }: ServiceTimeProps) => { try { const report = structuredClone(currentReport); report.report_data._deleted = false; - - if (currentReport.report_date === today) { - const hoursMinutes = currentReport.report_data.hours.field_service; - const [hours, minutes] = hoursMinutes.split(':').map(Number); - - let seconds = hours * 3600; - - if (minutes) seconds += minutes * 60; - - report.report_data.timer.value = seconds; - } - await handleSaveDailyFieldServiceReport(report); onClose(); diff --git a/src/features/ministry/report/standard_editor/index.styles.ts b/src/features/ministry/report/standard_editor/index.styles.ts index 1d8ebed3fd..db7c316f5a 100644 --- a/src/features/ministry/report/standard_editor/index.styles.ts +++ b/src/features/ministry/report/standard_editor/index.styles.ts @@ -22,4 +22,4 @@ export const TextFieldStandard = styled(TextField)({ '.MuiInputAdornment-root': { marginLeft: '0px !important', }, -}); +}) as unknown as typeof TextField; diff --git a/src/features/ministry/report/standard_editor/index.tsx b/src/features/ministry/report/standard_editor/index.tsx index a5727246ce..e7ae37c965 100644 --- a/src/features/ministry/report/standard_editor/index.tsx +++ b/src/features/ministry/report/standard_editor/index.tsx @@ -37,10 +37,15 @@ const StandardEditor = (props: TextFieldStandardProps) => { type="number" value={inputValue} onChange={handleValueChange} - inputProps={{ - className: props.className || 'h2', - style: { - color: inputValue === 0 ? 'var(--accent-350)' : 'var(--black)', + slotProps={{ + htmlInput: { + className: props.className || 'h2', + inputMode: 'numeric', + pattern: '[0-9]*', + style: { + color: + inputValue === 0 ? 'var(--accent-350)' : 'var(--black)', + }, }, }} /> diff --git a/src/features/persons/assignment_group/useAssignmentGroup.tsx b/src/features/persons/assignment_group/useAssignmentGroup.tsx index a4fc461fe9..2eae3de070 100644 --- a/src/features/persons/assignment_group/useAssignmentGroup.tsx +++ b/src/features/persons/assignment_group/useAssignmentGroup.tsx @@ -5,13 +5,17 @@ import { personCurrentDetailsState } from '@states/persons'; import { useRecoilValue } from 'recoil'; const useAssignmentGroup = (male: boolean) => { - const person = useRecoilValue(personCurrentDetailsState); const { t } = useAppTranslation(); + const person = useRecoilValue(personCurrentDetailsState); + const checkGroupDisabled = (id: string) => { let isDisabled = true; if (id === 'ministry') { + const isFR = personIsFR(person); + if (isFR) return false; + const isPublisher = personIsPublisher(person); return !isPublisher; } @@ -28,11 +32,42 @@ const useAssignmentGroup = (male: boolean) => { const checkAssignmentDisabled = (code: AssignmentCode) => { let isDisabled = true; + const assignments = person.person_data.assignments.filter( + (record) => !record._deleted + ); + if (code === AssignmentCode.MINISTRY_HOURS_CREDIT) { const isFR = personIsFR(person); return !isFR; } + if (code === AssignmentCode.MM_AssistantOnly) { + if ( + assignments.some( + (record) => + (record.code >= AssignmentCode.MM_StartingConversation && + record.code <= AssignmentCode.MM_Discussion) || + record.code == AssignmentCode.MM_Talk + ) + ) { + return true; + } + } + + if ( + (code >= AssignmentCode.MM_StartingConversation && + code <= AssignmentCode.MM_Discussion) || + code === AssignmentCode.MM_Talk + ) { + if ( + assignments.some( + (record) => record.code === AssignmentCode.MM_AssistantOnly + ) + ) { + return true; + } + } + if (male) isDisabled = false; if (!male) { @@ -55,7 +90,7 @@ const useAssignmentGroup = (male: boolean) => { }; const isDisabledByGender = (id: string) => { - return !male && id !== 'applyFieldMinistryPart'; + return !male && id !== 'applyFieldMinistryPart' && id !== 'ministry'; }; const getTooltipsForAssignmentTitles = ( diff --git a/src/features/persons/assignments/useAssignments.tsx b/src/features/persons/assignments/useAssignments.tsx index a612039d19..cb467e06a7 100644 --- a/src/features/persons/assignments/useAssignments.tsx +++ b/src/features/persons/assignments/useAssignments.tsx @@ -148,6 +148,7 @@ const useAssignments = () => { const current = newPerson.person_data.assignments.find( (record) => record.code === item.code ); + if (!current) { newPerson.person_data.assignments.push({ code: item.code, diff --git a/src/features/persons/speakers_catalog/my_congregation/speaker_edit/index.tsx b/src/features/persons/speakers_catalog/my_congregation/speaker_edit/index.tsx index f99fb5c509..6193dc0a46 100644 --- a/src/features/persons/speakers_catalog/my_congregation/speaker_edit/index.tsx +++ b/src/features/persons/speakers_catalog/my_congregation/speaker_edit/index.tsx @@ -118,6 +118,21 @@ const SpeakerEditView = ({ speaker }: SpeakerEditViewType) => { getOptionLabel={(option: PublicTalkType) => option.talk_number.toString() } + filterOptions={(options, params) => { + const inputValue = params.inputValue.toLowerCase(); + + return options.filter((record) => { + const numberMatch = record.talk_number + .toString() + .includes(inputValue); + + const titleMatch = record.talk_title + .toLowerCase() + .includes(inputValue); + + return numberMatch || titleMatch; + }); + }} value={selectedTalks} onChange={(e, value: PublicTalkType[]) => handleTalksUpdate(value)} renderOption={(props, option) => ( diff --git a/src/features/reminders/useReminders.tsx b/src/features/reminders/useReminders.tsx index f24c0cebb0..b1bd2f4d99 100644 --- a/src/features/reminders/useReminders.tsx +++ b/src/features/reminders/useReminders.tsx @@ -8,6 +8,7 @@ import { branchFieldReportsState } from '@states/branch_field_service_reports'; import useCurrentUser from '@hooks/useCurrentUser'; import useMinistryMonthlyRecord from '@features/ministry/hooks/useMinistryMonthlyRecord'; import usePerson from '@features/persons/hooks/usePerson'; +import { secretaryRoleState } from '@states/settings'; const useReminders = () => { const { t } = useAppTranslation(); @@ -16,11 +17,12 @@ const useReminders = () => { const currentReport = useMemo(() => currentReportMonth(), []); - const { isSecretary, person } = useCurrentUser(); + const { person } = useCurrentUser(); const { status } = useMinistryMonthlyRecord(currentReport); const branchReports = useRecoilValue(branchFieldReportsState); + const isSecretary = useRecoilValue(secretaryRoleState); const [reminders, setReminders] = useState([]); diff --git a/src/features/reports/field_service/persons_list/usePersonsList.tsx b/src/features/reports/field_service/persons_list/usePersonsList.tsx index a1adcfb53a..3672a987a8 100644 --- a/src/features/reports/field_service/persons_list/usePersonsList.tsx +++ b/src/features/reports/field_service/persons_list/usePersonsList.tsx @@ -1,5 +1,5 @@ import { useEffect, useMemo } from 'react'; -import { useRecoilState, useRecoilValue } from 'recoil'; +import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'; import { useBreakpoints } from '@hooks/index'; import { AssignmentCode } from '@definition/assignment'; import { @@ -7,6 +7,7 @@ import { personFilterFieldServiceReportState, personSearchFieldServiceReportState, selectedMonthFieldServiceReportState, + selectedPublisherReportState, } from '@states/field_service_reports'; import { PersonType } from '@definition/person'; import { CongFieldServiceReportType } from '@definition/cong_field_service_reports'; @@ -39,6 +40,8 @@ const usePersonsList = () => { personSearchFieldServiceReportState ); + const setSelectedPublisher = useSetRecoilState(selectedPublisherReportState); + const currentFilter = useRecoilValue(personFilterFieldServiceReportState); const currentMonth = useRecoilValue(selectedMonthFieldServiceReportState); const reports = useRecoilValue(congFieldServiceReportsState); @@ -310,6 +313,12 @@ const usePersonsList = () => { const handleSearchChange = (value: string) => setSearch(value); + useEffect(() => { + if (persons.length === 0) { + setSelectedPublisher(undefined); + } + }, [persons, setSelectedPublisher]); + useEffect(() => { setTimeout(() => { if (!desktopUp) { diff --git a/src/features/reports/publisher_records/years_stats/useYearsStats.tsx b/src/features/reports/publisher_records/years_stats/useYearsStats.tsx index c1e433b630..3fab262d1c 100644 --- a/src/features/reports/publisher_records/years_stats/useYearsStats.tsx +++ b/src/features/reports/publisher_records/years_stats/useYearsStats.tsx @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { buildServiceYearsList, currentReportMonth } from '@utils/date'; +import { buildServiceYearsList, currentServiceYear } from '@utils/date'; import YearDetails from './year_details'; const useYearsStats = () => { @@ -10,8 +10,7 @@ const useYearsStats = () => { }, []); const intial_value = useMemo(() => { - const month = currentReportMonth(); - const year = month.split('/')[0]; + const year = currentServiceYear(); const findIndex = serviceYears.findIndex((record) => record.year === year); return findIndex; diff --git a/src/features/reports/publisher_records_details/month_item/index.tsx b/src/features/reports/publisher_records_details/month_item/index.tsx index e36a9fae67..872f9a10b7 100644 --- a/src/features/reports/publisher_records_details/month_item/index.tsx +++ b/src/features/reports/publisher_records_details/month_item/index.tsx @@ -7,6 +7,7 @@ import Badge from '@components/badge'; import IconButton from '@components/icon_button'; import MonthDetails from '../month_details'; import ReportDetails from '../report_details'; +import Tooltip from '@components/tooltip'; import Typography from '@components/typography'; const MonthItem = (props: MonthItemProps) => { @@ -30,90 +31,106 @@ const MonthItem = (props: MonthItemProps) => { handleCloseEditor, handleOpenEditor, mobileShowEdit, + not_publisher, + report_locked, } = useMonthItem(props); return ( - - {editorOpen && ( - - )} + + + {editorOpen && ( + + )} - - - {!isCurrent && !isAhead && monthStatus === 'shared' && ( - - )} - {!isCurrent && !isAhead && monthStatus === 'not_shared' && ( - - )} + + + {!isCurrent && !isAhead && monthStatus === 'shared' && ( + + )} + + {!isCurrent && !isAhead && monthStatus === 'not_shared' && ( + + )} - - {monthname} - + + {monthname} + - {isAP && ( - + )} + + + {laptopDown && ( + )} - - {laptopDown && ( - - )} + {!isCurrent && !isAhead && comments.length > 0 && ( + + {comments} + + )} + - {!isCurrent && !isAhead && comments.length > 0 && ( - - {comments} - - )} - + + {!report_locked && (showEdit || (laptopDown && mobileShowEdit)) && ( + + + + )} - - {(showEdit || (laptopDown && mobileShowEdit)) && ( - - - - )} + {report_locked && (showEdit || (laptopDown && mobileShowEdit)) && ( + + + + + + )} - {!laptopDown && ( - - )} + {!laptopDown && ( + + )} + - + ); }; diff --git a/src/features/reports/publisher_records_details/month_item/useMonthItem.tsx b/src/features/reports/publisher_records_details/month_item/useMonthItem.tsx index 02e63a322d..1dbd89f440 100644 --- a/src/features/reports/publisher_records_details/month_item/useMonthItem.tsx +++ b/src/features/reports/publisher_records_details/month_item/useMonthItem.tsx @@ -29,6 +29,12 @@ const useMonthItem = ({ month, person }: MonthItemProps) => { return branchReports.find((record) => record.report_date === month); }, [branchReports, month]); + const branch_report_submitted = useMemo(() => { + if (!branchReport) return; + + return branchReport.report_data.submitted; + }, [branchReport]); + const report = useMemo(() => { if (!person) return; @@ -56,16 +62,22 @@ const useMonthItem = ({ month, person }: MonthItemProps) => { return month > current; }, [month]); - const monthStatus: MonthStatusType = useMemo(() => { - if (!first_report || first_report?.length === 0) return; + const not_publisher = useMemo(() => { + if (!first_report || first_report?.length === 0) return true; + + if (month < first_report) return true; + + return false; + }, [first_report, month]); - if (month < first_report) return; + const monthStatus: MonthStatusType = useMemo(() => { + if (not_publisher) return; if (!report) return 'not_shared'; const status = report.report_data.shared_ministry ? 'shared' : 'not_shared'; return status; - }, [month, first_report, report]); + }, [report, not_publisher]); const isAP = useMemo(() => { return personIsEnrollmentActive(person, 'AP', month); @@ -112,16 +124,12 @@ const useMonthItem = ({ month, person }: MonthItemProps) => { if (!branchReport) return true; - if (branchReport.report_data.submitted && monthStatus === 'not_shared') { - return true; - } - - if (!branchReport.report_data.submitted) { - return true; - } + return true; + }, [isInactive, month, first_report, branchReport]); - return false; - }, [isInactive, month, first_report, branchReport, monthStatus]); + const report_locked = useMemo(() => { + return branch_report_submitted && monthStatus === 'shared'; + }, [branch_report_submitted, monthStatus]); const mobileShowEdit = useMemo(() => { if (!allowEdit) return false; @@ -167,6 +175,9 @@ const useMonthItem = ({ month, person }: MonthItemProps) => { handleOpenEditor, handleCloseEditor, mobileShowEdit, + not_publisher, + branch_report_submitted, + report_locked, }; }; diff --git a/src/features/reports/publisher_records_details/report_details/late_report/index.tsx b/src/features/reports/publisher_records_details/report_details/late_report/index.tsx index 3a169aa173..0812098810 100644 --- a/src/features/reports/publisher_records_details/report_details/late_report/index.tsx +++ b/src/features/reports/publisher_records_details/report_details/late_report/index.tsx @@ -1,32 +1,59 @@ -import { Stack } from '@mui/material'; +import { Box, Stack } from '@mui/material'; import { useAppTranslation } from '@hooks/index'; import useLateReport from './useLateReport'; import Checkbox from '@components/checkbox'; import Typography from '@components/typography'; +import { IconInfo } from '@components/icons'; const LateReport = () => { const { t } = useAppTranslation(); - const { show_late, late_sent, checked, handleChecked, readOnly } = - useLateReport(); + const { + show_late, + late_sent, + checked, + handleChecked, + readOnly, + branch_submitted, + } = useLateReport(); if (!show_late) return <>; return ( - - handleChecked(e.target.checked)} - /> - - {late_sent} - + + {branch_submitted && ( + + + + {t('tr_alreadySubmittedWarning')} + + + )} + + + handleChecked(e.target.checked)} + /> + + {late_sent} + + ); }; diff --git a/src/features/reports/publisher_records_details/report_details/late_report/useLateReport.tsx b/src/features/reports/publisher_records_details/report_details/late_report/useLateReport.tsx index 31915590fa..f069faf4d8 100644 --- a/src/features/reports/publisher_records_details/report_details/late_report/useLateReport.tsx +++ b/src/features/reports/publisher_records_details/report_details/late_report/useLateReport.tsx @@ -61,7 +61,14 @@ const useLateReport = () => { setCurrentReport(lateReport); }; - return { show_late, late_sent, checked, handleChecked, readOnly }; + return { + show_late, + late_sent, + checked, + handleChecked, + readOnly, + branch_submitted, + }; }; export default useLateReport; diff --git a/src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx b/src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx index 183963af74..df52473a67 100644 --- a/src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx +++ b/src/features/reports/publisher_records_details/years_stats/useYearsStats.tsx @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { buildServiceYearsList, currentReportMonth } from '@utils/date'; +import { buildServiceYearsList, currentServiceYear } from '@utils/date'; import YearDetails from '../year_details'; const useYearsStats = () => { @@ -9,8 +9,7 @@ const useYearsStats = () => { }, []); const intial_value = useMemo(() => { - const month = currentReportMonth(); - const year = month.split('/')[0]; + const year = currentServiceYear(); const findIndex = serviceYears.findIndex((record) => record.year === year); return findIndex; diff --git a/src/features/reports/service_year_month_selector/month_selector/index.tsx b/src/features/reports/service_year_month_selector/month_selector/index.tsx index 370e25c35d..9e330b7b35 100644 --- a/src/features/reports/service_year_month_selector/month_selector/index.tsx +++ b/src/features/reports/service_year_month_selector/month_selector/index.tsx @@ -19,6 +19,7 @@ const MonthSelector = ({ return (