Skip to content

Commit

Permalink
refactor: add changes requested in pr
Browse files Browse the repository at this point in the history
  • Loading branch information
seandreassen committed Nov 4, 2024
1 parent 07a57ce commit 8f70617
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
2 changes: 1 addition & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"scheduleCell": {
"onShift": "{count, plural, =0 {Closed} =1 {1 person on shift} other {# people on shift}}",
"scheduleCellDialog": {
"empty": "No-one on shift",
"empty": "No one on shift",
"registerSection": {
"recurring": "Recurring",
"register": "Register"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Label } from '@/components/ui/Label';
import { cx } from '@/lib/utils';
import { useTranslations } from 'next-intl';

function RegisterSection({ className }: { className?: string }) {
function RegisterShift({ className }: { className?: string }) {
const t = useTranslations(
'shiftSchedule.scheduleTable.scheduleCell.scheduleCellDialog.registerSection',
);
Expand All @@ -20,4 +20,4 @@ function RegisterSection({ className }: { className?: string }) {
);
}

export { RegisterSection };
export { RegisterShift };
8 changes: 2 additions & 6 deletions src/components/shift-schedule/ScheduleCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,14 @@ function ScheduleCell({ tDialog, members }: ScheduleCellProps) {
{/* Icon displaying amount of people on shift */}
{members.length === 1 ? (
<UserIcon className='size-7' />
) : members.length > 1 ? (
<UsersIcon className='size-7' />
) : (
<></>
members.length > 1 && <UsersIcon className='size-7' />
)}
<div className='flex flex-col'>
{/* Amount of people on shift */}
<span>{t('onShift', { count: members.length })}</span>
{/* Skill icons */}
{members.length === 0 ? (
<></>
) : (
{members.length !== 0 && (
<span className='leading-7'>[skill icons total]</span>
)}
</div>
Expand Down
34 changes: 14 additions & 20 deletions src/components/shift-schedule/ScheduleCellDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RegisterSection } from '@/components/shift-schedule/RegisterSection';
import { RegisterShift } from '@/components/shift-schedule/RegisterShift';
import { DialogHeader, DialogTitle } from '@/components/ui/Dialog';
import { useTranslations } from 'next-intl';

Expand All @@ -17,23 +17,6 @@ function ScheduleCellDialog({ tDialog, members }: ScheduleCellDialogProps) {
'shiftSchedule.scheduleTable.scheduleCell.scheduleCellDialog',
);

let membersDisplay: React.ReactNode;

if (members.length === 0) {
membersDisplay = <p className='leading-tight'>{t('empty')}</p>;
} else {
membersDisplay = (
<div>
{members.map((member) => (
<section key={member.name} className='mb-3 last:mb-0'>
<p className='leading-tight'>{member.name}</p>
<section className='mt-0.5 ml-5'>[skill icons]</section>
</section>
))}
</div>
);
}

return (
<>
<DialogHeader>
Expand All @@ -43,8 +26,19 @@ function ScheduleCellDialog({ tDialog, members }: ScheduleCellDialogProps) {
</DialogTitle>
</DialogHeader>
<div className='flex justify-between gap-8 px-1.5 pb-1.5'>
{membersDisplay}
<RegisterSection className='mt-auto min-w-fit' />
{members.length === 0 ? (
<p className='leading-tight'>{t('empty')}</p>
) : (
<div>
{members.map((member) => (
<section key={member.name} className='mb-3 last:mb-0'>
<p className='leading-tight'>{member.name}</p>
<section className='mt-0.5 ml-5'>[skill icons]</section>
</section>
))}
</div>
)}
<RegisterShift className='mt-auto min-w-fit' />
</div>
</>
);
Expand Down

0 comments on commit 8f70617

Please sign in to comment.