Skip to content

Commit

Permalink
chore: file rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Burtey committed Jul 20, 2023
1 parent 83faec0 commit a4e3982
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 148 deletions.
118 changes: 0 additions & 118 deletions app/screens/phone-auth-screen/badger-phone-01.svg

This file was deleted.

4 changes: 2 additions & 2 deletions app/screens/phone-auth-screen/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./phone-validation"
export * from "./phone-input"
export * from "./phone-login-validation"
export * from "./phone-login-input"
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Meta } from "@storybook/react"
import { MockedProvider } from "@apollo/client/testing"
import { createCache } from "../../graphql/cache"
import { StoryScreen } from "../../../.storybook/views"
import { PhoneValidationScreen } from "./phone-validation"
import { PhoneValidationScreen } from "./phone-registration-validation"

const mocks = []

Expand Down
19 changes: 8 additions & 11 deletions app/screens/phone-auth-screen/useRequestPhoneCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export const ErrorType = {
UnsupportedCountryError: "UnsupportedCountryError",
} as const

import axios from "axios"

type ErrorType = (typeof ErrorType)[keyof typeof ErrorType]

export type RequestPhoneCodeStatus =
Expand Down Expand Up @@ -144,8 +146,12 @@ export const useRequestPhoneCode = ({
const getCountryCodeFromIP = async () => {
let defaultCountryCode = "SV" as CountryCode
try {
const response = (await fetchWithTimeout("https://ipapi.co/json/")) as Response
const data = await response.json()
const response = await axios({
method: "get",
url: "https://ipapi.co/json/",
timeout: 5000,
})
const data = response.data

if (data && data.country_code) {
const countryCode = data.country_code
Expand Down Expand Up @@ -308,12 +314,3 @@ export const useRequestPhoneCode = ({
loadingSupportedCountries,
}
}

const fetchWithTimeout = (url: string, timeout = 5000) => {
return Promise.race([
fetch(url),
new Promise((_, reject) => {
setTimeout(() => reject(new Error("request timed out")), timeout)
}),
])
}
21 changes: 5 additions & 16 deletions app/screens/settings-screen/account-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,23 +400,12 @@ export const AccountScreen = () => {
id: "phone",
icon: "call-outline",
subTitleText: phoneNumber,
action: () => {},
enabled: false,
greyed: true,
hidden: !isAtLeastLevelOne,
},
{
category: LL.AccountScreen.removePhone(),
id: "remove-phone",
icon: "trash-outline",
subTitleText: emailAndPhoneActivated ? undefined : LL.AccountScreen.addEmailFirst(),
action: deletePhonePrompt,
enabled: emailAndPhoneActivated,
greyed: !emailAndPhoneActivated,
chevron: false,
styleDivider: true,
hidden: true,
// hidden: !email,
chevronLogo: emailAndPhoneActivated ? "close-circle-outline" : undefined,
chevronColor: emailAndPhoneActivated ? colors.red : undefined,
chevronSize: emailAndPhoneActivated ? 28 : undefined,
hidden: !isAtLeastLevelOne,
},

{
Expand Down Expand Up @@ -464,7 +453,7 @@ export const AccountScreen = () => {
accountSettingsList.push({
category: LL.support.deleteAccount(),
id: "deleteAccount",
icon: "close-circle-outline",
icon: "trash-outline",
dangerous: true,
action: deleteAccountAction,
enabled: true,
Expand Down

0 comments on commit a4e3982

Please sign in to comment.