Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appeals - Add warning and tooltip to Received title and pledge status dropdown #1203

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
IconButton,
Menu,
MenuItem,
Tooltip,
Typography,
} from '@mui/material';
import { styled } from '@mui/material/styles';
Expand Down Expand Up @@ -163,7 +164,29 @@ export const ContactFlowColumn: React.FC<Props> = ({
<Card>
<ContainerBox p={2} data-testid="column-header" color={color}>
<Box width="80%">
<ColumnTitle variant="h6">{title}</ColumnTitle>
{appealStatus === AppealStatusEnum.ReceivedNotProcessed ? (
<Tooltip
title={
<>
<Typography>
{t(
'Do not move a contact into this column called "Received". Due to an outdated feature, contacts must first be moved to "Committed". If the gift has been recorded, you can then move the contact into the column called "Given".',
)}
</Typography>

<Typography>
{t(
'In a few cases, the contact may automatically move backward from "Given" to "Received" if the processing is not complete. This behavior is due to the current system design, which we plan to update, but the work will take time and needs to be scheduled.',
)}
</Typography>
</>
}
>
<ColumnTitle variant="h6">{title}</ColumnTitle>
</Tooltip>
) : (
<ColumnTitle variant="h6">{title}</ColumnTitle>
)}
</Box>
<Box display="flex" alignItems="center">
<Typography>{data?.contacts.totalCount || 0}</Typography>
Expand Down
43 changes: 43 additions & 0 deletions src/components/Tool/Appeal/Modals/PledgeModal/PledgeModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,47 @@ describe('PledgeModal', () => {
expect(getByRole('option', { name: 'Received' })).toBeInTheDocument();
expect(queryByRole('option', { name: 'Given' })).not.toBeInTheDocument();
});

describe('Warning when switching status to Received', () => {
test.each([
{
testName: 'New Pledge should show warnings',
pledge: undefined,
expectToFindWarnings: true,
},
{
testName: 'Existing Pledge should show warnings',
pledge: {
...defaultPledge,
status: PledgeStatusEnum.NotReceived,
},
expectToFindWarnings: true,
},
{
testName:
'Existing Pledge with status "Received" should not show warnings',
pledge: {
...defaultPledge,
status: PledgeStatusEnum.ReceivedNotProcessed,
},
expectToFindWarnings: false,
},
])('$testName', ({ pledge, expectToFindWarnings }) => {
const { getByRole, queryByTestId } = render(
<Components pledge={pledge} />,
);

userEvent.click(getByRole('combobox', { name: 'Status' }));
userEvent.click(getByRole('option', { name: 'Received' }));

const warning = queryByTestId('received-warnings');
if (expectToFindWarnings) {
// eslint-disable-next-line jest/no-conditional-expect
expect(warning).toBeInTheDocument();
} else {
// eslint-disable-next-line jest/no-conditional-expect
expect(warning).not.toBeInTheDocument();
}
});
});
});
21 changes: 21 additions & 0 deletions src/components/Tool/Appeal/Modals/PledgeModal/PledgeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export const PledgeModal: React.FC<PledgeModalProps> = ({
onSubmit={onSubmit}
>
{({
values: { status },
setFieldValue,
handleSubmit,
isSubmitting,
Expand Down Expand Up @@ -427,6 +428,26 @@ export const PledgeModal: React.FC<PledgeModalProps> = ({
</FormControl>
</Grid>
</Grid>
{status === PledgeStatusEnum.ReceivedNotProcessed &&
initialValues.status !== status && (
<Alert
severity="warning"
sx={{ marginTop: 2 }}
data-testid="received-warnings"
>
<Typography>
{t(
'Do not move a contact into this column called "Received". Due to an outdated feature, contacts must first be moved to "Committed". If the gift has been recorded, you can then move the contact into the column called "Given".',
)}
</Typography>

<Typography>
{t(
'In a few cases, the contact may automatically move backward from "Given" to "Received" if the processing is not complete. This behavior is due to the current system design, which we plan to update, but the work will take time and needs to be scheduled.',
)}
</Typography>
</Alert>
)}
</DialogContent>
<DialogActions>
<CancelButton onClick={handleClose} disabled={isSubmitting} />
Expand Down
Loading