From a4e3982f171e6f59600303924a3d83ead7c4b318 Mon Sep 17 00:00:00 2001 From: Nicolas Burtey Date: Mon, 17 Jul 2023 13:27:37 +0100 Subject: [PATCH] chore: file rename --- .../phone-auth-screen/badger-phone-01.svg | 118 ------------------ app/screens/phone-auth-screen/index.ts | 4 +- ...ories.tsx => phone-login-flow.stories.tsx} | 0 ...{phone-input.tsx => phone-login-input.tsx} | 0 ...tsx => phone-login-validation.stories.tsx} | 2 +- ...idation.tsx => phone-login-validation.tsx} | 0 .../phone-auth-screen/useRequestPhoneCode.ts | 19 ++- .../settings-screen/account-screen.tsx | 21 +--- 8 files changed, 16 insertions(+), 148 deletions(-) delete mode 100644 app/screens/phone-auth-screen/badger-phone-01.svg rename app/screens/phone-auth-screen/{phone-flow.stories.tsx => phone-login-flow.stories.tsx} (100%) rename app/screens/phone-auth-screen/{phone-input.tsx => phone-login-input.tsx} (100%) rename app/screens/phone-auth-screen/{phone-validation.stories.tsx => phone-login-validation.stories.tsx} (91%) rename app/screens/phone-auth-screen/{phone-validation.tsx => phone-login-validation.tsx} (100%) diff --git a/app/screens/phone-auth-screen/badger-phone-01.svg b/app/screens/phone-auth-screen/badger-phone-01.svg deleted file mode 100644 index cab0b65ab4..0000000000 --- a/app/screens/phone-auth-screen/badger-phone-01.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/screens/phone-auth-screen/index.ts b/app/screens/phone-auth-screen/index.ts index 9e83fae458..140f132132 100644 --- a/app/screens/phone-auth-screen/index.ts +++ b/app/screens/phone-auth-screen/index.ts @@ -1,2 +1,2 @@ -export * from "./phone-validation" -export * from "./phone-input" +export * from "./phone-login-validation" +export * from "./phone-login-input" diff --git a/app/screens/phone-auth-screen/phone-flow.stories.tsx b/app/screens/phone-auth-screen/phone-login-flow.stories.tsx similarity index 100% rename from app/screens/phone-auth-screen/phone-flow.stories.tsx rename to app/screens/phone-auth-screen/phone-login-flow.stories.tsx diff --git a/app/screens/phone-auth-screen/phone-input.tsx b/app/screens/phone-auth-screen/phone-login-input.tsx similarity index 100% rename from app/screens/phone-auth-screen/phone-input.tsx rename to app/screens/phone-auth-screen/phone-login-input.tsx diff --git a/app/screens/phone-auth-screen/phone-validation.stories.tsx b/app/screens/phone-auth-screen/phone-login-validation.stories.tsx similarity index 91% rename from app/screens/phone-auth-screen/phone-validation.stories.tsx rename to app/screens/phone-auth-screen/phone-login-validation.stories.tsx index 9e4084f965..9cd9827caf 100644 --- a/app/screens/phone-auth-screen/phone-validation.stories.tsx +++ b/app/screens/phone-auth-screen/phone-login-validation.stories.tsx @@ -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 = [] diff --git a/app/screens/phone-auth-screen/phone-validation.tsx b/app/screens/phone-auth-screen/phone-login-validation.tsx similarity index 100% rename from app/screens/phone-auth-screen/phone-validation.tsx rename to app/screens/phone-auth-screen/phone-login-validation.tsx diff --git a/app/screens/phone-auth-screen/useRequestPhoneCode.ts b/app/screens/phone-auth-screen/useRequestPhoneCode.ts index df409a09c0..e8cdec2545 100644 --- a/app/screens/phone-auth-screen/useRequestPhoneCode.ts +++ b/app/screens/phone-auth-screen/useRequestPhoneCode.ts @@ -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 = @@ -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 @@ -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) - }), - ]) -} diff --git a/app/screens/settings-screen/account-screen.tsx b/app/screens/settings-screen/account-screen.tsx index b7fc4594db..d20915f7b4 100644 --- a/app/screens/settings-screen/account-screen.tsx +++ b/app/screens/settings-screen/account-screen.tsx @@ -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, }, { @@ -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,