diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 23b56d921c4d..b7b6cf53a176 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -571,6 +571,10 @@ const ONYXKEYS = { REIMBURSEMENT_ACCOUNT_FORM_DRAFT: 'reimbursementAccountDraft', PERSONAL_BANK_ACCOUNT_FORM: 'personalBankAccount', PERSONAL_BANK_ACCOUNT_FORM_DRAFT: 'personalBankAccountDraft', + DISABLE_AUTO_RENEW_SURVEY_FORM: 'disableAutoRenewSurveyForm', + DISABLE_AUTO_RENEW_SURVEY_FORM_DRAFT: 'disableAutoRenewSurveyFormDraft', + REQUEST_EARLY_CANCELLATION_FORM: 'requestEarlyCancellationForm', + REQUEST_EARLY_CANCELLATION_FORM_DRAFT: 'requestEarlyCancellationFormDraft', EXIT_SURVEY_REASON_FORM: 'exitSurveyReasonForm', EXIT_SURVEY_REASON_FORM_DRAFT: 'exitSurveyReasonFormDraft', EXIT_SURVEY_RESPONSE_FORM: 'exitSurveyResponseForm', @@ -647,6 +651,8 @@ type OnyxFormValuesMapping = { [ONYXKEYS.FORMS.ROOM_SETTINGS_FORM]: FormTypes.RoomSettingsForm; [ONYXKEYS.FORMS.NEW_TASK_FORM]: FormTypes.NewTaskForm; [ONYXKEYS.FORMS.EDIT_TASK_FORM]: FormTypes.EditTaskForm; + [ONYXKEYS.FORMS.DISABLE_AUTO_RENEW_SURVEY_FORM]: FormTypes.FeedbackSurveyForm; + [ONYXKEYS.FORMS.REQUEST_EARLY_CANCELLATION_FORM]: FormTypes.FeedbackSurveyForm; [ONYXKEYS.FORMS.EXIT_SURVEY_REASON_FORM]: FormTypes.ExitSurveyReasonForm; [ONYXKEYS.FORMS.EXIT_SURVEY_RESPONSE_FORM]: FormTypes.ExitSurveyResponseForm; [ONYXKEYS.FORMS.MONEY_REQUEST_DESCRIPTION_FORM]: FormTypes.MoneyRequestDescriptionForm; diff --git a/src/components/FeedbackSurvey.tsx b/src/components/FeedbackSurvey.tsx index 71b0da06bd5f..a17cca5efae4 100644 --- a/src/components/FeedbackSurvey.tsx +++ b/src/components/FeedbackSurvey.tsx @@ -1,19 +1,28 @@ -import React, {useState} from 'react'; +import React, {useEffect, useMemo, useState} from 'react'; import type {StyleProp, ViewStyle} from 'react-native'; import {View} from 'react-native'; +import {useOnyx} from 'react-native-onyx'; import useLocalize from '@hooks/useLocalize'; -import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as FormActions from '@libs/actions/FormActions'; import CONST from '@src/CONST'; import type {FeedbackSurveyOptionID} from '@src/CONST'; -import type {TranslationPaths} from '@src/languages/types'; +import type ONYXKEYS from '@src/ONYXKEYS'; +import INPUT_IDS from '@src/types/form/FeedbackSurveyForm'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import FixedFooter from './FixedFooter'; +import FormProvider from './Form/FormProvider'; +import InputWrapper from './Form/InputWrapper'; import FormAlertWithSubmitButton from './FormAlertWithSubmitButton'; -import SingleOptionSelector from './SingleOptionSelector'; +import RadioButtons from './RadioButtons'; +import type {Choice} from './RadioButtons'; import Text from './Text'; import TextInput from './TextInput'; type FeedbackSurveyProps = { + /** A unique Onyx key identifying the form */ + formID: typeof ONYXKEYS.FORMS.DISABLE_AUTO_RENEW_SURVEY_FORM | typeof ONYXKEYS.FORMS.REQUEST_EARLY_CANCELLATION_FORM; + /** Title of the survey */ title: string; @@ -36,71 +45,88 @@ type FeedbackSurveyProps = { isLoading?: boolean; }; -type Option = { - key: FeedbackSurveyOptionID; - 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, footerText, isNoteRequired, isLoading}: FeedbackSurveyProps) { +function FeedbackSurvey({title, description, onSubmit, optionRowStyles, footerText, isNoteRequired, isLoading, formID}: FeedbackSurveyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - const theme = useTheme(); - - const selectCircleStyles: StyleProp = {borderColor: theme.border}; - const [reason, setReason] = useState