From 238d716e738f385e39c4b52aaf3ba1ede993b242 Mon Sep 17 00:00:00 2001 From: weronika Date: Sat, 9 Mar 2024 13:33:35 +0100 Subject: [PATCH 01/11] prepare google button with logic --- assets/google-icon.png | Bin 0 -> 830 bytes src/constants/images.ts | 2 + .../components/GoogleButton/GoogleButton.tsx | 20 +++++ .../GoogleButton/NativeGoogleButton.tsx | 80 ++++++++++++++++++ .../components/GoogleButton/index.tsx | 11 +++ src/design-system/components/index.ts | 1 + src/i18n/translations/en.json | 6 +- src/i18n/translations/pl.json | 6 +- src/screens/SignInScreen.tsx | 6 +- 9 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 assets/google-icon.png create mode 100644 src/design-system/components/GoogleButton/GoogleButton.tsx create mode 100644 src/design-system/components/GoogleButton/NativeGoogleButton.tsx create mode 100644 src/design-system/components/GoogleButton/index.tsx diff --git a/assets/google-icon.png b/assets/google-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a524ee8f788a1608f3c2fdd8186eb0fa39f64374 GIT binary patch literal 830 zcmV-E1Ht@>P)P000;W1^@s654Bdt00009a7bBm000XU z000XU0RWnu7ytkO0drDELIAGL9O(c600d`2O+f$vv5yPOmt-D)Y z76jj*{ZyRYYW+$ieMkZdQB{q&UC5g!>;wSu22Nyhc9{+khA^=Wnw1!%RM+Ba(!S{6 zy4HsxaWYFgdBzB*42{op7p&J%S%XO2NJ6*}SV%TU&#mcO0nw(GLC4XPg||g;!L}3* zsy@Hem0!)e*)S3{FT}ATq<_r!g8r@buU3b?Mg(5L0#9;%oI9>U$K6lRdbz|D^!Uvn zpr{32stH;yeFaMRJ=dFYS}>BtK_&1j2p&X+-Ws2j0G=5LsNSR zr^d<|_&M8eP0&9V8zG%_!O00R%J{I5S{a*_&GHK~x5;bSo(OE+l>9r_tZNX;<{!01 zEhLO+Ha1NJ6W|WoW@s|dBoV=sEPmxGv~1p~&ah%|d>^g$Iub@S6U!h3<8TOYS|_x9 znFLNf5zRkoJLt+jyJ2bmWA;?+3@LhVZ@U?o`>AMw&tq>UZdlsB>yHErI0-xkYu>xT zEpAm^W3b>NJVJhd&Xc{;Ok;5%vk!dqB$+916FFKaRZ^CWQ|OHUIzs07*qo IM6N<$f_zPEUH||9 literal 0 HcmV?d00001 diff --git a/src/constants/images.ts b/src/constants/images.ts index ba65176d..af434fae 100644 --- a/src/constants/images.ts +++ b/src/constants/images.ts @@ -7,3 +7,5 @@ export const lightLogoFull = require('@baca/assets/logo/logo-full-light.png') export const darkLogoSygnet = require('@baca/assets/logo/logo-sygnet-dark.png') export const lightLogoSygnet = require('@baca/assets/logo/logo-sygnet-light.png') + +export const googleIcon = require('@baca/assets/google-icon.png') diff --git a/src/design-system/components/GoogleButton/GoogleButton.tsx b/src/design-system/components/GoogleButton/GoogleButton.tsx new file mode 100644 index 00000000..f3798f95 --- /dev/null +++ b/src/design-system/components/GoogleButton/GoogleButton.tsx @@ -0,0 +1,20 @@ +import { Image } from 'react-native' + +import { Button } from '../Button' +import { Text } from '../Text' + +import { googleIcon } from '@baca/constants' + +type GoogleButtonProps = { + onPress: () => void + isDisabled?: boolean +} + +export const GoogleButton = ({ onPress, isDisabled }: GoogleButtonProps) => { + return ( + + ) +} diff --git a/src/design-system/components/GoogleButton/NativeGoogleButton.tsx b/src/design-system/components/GoogleButton/NativeGoogleButton.tsx new file mode 100644 index 00000000..f3c53bc1 --- /dev/null +++ b/src/design-system/components/GoogleButton/NativeGoogleButton.tsx @@ -0,0 +1,80 @@ +import { FC } from 'react' +import { useTranslation } from 'react-i18next' + +import { GoogleButton } from './GoogleButton' + +import { isExpoGo } from '@baca/constants' +import { useCallback, useEffect, useState } from '@baca/hooks' +import { useAuthGoogleControllerLogin } from '@baca/api/query/auth-social/auth-social' + +let NativeGoogleButton: FC + +if (!isExpoGo) { + // Conditionall import makes it work with expo go + import('@react-native-google-signin/google-signin').then(({ GoogleSignin, statusCodes }) => { + type GoogleSignInError = Error & { code: keyof typeof statusCodes } + + NativeGoogleButton = () => { + const [isDisabled, setIsDisabled] = useState(false) + const { mutate: signInByGoogle } = useAuthGoogleControllerLogin() + const { t } = useTranslation() + + useEffect(() => { + // No extra configuration is needed, + // but for the more customisation check: + // https://github.com/react-native-google-signin/google-signin#configureoptions + GoogleSignin?.configure?.() + }, []) + + const verifyPlayServices = useCallback(async (): Promise => { + setIsDisabled(!(await GoogleSignin?.hasPlayServices?.())) + }, []) + + useEffect(() => { + verifyPlayServices() + }, [verifyPlayServices]) + + const verifyToken = useCallback(async (): Promise => { + const tokenResponse = await GoogleSignin?.getTokens?.() + const { accessToken } = tokenResponse || {} + await signInByGoogle({ + data: { + idToken: accessToken, + }, + }) + }, [signInByGoogle]) + + const signIn = useCallback(async (): Promise => { + try { + await GoogleSignin?.signIn?.() + await verifyToken() + } catch (error) { + // TODO: This could be extracted to external function with an additional handling of the error codes + const typedError = error as GoogleSignInError + + if (typedError.code) { + switch (typedError.code) { + case statusCodes?.SIGN_IN_CANCELLED: + case statusCodes?.IN_PROGRESS: + break + case statusCodes?.PLAY_SERVICES_NOT_AVAILABLE: + // TODO: wait for toast components + alert(t('errors.play_services_not_available')) + break + default: + alert(t('errors.something_went_wrong')) + break + } + return + } + + alert(t('errors.something_went_wrong')) + } + }, [t, verifyToken]) + + return + } + }) +} + +export { NativeGoogleButton } diff --git a/src/design-system/components/GoogleButton/index.tsx b/src/design-system/components/GoogleButton/index.tsx new file mode 100644 index 00000000..2612d852 --- /dev/null +++ b/src/design-system/components/GoogleButton/index.tsx @@ -0,0 +1,11 @@ +import { NativeGoogleButton } from './NativeGoogleButton' + +import { isExpoGo } from '@baca/constants' + +export const SignInWithGoogle = () => { + if (isExpoGo) { + return null + } + + return +} diff --git a/src/design-system/components/index.ts b/src/design-system/components/index.ts index 2ed363a5..6f743317 100644 --- a/src/design-system/components/index.ts +++ b/src/design-system/components/index.ts @@ -3,6 +3,7 @@ export * from './Box' export * from './Button' export * from './Center' export * from './Column' +export * from './GoogleButton' export * from './GradientBox' export * from './Row' export * from './Spacer' diff --git a/src/i18n/translations/en.json b/src/i18n/translations/en.json index c3b79572..b7ae95ad 100644 --- a/src/i18n/translations/en.json +++ b/src/i18n/translations/en.json @@ -25,7 +25,8 @@ "screen_not_found": "NotFound screen", "something_went_wrong": "Something went wrong", "token_expired": "Token expired", - "missing_auth": "Missing auth" + "missing_auth": "Missing auth", + "play_services_not_available": "Usługi play są niedostępne." }, "form": { "invalid_email_format": "Incorrect e-mail address", @@ -151,7 +152,8 @@ "password_placeholder": "password", "remember_me": "Remember me", "sign_in": "Sign in", - "sign_up": "Sign up" + "sign_up": "Sign up", + "sign_in_by_google": "Log in with Google" }, "sign_up_screen": { "agree_terms_label": "I agree to the Terms and Conditions", diff --git a/src/i18n/translations/pl.json b/src/i18n/translations/pl.json index bcccdb19..7482cbd5 100644 --- a/src/i18n/translations/pl.json +++ b/src/i18n/translations/pl.json @@ -25,7 +25,8 @@ "missing_auth": "Brak autoryzacji", "screen_not_found": "NotFound screen", "something_went_wrong": "Coś poszło nie tak", - "token_expired": "Token wygasł" + "token_expired": "Token wygasł", + "play_services_not_available": "Usługi play są niedostępne." }, "form": { "invalid_email_format": "Zły adres e-mail", @@ -150,7 +151,8 @@ "password_placeholder": "hasło", "remember_me": "Zapamiętaj mnie", "sign_in": "Zaloguj", - "sign_up": "Zarejestruj" + "sign_up": "Zarejestruj", + "sign_in_by_google": "Zaloguj się przez Google" }, "sign_up_screen": { "agree_terms_label": "Zgadzam się z warunkami użytkowania", diff --git a/src/screens/SignInScreen.tsx b/src/screens/SignInScreen.tsx index d156352e..40e6d91f 100644 --- a/src/screens/SignInScreen.tsx +++ b/src/screens/SignInScreen.tsx @@ -1,7 +1,7 @@ import { ControlledField, KeyboardAwareScrollView, LanguagePicker, Version } from '@baca/components' import { REGEX, darkLogo, lightLogo } from '@baca/constants' import { useColorScheme } from '@baca/contexts' -import { Box, Button, Center, Spacer, Text } from '@baca/design-system' +import { Box, Button, Center, SignInWithGoogle, Spacer, Text } from '@baca/design-system' import { useCallback, useSignInForm, @@ -91,12 +91,14 @@ export const SignInScreen = (): JSX.Element => { + {t('sign_in_screen.do_not_have_an_account')} From e362d4847c6ac70b50023644d129fa245ce1ae75 Mon Sep 17 00:00:00 2001 From: weronika Date: Sat, 9 Mar 2024 13:42:43 +0100 Subject: [PATCH 02/11] run lint --- .../components/GoogleButton/GoogleButton.tsx | 3 +-- .../components/GoogleButton/NativeGoogleButton.tsx | 7 +++---- src/design-system/components/GoogleButton/index.tsx | 9 ++++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/design-system/components/GoogleButton/GoogleButton.tsx b/src/design-system/components/GoogleButton/GoogleButton.tsx index f3798f95..d12c4861 100644 --- a/src/design-system/components/GoogleButton/GoogleButton.tsx +++ b/src/design-system/components/GoogleButton/GoogleButton.tsx @@ -1,10 +1,9 @@ +import { googleIcon } from '@baca/constants' import { Image } from 'react-native' import { Button } from '../Button' import { Text } from '../Text' -import { googleIcon } from '@baca/constants' - type GoogleButtonProps = { onPress: () => void isDisabled?: boolean diff --git a/src/design-system/components/GoogleButton/NativeGoogleButton.tsx b/src/design-system/components/GoogleButton/NativeGoogleButton.tsx index f3c53bc1..25f26ef4 100644 --- a/src/design-system/components/GoogleButton/NativeGoogleButton.tsx +++ b/src/design-system/components/GoogleButton/NativeGoogleButton.tsx @@ -1,12 +1,11 @@ +import { useAuthGoogleControllerLogin } from '@baca/api/query/auth-social/auth-social' +import { isExpoGo } from '@baca/constants' +import { useCallback, useEffect, useState } from '@baca/hooks' import { FC } from 'react' import { useTranslation } from 'react-i18next' import { GoogleButton } from './GoogleButton' -import { isExpoGo } from '@baca/constants' -import { useCallback, useEffect, useState } from '@baca/hooks' -import { useAuthGoogleControllerLogin } from '@baca/api/query/auth-social/auth-social' - let NativeGoogleButton: FC if (!isExpoGo) { diff --git a/src/design-system/components/GoogleButton/index.tsx b/src/design-system/components/GoogleButton/index.tsx index 2612d852..3e524a37 100644 --- a/src/design-system/components/GoogleButton/index.tsx +++ b/src/design-system/components/GoogleButton/index.tsx @@ -1,10 +1,13 @@ -import { NativeGoogleButton } from './NativeGoogleButton' - import { isExpoGo } from '@baca/constants' +import { GoogleButton } from './GoogleButton' +import { NativeGoogleButton } from './NativeGoogleButton' + export const SignInWithGoogle = () => { if (isExpoGo) { - return null + return ( + alert('Need to test on build version.')} /> + ) } return From 5f6cf2adbb24d5b76290260d339c9b1d91061a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Baumruck?= Date: Fri, 5 Apr 2024 12:01:09 +0200 Subject: [PATCH 03/11] show Google Button in sign in screen --- .env | 3 --- .../components/GoogleButton/GoogleButton.tsx | 2 +- src/screens/auth/SignInScreen.tsx | 12 +++++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 4783255f..00000000 --- a/.env +++ /dev/null @@ -1,3 +0,0 @@ -ENVIRONMENT=production -ANDROID_FIREBASE_CONFIG=ewogICJwcm9qZWN0X2luZm8iOiB7CiAgICAicHJvamVjdF9udW1iZXIiOiAiMzYzNTM0MTMzMDk1IiwKICAgICJwcm9qZWN0X2lkIjogInNjaG9vbHBpbG90LWRldmVsb3BtZW50IiwKICAgICJzdG9yYWdlX2J1Y2tldCI6ICJzY2hvb2xwaWxvdC1kZXZlbG9wbWVudC5hcHBzcG90LmNvbSIKICB9LAogICJjbGllbnQiOiBbCiAgICB7CiAgICAgICJjbGllbnRfaW5mbyI6IHsKICAgICAgICAibW9iaWxlc2RrX2FwcF9pZCI6ICIxOjM2MzUzNDEzMzA5NTphbmRyb2lkOjUzYTYwODI2NjZkMzc4MmM5MzMxYzIiLAogICAgICAgICJhbmRyb2lkX2NsaWVudF9pbmZvIjogewogICAgICAgICAgInBhY2thZ2VfbmFtZSI6ICJvbmxpbmUuYmluYXJhcHBzIgogICAgICAgIH0KICAgICAgfSwKICAgICAgIm9hdXRoX2NsaWVudCI6IFsKICAgICAgICB7CiAgICAgICAgICAiY2xpZW50X2lkIjogIjM2MzUzNDEzMzA5NS0zZGdvMmRnNnI0bzNmdDkyMHA0dTRtaGIwdG1vM25sbS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsCiAgICAgICAgICAiY2xpZW50X3R5cGUiOiAzCiAgICAgICAgfQogICAgICBdLAogICAgICAiYXBpX2tleSI6IFsKICAgICAgICB7CiAgICAgICAgICAiY3VycmVudF9rZXkiOiAiQUl6YVN5QUFjM2VvUTF4Z1RxSHNfZmdTSHZzSGlYeG5QdndoNVg4IgogICAgICAgIH0KICAgICAgXSwKICAgICAgInNlcnZpY2VzIjogewogICAgICAgICJhcHBpbnZpdGVfc2VydmljZSI6IHsKICAgICAgICAgICJvdGhlcl9wbGF0Zm9ybV9vYXV0aF9jbGllbnQiOiBbCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAiY2xpZW50X2lkIjogIjM2MzUzNDEzMzA5NS0zZGdvMmRnNnI0bzNmdDkyMHA0dTRtaGIwdG1vM25sbS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsCiAgICAgICAgICAgICAgImNsaWVudF90eXBlIjogMwogICAgICAgICAgICB9LAogICAgICAgICAgICB7CiAgICAgICAgICAgICAgImNsaWVudF9pZCI6ICIzNjM1MzQxMzMwOTUtYm1maG9tM2NrMjdpdWRyZmJnMnI3MWNlZTUwMDc4bTIuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLAogICAgICAgICAgICAgICJjbGllbnRfdHlwZSI6IDIsCiAgICAgICAgICAgICAgImlvc19pbmZvIjogewogICAgICAgICAgICAgICAgImJ1bmRsZV9pZCI6ICJvbmxpbmUuYmluYXJhcHBzIgogICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgXQogICAgICAgIH0KICAgICAgfQogICAgfQogIF0sCiAgImNvbmZpZ3VyYXRpb25fdmVyc2lvbiI6ICIxIgp9 -IOS_FIREBASE_CONFIG=PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+Q0xJRU5UX0lEPC9rZXk+Cgk8c3RyaW5nPjM2MzUzNDEzMzA5NS1ibWZob20zY2syN2l1ZHJmYmcycjcxY2VlNTAwNzhtMi5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbTwvc3RyaW5nPgoJPGtleT5SRVZFUlNFRF9DTElFTlRfSUQ8L2tleT4KCTxzdHJpbmc+Y29tLmdvb2dsZXVzZXJjb250ZW50LmFwcHMuMzYzNTM0MTMzMDk1LWJtZmhvbTNjazI3aXVkcmZiZzJyNzFjZWU1MDA3OG0yPC9zdHJpbmc+Cgk8a2V5PkFQSV9LRVk8L2tleT4KCTxzdHJpbmc+QUl6YVN5RExCc1gxRUVFZ2hhTDhydkVPbTJSbzFDNHA5LUVidlhjPC9zdHJpbmc+Cgk8a2V5PkdDTV9TRU5ERVJfSUQ8L2tleT4KCTxzdHJpbmc+MzYzNTM0MTMzMDk1PC9zdHJpbmc+Cgk8a2V5PlBMSVNUX1ZFUlNJT048L2tleT4KCTxzdHJpbmc+MTwvc3RyaW5nPgoJPGtleT5CVU5ETEVfSUQ8L2tleT4KCTxzdHJpbmc+b25saW5lLmJpbmFyYXBwczwvc3RyaW5nPgoJPGtleT5QUk9KRUNUX0lEPC9rZXk+Cgk8c3RyaW5nPnNjaG9vbHBpbG90LWRldmVsb3BtZW50PC9zdHJpbmc+Cgk8a2V5PlNUT1JBR0VfQlVDS0VUPC9rZXk+Cgk8c3RyaW5nPnNjaG9vbHBpbG90LWRldmVsb3BtZW50LmFwcHNwb3QuY29tPC9zdHJpbmc+Cgk8a2V5PklTX0FEU19FTkFCTEVEPC9rZXk+Cgk8ZmFsc2U+PC9mYWxzZT4KCTxrZXk+SVNfQU5BTFlUSUNTX0VOQUJMRUQ8L2tleT4KCTxmYWxzZT48L2ZhbHNlPgoJPGtleT5JU19BUFBJTlZJVEVfRU5BQkxFRDwva2V5PgoJPHRydWU+PC90cnVlPgoJPGtleT5JU19HQ01fRU5BQkxFRDwva2V5PgoJPHRydWU+PC90cnVlPgoJPGtleT5JU19TSUdOSU5fRU5BQkxFRDwva2V5PgoJPHRydWU+PC90cnVlPgoJPGtleT5HT09HTEVfQVBQX0lEPC9rZXk+Cgk8c3RyaW5nPjE6MzYzNTM0MTMzMDk1OmlvczpiZDM2N2E3ZDExMTQxYTIwOTMzMWMyPC9zdHJpbmc+CjwvZGljdD4KPC9wbGlzdD4= \ No newline at end of file diff --git a/src/design-system/components/GoogleButton/GoogleButton.tsx b/src/design-system/components/GoogleButton/GoogleButton.tsx index d12c4861..2196d77c 100644 --- a/src/design-system/components/GoogleButton/GoogleButton.tsx +++ b/src/design-system/components/GoogleButton/GoogleButton.tsx @@ -11,7 +11,7 @@ type GoogleButtonProps = { export const GoogleButton = ({ onPress, isDisabled }: GoogleButtonProps) => { return ( - diff --git a/src/screens/auth/SignInScreen.tsx b/src/screens/auth/SignInScreen.tsx index 87d7f898..0202b87a 100644 --- a/src/screens/auth/SignInScreen.tsx +++ b/src/screens/auth/SignInScreen.tsx @@ -6,7 +6,16 @@ import { Version, } from '@baca/components' import { REGEX, isWeb } from '@baca/constants' -import { Box, Button, Center, Display, Row, Spacer, Text } from '@baca/design-system' +import { + Box, + Button, + Center, + Display, + Row, + SignInWithGoogle, + Spacer, + Text, +} from '@baca/design-system' import { useCallback, useSignInForm, useTranslation } from '@baca/hooks' import { useRouter } from 'expo-router' @@ -104,6 +113,7 @@ export const SignInScreen = (): JSX.Element => { > {t('sign_in_screen.sign_in')} + {t('sign_in_screen.do_not_have_an_account')} From daffef8ed6c087a6d4422604c5ff48d17b41fb75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Baumruck?= Date: Tue, 9 Apr 2024 14:29:06 +0200 Subject: [PATCH 04/11] improve google sign in logic --- assets/social/apple-icon-dark.png | Bin 0 -> 357 bytes assets/social/apple-icon.png | Bin 0 -> 328 bytes assets/social/facebook-icon.png | Bin 0 -> 733 bytes assets/{ => social}/google-icon.png | Bin .../GoogleButton/NativeGoogleButton.tsx | 57 +++++++++++------ .../SocialButtons/GoogleButton/index.tsx | 8 +++ .../molecules/SocialButtons/SocialButton.tsx | 53 ++++++++++++++++ .../molecules/SocialButtons/index.ts | 2 + src/components/molecules/index.ts | 1 + src/components/wrappers/FormWrapper.tsx | 1 + src/constants/env.ts | 3 +- src/constants/images.ts | 5 +- .../components/Button/Button.tsx | 5 +- .../components/GoogleButton/GoogleButton.tsx | 19 ------ .../components/GoogleButton/index.tsx | 14 ----- src/design-system/components/index.ts | 1 - src/design-system/config/theme.ts | 2 +- src/i18n/translations/en.json | 2 + src/i18n/translations/pl.json | 2 + src/screens/ComponentsScreen.tsx | 59 ++++++------------ src/screens/auth/SignInScreen.tsx | 26 +++----- 21 files changed, 147 insertions(+), 113 deletions(-) create mode 100644 assets/social/apple-icon-dark.png create mode 100644 assets/social/apple-icon.png create mode 100644 assets/social/facebook-icon.png rename assets/{ => social}/google-icon.png (100%) rename src/{design-system/components => components/molecules/SocialButtons}/GoogleButton/NativeGoogleButton.tsx (58%) create mode 100644 src/components/molecules/SocialButtons/GoogleButton/index.tsx create mode 100644 src/components/molecules/SocialButtons/SocialButton.tsx create mode 100644 src/components/molecules/SocialButtons/index.ts delete mode 100644 src/design-system/components/GoogleButton/GoogleButton.tsx delete mode 100644 src/design-system/components/GoogleButton/index.tsx diff --git a/assets/social/apple-icon-dark.png b/assets/social/apple-icon-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..213c5404282c2e24aab18f7459e3c631eb3d0564 GIT binary patch literal 357 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9GG!XV7ZFl!D-1!HlL zyA#8@b22Z19F}xPUq=Rpjs4tz5?O)#U!E?GAr*{gr}XkR83?rUt0yp9H~A?@pWw(@ zApJt^5z7OX4UJZeIStZt-aGY5Ep&($+W&;LDE!{ne&tOqGm}>|_&t%HA@}3#yc(v% zE&BtX2usAJ&)%!2V3K^6x%nbrzvz+$)>GIW1C;bO3fy|JXV3KutUu?toe6LhEf1C~ zT9Y4|k!?5aMuJ<+~Q2*`ZK~=CvNye{|&JLh6019tDnm{r-UW|tD=h# literal 0 HcmV?d00001 diff --git a/assets/social/apple-icon.png b/assets/social/apple-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..34a7babe340408635a155accc5ede1c772a32149 GIT binary patch literal 328 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9GG!XV7ZFl!D-1!HlL zyA#8@b22Z19F}xPUq=Rpjs4tz5?O)#yPhtNAr*{wrzG+oG7xB$*OYctdlywbG$n;bH}GBw>8!Gc?%!f#%UgUP<>AJSm5R>G8U(7 zrmWR|pkku`AW+*tzxJ8brgvZUFIzr(IngTNA$NwtWv!ISPbR$Ge@Z;Sx$HvQjU7xy zi4Mo_-=5=Wwrs)g01jpmrjT9}d!>M~khBGrt&KrHZ0g!}U*5BBXWI4Xb*VF!#7Qt* Vm(HoX(E;=*gQu&X%Q~loCII%^ef$6b literal 0 HcmV?d00001 diff --git a/assets/social/facebook-icon.png b/assets/social/facebook-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..cc1109866152d9dda6aa0326394f647cd63fd31b GIT binary patch literal 733 zcmV<30wVp1P)P000;W1^@s654Bdt00009a7bBm000XU z000XU0RWnu7ytkO0drDELIAGL9O(c600d`2O+f$vv5yPBi#7KXGe3`p$&Vl1k}+=_uPLDH#249yG@1vVy_%7D~N zY=|J5uCb_SQwD56KwRSgd*6=Trj6}1X`f{I-#`1_{kwm63^5qanOPt)4alqnOEVy? z_9bM6fmMWb-hMCYZ=!6lFvU>r_bi#p`$l6>gXD#J@#KrHNXYXHdH$T1SsWfKV9rc^ zK{rB4S_CV!%%FGFh-hLjQ9zQOGt*is@u?evQyRnQ2oL0SQ_v&Zh#IzY$y(GcB_#db zR4VbP8-n>88tz^lXxsbxL*PpB&)%(bWbYxp?)wG}jA37?i!?2kK_FNa$wd z<9<4;^8*CG8qy8Zx+OdENXaMF!VQ;XY?2`w7tZiD`O7zfn@|6`MB!l5lJqP&<@OW}r{3ZaQHqNm(;FxMQFXsMN1*icme{;&ZZLqmoL&>eOwkhF_hL*VI&yqG01qz$t5uuF3L)`}&zhYwl_&reZ9udZA7Tlo`K!c2B5M!L; zZxKadt2o#(uc2*)yjh~x(&_u=6jkgLHMxr<`_0s93YbtQX3k4h3y8oDeE0AE2Exsk P00000NkvXXu0mjfz!Osm literal 0 HcmV?d00001 diff --git a/assets/google-icon.png b/assets/social/google-icon.png similarity index 100% rename from assets/google-icon.png rename to assets/social/google-icon.png diff --git a/src/design-system/components/GoogleButton/NativeGoogleButton.tsx b/src/components/molecules/SocialButtons/GoogleButton/NativeGoogleButton.tsx similarity index 58% rename from src/design-system/components/GoogleButton/NativeGoogleButton.tsx rename to src/components/molecules/SocialButtons/GoogleButton/NativeGoogleButton.tsx index 25f26ef4..c63c21a5 100644 --- a/src/design-system/components/GoogleButton/NativeGoogleButton.tsx +++ b/src/components/molecules/SocialButtons/GoogleButton/NativeGoogleButton.tsx @@ -1,15 +1,17 @@ import { useAuthGoogleControllerLogin } from '@baca/api/query/auth-social/auth-social' -import { isExpoGo } from '@baca/constants' +import { ENV, isExpoGo, isWeb } from '@baca/constants' import { useCallback, useEffect, useState } from '@baca/hooks' +import { assignPushToken, setToken } from '@baca/services' +import { isSignedInAtom, store } from '@baca/store' +import { showErrorToast } from '@baca/utils' import { FC } from 'react' import { useTranslation } from 'react-i18next' -import { GoogleButton } from './GoogleButton' +import { SocialButton } from '../SocialButton' -let NativeGoogleButton: FC - -if (!isExpoGo) { - // Conditionall import makes it work with expo go +let NativeGoogleButton: FC = () => undefined +if (!isExpoGo && !isWeb) { + // Conditionally import makes it work with expo go import('@react-native-google-signin/google-signin').then(({ GoogleSignin, statusCodes }) => { type GoogleSignInError = Error & { code: keyof typeof statusCodes } @@ -20,9 +22,11 @@ if (!isExpoGo) { useEffect(() => { // No extra configuration is needed, - // but for the more customisation check: + // but for the more customization check: // https://github.com/react-native-google-signin/google-signin#configureoptions - GoogleSignin?.configure?.() + GoogleSignin?.configure?.({ + webClientId: ENV.WEB_CLIENT_ID, + }) }, []) const verifyPlayServices = useCallback(async (): Promise => { @@ -35,12 +39,28 @@ if (!isExpoGo) { const verifyToken = useCallback(async (): Promise => { const tokenResponse = await GoogleSignin?.getTokens?.() - const { accessToken } = tokenResponse || {} - await signInByGoogle({ - data: { - idToken: accessToken, + + const { idToken } = tokenResponse || {} + + signInByGoogle( + { + data: { + idToken, + }, }, - }) + { + onSuccess: async (response) => { + const { user, ...token } = response + if (token) { + await setToken(token) + } + store.set(isSignedInAtom, true) + + // Send push token to backend + await assignPushToken() + }, + } + ) }, [signInByGoogle]) const signIn = useCallback(async (): Promise => { @@ -51,27 +71,26 @@ if (!isExpoGo) { // TODO: This could be extracted to external function with an additional handling of the error codes const typedError = error as GoogleSignInError - if (typedError.code) { + if (typedError?.code) { switch (typedError.code) { case statusCodes?.SIGN_IN_CANCELLED: case statusCodes?.IN_PROGRESS: break case statusCodes?.PLAY_SERVICES_NOT_AVAILABLE: - // TODO: wait for toast components - alert(t('errors.play_services_not_available')) + showErrorToast({ description: t('errors.play_services_not_available') }) break default: - alert(t('errors.something_went_wrong')) + showErrorToast({ description: t('errors.something_went_wrong') }) break } return } - alert(t('errors.something_went_wrong')) + showErrorToast({ description: t('errors.something_went_wrong') }) } }, [t, verifyToken]) - return + return } }) } diff --git a/src/components/molecules/SocialButtons/GoogleButton/index.tsx b/src/components/molecules/SocialButtons/GoogleButton/index.tsx new file mode 100644 index 00000000..057f40b1 --- /dev/null +++ b/src/components/molecules/SocialButtons/GoogleButton/index.tsx @@ -0,0 +1,8 @@ +import { isExpoGo, isWeb } from '@baca/constants' + +import { NativeGoogleButton } from './NativeGoogleButton' + +export const GoogleButton = () => { + if (isExpoGo || isWeb) return undefined //TODO: Add google button for web + return +} diff --git a/src/components/molecules/SocialButtons/SocialButton.tsx b/src/components/molecules/SocialButtons/SocialButton.tsx new file mode 100644 index 00000000..240329e5 --- /dev/null +++ b/src/components/molecules/SocialButtons/SocialButton.tsx @@ -0,0 +1,53 @@ +import { appleIconDark, appleIcon, facebookIcon, googleIcon } from '@baca/constants' +import { useColorScheme } from '@baca/contexts' +import { Button, ButtonProps } from '@baca/design-system' +import i18n from '@baca/i18n' +import { FC } from 'react' +import { Image, ImageSourcePropType } from 'react-native' + +type SocialMediaType = 'apple' | 'facebook' | 'google' + +const SocialButtonVariants: { + [key in SocialMediaType]: { + source: { light: ImageSourcePropType; dark?: ImageSourcePropType } + text: () => string + } +} = { + apple: { + source: { light: appleIcon, dark: appleIconDark }, + text: () => i18n.t('sign_in_screen.sign_in_by_apple'), + }, + facebook: { + source: { light: facebookIcon }, + text: () => i18n.t('sign_in_screen.sign_in_by_facebook'), + }, + google: { + source: { light: googleIcon }, + text: () => i18n.t('sign_in_screen.sign_in_by_google'), + }, +} + +type SocialButtonProps = { + onPress: () => void + type: SocialMediaType +} & ButtonProps + +export const SocialButton: FC = ({ type = 'google', ...rest }) => { + const { colorScheme } = useColorScheme() + + const { source, text } = SocialButtonVariants[type] + + return ( + + ) +} diff --git a/src/components/molecules/SocialButtons/index.ts b/src/components/molecules/SocialButtons/index.ts new file mode 100644 index 00000000..e81f3f99 --- /dev/null +++ b/src/components/molecules/SocialButtons/index.ts @@ -0,0 +1,2 @@ +export * from './GoogleButton' +export * from './SocialButton' diff --git a/src/components/molecules/index.ts b/src/components/molecules/index.ts index 4f4e7d1d..e0da150f 100644 --- a/src/components/molecules/index.ts +++ b/src/components/molecules/index.ts @@ -1,3 +1,4 @@ export * from './Field' export * from './MenuItem' +export * from './SocialButtons' export * from './TextArea' diff --git a/src/components/wrappers/FormWrapper.tsx b/src/components/wrappers/FormWrapper.tsx index 1375cc6f..ee4a42a2 100644 --- a/src/components/wrappers/FormWrapper.tsx +++ b/src/components/wrappers/FormWrapper.tsx @@ -21,6 +21,7 @@ export const FormWrapper: FC> = ({ return ( ) : ( (props: PressableStateCallbackType) => ( - + + {leftElement && leftElement} {leftIconName && iconElement(props, leftIconName)} {childrenElement(props)} {rightIconName && iconElement(props, rightIconName)} diff --git a/src/design-system/components/GoogleButton/GoogleButton.tsx b/src/design-system/components/GoogleButton/GoogleButton.tsx deleted file mode 100644 index 2196d77c..00000000 --- a/src/design-system/components/GoogleButton/GoogleButton.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { googleIcon } from '@baca/constants' -import { Image } from 'react-native' - -import { Button } from '../Button' -import { Text } from '../Text' - -type GoogleButtonProps = { - onPress: () => void - isDisabled?: boolean -} - -export const GoogleButton = ({ onPress, isDisabled }: GoogleButtonProps) => { - return ( - - ) -} diff --git a/src/design-system/components/GoogleButton/index.tsx b/src/design-system/components/GoogleButton/index.tsx deleted file mode 100644 index 3e524a37..00000000 --- a/src/design-system/components/GoogleButton/index.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { isExpoGo } from '@baca/constants' - -import { GoogleButton } from './GoogleButton' -import { NativeGoogleButton } from './NativeGoogleButton' - -export const SignInWithGoogle = () => { - if (isExpoGo) { - return ( - alert('Need to test on build version.')} /> - ) - } - - return -} diff --git a/src/design-system/components/index.ts b/src/design-system/components/index.ts index fc19ef70..0e63b20c 100644 --- a/src/design-system/components/index.ts +++ b/src/design-system/components/index.ts @@ -4,7 +4,6 @@ export * from './BoxWithShadow' export * from './Button' export * from './Center' export * from './Column' -export * from './GoogleButton' export * from './GradientBox' export * from './Row' export * from './Spacer' diff --git a/src/design-system/config/theme.ts b/src/design-system/config/theme.ts index 37bf664c..00190a60 100644 --- a/src/design-system/config/theme.ts +++ b/src/design-system/config/theme.ts @@ -334,7 +334,7 @@ export const shadows = { shadowOffset: { width: 0, height: 0 }, shadowColor: themeColors.primitives['Gray (light mode)'][400], shadowOpacity: 1, - shadowRadius: 8, + shadowRadius: 2, elevation: 3, }, } diff --git a/src/i18n/translations/en.json b/src/i18n/translations/en.json index a4ef8a1e..9c95fff0 100644 --- a/src/i18n/translations/en.json +++ b/src/i18n/translations/en.json @@ -225,6 +225,8 @@ "sign_in_screen": { "do_not_have_an_account": "Don't have an account?", "forgot_password": "Forgot password", + "sign_in_by_apple": "Log in with Apple", + "sign_in_by_facebook": "Log in with Facebook", "sign_in_by_google": "Log in with Google", "sign_in": "Log in", "sign_up": "Sign up", diff --git a/src/i18n/translations/pl.json b/src/i18n/translations/pl.json index 69ba91f3..0bac3c26 100644 --- a/src/i18n/translations/pl.json +++ b/src/i18n/translations/pl.json @@ -223,6 +223,8 @@ "sign_in_screen": { "do_not_have_an_account": "Nie masz konta?", "forgot_password": "Nie pamiętam hasła", + "sign_in_by_apple": "Zaloguj się przez Apple", + "sign_in_by_facebook": "Zaloguj się przez Facebook", "sign_in_by_google": "Zaloguj się przez Google", "sign_in": "Zaloguj się", "sign_up": "Zarejestruj się", diff --git a/src/screens/ComponentsScreen.tsx b/src/screens/ComponentsScreen.tsx index 8bc6da7b..f3e9de42 100644 --- a/src/screens/ComponentsScreen.tsx +++ b/src/screens/ComponentsScreen.tsx @@ -1,6 +1,7 @@ +import { SocialButton } from '@baca/components' import { Loader, Box, Text, Button, Center, ScrollView, Display } from '@baca/design-system' import { useCallback, useScreenOptions, useTranslation } from '@baca/hooks' -import { showInformationToast } from '@baca/utils' +import { noop, showInformationToast } from '@baca/utils' import * as Linking from 'expo-linking' const loaderVariants = [ @@ -48,61 +49,39 @@ export const ComponentsScreen = (): JSX.Element => { {t('components_screen.test_notification')} - - - {t('components_screen.typography.label')} - - - {t('components_screen.button_variants.header')} - + + {t('components_screen.button_variants.header')}: - - + + - - + + - - - - - + + + + - - + + + + {t('sign_in_screen.do_not_have_an_account')} From 61bedac2e447a86ec9e0d85a02aaf301f79ba870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Baumruck?= Date: Tue, 9 Apr 2024 14:33:15 +0200 Subject: [PATCH 05/11] update failing snapshots --- .../components/Button/__snapshots__/Button.test.tsx.snap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/design-system/components/Button/__snapshots__/Button.test.tsx.snap b/src/design-system/components/Button/__snapshots__/Button.test.tsx.snap index 541ac05a..8acaea4b 100644 --- a/src/design-system/components/Button/__snapshots__/Button.test.tsx.snap +++ b/src/design-system/components/Button/__snapshots__/Button.test.tsx.snap @@ -49,11 +49,13 @@ exports[`Button renders correctly 1`] = ` testID="baseButton" > Date: Tue, 9 Apr 2024 15:32:16 +0200 Subject: [PATCH 06/11] add google sign in button to sign up screen --- src/screens/auth/SignUpScreen.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/screens/auth/SignUpScreen.tsx b/src/screens/auth/SignUpScreen.tsx index c009e066..4706bc52 100644 --- a/src/screens/auth/SignUpScreen.tsx +++ b/src/screens/auth/SignUpScreen.tsx @@ -1,4 +1,4 @@ -import { CompanyLogo, ControlledField, FormWrapper } from '@baca/components' +import { CompanyLogo, ControlledField, FormWrapper, GoogleButton } from '@baca/components' import { Box, Button, Center, Display, Row, Spacer, Text } from '@baca/design-system' import { useSignUpForm, useTranslation } from '@baca/hooks' import { router } from 'expo-router' @@ -118,6 +118,10 @@ export const SignUpScreen = () => { {t('sign_up_screen.get_started')} + + + + {t('sign_up_screen.already_have_an_account')} From e943223cdb08c852fb9573511cb1cb1911e152ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Baumruck?= Date: Wed, 10 Apr 2024 08:50:59 +0200 Subject: [PATCH 07/11] update swagger --- scripts/data/swagger-spec.json | 28 ++++++------------- src/api/query/auth/auth.msw.ts | 2 +- src/api/types/authGoogleLoginDto.ts | 4 +-- src/api/types/errorValidationEntity.ts | 2 +- src/api/types/index.ts | 2 +- ...sentProperties.ts => lastConsentEntity.ts} | 2 +- src/api/types/refreshEntity.ts | 2 +- src/api/types/userEntity.ts | 4 +-- 8 files changed, 18 insertions(+), 28 deletions(-) rename src/api/types/{lastConsentProperties.ts => lastConsentEntity.ts} (95%) diff --git a/scripts/data/swagger-spec.json b/scripts/data/swagger-spec.json index 9f9f29e9..983cae3d 100644 --- a/scripts/data/swagger-spec.json +++ b/scripts/data/swagger-spec.json @@ -416,7 +416,7 @@ } }, "401": { - "description": "Unauthorized - Invalid credentials", + "description": "Unauthorized", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorUnauthorizedEntity" } @@ -1287,7 +1287,7 @@ "ErrorValidationEntity": { "type": "object", "properties": { - "status": { + "statusCode": { "type": "number", "description": "HTTP status code indicating the error", "example": 422 @@ -1299,7 +1299,7 @@ "additionalProperties": { "type": "string" } } }, - "required": ["status", "errors"] + "required": ["statusCode", "errors"] }, "UpdateArticleDto": { "type": "object", @@ -1434,7 +1434,7 @@ }, "required": ["id", "name"] }, - "LastConsentProperties": { + "LastConsentEntity": { "type": "object", "properties": { "termsAccepted": { @@ -1508,17 +1508,7 @@ "example": { "id": 1, "name": "ACTIVE" }, "allOf": [{ "$ref": "#/components/schemas/Status" }] }, - "consent": { - "example": { - "createdAt": "2024-03-07T23:29:27.697Z", - "privacyPolicyAccepted": true, - "privacyPolicyVersion": "1.0", - "termsAccepted": true, - "termsVersion": "1.0", - "updatedAt": "2024-03-07T23:29:27.697Z" - }, - "allOf": [{ "$ref": "#/components/schemas/LastConsentProperties" }] - } + "consent": { "$ref": "#/components/schemas/LastConsentEntity" } }, "required": [ "id", @@ -1779,7 +1769,7 @@ "description": "The refresh token for refreshing the access token." }, "tokenExpires": { - "type": "string", + "type": "number", "example": 1708531622031, "description": "The expiry date of the access token." } @@ -1837,13 +1827,13 @@ "AuthGoogleLoginDto": { "type": "object", "properties": { - "idToken": { + "accessToken": { "type": "string", "example": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjFlOGI2ZTFlYTI1Y2I2M2Q0ZTI5YWI1Y2M2ZDZmODBlZjRmNDY2NjciLCJ0eXAiOiJKV1QifQ.eyJhenAiOiIxMjM0NTY3ODkwMTIzNDU2Nzg5MC5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImF1ZCI6IjEyMzQ1Njc4OTAxMjM0NTY3ODkwLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiZXhwIjoxNjUxNTc2MDAwLCJpYXQiOjE2NTE1NzI0MDAsImlzcyI6ImFjY291bnRzLmdvb2dsZS5jb20iLCJzdWIiOiIxMjM0NTY3ODkwMTIzNDU2Nzg5MCIsImVtYWlsIjoianVzdHVzZXJAZ21haWwuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsIm5hbWUiOiJKdXN0IFVzZXIiLCJwaWN0dXJlIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9qdXN0dXNlci9waG90by5qcGciLCJnaXZlbl9uYW1lIjoiSnVzdCIsImZhbWlseV9uYW1lIjoiVXNlciJ9.QWxsYWtoemF0aGtqZGxza2FqaGRsa2FqZGxza2FqZGhza2FqaGRrc2FqaGtqZHNhbGtqZHNhbGtqZGhsYWtqZHNhbGtqaGRsYWtqaGRza2FqaGRrc2FqaGRrc2FqaGRrc2Fq", - "description": "Google ID token obtained after user authentication using Google OAuth. Use this token to authenticate the request to the application." + "description": "Google Access token obtained after user authentication using Google OAuth. Use this token to authenticate the request to the application." } }, - "required": ["idToken"] + "required": ["accessToken"] }, "AuthFacebookLoginDto": { "type": "object", diff --git a/src/api/query/auth/auth.msw.ts b/src/api/query/auth/auth.msw.ts index 398ac953..28ce03d3 100644 --- a/src/api/query/auth/auth.msw.ts +++ b/src/api/query/auth/auth.msw.ts @@ -130,7 +130,7 @@ export const getAuthControllerRefreshResponseMock = ( ): RefreshEntity => ({ accessToken: faker.word.sample(), refreshToken: faker.word.sample(), - tokenExpires: faker.word.sample(), + tokenExpires: faker.number.int({ min: undefined, max: undefined }), ...overrideResponse, }) diff --git a/src/api/types/authGoogleLoginDto.ts b/src/api/types/authGoogleLoginDto.ts index f0b31967..67b9f6da 100644 --- a/src/api/types/authGoogleLoginDto.ts +++ b/src/api/types/authGoogleLoginDto.ts @@ -8,6 +8,6 @@ */ export interface AuthGoogleLoginDto { - /** Google ID token obtained after user authentication using Google OAuth. Use this token to authenticate the request to the application. */ - idToken: string + /** Google Access token obtained after user authentication using Google OAuth. Use this token to authenticate the request to the application. */ + accessToken: string } diff --git a/src/api/types/errorValidationEntity.ts b/src/api/types/errorValidationEntity.ts index 38e77c14..5abc5437 100644 --- a/src/api/types/errorValidationEntity.ts +++ b/src/api/types/errorValidationEntity.ts @@ -12,5 +12,5 @@ export interface ErrorValidationEntity { /** Object containing field-specific validation errors */ errors: ErrorValidationEntityErrors /** HTTP status code indicating the error */ - status: number + statusCode: number } diff --git a/src/api/types/index.ts b/src/api/types/index.ts index cf69b96d..0915bd06 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -38,7 +38,7 @@ export * from './healthCheckInfoDto' export * from './healthCheckStatusDto' export * from './healthEntity' export * from './healthEntityError' -export * from './lastConsentProperties' +export * from './lastConsentEntity' export * from './refreshEntity' export * from './role' export * from './roleDto' diff --git a/src/api/types/lastConsentProperties.ts b/src/api/types/lastConsentEntity.ts similarity index 95% rename from src/api/types/lastConsentProperties.ts rename to src/api/types/lastConsentEntity.ts index 25675c10..a26caaf8 100644 --- a/src/api/types/lastConsentProperties.ts +++ b/src/api/types/lastConsentEntity.ts @@ -7,7 +7,7 @@ * OpenAPI spec version: 1.0 */ -export interface LastConsentProperties { +export interface LastConsentEntity { /** The date and time when the consents were last created or the user agreed to the terms for the first time. */ createdAt: string /** Whether the privacy policy was accepted. */ diff --git a/src/api/types/refreshEntity.ts b/src/api/types/refreshEntity.ts index a18e4a16..bddcd5dc 100644 --- a/src/api/types/refreshEntity.ts +++ b/src/api/types/refreshEntity.ts @@ -13,5 +13,5 @@ export interface RefreshEntity { /** The refresh token for refreshing the access token. */ refreshToken: string /** The expiry date of the access token. */ - tokenExpires: string + tokenExpires: number } diff --git a/src/api/types/userEntity.ts b/src/api/types/userEntity.ts index 3c3b90cf..218e4f80 100644 --- a/src/api/types/userEntity.ts +++ b/src/api/types/userEntity.ts @@ -6,12 +6,12 @@ * API documentation for the starter-kit project in NestJS by BinarApps. The API allows management of users, sessions and offers various functions for logged in users. Contains examples of authentication, authorization, and CRUD for selected resources. * OpenAPI spec version: 1.0 */ -import type { LastConsentProperties } from './lastConsentProperties' +import type { LastConsentEntity } from './lastConsentEntity' import type { Role } from './role' import type { Status } from './status' export interface UserEntity { - consent?: LastConsentProperties + consent?: LastConsentEntity createdAt: string deletedAt: string email: string From 9a7f6130a7d87b02cf05e2367a16f0ec9a3851f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Baumruck?= Date: Wed, 10 Apr 2024 08:52:04 +0200 Subject: [PATCH 08/11] add changes to google sign in --- .../SocialButtons/GoogleButton/NativeGoogleButton.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/molecules/SocialButtons/GoogleButton/NativeGoogleButton.tsx b/src/components/molecules/SocialButtons/GoogleButton/NativeGoogleButton.tsx index c63c21a5..7f0d1b0f 100644 --- a/src/components/molecules/SocialButtons/GoogleButton/NativeGoogleButton.tsx +++ b/src/components/molecules/SocialButtons/GoogleButton/NativeGoogleButton.tsx @@ -40,12 +40,12 @@ if (!isExpoGo && !isWeb) { const verifyToken = useCallback(async (): Promise => { const tokenResponse = await GoogleSignin?.getTokens?.() - const { idToken } = tokenResponse || {} + const { accessToken } = tokenResponse || {} signInByGoogle( { data: { - idToken, + accessToken, }, }, { From 7a1597c94c8bd4c4c1e1e730536cbf051b42b22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Baumruck?= Date: Wed, 10 Apr 2024 09:04:14 +0200 Subject: [PATCH 09/11] remove refresh token from async storage keys --- src/constants/asyncStorageKeys.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/constants/asyncStorageKeys.ts b/src/constants/asyncStorageKeys.ts index 65bd3e76..8765d32b 100644 --- a/src/constants/asyncStorageKeys.ts +++ b/src/constants/asyncStorageKeys.ts @@ -4,7 +4,6 @@ export const ASYNC_STORAGE_KEYS = { NEXT_DEEP_LINK: '@navigation/next_deeplink', PUSH_TOKEN: '@notification/push-token', USER_LANGUAGE: '@language/user-language', - USER_REFRESH_TOKEN: 'user_token-refresh_token', // This value is used in `expo-secure-store` package and it can't include '@' and '/' USER_TOKEN: 'user_token-token', // This value is used in `expo-secure-store` package and it can't include '@' and '/' WAS_PUSH_TOKEN_SEND: '@notification/was-push-token-send', } as const From a9e7ddc592d1426ef187c99bdff7a1a44133bee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Baumruck?= Date: Fri, 12 Apr 2024 10:08:20 +0200 Subject: [PATCH 10/11] add CR fixes --- src/components/molecules/SocialButtons/GoogleButton/index.tsx | 3 ++- src/components/molecules/SocialButtons/SocialButton.tsx | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/molecules/SocialButtons/GoogleButton/index.tsx b/src/components/molecules/SocialButtons/GoogleButton/index.tsx index 057f40b1..184d596c 100644 --- a/src/components/molecules/SocialButtons/GoogleButton/index.tsx +++ b/src/components/molecules/SocialButtons/GoogleButton/index.tsx @@ -3,6 +3,7 @@ import { isExpoGo, isWeb } from '@baca/constants' import { NativeGoogleButton } from './NativeGoogleButton' export const GoogleButton = () => { - if (isExpoGo || isWeb) return undefined //TODO: Add google button for web + //TODO: Add google button for web + if (isExpoGo || isWeb) return null return } diff --git a/src/components/molecules/SocialButtons/SocialButton.tsx b/src/components/molecules/SocialButtons/SocialButton.tsx index 240329e5..a8e96848 100644 --- a/src/components/molecules/SocialButtons/SocialButton.tsx +++ b/src/components/molecules/SocialButtons/SocialButton.tsx @@ -7,7 +7,7 @@ import { Image, ImageSourcePropType } from 'react-native' type SocialMediaType = 'apple' | 'facebook' | 'google' -const SocialButtonVariants: { +const socialButtonVariants: { [key in SocialMediaType]: { source: { light: ImageSourcePropType; dark?: ImageSourcePropType } text: () => string @@ -35,7 +35,7 @@ type SocialButtonProps = { export const SocialButton: FC = ({ type = 'google', ...rest }) => { const { colorScheme } = useColorScheme() - const { source, text } = SocialButtonVariants[type] + const { source, text } = socialButtonVariants[type] return (