Skip to content

Commit

Permalink
update js docs and remove FullScreenLoadingIndicator
Browse files Browse the repository at this point in the history
  • Loading branch information
hungvu193 committed Sep 7, 2024
1 parent 7578c92 commit e1d133b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/components/ValidateCodeActionModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Modal from '@components/Modal';
import ScreenWrapper from '@components/ScreenWrapper';
Expand Down Expand Up @@ -54,21 +53,18 @@ function ValidateCodeActionModal({isVisible, title, description, onClose, valida
title={title}
onBackButtonPress={hide}
/>
{validateCodeAction?.isLoading ? (
<FullScreenLoadingIndicator style={[themeStyles.flex1, themeStyles.pRelative]} />
) : (
<View style={[themeStyles.ph5, themeStyles.mt3, themeStyles.mb7]}>
<Text style={[themeStyles.mb3]}>{description}</Text>
<ValidateCodeForm
validateCodeAction={validateCodeAction}
validatePendingAction={validatePendingAction}
validateError={validateError}
handleSubmitForm={handleSubmitForm}
clearError={clearError}
ref={validateCodeFormRef}
/>
</View>
)}

<View style={[themeStyles.ph5, themeStyles.mt3, themeStyles.mb7]}>
<Text style={[themeStyles.mb3]}>{description}</Text>
<ValidateCodeForm
validateCodeAction={validateCodeAction}
validatePendingAction={validatePendingAction}
validateError={validateError}
handleSubmitForm={handleSubmitForm}
clearError={clearError}
ref={validateCodeFormRef}
/>
</View>
</ScreenWrapper>
</Modal>
);
Expand Down
10 changes: 10 additions & 0 deletions src/libs/actions/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ function clearContactMethod(contactMethod: string) {
});
}

/**
* Clears error for a sepcific field on validate action code.
*/
function clearValidateCodeActionError(fieldName: string) {
Onyx.merge(ONYXKEYS.VALIDATE_ACTION_CODE, {
errorFields: {
Expand Down Expand Up @@ -317,6 +320,10 @@ function clearUnvalidatedNewContactMethodAction() {
});
}

/**
* When user adds a new contact method, they need to verify the magic code first
* So we add the temporary contact method to Onyx to use it later, after user verified magic code.
*/
function addPendingContactMethod(contactMethod: string) {
Onyx.merge(ONYXKEYS.PENDING_CONTACT_ACTION, {
contactMethod,
Expand Down Expand Up @@ -483,6 +490,9 @@ function addNewContactMethod(contactMethod: string, validateCode = '') {
API.write(WRITE_COMMANDS.ADD_NEW_CONTACT_METHOD, parameters, {optimisticData, successData, failureData});
}

/**
* Requests a magic code to verify current user
*/
function requestValidateCodeAction() {
const optimisticData: OnyxUpdate[] = [
{
Expand Down

0 comments on commit e1d133b

Please sign in to comment.