Skip to content

Commit b41bd37

Browse files
committed
refactor(ui): Update TaskSetupMFA to handle optional auto-navigation and improve type definitions for session tasks
1 parent a552311 commit b41bd37

5 files changed

Lines changed: 874 additions & 28 deletions

File tree

packages/ui/src/components/SessionTasks/tasks/TaskSetupMfa/SmsCodeFlowScreen.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import { useClerk, useReverification, useSession, useUser } from '@clerk/shared/react';
1+
import { useReverification, useUser } from '@clerk/shared/react';
22
import type { PhoneNumberResource, UserResource } from '@clerk/shared/types';
33
import React, { useRef } from 'react';
44

55
import { useWizard, Wizard } from '@/common';
66
import { MfaBackupCodeList } from '@/components/UserProfile/MfaBackupCodeList';
7-
import { useEnvironment } from '@/contexts';
8-
import { useSessionTasksContext, useTaskSetupMFAContext } from '@/contexts/components/SessionTasks';
97
import { Action, Actions } from '@/elements/Actions';
108
import { useCardState } from '@/elements/contexts';
119
import { Form } from '@/elements/Form';
1210
import { FormButtonContainer } from '@/elements/FormButtons';
1311
import { PreviewButton } from '@/elements/PreviewButton';
12+
import { type VerificationCodeCardProps, VerificationCodeContent } from '@/elements/VerificationCodeCard';
1413
import { Add } from '@/icons';
15-
import { useRouter } from '@/router';
1614
import { Button, Col, descriptors, Flex, Flow, localizationKeys, Text } from '@/ui/customizables';
1715
import { Card } from '@/ui/elements/Card';
1816
import { Header } from '@/ui/elements/Header';
@@ -22,7 +20,6 @@ import { getFlagEmojiFromCountryIso, parsePhoneString, stringToFormattedPhoneStr
2220
import { useFormControl } from '@/ui/utils/useFormControl';
2321

2422
import { SharedFooterActionForSignOut } from './shared';
25-
import { VerificationCodeContent, type VerificationCodeCardProps } from '@/elements/VerificationCodeCard';
2623

2724
type MFAVerifyPhoneForSessionTasksProps = {
2825
resourceRef: React.MutableRefObject<PhoneNumberResource | undefined>;
@@ -43,8 +40,8 @@ const MFAVerifyPhoneForSessionTasks = (props: MFAVerifyPhoneForSessionTasksProps
4340
const enableMfa = async () => {
4441
card.setLoading(phone?.id);
4542
try {
46-
await setReservedForSecondFactor();
47-
resourceRef.current = phone;
43+
const result = await setReservedForSecondFactor();
44+
resourceRef.current = result;
4845
onSuccess();
4946
} catch (err) {
5047
handleError(err as Error, [], card.setError);
@@ -213,8 +210,8 @@ const PhoneItem = ({ phone, onSuccess, onUnverifiedPhoneClick, resourceRef }: Ph
213210

214211
card.setLoading(phone.id);
215212
try {
216-
await setReservedForSecondFactor();
217-
resourceRef.current = phone;
213+
const result = await setReservedForSecondFactor();
214+
resourceRef.current = result;
218215
onSuccess();
219216
} catch (err) {
220217
handleError(err as Error, [], card.setError);
@@ -315,7 +312,7 @@ const SmsCodeScreen = (props: SmsCodeScreenProps) => {
315312
width: t.sizes.$8,
316313
height: t.sizes.$6,
317314
})}
318-
></Action>
315+
/>
319316
</Actions>
320317
<Flex
321318
justify='center'

0 commit comments

Comments
 (0)