Skip to content

Commit

Permalink
feat(corpus): [MC-1446] Add new 'Publisher Request' rejection reason
Browse files Browse the repository at this point in the history
  • Loading branch information
nina-py committed Sep 6, 2024
1 parent 437c01f commit 2811b2b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/api/generatedTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,7 @@ export enum RejectionReason {
Paywall = 'PAYWALL',
PoliticalOpinion = 'POLITICAL_OPINION',
PublisherQuality = 'PUBLISHER_QUALITY',
PublisherRequest = 'PUBLISHER_REQUEST',
TimeSensitive = 'TIME_SENSITIVE',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ describe('The RejectItemForm component', () => {
render(<RejectItemForm onSubmit={handleSubmit} />);

const checkboxes = screen.getAllByRole('checkbox');
// We have six rejection reasons. They come from an enum in the Curated Corpus
// We have seven rejection reasons. They come from an enum in the Curated Corpus
// API schema - RejectionReason and are available through the codegen types.
expect(checkboxes).toHaveLength(6);
expect(checkboxes).toHaveLength(7);

const buttons = screen.getAllByRole('button');
// "Save" and "Cancel" buttons are expected here.
Expand Down
20 changes: 16 additions & 4 deletions src/curated-corpus/components/RejectItemForm/RejectItemForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const RejectItemForm: React.FC<
[RejectionReason.OffensiveMaterial]: false,
[RejectionReason.TimeSensitive]: false,
[RejectionReason.Misinformation]: false,
[RejectionReason.PublisherRequest]: false,
[RejectionReason.Other]: false,
reason: '',
},
Expand Down Expand Up @@ -97,10 +98,6 @@ export const RejectItemForm: React.FC<
}
label="Offensive material"
/>
</FormGroup>
</Grid>
<Grid item xs={12} sm={6}>
<FormGroup>
<FormControlLabel
control={
<Checkbox
Expand All @@ -112,6 +109,10 @@ export const RejectItemForm: React.FC<
}
label="Time sensitive"
/>
</FormGroup>
</Grid>
<Grid item xs={12} sm={6}>
<FormGroup>
<FormControlLabel
control={
<Checkbox
Expand All @@ -123,6 +124,17 @@ export const RejectItemForm: React.FC<
}
label="Misinformation"
/>
<FormControlLabel
control={
<Checkbox
color="primary"
{...formik.getFieldProps({
name: RejectionReason.PublisherRequest,
})}
/>
}
label="Publisher Request"
/>
<FormControlLabel
control={
<Checkbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const validationSchema = yup
[RejectionReason.OffensiveMaterial]: yup.boolean(),
[RejectionReason.TimeSensitive]: yup.boolean(),
[RejectionReason.Misinformation]: yup.boolean(),
[RejectionReason.PublisherRequest]: yup.boolean(),
[RejectionReason.Other]: yup.boolean(),
})
.test('reason', '', (obj) => {
Expand All @@ -18,6 +19,7 @@ export const validationSchema = yup
obj[RejectionReason.OffensiveMaterial] ||
obj[RejectionReason.TimeSensitive] ||
obj[RejectionReason.Misinformation] ||
obj[RejectionReason.PublisherRequest] ||
obj[RejectionReason.Other]
) {
return true;
Expand Down

0 comments on commit 2811b2b

Please sign in to comment.