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

Calendar visit types are long - totals not showing #1024

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -112,13 +112,20 @@
border: 1px solid grey;
}

.smallDesktop {
.smallDesktopEmpty {
height: 100px;
}

.largeDesktop {
.largeDesktopEmpty {
height: 150px;
}
.smallDesktop {
height: auto;
}

.largeDesktop {
height: auto;
}

.red {
background-color: colors.$red-70;
Expand Down
Expand Up @@ -26,56 +26,68 @@ const MonthlyWorkloadView: React.FC<MonthlyWorkloadViewProps> = ({ dateTime, eve
const onClick = (serviceUuid) => {
navigate({ to: `${spaHomePage}/appointments/${dayjs(dateTime).format('YYYY-MM-DD')}/${serviceUuid}` });
};

return (
<div
onClick={() => {
onClick('');
}}
className={classNames(
styles[isSameMonth(dateTime, dayjs(selectedDate)) ? 'monthly-cell' : 'monthly-cell-disabled'],
{
[styles.greyBackground]: currentData?.services,
[styles.smallDesktop]: layout === 'small-desktop',
[styles.largeDesktop]: layout !== 'small-desktop',
},
)}>
{isSameMonth(dateTime, dayjs(selectedDate)) && (
<p>
<b className={styles.calendarDate}>{dateTime.format('D')}</b>
{currentData?.services && (
<div className={styles.currentData}>
{currentData.services.map(({ serviceName, serviceUuid, count }, i) => (
if (!currentData) {
return (
<div
className={classNames(
styles[isSameMonth(dateTime, dayjs(selectedDate)) ? 'monthly-cell' : 'monthly-cell-disabled'],
{
[styles.greyBackground]: currentData?.services,
[styles.smallDesktopEmpty]: layout === 'small-desktop',
[styles.largeDesktopEmpty]: layout !== 'small-desktop',
},
)}>
{isSameMonth(dateTime, dayjs(selectedDate)) && <b className={styles.calendarDate}>{dateTime.format('D')}</b>}
</div>
);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a single check for currentData while calling isSameMonth() should be fine, no need for if-else clause.
Rest looks great.

return (
<div
className={classNames(
styles[isSameMonth(dateTime, dayjs(selectedDate)) ? 'monthly-cell' : 'monthly-cell-disabled'],
{
[styles.greyBackground]: currentData?.services,
[styles.smallDesktop]: layout === 'small-desktop',
[styles.largeDesktop]: layout !== 'small-desktop',
},
)}>
{isSameMonth(dateTime, dayjs(selectedDate)) && (
<p>
<b className={styles.calendarDate}>{dateTime.format('D')}</b>
{currentData?.services && (
<div className={styles.currentData}>
{currentData.services.map(({ serviceName, serviceUuid, count }, i) => (
<div
key={`${serviceUuid}-${count}-${i}`}
role="button"
tabIndex={0}
onClick={(e) => {
e.stopPropagation();
onClick(serviceUuid);
}}
className={styles.serviceArea}>
<span>{serviceName}</span>
<span>{count}</span>
</div>
))}
<div
key={`${serviceUuid}-${count}-${i}`}
role="button"
tabIndex={0}
onClick={(e) => {
e.stopPropagation();
onClick(serviceUuid);
onClick('');
}}
className={styles.serviceArea}>
<span>{serviceName}</span>
<span>{count}</span>
className={classNames(styles.serviceArea, styles.green)}>
<span>{t('total', 'Total')}</span>
<span>{currentData?.services.reduce((sum, { count = 0 }) => sum + count, 0)}</span>
</div>
))}
<div
role="button"
tabIndex={0}
onClick={(e) => {
e.stopPropagation();
onClick('');
}}
className={classNames(styles.serviceArea, styles.green)}>
<span>{t('total', 'Total')}</span>
<span>{currentData?.services.reduce((sum, { count = 0 }) => sum + count, 0)}</span>
</div>
</div>
)}
</p>
)}
</div>
);
)}
</p>
)}
</div>
);
}
};

export default MonthlyWorkloadView;