Skip to content

Commit

Permalink
refactor: [M3-8442] - Remove Double border on "Billing & Payment Hist…
Browse files Browse the repository at this point in the history
…ory" table without using theme.
  • Loading branch information
hasyed-akamai committed Oct 23, 2024
1 parent cd35039 commit c24adc3
Showing 1 changed file with 32 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { getAll } from 'src/utilities/getAll';
import { getTaxID } from '../../billingUtils';

import type { Invoice, InvoiceItem, Payment } from '@linode/api-v4/lib/account';
import type { Theme } from '@mui/material/styles';
import type { Theme, SxProps } from '@mui/material/styles';

const useStyles = makeStyles()((theme: Theme) => ({
activeSince: {
Expand Down Expand Up @@ -354,34 +354,39 @@ export const BillingActivityPanel = React.memo((props: Props) => {
);
}
if (orderedPaginatedData.length > 0) {
return orderedPaginatedData.map((thisItem) => (
<ActivityFeedItem
downloadPDF={
thisItem.type === 'invoice'
? downloadInvoicePDF
: downloadPaymentPDF
}
hasError={pdfErrors.has(`${thisItem.type}-${thisItem.id}`)}
isLoading={pdfLoading.has(`${thisItem.type}-${thisItem.id}`)}
key={`${thisItem.type}-${thisItem.id}`}
{...thisItem}
/>
));
return orderedPaginatedData.map((thisItem, idx) => {
const lastItem = idx === orderedPaginatedData.length - 1;
return (
<ActivityFeedItem
sxRow={
lastItem
? {
'& .MuiTableCell-root': {
borderBottom: 0,
},
}
: {}
}
downloadPDF={
thisItem.type === 'invoice'
? downloadInvoicePDF
: downloadPaymentPDF
}
hasError={pdfErrors.has(`${thisItem.type}-${thisItem.id}`)}
isLoading={pdfLoading.has(`${thisItem.type}-${thisItem.id}`)}
key={`${thisItem.type}-${thisItem.id}`}
{...thisItem}
/>
);
});
}

return null;
};

return (
<Grid data-qa-billing-activity-panel xs={12}>
<Paper
sx={(theme) => ({
border:
theme.name === 'light'
? `1px solid ${theme.borderColors.divider}`
: 0,
})}
>
<Paper variant="outlined">
<StyledBillingAndPaymentHistoryHeader
className={classes.headerContainer}
>
Expand Down Expand Up @@ -445,7 +450,7 @@ export const BillingActivityPanel = React.memo((props: Props) => {
/>
</div>
</StyledBillingAndPaymentHistoryHeader>
<Table aria-label="List of Invoices and Payments">
<Table aria-label="List of Invoices and Payments" sx={{ border: 0 }}>
<TableHead>
<TableRow>
<TableCell className={classes.descriptionColumn}>
Expand Down Expand Up @@ -482,8 +487,7 @@ export const BillingActivityPanel = React.memo((props: Props) => {

const StyledBillingAndPaymentHistoryHeader = styled('div', {
name: 'BillingAndPaymentHistoryHeader',
})(({ theme }) => ({
border: theme.name === 'dark' ? `1px solid ${theme.borderColors.divider}` : 0,
})(() => ({
borderBottom: 0,
padding: `15px 0px 15px 20px`,
}));
Expand All @@ -495,12 +499,14 @@ interface ActivityFeedItemProps extends ActivityFeedItem {
downloadPDF: (id: number) => void;
hasError: boolean;
isLoading: boolean;
sxRow: SxProps<Theme>;
}

export const ActivityFeedItem = React.memo((props: ActivityFeedItemProps) => {
const { classes } = useStyles();

const {
sxRow,
date,
downloadPDF,
hasError,
Expand All @@ -527,7 +533,7 @@ export const ActivityFeedItem = React.memo((props: ActivityFeedItemProps) => {
};

return (
<TableRow data-testid={`${type}-${id}`}>
<TableRow data-testid={`${type}-${id}`} sx={sxRow}>
<TableCell>
{type === 'invoice' ? (
<Link to={`/account/billing/invoices/${id}`}>{label}</Link>
Expand Down

0 comments on commit c24adc3

Please sign in to comment.