Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reports): add tooltip to the late reports #3254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,26 +1,59 @@
import { Stack } from '@mui/material';
import { Box, Stack } from '@mui/material';
import { useAppTranslation } from '@hooks/index';
import { LateReportProps } from './index.types';
import useLateReport from './useLateReport';
import Checkbox from '@components/checkbox';
import Typography from '@components/typography';
import Tooltip from '@components/tooltip';
import { IconHelpFilled } from '@components/icons';

const LateReport = ({ person }: LateReportProps) => {
const { t } = useAppTranslation();

const { show_late, late_sent, checked, handleChecked, readOnly } =
useLateReport(person);
const {
show_late,
late_sent,
checked,
handleChecked,
readOnly,
setLateCheckboxHelpIsHovered,
lateCheckboxHelpIsHovered,
} = useLateReport(person);

return (
<>
{show_late && (
<Stack spacing="4px" alignItems="flex-end">
<Checkbox
readOnly={readOnly}
label={t('tr_lateReport')}
checked={checked}
onChange={(e) => handleChecked(e.target.checked)}
/>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Checkbox
readOnly={readOnly}
label={t('tr_lateReport')}
checked={checked}
onChange={(e) => handleChecked(e.target.checked)}
sx={{ marginRight: '4px' }}
/>
<Tooltip title={t('tr_lateReportTooltip')} placement="bottom-start">
<Box
onMouseEnter={() => setLateCheckboxHelpIsHovered(true)}
onMouseLeave={() => setLateCheckboxHelpIsHovered(false)}
sx={{
display: 'flex',
alignItems: 'center',
}}
>
<IconHelpFilled
width={16}
height={16}
color={
lateCheckboxHelpIsHovered
? 'var(--accent-main)'
: 'var(--black)'
}
/>
</Box>
</Tooltip>
</Box>

<Typography
align="right"
className="label-small-medium"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const useLateReport = (person: PersonType) => {
const shortDateFormat = useRecoilValue(shortDateFormatState);
const branchReports = useRecoilValue(branchFieldReportsState);

const [lateCheckboxHelpIsHovered, setLateCheckboxHelpIsHovered] =
useState(false);

const branch_submitted = useMemo(() => {
const report = branchReports.find(
(record) => record.report_date === currentMonth
Expand Down Expand Up @@ -127,7 +130,15 @@ const useLateReport = (person: PersonType) => {
}
};

return { show_late, late_sent, checked, handleChecked, readOnly };
return {
show_late,
late_sent,
checked,
handleChecked,
readOnly,
setLateCheckboxHelpIsHovered,
lateCheckboxHelpIsHovered,
};
};

export default useLateReport;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { useAppTranslation } from '@hooks/index';
import useLateReport from './useLateReport';
import Checkbox from '@components/checkbox';
import Typography from '@components/typography';
import { IconInfo } from '@components/icons';
import { IconHelpFilled, IconInfo } from '@components/icons';
import Tooltip from '@components/tooltip';

const LateReport = () => {
const { t } = useAppTranslation();
Expand All @@ -15,6 +16,8 @@ const LateReport = () => {
handleChecked,
readOnly,
branch_submitted,
lateCheckboxHelpIsHovered,
setLateCheckboxHelpIsHovered,
} = useLateReport();

if (!show_late) return <></>;
Expand All @@ -40,12 +43,35 @@ const LateReport = () => {
)}

<Stack spacing="4px">
<Checkbox
readOnly={readOnly}
label={t('tr_lateReport')}
checked={checked}
onChange={(e) => handleChecked(e.target.checked)}
/>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<Checkbox
readOnly={readOnly}
label={t('tr_lateReport')}
checked={checked}
onChange={(e) => handleChecked(e.target.checked)}
sx={{ marginRight: '4px' }}
/>
<Tooltip title={t('tr_lateReportTooltip')} placement="bottom-start">
<Box
onMouseEnter={() => setLateCheckboxHelpIsHovered(true)}
onMouseLeave={() => setLateCheckboxHelpIsHovered(false)}
sx={{
display: 'flex',
alignItems: 'center',
}}
>
<IconHelpFilled
width={16}
height={16}
color={
lateCheckboxHelpIsHovered
? 'var(--accent-main)'
: 'var(--black)'
}
/>
</Box>
</Tooltip>
</Box>
<Typography
align="right"
className="label-small-medium"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react';
import { useMemo, useState } from 'react';
import { useRecoilState, useRecoilValue } from 'recoil';
import { useAppTranslation } from '@hooks/index';
import { publisherCurrentReportState } from '@states/field_service_reports';
Expand All @@ -13,6 +13,9 @@ const useLateReport = () => {
publisherCurrentReportState
);

const [lateCheckboxHelpIsHovered, setLateCheckboxHelpIsHovered] =
useState(false);

const shortDateFormat = useRecoilValue(shortDateFormatState);
const branchReports = useRecoilValue(branchFieldReportsState);

Expand Down Expand Up @@ -68,6 +71,8 @@ const useLateReport = () => {
handleChecked,
readOnly,
branch_submitted,
lateCheckboxHelpIsHovered,
setLateCheckboxHelpIsHovered,
};
};

Expand Down
3 changes: 2 additions & 1 deletion src/locales/en/congregation.json
Original file line number Diff line number Diff line change
Expand Up @@ -454,5 +454,6 @@
"tr_importDataConfirmDesc": "Select the data you want to import to replace your records in Organized",
"tr_importDataCompleted": "Import completed",
"tr_importDataCompletedDesc": "Your data has been imported successfully. Organized app will now reload.",
"tr_markDisqualifiedTitle": "Mark as disqualified"
"tr_markDisqualifiedTitle": "Mark as disqualified",
"tr_lateReportTooltip": "Mark a report as 'Late' if the monthly branch office report has already been submitted. Late report will automatically be included in next month's submission."
}
Loading