Skip to content
Merged
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
152 changes: 83 additions & 69 deletions src/components/Payroll/PayrollOverview/PayrollOverviewPresentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { PayrollFlowAlert } from '../PayrollFlow/PayrollFlowComponents'
import { calculateTotalPayroll } from '../helpers'
import { FastAchSubmissionBlockerBanner, GenericBlocker } from './SubmissionBlockers'
import styles from './PayrollOverviewPresentation.module.scss'
import { DataView, Flex, FlexItem, PayrollLoading } from '@/components/Common'
import { DataView, Flex, Grid, PayrollLoading } from '@/components/Common'
import { useContainerBreakpoints } from '@/hooks/useContainerBreakpoints/useContainerBreakpoints'
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
import { useI18n } from '@/i18n'
Expand Down Expand Up @@ -229,22 +229,24 @@ export const PayrollOverviewPresentation = ({
),
},
]
if (isProcessed) {
if (isProcessed && isDesktop) {
companyPaysColumns.push({
key: 'paystubs',
title: t('tableHeaders.paystub'),
render: (employeeCompensations: EmployeeCompensations) => (
<ButtonIcon
aria-label={t('downloadPaystubLabel')}
variant="tertiary"
onClick={() => {
if (employeeCompensations.employeeUuid) {
onPaystubDownload(employeeCompensations.employeeUuid)
}
}}
>
<DownloadIcon />
</ButtonIcon>
<Flex justifyContent="flex-end">
<ButtonIcon
aria-label={t('downloadPaystubLabel')}
variant="tertiary"
onClick={() => {
if (employeeCompensations.employeeUuid) {
onPaystubDownload(employeeCompensations.employeeUuid)
}
}}
>
<DownloadIcon />
</ButtonIcon>
Comment on lines +238 to +248
Copy link
Member

Choose a reason for hiding this comment

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

Nit: we could probs break this button and the one below into a single variable so that it can get maintained in a single place so if it gets updated it gets update on both

</Flex>
),
})
}
Expand All @@ -257,6 +259,23 @@ export const PayrollOverviewPresentation = ({
label={t('dataViews.companyPaysTable')}
columns={companyPaysColumns}
data={payrollData.employeeCompensations!}
itemMenu={
isProcessed && !isDesktop
? (employeeCompensations: EmployeeCompensations) => (
<ButtonIcon
aria-label={t('downloadPaystubLabel')}
variant="tertiary"
onClick={() => {
if (employeeCompensations.employeeUuid) {
onPaystubDownload(employeeCompensations.employeeUuid)
}
}}
>
<DownloadIcon />
</ButtonIcon>
)
: undefined
}
footer={() => ({
employeeName: (
<>
Expand Down Expand Up @@ -538,16 +557,50 @@ export const PayrollOverviewPresentation = ({
},
]

const actions = isProcessed ? (
<>
<Button onClick={onPayrollReceipt} variant="secondary" isDisabled={isSubmitting}>
{t('payrollReceiptCta')}
</Button>
<Button
onClick={() => {
setIsCancelDialogOpen(true)
}}
variant="error"
isDisabled={isSubmitting}
>
{t('cancelCta')}
</Button>
</>
) : (
<>
<Button onClick={onEdit} variant="secondary" isDisabled={isSubmitting}>
{t('editCta')}
</Button>
<Button
onClick={onSubmit}
isDisabled={
isSubmitting ||
(submissionBlockers.length > 0 &&
(submissionBlockers.some(
blocker =>
!PAYROLL_RESOLVABLE_SUBMISSION_BLOCKER_TYPES.includes(blocker.blockerType || ''),
) ||
submissionBlockers.some(
blocker => !selectedUnblockOptions[blocker.blockerType || ''],
)))
}
>
{t('submitCta')}
</Button>
</>
)

return (
<div ref={containerRef} className={styles.container}>
<Flex flexDirection="column" alignItems="stretch">
<Flex
flexDirection={isDesktop ? 'row' : 'column'}
justifyContent={isDesktop ? 'space-between' : 'normal'}
alignItems={isDesktop ? 'flex-start' : 'stretch'}
gap={isDesktop ? 0 : 16}
>
<FlexItem flexGrow={1}>
<Flex justifyContent="space-between" alignItems="flex-start" gap={16}>
<Flex flexDirection="column" gap={4}>
<Heading as="h1">{isProcessed ? t('summaryTitle') : t('overviewTitle')}</Heading>
<Text>
<Trans
Expand All @@ -557,57 +610,18 @@ export const PayrollOverviewPresentation = ({
values={getPayrollOverviewTitle(payrollData.payPeriod, dateFormatter)}
/>
</Text>
</FlexItem>
<FlexItem flexGrow={isDesktop ? 1 : 0}>
<Flex
flexDirection={isDesktop ? 'row' : 'column'}
justifyContent={isDesktop ? 'flex-end' : 'normal'}
alignItems={isDesktop ? 'flex-start' : 'stretch'}
gap={12}
>
{isProcessed ? (
<>
<Button onClick={onPayrollReceipt} variant="secondary" isDisabled={isSubmitting}>
{t('payrollReceiptCta')}
</Button>
<Button
onClick={() => {
setIsCancelDialogOpen(true)
}}
variant="error"
isDisabled={isSubmitting}
>
{t('cancelCta')}
</Button>
</>
) : (
<>
<Button onClick={onEdit} variant="secondary" isDisabled={isSubmitting}>
{t('editCta')}
</Button>
<Button
onClick={onSubmit}
isDisabled={
isSubmitting ||
(submissionBlockers.length > 0 &&
(submissionBlockers.some(
blocker =>
!PAYROLL_RESOLVABLE_SUBMISSION_BLOCKER_TYPES.includes(
blocker.blockerType || '',
),
) ||
submissionBlockers.some(
blocker => !selectedUnblockOptions[blocker.blockerType || ''],
)))
}
>
{t('submitCta')}
</Button>
</>
)}
</Flex>
{isDesktop && (
<Flex gap={8} justifyContent="flex-end">
{actions}
</Flex>
</FlexItem>
)}
</Flex>
{!isDesktop && (
<Grid gridTemplateColumns="1fr" gap={8}>
{actions}
</Grid>
)}
{isSubmitting ? (
<PayrollLoading title={t('loadingTitle')} description={t('loadingDescription')} />
) : (
Expand Down