Compare commits

...

2 Commits

  1. 1
      src/api/auth/requests.interfaces.ts
  2. 4
      src/modules/auth/hooks/use-authorization.hook.ts
  3. 2
      src/modules/auth/screens/confirm-code.screen.tsx
  4. 4
      src/services/domain/auth.service.ts

1
src/api/auth/requests.interfaces.ts

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
export interface IRequestConfirmationCodePayload {
phoneNumber: string
isResend?: boolean
}
export interface IFinishLoginPayload {

4
src/modules/auth/hooks/use-authorization.hook.ts

@ -26,7 +26,7 @@ export const useAuthorization = ({ onSentCode, onConfirmCode }: IParams) => { @@ -26,7 +26,7 @@ export const useAuthorization = ({ onSentCode, onConfirmCode }: IParams) => {
if (isForbidden) setFirbiddenError()
}, [isForbidden])
const sendCode = async (phoneNumber: string) => {
const sendCode = async (phoneNumber: string, isResend: boolean = false) => {
setLoading(true)
try {
if (!phoneNumber) {
@ -34,7 +34,7 @@ export const useAuthorization = ({ onSentCode, onConfirmCode }: IParams) => { @@ -34,7 +34,7 @@ export const useAuthorization = ({ onSentCode, onConfirmCode }: IParams) => {
return
}
await authService.sendConfirmationCode(phoneNumber)
await authService.sendConfirmationCode(phoneNumber, isResend)
if (onSentCode) onSentCode()
clearError()
} catch (e: any) {

2
src/modules/auth/screens/confirm-code.screen.tsx

@ -55,7 +55,7 @@ export const ConfirmCode: FC = () => { @@ -55,7 +55,7 @@ export const ConfirmCode: FC = () => {
const resendCode = async () => {
restartCountDown()
setConfirmCode('')
await sendCode(getPhoneNumber())
await sendCode(getPhoneNumber(), true)
setField(false)
focusInput()
}

4
src/services/domain/auth.service.ts

@ -21,8 +21,8 @@ let phoneNumber: string @@ -21,8 +21,8 @@ let phoneNumber: string
const setPhoneNumber = (value: string) => (phoneNumber = value)
const getPhoneNumber = () => phoneNumber
const sendConfirmationCode = async (phoneNumber: string) => {
await requestConfirmationCode({ phoneNumber })
const sendConfirmationCode = async (phoneNumber: string, isResend: boolean = false) => {
await requestConfirmationCode({ phoneNumber, isResend })
setPhoneNumber(phoneNumber)
}

Loading…
Cancel
Save