Skip to content

Commit 03c0d59

Browse files
committed
fix: updated to move download icon position on card
1 parent 245891d commit 03c0d59

File tree

1 file changed

+69
-59
lines changed

1 file changed

+69
-59
lines changed

src/components/Payroll/PayrollOverview/PayrollOverviewPresentation.tsx

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { PayrollFlowAlert } from '../PayrollFlow/PayrollFlowComponents'
1212
import { calculateTotalPayroll } from '../helpers'
1313
import { FastAchSubmissionBlockerBanner, GenericBlocker } from './SubmissionBlockers'
1414
import styles from './PayrollOverviewPresentation.module.scss'
15-
import { DataView, Flex, FlexItem, PayrollLoading } from '@/components/Common'
15+
import { ActionsLayout, DataView, Flex, PayrollLoading } from '@/components/Common'
1616
import { useContainerBreakpoints } from '@/hooks/useContainerBreakpoints/useContainerBreakpoints'
1717
import { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'
1818
import { useI18n } from '@/i18n'
@@ -229,7 +229,7 @@ export const PayrollOverviewPresentation = ({
229229
),
230230
},
231231
]
232-
if (isProcessed) {
232+
if (isProcessed && isDesktop) {
233233
companyPaysColumns.push({
234234
key: 'paystubs',
235235
title: t('tableHeaders.paystub'),
@@ -259,6 +259,23 @@ export const PayrollOverviewPresentation = ({
259259
label={t('dataViews.companyPaysTable')}
260260
columns={companyPaysColumns}
261261
data={payrollData.employeeCompensations!}
262+
itemMenu={
263+
isProcessed && !isDesktop
264+
? (employeeCompensations: EmployeeCompensations) => (
265+
<ButtonIcon
266+
aria-label={t('downloadPaystubLabel')}
267+
variant="tertiary"
268+
onClick={() => {
269+
if (employeeCompensations.employeeUuid) {
270+
onPaystubDownload(employeeCompensations.employeeUuid)
271+
}
272+
}}
273+
>
274+
<DownloadIcon />
275+
</ButtonIcon>
276+
)
277+
: undefined
278+
}
262279
footer={() => ({
263280
employeeName: (
264281
<>
@@ -540,16 +557,56 @@ export const PayrollOverviewPresentation = ({
540557
},
541558
]
542559

560+
const actions = (
561+
<ActionsLayout justifyContent="end">
562+
{isProcessed ? (
563+
<>
564+
<Button onClick={onPayrollReceipt} variant="secondary" isDisabled={isSubmitting}>
565+
{t('payrollReceiptCta')}
566+
</Button>
567+
<Button
568+
onClick={() => {
569+
setIsCancelDialogOpen(true)
570+
}}
571+
variant="error"
572+
isDisabled={isSubmitting}
573+
>
574+
{t('cancelCta')}
575+
</Button>
576+
</>
577+
) : (
578+
<>
579+
<Button onClick={onEdit} variant="secondary" isDisabled={isSubmitting}>
580+
{t('editCta')}
581+
</Button>
582+
<Button
583+
onClick={onSubmit}
584+
isDisabled={
585+
isSubmitting ||
586+
(submissionBlockers.length > 0 &&
587+
(submissionBlockers.some(
588+
blocker =>
589+
!PAYROLL_RESOLVABLE_SUBMISSION_BLOCKER_TYPES.includes(
590+
blocker.blockerType || '',
591+
),
592+
) ||
593+
submissionBlockers.some(
594+
blocker => !selectedUnblockOptions[blocker.blockerType || ''],
595+
)))
596+
}
597+
>
598+
{t('submitCta')}
599+
</Button>
600+
</>
601+
)}
602+
</ActionsLayout>
603+
)
604+
543605
return (
544606
<div ref={containerRef} className={styles.container}>
545607
<Flex flexDirection="column" alignItems="stretch">
546-
<Flex
547-
flexDirection={isDesktop ? 'row' : 'column'}
548-
justifyContent={isDesktop ? 'space-between' : 'normal'}
549-
alignItems={isDesktop ? 'flex-start' : 'stretch'}
550-
gap={isDesktop ? 0 : 16}
551-
>
552-
<FlexItem flexGrow={1}>
608+
<Flex justifyContent="space-between" alignItems="flex-start" gap={16}>
609+
<Flex flexDirection="column" gap={4}>
553610
<Heading as="h1">{isProcessed ? t('summaryTitle') : t('overviewTitle')}</Heading>
554611
<Text>
555612
<Trans
@@ -559,57 +616,10 @@ export const PayrollOverviewPresentation = ({
559616
values={getPayrollOverviewTitle(payrollData.payPeriod, dateFormatter)}
560617
/>
561618
</Text>
562-
</FlexItem>
563-
<FlexItem flexGrow={isDesktop ? 1 : 0}>
564-
<Flex
565-
flexDirection={isDesktop ? 'row' : 'column'}
566-
justifyContent={isDesktop ? 'flex-end' : 'normal'}
567-
alignItems={isDesktop ? 'flex-start' : 'stretch'}
568-
gap={12}
569-
>
570-
{isProcessed ? (
571-
<>
572-
<Button onClick={onPayrollReceipt} variant="secondary" isDisabled={isSubmitting}>
573-
{t('payrollReceiptCta')}
574-
</Button>
575-
<Button
576-
onClick={() => {
577-
setIsCancelDialogOpen(true)
578-
}}
579-
variant="error"
580-
isDisabled={isSubmitting}
581-
>
582-
{t('cancelCta')}
583-
</Button>
584-
</>
585-
) : (
586-
<>
587-
<Button onClick={onEdit} variant="secondary" isDisabled={isSubmitting}>
588-
{t('editCta')}
589-
</Button>
590-
<Button
591-
onClick={onSubmit}
592-
isDisabled={
593-
isSubmitting ||
594-
(submissionBlockers.length > 0 &&
595-
(submissionBlockers.some(
596-
blocker =>
597-
!PAYROLL_RESOLVABLE_SUBMISSION_BLOCKER_TYPES.includes(
598-
blocker.blockerType || '',
599-
),
600-
) ||
601-
submissionBlockers.some(
602-
blocker => !selectedUnblockOptions[blocker.blockerType || ''],
603-
)))
604-
}
605-
>
606-
{t('submitCta')}
607-
</Button>
608-
</>
609-
)}
610-
</Flex>
611-
</FlexItem>
619+
</Flex>
620+
{isDesktop && actions}
612621
</Flex>
622+
{!isDesktop && actions}
613623
{isSubmitting ? (
614624
<PayrollLoading title={t('loadingTitle')} description={t('loadingDescription')} />
615625
) : (

0 commit comments

Comments
 (0)