diff --git a/app.json b/app.json index 0844c12f..65dde140 100644 --- a/app.json +++ b/app.json @@ -43,6 +43,15 @@ "useFrameworks": "static" } } + ], + [ + "react-native-fbsdk-next", + { + "appID": "974812100702878", + "clientToken": "434baaffa008eb537185c49ff516e3a8", + "displayName": "BACA", + "scheme": "fb974812100702878" + } ] ], "web": { diff --git a/app/(app)/(common)/privacy-policy.tsx b/app/(app)/(common)/privacy-policy.tsx index bd239e6c..7bd58abb 100644 --- a/app/(app)/(common)/privacy-policy.tsx +++ b/app/(app)/(common)/privacy-policy.tsx @@ -1,3 +1,3 @@ -import { BlogScreen } from '@baca/screens/BlogScreen' +import { PrivacyPolicyScreen } from '@baca/screens' -export default BlogScreen +export default PrivacyPolicyScreen diff --git a/docs/src/components/HomepageFeatures/index.tsx b/docs/src/components/HomepageFeatures/index.tsx index 1fba575b..68dfc13c 100644 --- a/docs/src/components/HomepageFeatures/index.tsx +++ b/docs/src/components/HomepageFeatures/index.tsx @@ -33,7 +33,7 @@ const FeatureList: FeatureItem[] = [ title: 'Powered by React Native and Expo', Svg: require('@site/static/img/undraw_docusaurus_react.svg').default, description: ( - <>We are using the newest tools to acheive the best performance and developer experience. + <>We are using the newest tools to achieve the best performance and developer experience. ), }, ] diff --git a/package.json b/package.json index 981bf60f..5646b495 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,8 @@ "react-dom": "18.2.0", "react-hook-form": "^7.49.3", "react-i18next": "^14.0.1", - "react-native": "0.73.5", + "react-native": "0.73.6", + "react-native-fbsdk-next": "^12.1.4", "react-native-gesture-handler": "~2.14.0", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-notificated": "^0.0.1-beta.2", diff --git a/src/components/molecules/SocialButtons/FacebookButton/NativeFacebookButton.tsx b/src/components/molecules/SocialButtons/FacebookButton/NativeFacebookButton.tsx new file mode 100644 index 00000000..b2c1a3d3 --- /dev/null +++ b/src/components/molecules/SocialButtons/FacebookButton/NativeFacebookButton.tsx @@ -0,0 +1,41 @@ +import { useAuthFacebookControllerLogin } from '@baca/api/query/auth-social/auth-social' +import { isExpoGo, isWeb } from '@baca/constants' +import { assignPushToken, setToken } from '@baca/services' +import { isSignedInAtom, store } from '@baca/store' + +import { SocialButton } from '../SocialButton' + +export const NativeFacebookButton = () => { + const { mutate: loginWithFacebook } = useAuthFacebookControllerLogin() + + if (isExpoGo || isWeb) return null + + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { AccessToken, LoginManager } = require('react-native-fbsdk-next') + + const handleLogin = async () => { + await LoginManager.logInWithPermissions(['email', 'public_profile'], 'enabled') + + const { accessToken } = (await AccessToken.getCurrentAccessToken()) || {} + + accessToken && + loginWithFacebook( + { data: { accessToken } }, + { + onSuccess: async (response) => { + const { user, ...token } = response + if (token) { + await setToken(token) + } + store.set(isSignedInAtom, true) + + // Send push token to backend + await assignPushToken() + }, + } + ) + } + + // eslint-disable-next-line react/jsx-no-bind + return +} diff --git a/src/components/molecules/SocialButtons/FacebookButton/index.tsx b/src/components/molecules/SocialButtons/FacebookButton/index.tsx new file mode 100644 index 00000000..012c7f0b --- /dev/null +++ b/src/components/molecules/SocialButtons/FacebookButton/index.tsx @@ -0,0 +1,10 @@ +import { isExpoGo, isWeb } from '@baca/constants' + +import { NativeFacebookButton } from './NativeFacebookButton' + +export const FacebookButton = () => { + //TODO: Add facebook button for web + if (isExpoGo || isWeb) return null + + return +} diff --git a/src/components/molecules/SocialButtons/index.ts b/src/components/molecules/SocialButtons/index.ts index e81f3f99..84472267 100644 --- a/src/components/molecules/SocialButtons/index.ts +++ b/src/components/molecules/SocialButtons/index.ts @@ -1,2 +1,3 @@ export * from './GoogleButton' +export * from './FacebookButton' export * from './SocialButton' diff --git a/src/screens/NotFoundScreen.tsx b/src/screens/NotFoundScreen.tsx index 488ad025..db9025ac 100644 --- a/src/screens/NotFoundScreen.tsx +++ b/src/screens/NotFoundScreen.tsx @@ -1,5 +1,12 @@ -import { Center, Text } from '@baca/design-system' +import { Box, Button, Text } from '@baca/design-system' import { useScreenOptions, useTranslation } from '@baca/hooks' +import { router } from 'expo-router' +import { StyleSheet } from 'react-native' +import { SafeAreaView } from 'react-native-safe-area-context' + +const navigateToLogin = () => { + router.navigate('/sign-in') +} export const NotFoundScreen = (): JSX.Element => { const { t } = useTranslation() @@ -9,8 +16,15 @@ export const NotFoundScreen = (): JSX.Element => { }) return ( -
- {t('errors.screen_not_found')} -
+ + + {t('errors.screen_not_found')} + + diff --git a/src/screens/index.ts b/src/screens/index.ts index 8eff38bd..e05bd6c5 100644 --- a/src/screens/index.ts +++ b/src/screens/index.ts @@ -9,6 +9,7 @@ export * from './DetailsScreen' export * from './ExamplesScreen' export * from './HomeScreen' export * from './NotFoundScreen' +export * from './PrivacyPolicyScreen' export * from './ProfileScreen' export * from './PushNotificationsHelpersScreen' export * from './SettingsScreen' diff --git a/yarn.lock b/yarn.lock index 685d71c9..f7ac0fb6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11485,6 +11485,11 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== +react-native-fbsdk-next@^12.1.4: + version "12.1.4" + resolved "https://registry.yarnpkg.com/react-native-fbsdk-next/-/react-native-fbsdk-next-12.1.4.tgz#b5525df79ca3181f3e1868eb3c7fa316c6297a8d" + integrity sha512-6fC+RTG0kwkZkjO/FYNvva1O60EmmvK/8+ifLmLf+eOHybkjKdcSsnbEk7iODyjZALhyAvDaYYyq27yyJo1X5Q== + react-native-flipper@^0.164.0: version "0.164.0" resolved "https://registry.yarnpkg.com/react-native-flipper/-/react-native-flipper-0.164.0.tgz#64f6269a86a13a72e30f53ba9f5281d2073a7697" @@ -11576,10 +11581,10 @@ react-native-web@~0.19.6: postcss-value-parser "^4.2.0" styleq "^0.1.3" -react-native@0.73.5: - version "0.73.5" - resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.73.5.tgz#724fd1ae8ec8fee1dcf619c82bdd1695d3cff463" - integrity sha512-iHgDArmF4CrhL0qTj+Rn+CBN5pZWUL9lUGl8ub+V9Hwu/vnzQQh8rTMVSwVd2sV6N76KjpE5a4TfIAHkpIHhKg== +react-native@0.73.6: + version "0.73.6" + resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.73.6.tgz#ed4c675e205a34bd62c4ce8b9bd1ca5c85126d5b" + integrity sha512-oqmZe8D2/VolIzSPZw+oUd6j/bEmeRHwsLn1xLA5wllEYsZ5zNuMsDus235ONOnCRwexqof/J3aztyQswSmiaA== dependencies: "@jest/create-cache-key-function" "^29.6.3" "@react-native-community/cli" "12.3.6"