Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Burtey committed Jul 18, 2023
1 parent 780bdba commit f9634e7
Show file tree
Hide file tree
Showing 10 changed files with 680 additions and 22 deletions.
11 changes: 11 additions & 0 deletions app/graphql/generated.gql
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,17 @@ mutation userPhoneDelete {
}
}

mutation userPhoneRegistrationInitiate($input: UserPhoneRegistrationInitiateInput!) {
userPhoneRegistrationInitiate(input: $input) {
errors {
message
__typename
}
success
__typename
}
}

mutation userUpdateLanguage($input: UserUpdateLanguageInput!) {
userUpdateLanguage(input: $input) {
errors {
Expand Down
43 changes: 43 additions & 0 deletions app/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,13 @@ export type SupportedCountriesQueryVariables = Exact<{ [key: string]: never; }>;

export type SupportedCountriesQuery = { readonly __typename: 'Query', readonly globals?: { readonly __typename: 'Globals', readonly supportedCountries: ReadonlyArray<{ readonly __typename: 'Country', readonly id: string, readonly supportedAuthChannels: ReadonlyArray<PhoneCodeChannelType> }> } | null };

export type UserPhoneRegistrationInitiateMutationVariables = Exact<{
input: UserPhoneRegistrationInitiateInput;
}>;


export type UserPhoneRegistrationInitiateMutation = { readonly __typename: 'Mutation', readonly userPhoneRegistrationInitiate: { readonly __typename: 'SuccessPayload', readonly success?: boolean | null, readonly errors: ReadonlyArray<{ readonly __typename: 'GraphQLApplicationError', readonly message: string }> } };

export type MyLnUpdatesSubscriptionVariables = Exact<{ [key: string]: never; }>;


Expand Down Expand Up @@ -3665,6 +3672,42 @@ export function useSupportedCountriesLazyQuery(baseOptions?: Apollo.LazyQueryHoo
export type SupportedCountriesQueryHookResult = ReturnType<typeof useSupportedCountriesQuery>;
export type SupportedCountriesLazyQueryHookResult = ReturnType<typeof useSupportedCountriesLazyQuery>;
export type SupportedCountriesQueryResult = Apollo.QueryResult<SupportedCountriesQuery, SupportedCountriesQueryVariables>;
export const UserPhoneRegistrationInitiateDocument = gql`
mutation userPhoneRegistrationInitiate($input: UserPhoneRegistrationInitiateInput!) {
userPhoneRegistrationInitiate(input: $input) {
errors {
message
}
success
}
}
`;
export type UserPhoneRegistrationInitiateMutationFn = Apollo.MutationFunction<UserPhoneRegistrationInitiateMutation, UserPhoneRegistrationInitiateMutationVariables>;

/**
* __useUserPhoneRegistrationInitiateMutation__
*
* To run a mutation, you first call `useUserPhoneRegistrationInitiateMutation` within a React component and pass it any options that fit your needs.
* When your component renders, `useUserPhoneRegistrationInitiateMutation` returns a tuple that includes:
* - A mutate function that you can call at any time to execute the mutation
* - An object with fields that represent the current status of the mutation's execution
*
* @param baseOptions options that will be passed into the mutation, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options-2;
*
* @example
* const [userPhoneRegistrationInitiateMutation, { data, loading, error }] = useUserPhoneRegistrationInitiateMutation({
* variables: {
* input: // value for 'input'
* },
* });
*/
export function useUserPhoneRegistrationInitiateMutation(baseOptions?: Apollo.MutationHookOptions<UserPhoneRegistrationInitiateMutation, UserPhoneRegistrationInitiateMutationVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useMutation<UserPhoneRegistrationInitiateMutation, UserPhoneRegistrationInitiateMutationVariables>(UserPhoneRegistrationInitiateDocument, options);
}
export type UserPhoneRegistrationInitiateMutationHookResult = ReturnType<typeof useUserPhoneRegistrationInitiateMutation>;
export type UserPhoneRegistrationInitiateMutationResult = Apollo.MutationResult<UserPhoneRegistrationInitiateMutation>;
export type UserPhoneRegistrationInitiateMutationOptions = Apollo.BaseMutationOptions<UserPhoneRegistrationInitiateMutation, UserPhoneRegistrationInitiateMutationVariables>;
export const MyLnUpdatesDocument = gql`
subscription myLnUpdates {
myUpdates {
Expand Down
12 changes: 12 additions & 0 deletions app/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,18 @@ const en: BaseTranslation = {
tryAgain: "Try Again",
sendViaOtherChannel: "You selected to receive the code via {channel: string}. You can try receiving via {other: string} instead",
},
PhoneRegistrationSetScreen: {
title: "Phone set up",
header: "Enter your phone number, and we'll text you an access code.",
headerVerify: "Verify you are human",
errorRequestingCode: "Something went wrong requesting the phone code, please try again later.",
errorInvalidPhoneNumber: "Invalid phone number. Are you sure you entered the right number?",
errorUnsupportedCountry: "We are unable to support customers in your country.",
placeholder: "Phone Number",
verify: "Click to Verify",
sms: "Send via SMS",
whatsapp: "Send via WhatsApp",
},
EmailRegistrationInitiateScreen: {
title: "Add your email",
header: "Enter your email address, and we'll send you an access code.",
Expand Down
84 changes: 84 additions & 0 deletions app/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2638,6 +2638,48 @@ type RootTranslation = {
*/
sendViaOtherChannel: RequiredParams<'channel' | 'other'>
}
PhoneRegistrationSetScreen: {
/**
* P​h​o​n​e​ ​s​e​t​ ​u​p
*/
title: string
/**
* E​n​t​e​r​ ​y​o​u​r​ ​p​h​o​n​e​ ​n​u​m​b​e​r​,​ ​a​n​d​ ​w​e​'​l​l​ ​t​e​x​t​ ​y​o​u​ ​a​n​ ​a​c​c​e​s​s​ ​c​o​d​e​.
*/
header: string
/**
* V​e​r​i​f​y​ ​y​o​u​ ​a​r​e​ ​h​u​m​a​n
*/
headerVerify: string
/**
* S​o​m​e​t​h​i​n​g​ ​w​e​n​t​ ​w​r​o​n​g​ ​r​e​q​u​e​s​t​i​n​g​ ​t​h​e​ ​p​h​o​n​e​ ​c​o​d​e​,​ ​p​l​e​a​s​e​ ​t​r​y​ ​a​g​a​i​n​ ​l​a​t​e​r​.
*/
errorRequestingCode: string
/**
* I​n​v​a​l​i​d​ ​p​h​o​n​e​ ​n​u​m​b​e​r​.​ ​A​r​e​ ​y​o​u​ ​s​u​r​e​ ​y​o​u​ ​e​n​t​e​r​e​d​ ​t​h​e​ ​r​i​g​h​t​ ​n​u​m​b​e​r​?
*/
errorInvalidPhoneNumber: string
/**
* W​e​ ​a​r​e​ ​u​n​a​b​l​e​ ​t​o​ ​s​u​p​p​o​r​t​ ​c​u​s​t​o​m​e​r​s​ ​i​n​ ​y​o​u​r​ ​c​o​u​n​t​r​y​.
*/
errorUnsupportedCountry: string
/**
* P​h​o​n​e​ ​N​u​m​b​e​r
*/
placeholder: string
/**
* C​l​i​c​k​ ​t​o​ ​V​e​r​i​f​y
*/
verify: string
/**
* S​e​n​d​ ​v​i​a​ ​S​M​S
*/
sms: string
/**
* S​e​n​d​ ​v​i​a​ ​W​h​a​t​s​A​p​p
*/
whatsapp: string
}
EmailRegistrationInitiateScreen: {
/**
* A​d​d​ ​y​o​u​r​ ​e​m​a​i​l
Expand Down Expand Up @@ -5853,6 +5895,48 @@ export type TranslationFunctions = {
*/
sendViaOtherChannel: (arg: { channel: string, other: string }) => LocalizedString
}
PhoneRegistrationSetScreen: {
/**
* Phone set up
*/
title: () => LocalizedString
/**
* Enter your phone number, and we'll text you an access code.
*/
header: () => LocalizedString
/**
* Verify you are human
*/
headerVerify: () => LocalizedString
/**
* Something went wrong requesting the phone code, please try again later.
*/
errorRequestingCode: () => LocalizedString
/**
* Invalid phone number. Are you sure you entered the right number?
*/
errorInvalidPhoneNumber: () => LocalizedString
/**
* We are unable to support customers in your country.
*/
errorUnsupportedCountry: () => LocalizedString
/**
* Phone Number
*/
placeholder: () => LocalizedString
/**
* Click to Verify
*/
verify: () => LocalizedString
/**
* Send via SMS
*/
sms: () => LocalizedString
/**
* Send via WhatsApp
*/
whatsapp: () => LocalizedString
}
EmailRegistrationInitiateScreen: {
/**
* Add your email
Expand Down
12 changes: 12 additions & 0 deletions app/i18n/raw-i18n/source/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,18 @@
"tryAgain": "Try Again",
"sendViaOtherChannel": "You selected to receive the code via {channel: string}. You can try receiving via {other: string} instead"
},
"PhoneRegistrationSetScreen": {
"title": "Phone set up",
"header": "Enter your phone number, and we'll text you an access code.",
"headerVerify": "Verify you are human",
"errorRequestingCode": "Something went wrong requesting the phone code, please try again later.",
"errorInvalidPhoneNumber": "Invalid phone number. Are you sure you entered the right number?",
"errorUnsupportedCountry": "We are unable to support customers in your country.",
"placeholder": "Phone Number",
"verify": "Click to Verify",
"sms": "Send via SMS",
"whatsapp": "Send via WhatsApp"
},
"EmailRegistrationInitiateScreen": {
"title": "Add your email",
"header": "Enter your email address, and we'll send you an access code.",
Expand Down
19 changes: 5 additions & 14 deletions app/screens/phone-auth-screen/phone-login-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ import { ContactSupportButton } from "@app/components/contact-support-button/con
import { useI18nContext } from "@app/i18n/i18n-react"
import { makeStyles, useTheme, Text, Input } from "@rneui/themed"
import { Screen } from "../../components/screen"
import { useAppConfig } from "../../hooks"
import type { PhoneValidationStackParamList } from "../../navigation/stack-param-lists"
import {
ErrorType,
RequestPhoneCodeStatus,
useRequestPhoneCode,
} from "./useRequestPhoneCode"
useRequestPhoneCodeLogin,
} from "./request-phone-code-login"
import { GaloyPrimaryButton } from "@app/components/atomic/galoy-primary-button"
import { GaloySecondaryButton } from "@app/components/atomic/galoy-secondary-button"
import { GaloyErrorBox } from "@app/components/atomic/galoy-error-box"
Expand Down Expand Up @@ -104,7 +103,7 @@ export const PhoneLoginSetScreen: React.FC = () => {

const navigation =
useNavigation<StackNavigationProp<PhoneValidationStackParamList, "phoneLoginSet">>()
const { appConfig } = useAppConfig()

const {
theme: { colors, mode: themeMode },
} = useTheme()
Expand All @@ -124,9 +123,7 @@ export const PhoneLoginSetScreen: React.FC = () => {
setCountryCode,
supportedCountries,
loadingSupportedCountries,
} = useRequestPhoneCode({
skipRequestPhoneCode: appConfig.galoyInstance.name === "Local",
})
} = useRequestPhoneCodeLogin()

const { LL } = useI18nContext()

Expand All @@ -150,8 +147,6 @@ export const PhoneLoginSetScreen: React.FC = () => {
)
}

const showCaptcha = false

let errorMessage: string | undefined
if (error) {
switch (error) {
Expand Down Expand Up @@ -225,11 +220,7 @@ export const PhoneLoginSetScreen: React.FC = () => {
>
<View style={styles.viewWrapper}>
<View style={styles.textContainer}>
<Text type={"p1"}>
{showCaptcha
? LL.PhoneLoginSetScreen.headerVerify()
: LL.PhoneLoginSetScreen.header()}
</Text>
<Text type={"p1"}>{LL.PhoneLoginSetScreen.header()}</Text>
</View>

<View style={styles.inputContainer}>
Expand Down
2 changes: 1 addition & 1 deletion app/screens/phone-auth-screen/phone-login-validation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
logUpgradeLoginSuccess,
logValidateAuthCodeFailure,
} from "@app/utils/analytics"
import { PhoneCodeChannelToFriendlyName } from "./useRequestPhoneCode"
import { PhoneCodeChannelToFriendlyName } from "./request-phone-code-login"
import { AccountLevel, useLevel } from "@app/graphql/level-context"

const useStyles = makeStyles(({ colors }) => ({
Expand Down
Loading

0 comments on commit f9634e7

Please sign in to comment.