Skip to content

Commit a2ad5a1

Browse files
authored
Merge branch 'main' into HNT-1140-remove-subtitle-requirement
2 parents 48883f9 + 6a2b94a commit a2ad5a1

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

src/curated-corpus/components/CustomSectionDetails/CustomSectionDetails.tsx

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from 'react';
22
import { useParams, useHistory } from 'react-router-dom';
3+
import { FormikHelpers, FormikValues } from 'formik';
34
import {
45
Box,
56
Typography,
@@ -23,8 +24,6 @@ import {
2324
SectionStatus,
2425
CreateSectionItemInput,
2526
CreateApprovedCorpusItemInput,
26-
RemoveSectionItemInput,
27-
SectionItemRemovalReason,
2827
useGetSectionsWithSectionItemsQuery,
2928
useCreateSectionItemMutation,
3029
useCreateApprovedCorpusItemMutation,
@@ -43,7 +42,7 @@ import {
4342
DuplicateProspectModal,
4443
EditCustomSectionModal,
4544
DeleteConfirmationModal,
46-
RemoveItemConfirmationModal,
45+
RemoveSectionItemModal,
4746
} from '..';
4847
import { HandleApiResponse } from '../../../_shared/components';
4948
import { useToggle, useRunMutation } from '../../../_shared/hooks';
@@ -686,43 +685,41 @@ export const CustomSectionDetails: React.FC<CustomSectionDetailsProps> = ({
686685
}}
687686
/>
688687

689-
{/* Remove Item Confirmation Modal */}
690-
<RemoveItemConfirmationModal
691-
open={removeItemModalOpen}
692-
onClose={() => {
693-
toggleRemoveItemModal();
694-
setItemToRemove(undefined);
695-
}}
696-
onConfirm={async () => {
697-
if (itemToRemove) {
698-
// TODO(HNT-1126): Align this removal flow with the ML section modal so editors
699-
// can pick from the standardized removal reasons instead of defaulting to Other.
700-
const input: RemoveSectionItemInput = {
701-
externalId: itemToRemove.externalId,
702-
deactivateReasons: [SectionItemRemovalReason.Other],
703-
};
704-
705-
await runMutation(
688+
{/* Remove Item Modal - reuses the same modal as ML sections */}
689+
{itemToRemove && (
690+
<RemoveSectionItemModal
691+
itemTitle={itemToRemove.approvedItem.title}
692+
isOpen={removeItemModalOpen}
693+
onSave={(values: FormikValues, formikHelpers: FormikHelpers<any>) => {
694+
// Run the mutation with the selected removal reasons from the form
695+
runMutation(
706696
removeItemMutation,
707697
{
708698
variables: {
709-
data: input,
699+
data: {
700+
externalId: itemToRemove.externalId,
701+
deactivateReasons: values.removalReasons,
702+
},
710703
},
711704
},
712705
'Item removed from section successfully',
713706
() => {
714707
toggleRemoveItemModal();
715708
setItemToRemove(undefined);
709+
formikHelpers.setSubmitting(false);
716710
refetch();
717711
},
718712
() => {
719-
toggleRemoveItemModal();
713+
formikHelpers.setSubmitting(false);
720714
},
721715
);
722-
}
723-
}}
724-
itemTitle={itemToRemove?.approvedItem?.title}
725-
/>
716+
}}
717+
toggleModal={() => {
718+
toggleRemoveItemModal();
719+
setItemToRemove(undefined);
720+
}}
721+
/>
722+
)}
726723
</Box>
727724
);
728725
};

src/curated-corpus/components/CustomSectionForm/CustomSectionForm.validation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ export const getValidationSchema = (isEditMode: boolean = false) => {
4444
'not-in-past',
4545
'Start date cannot be in the past',
4646
function (value) {
47-
// TODO(HNT-1125): Remove the edit-mode bypass and enforce start-date validation
48-
// for manually typed values once editorial confirms we should always require
49-
// startDate >= today for new and existing sections.
50-
if (!value || isEditMode) {
47+
// Always enforce start date validation, even in edit mode
48+
// This ensures scheduled or live sections always start on or after today
49+
if (!value) {
5150
return true;
5251
}
5352
const startDate = DateTime.fromJSDate(value).startOf('day');
@@ -59,7 +58,8 @@ export const getValidationSchema = (isEditMode: boolean = false) => {
5958
.date()
6059
.nullable()
6160
.test('not-in-past', 'End date cannot be in the past', function (value) {
62-
if (!value || isEditMode) {
61+
// Always enforce end date validation, even in edit mode
62+
if (!value) {
6363
return true;
6464
}
6565
const endDate = DateTime.fromJSDate(value).startOf('day');

0 commit comments

Comments
 (0)