-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44763 from JKobrynski/addRequestEarlyCancelationM…
…enuItem
- Loading branch information
Showing
24 changed files
with
386 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {useEffect, useMemo, useRef, useState} from 'react'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import type {CancellationType} from '@src/CONST'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
||
function useCancellationType(): CancellationType | undefined { | ||
const [cancellationDetails] = useOnyx(ONYXKEYS.NVP_PRIVATE_CANCELLATION_DETAILS); | ||
|
||
const [cancellationType, setCancellationType] = useState<CancellationType | undefined>(); | ||
|
||
// Store initial cancellation details array in a ref for comparison | ||
const previousCancellationDetails = useRef(cancellationDetails); | ||
|
||
const memoizedCancellationType = useMemo(() => { | ||
const pendingManualCancellation = cancellationDetails?.filter((detail) => detail.cancellationType === CONST.CANCELLATION_TYPE.MANUAL).find((detail) => !detail.cancellationDate); | ||
|
||
// There is a pending manual cancellation - return manual cancellation type | ||
if (pendingManualCancellation) { | ||
return CONST.CANCELLATION_TYPE.MANUAL; | ||
} | ||
|
||
// There are no new items in the cancellation details NVP | ||
if (previousCancellationDetails.current?.length === cancellationDetails?.length) { | ||
return; | ||
} | ||
|
||
// There is a new item in the cancellation details NVP, it has to be an automatic cancellation, as pending manual cancellations are handled above | ||
return CONST.CANCELLATION_TYPE.AUTOMATIC; | ||
}, [cancellationDetails]); | ||
|
||
useEffect(() => { | ||
if (!memoizedCancellationType) { | ||
return; | ||
} | ||
|
||
setCancellationType(memoizedCancellationType); | ||
}, [memoizedCancellationType]); | ||
|
||
return cancellationType; | ||
} | ||
|
||
export default useCancellationType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type {FeedbackSurveyOptionID} from '@src/CONST'; | ||
|
||
type CancelBillingSubscriptionParams = { | ||
cancellationReason: FeedbackSurveyOptionID; | ||
cancellationNote: string; | ||
}; | ||
|
||
export default CancelBillingSubscriptionParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...pages/settings/Subscription/CardSection/RequestEarlyCancellationMenuItem/index.native.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function RequestEarlyCancellationMenuItem() { | ||
return null; | ||
} | ||
|
||
export default RequestEarlyCancellationMenuItem; |
Oops, something went wrong.