Skip to content

Commit

Permalink
Added Column names
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Aug 19, 2024
1 parent 81023ba commit c2648a2
Showing 1 changed file with 62 additions and 3 deletions.
65 changes: 62 additions & 3 deletions src/components/Tool/Appeal/List/ContactsList/ContactsList.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
import React from 'react';
import React, { useMemo } from 'react';
import { Grid, Typography } from '@mui/material';
import { Box } from '@mui/system';
import { useTranslation } from 'react-i18next';
import { makeStyles } from 'tss-react/mui';
import { InfiniteList } from 'src/components/InfiniteList/InfiniteList';
import { navBarHeight } from 'src/components/Layouts/Primary/Primary';
import NullState from 'src/components/Shared/Filters/NullState/NullState';
import { headerHeight } from 'src/components/Shared/Header/ListHeader';
import theme from 'src/theme';
import {
AppealHeaderInfo,
appealHeaderInfoHeight,
} from '../../AppealDetails/AppealHeaderInfo';
import { AppealQuery } from '../../AppealDetails/AppealsMainPanel/appealInfo.generated';
import {
AppealStatusEnum,
AppealsContext,
AppealsType,
} from '../../AppealsContext/AppealsContext';
import { ContactRow } from '../ContactRow/ContactRow';

const useStyles = makeStyles()(() => ({
headerContainer: {
borderBottom: `1px solid ${theme.palette.cruGrayLight.main}`,
},
contactHeader: {
padding: theme.spacing(1, 2),
},
givingHeader: {
padding: '8px 16px 8px 30px',
[theme.breakpoints.down('md')]: {
padding: '8px 16px 8px 8px',
},
},
}));

interface ContactsListProps {
appealInfo?: AppealQuery;
appealInfoLoading: boolean;
Expand All @@ -24,18 +44,57 @@ export const ContactsList: React.FC<ContactsListProps> = ({
appealInfo,
appealInfoLoading,
}) => {
const { contactsQueryResult, isFiltered, searchTerm, setActiveFilters } =
React.useContext(AppealsContext) as AppealsType;
const { t } = useTranslation();
const { classes } = useStyles();

const {
contactsQueryResult,
isFiltered,
searchTerm,
setActiveFilters,
activeFilters,
contactDetailsOpen,
} = React.useContext(AppealsContext) as AppealsType;

const { data, loading, fetchMore } = contactsQueryResult;

const columnName = useMemo(() => {
let name = t('Regular Giving');
if (
activeFilters.appealStatus === AppealStatusEnum.NotReceived ||
activeFilters.appealStatus === AppealStatusEnum.ReceivedNotProcessed
) {
name = t('Amount Committed');

Check warning on line 67 in src/components/Tool/Appeal/List/ContactsList/ContactsList.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Tool/Appeal/List/ContactsList/ContactsList.tsx#L67

Added line #L67 was not covered by tests
} else if (activeFilters.appealStatus === AppealStatusEnum.Processed) {
name = t('Donation(s)');

Check warning on line 69 in src/components/Tool/Appeal/List/ContactsList/ContactsList.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/Tool/Appeal/List/ContactsList/ContactsList.tsx#L69

Added line #L69 was not covered by tests
}
return name;
}, [activeFilters]);

return (
<>
<AppealHeaderInfo
appealInfo={appealInfo?.appeal}
loading={appealInfoLoading}
/>

<Grid container alignItems="center" className={classes.headerContainer}>
<Grid item xs={10} md={6} className={classes.contactHeader}>
<Typography variant="subtitle1" fontWeight={800}>
{t('Contact')}
</Typography>
</Grid>
<Grid item xs={2} md={6} className={classes.givingHeader}>
<Box justifyContent={contactDetailsOpen ? 'flex-end' : undefined}>
<Box>
<Typography variant="subtitle1" fontWeight={800}>
{columnName}
</Typography>
</Box>
</Box>
</Grid>
</Grid>

<InfiniteList
loading={loading}
data={data?.contacts?.nodes ?? []}
Expand Down

0 comments on commit c2648a2

Please sign in to comment.