Skip to content

Commit 15aa1ad

Browse files
authored
Merge pull request Expensify#64959 from Expensify/marcaaron-requestEarlyCancellation
[No QA] Add support for "none" cancellation type in `useCancellationType` hook and UI content map
2 parents fa68395 + efe316c commit 15aa1ad

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/hooks/useCancellationType.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
55
import useOnyx from './useOnyx';
66

77
function useCancellationType(): CancellationType | undefined {
8-
const [cancellationDetails] = useOnyx(ONYXKEYS.NVP_PRIVATE_CANCELLATION_DETAILS);
8+
const [cancellationDetails] = useOnyx(ONYXKEYS.NVP_PRIVATE_CANCELLATION_DETAILS, {canBeMissing: true});
99

1010
const [cancellationType, setCancellationType] = useState<CancellationType | undefined>();
1111

@@ -20,6 +20,12 @@ function useCancellationType(): CancellationType | undefined {
2020
return CONST.CANCELLATION_TYPE.MANUAL;
2121
}
2222

23+
// Check for cancellation with type "none"
24+
const noneCancellation = cancellationDetails?.find((detail) => detail.cancellationType === CONST.CANCELLATION_TYPE.NONE);
25+
if (noneCancellation) {
26+
return CONST.CANCELLATION_TYPE.NONE;
27+
}
28+
2329
// There are no new items in the cancellation details NVP
2430
// eslint-disable-next-line react-compiler/react-compiler
2531
if (previousCancellationDetails.current?.length === cancellationDetails?.length) {

src/pages/settings/Subscription/RequestEarlyCancellationPage/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function RequestEarlyCancellationPage() {
106106
const contentMap: Partial<Record<CancellationType, ReactNode>> = {
107107
[CONST.CANCELLATION_TYPE.MANUAL]: manualCancellationContent,
108108
[CONST.CANCELLATION_TYPE.AUTOMATIC]: automaticCancellationContent,
109+
[CONST.CANCELLATION_TYPE.NONE]: manualCancellationContent,
109110
};
110111

111112
const screenContent = cancellationType ? contentMap[cancellationType] : surveyContent;

0 commit comments

Comments
 (0)