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 23, 2024
1 parent 4c019a0 commit 0d73ade
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions src/components/Tool/Appeal/List/ContactsList/ContactsList.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
import React, { useEffect } from 'react';
import React, { useEffect, 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 @@ -25,15 +44,18 @@ export const ContactsList: React.FC<ContactsListProps> = ({
appealInfo,
appealInfoLoading,
}) => {
const { t } = useTranslation();
const { classes } = useStyles();
const [nullStateTitle, setNullStateTitle] = React.useState<string>('');

const {
contactsQueryResult,
isFiltered,
searchTerm,
setActiveFilters,
activeFilters,
contactDetailsOpen,
} = React.useContext(AppealsContext) as AppealsType;
const { t } = useTranslation();
const [nullStateTitle, setNullStateTitle] = React.useState<string>('');

const { data, loading, fetchMore } = contactsQueryResult;

Expand Down Expand Up @@ -71,13 +93,43 @@ export const ContactsList: React.FC<ContactsListProps> = ({
}
}, [activeFilters]);

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 102 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#L102

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

Check warning on line 104 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#L104

Added line #L104 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 0d73ade

Please sign in to comment.