-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #42990 from MrMuzyk/feat/subsription-settings-ui
feat: Subscription settings UI
- Loading branch information
Showing
16 changed files
with
353 additions
and
9 deletions.
There are no files selected for viewing
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,90 @@ | ||
import React, {useState} from 'react'; | ||
import type {StyleProp, ViewStyle} from 'react-native'; | ||
import {View} from 'react-native'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import CONST from '@src/CONST'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import FixedFooter from './FixedFooter'; | ||
import FormAlertWithSubmitButton from './FormAlertWithSubmitButton'; | ||
import SingleOptionSelector from './SingleOptionSelector'; | ||
import Text from './Text'; | ||
|
||
type FeedbackSurveyProps = { | ||
/** Title of the survey */ | ||
title: string; | ||
|
||
/** Description of the survey */ | ||
description: string; | ||
|
||
/** Callback to be called when the survey is submitted */ | ||
onSubmit: (reason: Option) => void; | ||
|
||
/** Styles for the option row element */ | ||
optionRowStyles?: StyleProp<ViewStyle>; | ||
}; | ||
|
||
type Option = { | ||
key: string; | ||
label: TranslationPaths; | ||
}; | ||
|
||
const OPTIONS: Option[] = [ | ||
{key: CONST.FEEDBACK_SURVEY_OPTIONS.TOO_LIMITED.ID, label: CONST.FEEDBACK_SURVEY_OPTIONS.TOO_LIMITED.TRANSLATION_KEY}, | ||
{key: CONST.FEEDBACK_SURVEY_OPTIONS.TOO_EXPENSIVE.ID, label: CONST.FEEDBACK_SURVEY_OPTIONS.TOO_EXPENSIVE.TRANSLATION_KEY}, | ||
{key: CONST.FEEDBACK_SURVEY_OPTIONS.INADEQUATE_SUPPORT.ID, label: CONST.FEEDBACK_SURVEY_OPTIONS.INADEQUATE_SUPPORT.TRANSLATION_KEY}, | ||
{key: CONST.FEEDBACK_SURVEY_OPTIONS.BUSINESS_CLOSING.ID, label: CONST.FEEDBACK_SURVEY_OPTIONS.BUSINESS_CLOSING.TRANSLATION_KEY}, | ||
]; | ||
|
||
function FeedbackSurvey({title, description, onSubmit, optionRowStyles}: FeedbackSurveyProps) { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
const theme = useTheme(); | ||
|
||
const selectCircleStyles: StyleProp<ViewStyle> = {borderColor: theme.border}; | ||
const [reason, setReason] = useState<Option>(); | ||
const [shouldShowReasonError, setShouldShowReasonError] = useState(false); | ||
|
||
const handleOptionSelect = (option: Option) => { | ||
setShouldShowReasonError(false); | ||
setReason(option); | ||
}; | ||
|
||
const handleSubmit = () => { | ||
if (!reason) { | ||
setShouldShowReasonError(true); | ||
return; | ||
} | ||
|
||
onSubmit(reason); | ||
}; | ||
|
||
return ( | ||
<View style={[styles.flexGrow1, styles.justifyContentBetween]}> | ||
<View style={styles.mh5}> | ||
<Text style={styles.textHeadline}>{title}</Text> | ||
<Text style={[styles.mt1, styles.mb3, styles.textNormalThemeText]}>{description}</Text> | ||
<SingleOptionSelector | ||
options={OPTIONS} | ||
optionRowStyles={[styles.mb7, optionRowStyles]} | ||
selectCircleStyles={selectCircleStyles} | ||
selectedOptionKey={reason?.key} | ||
onSelectOption={handleOptionSelect} | ||
/> | ||
</View> | ||
<FixedFooter> | ||
<FormAlertWithSubmitButton | ||
isAlertVisible={shouldShowReasonError} | ||
onSubmit={handleSubmit} | ||
message="common.error.pleaseCompleteForm" | ||
buttonText={translate('common.submit')} | ||
/> | ||
</FixedFooter> | ||
</View> | ||
); | ||
} | ||
|
||
FeedbackSurvey.displayName = 'FeedbackSurvey'; | ||
|
||
export default FeedbackSurvey; |
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
19 changes: 19 additions & 0 deletions
19
src/pages/settings/Subscription/DisableAutoRenewSurveyPage/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,19 @@ | ||
import React from 'react'; | ||
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
|
||
function DisableAutoRenewSurveyPage() { | ||
return ( | ||
<ScreenWrapper | ||
testID={DisableAutoRenewSurveyPage.displayName} | ||
includeSafeAreaPaddingBottom | ||
shouldEnableMaxHeight | ||
> | ||
<FullPageNotFoundView shouldShow /> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
DisableAutoRenewSurveyPage.displayName = 'DisableAutoRenewSurveyPage'; | ||
|
||
export default DisableAutoRenewSurveyPage; |
43 changes: 43 additions & 0 deletions
43
src/pages/settings/Subscription/DisableAutoRenewSurveyPage/index.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,43 @@ | ||
import React from 'react'; | ||
import FeedbackSurvey from '@components/FeedbackSurvey'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import ScrollView from '@components/ScrollView'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
|
||
function DisableAutoRenewSurveyPage() { | ||
const {translate} = useLocalize(); | ||
const styles = useThemeStyles(); | ||
|
||
const handleSubmit = () => { | ||
// TODO API call to submit feedback will be implemented in next phase | ||
}; | ||
|
||
return ( | ||
<ScreenWrapper | ||
testID={DisableAutoRenewSurveyPage.displayName} | ||
includeSafeAreaPaddingBottom={false} | ||
shouldEnablePickerAvoiding={false} | ||
shouldEnableMaxHeight | ||
> | ||
<HeaderWithBackButton | ||
title={translate('subscription.subscriptionSettings.disableAutoRenew')} | ||
onBackButtonPress={Navigation.goBack} | ||
/> | ||
<ScrollView contentContainerStyle={[styles.flexGrow1, styles.pt3]}> | ||
<FeedbackSurvey | ||
title={translate('subscription.subscriptionSettings.helpUsImprove')} | ||
description={translate('subscription.subscriptionSettings.whatsMainReason')} | ||
onSubmit={handleSubmit} | ||
optionRowStyles={styles.flex1} | ||
/> | ||
</ScrollView> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
DisableAutoRenewSurveyPage.displayName = 'DisableAutoRenewSurveyPage'; | ||
|
||
export default DisableAutoRenewSurveyPage; |
5 changes: 5 additions & 0 deletions
5
src/pages/settings/Subscription/SubscriptionSettings/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 SubscriptionSettings() { | ||
return null; | ||
} | ||
|
||
export default SubscriptionSettings; |
Oops, something went wrong.