From 62a6f5b5a9e7f51d4c87043dc24733a44f346404 Mon Sep 17 00:00:00 2001 From: Andrew Tapper Date: Thu, 9 Feb 2023 06:35:19 -0600 Subject: [PATCH] :fire: burn leftovers, add switch all axios urls to use apiURL constants for easy stage config switch --- .gitignore | 248 ++++++++++++++++++++++++++++++ .prettierrc | 4 +- android/app/debug.keystore | Bin 0 -> 2257 bytes app.json | 21 ++- index.js | 8 + metro.config.js | 4 + package.json | 11 +- src/components/EditFeastForm.js | 22 ++- src/context/AppProvider.js | 54 ------- src/context/AuthProvider.js | 68 ++------- src/hooks/useCreateFeast.js | 22 +-- src/hooks/useFeasts.js | 4 +- src/hooks/useVote.js | 22 +-- src/hooks/useWinner.js | 49 +----- src/screens/EditFeastScreen.js | 252 +------------------------------ src/screens/HomeScreen.js | 174 +++++---------------- src/screens/NewFeastScreen.js | 257 +------------------------------- yarn.lock | 92 +++++++----- 18 files changed, 418 insertions(+), 894 deletions(-) create mode 100644 android/app/debug.keystore create mode 100644 index.js create mode 100644 metro.config.js diff --git a/.gitignore b/.gitignore index 04c56fc..0ccc66c 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,251 @@ amplifytools.xcconfig .secret-* **.sample #amplify-do-not-edit-end +ios/.gitignore +ios/.xcode.env +ios/Podfile +ios/Podfile.properties.json +ios/DinderRN/AppDelegate.h +ios/DinderRN/AppDelegate.mm +ios/DinderRN/DinderRN.entitlements +ios/DinderRN/Info.plist +ios/DinderRN/main.m +ios/DinderRN/noop-file.swift +ios/DinderRN/SplashScreen.storyboard +ios/DinderRN/Images.xcassets/Contents.json +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@1x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@2x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@3x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@1x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@2x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@3x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@1x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@2x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@3x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-60x60@2x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-60x60@3x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-76x76@1x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-76x76@2x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/App-Icon-83.5x83.5@2x.png +ios/DinderRN/Images.xcassets/AppIcon.appiconset/Contents.json +ios/DinderRN/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png +ios/DinderRN/Images.xcassets/SplashScreen.imageset/Contents.json +ios/DinderRN/Images.xcassets/SplashScreen.imageset/image.png +ios/DinderRN/Images.xcassets/SplashScreenBackground.imageset/Contents.json +ios/DinderRN/Images.xcassets/SplashScreenBackground.imageset/image.png +ios/DinderRN/Supporting/Expo.plist +ios/DinderRN.xcodeproj/project.pbxproj +ios/DinderRN.xcodeproj/xcshareddata/xcschemes/DinderRN.xcscheme +android/.gitignore +android/build.gradle +android/gradle.properties +android/gradlew +android/gradlew.bat +android/settings.gradle +android/app/BUCK +android/app/build_defs.bzl +android/app/build.gradle +android/app/debug.keystore +android/app/proguard-rules.pro +android/app/src/debug/AndroidManifest.xml +android/app/src/debug/java/com/thinktapper/dinder/ReactNativeFlipper.java +android/app/src/main/AndroidManifest.xml +android/app/src/main/java/com/thinktapper/dinder/MainActivity.java +android/app/src/main/java/com/thinktapper/dinder/MainApplication.java +android/app/src/main/java/com/thinktapper/dinder/newarchitecture/MainApplicationReactNativeHost.java +android/app/src/main/java/com/thinktapper/dinder/newarchitecture/components/MainComponentsRegistry.java +android/app/src/main/java/com/thinktapper/dinder/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java +android/app/src/main/jni/Android.mk +android/app/src/main/jni/MainApplicationModuleProvider.cpp +android/app/src/main/jni/MainApplicationModuleProvider.h +android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h +android/app/src/main/jni/MainComponentsRegistry.cpp +android/app/src/main/jni/MainComponentsRegistry.h +android/app/src/main/jni/OnLoad.cpp +android/app/src/main/res/drawable/rn_edit_text_material.xml +android/app/src/main/res/drawable/splashscreen.xml +android/app/src/main/res/drawable-hdpi/splashscreen_image.png +android/app/src/main/res/drawable-mdpi/splashscreen_image.png +android/app/src/main/res/drawable-xhdpi/splashscreen_image.png +android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png +android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png +android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +android/app/src/main/res/mipmap-hdpi/ic_launcher.png +android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +android/app/src/main/res/mipmap-mdpi/ic_launcher.png +android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +android/app/src/main/res/values/colors.xml +android/app/src/main/res/values/strings.xml +android/app/src/main/res/values/styles.xml +android/app/src/main/res/values-night/colors.xml +android/gradle/wrapper/gradle-wrapper.jar +android/gradle/wrapper/gradle-wrapper.properties +# Expo +.expo +__generated__ +web-build +bare-apps + +# macOS +.DS_Store + +# Node +node_modules +npm-debug.log +yarn-error.log + +# Ruby +.direnv + +# Env +.envrc.local + +# Emacs +*~ + +# Vim +.*.swp +.*.swo +.*.swn +.*.swm + +# Sublime Text +*.sublime-project +*.sublime-workspace + +# Xcode +*.pbxuser +!default.pbxuser +*.xccheckout +*.xcscmblueprint +xcuserdata + +# IDEA / Android Studio +*.iml +.gradle +.idea + +# Eclipse +.project +.settings + +# VSCode +.history/ + +# Android +*.apk +*.hprof +/android/**/build +/android/**/.cxx +/android/**/local.properties +/android/captures +/android/expoview/libs/ReactAndroid-temp +/android/versioned-react-native/ReactAndroid +/android/versioned-react-native/ReactCommon +/android/versioned-react-native/codegen +/android/versioned-react-native/sdks +ReactAndroid-temp.aar +/android/prebuiltHermes +/android/versioned-abis/**/*.aar + +# Tools +jarjar-rules.txt + +# Dynamic Macros +/ios/Exponent/Supporting/EXBuildConstants.plist.bak +/ios/Exponent/Supporting/EXBuildConstants.plist.json +/ios/Exponent/Supporting/EXBuildConstants.plist +/ios/Exponent/Supporting/GoogleService-Info.plist +/ios/Exponent/Supporting/Info.plist.bak +/ios/Exponent/Supporting/Info.plist.json +/android/expoview/src/main/java/host/exp/exponent/generated/ExponentBuildConstants.java +/android/app/src/androidTest/java/host/exp/exponent/generated/TestBuildConstants.java +.kernel-ngrok-url + +# Template files +/android/app/src/main/AndroidManifest.xml +/android/app/google-services.json +/android/expoview/src/main/java/host/exp/exponent/generated/ExponentKeys.java +/apps/bare-expo/android/app/google-services.json +/apps/bare-expo/ios/BareExpo/GoogleService-Info.plist +/ios/Exponent/Generated/EXKeys.h +/ios/ExponentIntegrationTests/EXTestEnvironment.plist +/exponent-view-template/ios/Podfile + +# Template projects +templates/**/android/**/generated/* +templates/**/android/app/build +templates/**/Pods/** +templates/**/Podfile.lock +templates/**/yarn.lock + +# EYW template +/packages/expo-yarn-workspaces/workspace-template/yarn.lock + +# Codemod +.codemod.bookmark + +# Fastlane +/*.cer +/fastlane/report.xml +/fastlane/Preview.html +/fastlane/Deployment +/fastlane/test_output +/Preview.html +/gc_keys.json +/fastlane/gc_keys.json + +# CI +/android/logcat.txt + +# Shell apps +android-shell-app +shellAppBase-* +shellAppIntermediates +shellAppWorkspaces +/artifacts/* + +# Expo Client builds +/client-builds + +# Expo web env +.env.local +.env.development.local +.env.test.local +.env.production.local +apps/bare-expo/deploy-url.txt + +# Temporary files created by Metro to check the health of the file watcher +.metro-health-check* + +# Expo Doc merging +docs/pages/versions/*/react-native/ADDED_*.md +docs/pages/versions/*/react-native/REMOVED_*.md +docs/pages/versions/*/react-native/*.diff + +# Home +/home/dist + +# Prebuilds +/packages/**/*.xcframework +/packages/**/*.spec.json +/packages/**/Info-generated.plist + +# iOS +/ios/Pods +/ios/build +**/ios/.xcode.env.local +/ios/versioned-react-native/*/ReactNative/sdks/hermes-engine/destroot diff --git a/.prettierrc b/.prettierrc index 52ae4a0..a507d73 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,11 +1,11 @@ { - "printWidth": 100, + "printWidth": 140, "tabWidth": 2, "semi": false, "singleQuote": true, "trailingComma": "es5", "bracketSpacing": true, "bracketSameLine": true, - "jsxBracketSameLine": true, + "jsxBracketSameLine": false, "arrowParens": "always" } diff --git a/android/app/debug.keystore b/android/app/debug.keystore new file mode 100644 index 0000000000000000000000000000000000000000..364e105ed39fbfd62001429a68140672b06ec0de GIT binary patch literal 2257 zcmchYXEfYt8;7T1^dLH$VOTZ%2NOdOH5j5LYLtZ0q7x-V8_6gU5)#7dkq{HTmsfNq zB3ZqcAxeY^G10@?efK?Q&)M(qInVv!xjx+IKEL}p*K@LYvIzo#AZG>st5|P)KF1_Z;y){W{<7K{nl!CPuE z_^(!C(Ol0n8 zK13*rzAtW>(wULKPRYLd7G18F8#1P`V*9`(Poj26eOXYyBVZPno~Cvvhx7vPjAuZo zF?VD!zB~QG(!zbw#qsxT8%BSpqMZ4f70ZPn-3y$L8{EVbbN9$H`B&Z1quk9tgp5FM zuxp3pJ0b8u|3+#5bkJ4SRnCF2l7#DyLYXYY8*?OuAwK4E6J{0N=O3QNVzQ$L#FKkR zi-c@&!nDvezOV$i$Lr}iF$XEcwnybQ6WZrMKuw8gCL^U#D;q3t&HpTbqyD%vG=TeDlzCT~MXUPC|Leb-Uk+ z=vnMd(|>ld?Fh>V8poP;q;;nc@en$|rnP0ytzD&fFkCeUE^kG9Kx4wUh!!rpjwKDP zyw_e|a^x_w3E zP}}@$g>*LLJ4i0`Gx)qltL}@;mDv}D*xR^oeWcWdPkW@Uu)B^X&4W1$p6}ze!zudJ zyiLg@uggoMIArBr*27EZV7djDg@W1MaL+rcZ-lrANJQ%%>u8)ZMWU@R2qtnmG(acP z0d_^!t>}5W zpT`*2NR+0+SpTHb+6Js4b;%LJB;B_-ChhnU5py}iJtku*hm5F0!iql8Hrpcy1aYbT z1*dKC5ua6pMX@@iONI?Hpr%h;&YaXp9n!ND7-=a%BD7v&g zOO41M6EbE24mJ#S$Ui0-brR5ML%@|ndz^)YLMMV1atna{Fw<;TF@>d&F|!Z>8eg>>hkFrV)W+uv=`^F9^e zzzM2*oOjT9%gLoub%(R57p-`TXFe#oh1_{&N-YN z<}artH|m=d8TQuKSWE)Z%puU|g|^^NFwC#N=@dPhasyYjoy(fdEVfKR@cXKHZV-`06HsP`|Ftx;8(YD$fFXumLWbGnu$GMqRncXYY9mwz9$ap zQtfZB^_BeNYITh^hA7+(XNFox5WMeG_LtJ%*Q}$8VKDI_p8^pqX)}NMb`0e|wgF7D zuQACY_Ua<1ri{;Jwt@_1sW9zzdgnyh_O#8y+C;LcZq6=4e^cs6KvmK@$vVpKFGbQ= z$)Eux5C|Fx;Gtmv9^#Y-g@7Rt7*eLp5n!gJmn7&B_L$G?NCN`AP>cXQEz}%F%K;vUs{+l4Q{}eWW;ATe2 zqvXzxoIDy(u;F2q1JH7Sf;{jy_j})F+cKlIOmNfjBGHoG^CN zM|Ho&&X|L-36f}Q-obEACz`sI%2f&k>z5c$2TyTSj~vmO)BW~+N^kt`Jt@R|s!){H ze1_eCrlNaPkJQhL$WG&iRvF*YG=gXd1IyYQ9ew|iYn7r~g!wOnw;@n42>enAxBv*A zEmV*N#sxdicyNM=A4|yaOC5MByts}s_Hpfj|y<6G=o=!3S@eIFKDdpR7|FY>L&Wat&oW&cm&X~ z5Bt>Fcq(fgnvlvLSYg&o6>&fY`ODg4`V^lWWD=%oJ#Kbad2u~! zLECFS*??>|vDsNR&pH=Ze0Eo`sC_G`OjoEKVHY|wmwlX&(XBE<@sx3Hd^gtd-fNwUHsylg06p`U2y_={u}Bc App); +// It also ensures that whether you load the app in Expo Go or in a native build, +// the environment is set up appropriately +registerRootComponent(App); diff --git a/metro.config.js b/metro.config.js new file mode 100644 index 0000000..9430b0f --- /dev/null +++ b/metro.config.js @@ -0,0 +1,4 @@ +// Learn more https://docs.expo.io/guides/customizing-metro +const { getDefaultConfig } = require('expo/metro-config'); + +module.exports = getDefaultConfig(__dirname); diff --git a/package.json b/package.json index 353637d..15286b9 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ { "name": "dinderrn", "version": "1.0.0", - "main": "node_modules/expo/AppEntry.js", "scripts": { - "start": "expo start", - "android": "expo start --android", - "ios": "expo start --ios", + "start": "expo start --dev-client", + "android": "expo run:android", + "ios": "expo run:ios", "web": "expo start --web", "eject": "expo eject", "lint": "eslint .", @@ -25,14 +24,13 @@ "@tanstack/react-query": "^4.18.0", "@tanstack/react-query-persist-client": "^4.19.1", "axios": "^1.1.3", - "expo": "~46.0.16", + "expo": "~46.0.19", "expo-asset": "~8.6.3", "expo-secure-store": "~11.3.0", "expo-splash-screen": "~0.16.2", "expo-status-bar": "~1.4.0", "fast-json-patch": "^3.1.1", "formik": "^2.2.9", - "immer": "^9.0.17", "moment": "^2.29.4", "native-base": "^3.4.25", "patch-package": "^6.5.0", @@ -57,6 +55,7 @@ "react-native-screens": "~3.15.0", "react-native-svg": "12.3.0", "react-native-url-polyfill": "^1.3.0", + "react-native-web": "~0.18.7", "react-ridge-state": "^4.2.9", "twrnc": "^3.4.0", "yup": "^0.32.11" diff --git a/src/components/EditFeastForm.js b/src/components/EditFeastForm.js index d241f92..aee4585 100644 --- a/src/components/EditFeastForm.js +++ b/src/components/EditFeastForm.js @@ -47,10 +47,11 @@ import moment from 'moment' import { useAuthContext } from '../context/AuthProvider' import { feastState } from '../context/FeastState' import axios from 'axios' +import { apiURL } from '../lib/constants' const submitFeast = async (selectedFeast, formData, user) => { const response = await axios( - `http:localhost:3000/api/feast/${selectedFeast.id}`, + `${apiURL.remote}/api/feast/${selectedFeast.id}`, { method: 'PUT', data: { ...formData }, @@ -58,7 +59,7 @@ const submitFeast = async (selectedFeast, formData, user) => { // prettier-ignore 'authorization': `Bearer ${user?.token}`, }, - }, + } ) // console.warn('submitFeast:', JSON.stringify(response)) return response.data @@ -99,7 +100,7 @@ function EditFeastForm({ props }) { // onSettled: () => { // navigation.goBack() // }, - }, + } ) return ( @@ -200,7 +201,8 @@ function EditFeastForm({ props }) { selectedValue={formData.radius} onValueChange={(itemValue) => handleChange('radius', itemValue) - }> + } + > @@ -213,7 +215,8 @@ function EditFeastForm({ props }) { {editFeast.isLoading && ( @@ -233,7 +236,8 @@ function EditFeastForm({ props }) { flexShrink={1} space={2} alignItems="center" - justifyContent="space-between"> + justifyContent="space-between" + > + }} + > Failed to edit feast @@ -263,7 +268,8 @@ function EditFeastForm({ props }) { _text: { color: 'coolGray.600', }, - }}> + }} + > {editFeast.error.message} diff --git a/src/context/AppProvider.js b/src/context/AppProvider.js index 4b81d6d..8611af4 100644 --- a/src/context/AppProvider.js +++ b/src/context/AppProvider.js @@ -38,65 +38,11 @@ export const AppProvider = ({ children }) => { const [loading, setLoading] = useState(false) const { user } = useAuthContext() // const [activeScreen, setActiveScreen] = useState('Home') - // const [currentFeast, setCurrentFeast] = useState(null) - // const [places, setPlaces] = useState([]) - - // async function getFeastPlaces(feast, user) { - // if (!feast || !user) return null - - // const { data } = await axios({ - // url: `http://localhost:3000/api/feast/${feast.id}`, - // method: 'get', - // headers: { authorization: `Bearer ${user.token}` }, - // }) - - // setPlaces(data.feast.places) - - // // return data.success ? data.feast : null - // return data.feast.places - // } - - // const handleChangeFeast = (feast) => { - // setLoading(true) - // try { - // const feastPlaces = getFeastPlaces(feast, user) - // setCurrentFeast(feast) - // setPlaces(feast.places) - - // setAppData(feast) - // setLoading(false) - // return feast - // } catch (err) { - // console.warn(`Error saving feast change locally: ${err.message}`) - // setLoading(false) - // } - // } - - // useEffect(() => { - // const getDataFromStorage = async () => { - // const data = await getAppData() - // if (data) { - // setCurrentFeast(data.currentFeast) - // setPlaces(data.places) - // } - // } - - // getDataFromStorage().then(() => { - // console.log('Data retrieved from storage') - // }) - // }, []) const values = { color, activeColor, loading, - // activeScreen, - // setActiveScreen, - // currentFeast, - // setCurrentFeast, - // places, - // setPlaces, - // handleChangeFeast, } return {children} diff --git a/src/context/AuthProvider.js b/src/context/AuthProvider.js index 65909a9..bd99e70 100644 --- a/src/context/AuthProvider.js +++ b/src/context/AuthProvider.js @@ -12,10 +12,6 @@ import axios from 'axios' import { apiURL } from '../lib/constants' import { SECURE_SECRET } from '@env' -// const SECURE_AUTH_STORAGE_KEY = SECURE_SECRET - -const authClient = axios.create({ baseURL: 'http://localhost:3000' }) - const AuthContext = createContext({}) export const AuthProvider = ({ children }) => { @@ -31,7 +27,6 @@ export const AuthProvider = ({ children }) => { logout, signup, updateUser, - authRequest, } async function getStoredUser() { @@ -50,35 +45,21 @@ export const AuthProvider = ({ children }) => { return 'Success, User logged out' } - async function authRequest({ ...options }) { - authClient.defaults.headers.common['authorization'] = `Bearer ${user.token}` - // const onSuccess = (response) => response - // const onError = (error) => { - // return error - // } - - try { - const response = await authClient(options) - return response - } catch (error) { - return error - } - } - async function login(values) { - // authServerCall('/login', username, password) const { username, password } = values + setSplashLoading(true) try { - const response = await axios.post('http://localhost:3000/login', { + const response = await axios.post(`${apiURL.remote}/login`, { username, password, }) + + // update stored user data if ('user' in response.data && 'token' in response.data.user) { - // update stored user data await setStoredUser(response.data.user) setUser(response.data.user) - console.debug(`User ${response.data.user.username} logged in`) + // console.debug(`User ${response.data.user.username} logged in`) } setSplashLoading(false) } catch (err) { @@ -91,7 +72,7 @@ export const AuthProvider = ({ children }) => { setSplashLoading(true) try { const { data, status } = await axios({ - url: `${apiURL.local}/signup`, + url: `${apiURL.remote}/signup`, method: 'post', data: { email, @@ -102,7 +83,6 @@ export const AuthProvider = ({ children }) => { }) if ('user' in data && 'token' in data.user) { - // setIsSignOut(false) setUser(data.user) // update stored user data @@ -118,10 +98,9 @@ export const AuthProvider = ({ children }) => { } async function updateUser(values) { - // setIsSignOut(true) try { const response = await axios({ - url: 'http://localhost:3000/api/user/update', + url: `${apiURL.remote}/api/user/update`, method: 'put', data: { ...values }, headers: { @@ -129,13 +108,11 @@ export const AuthProvider = ({ children }) => { 'authorization': `Bearer ${user.token}`, }, }) - // console.log(JSON.stringify(response)) + + // update stored user data if ('user' in response.data && 'token' in response.data.user) { - // setIsSignOut(false) setUser(response.data.user) - // update stored user data await setStoredUser(response.data.user) - console.debug(`User ${response.data.user.username} updated`) } return response } catch (err) { @@ -144,26 +121,20 @@ export const AuthProvider = ({ children }) => { } async function logout() { - // setIsSignOut(true) try { const response = await axios({ - url: 'http://localhost:3000/logout', + url: `${apiURL.remote}/logout`, method: 'post', headers: { // prettier-ignore 'authorization': `Bearer ${user.token}`, }, }) - // console.log(JSON.stringify(response)) + // remove stored user data if (response.data.success) { setUser(null) - // remove stored user data await clearStoredUser() - // if (message === 'Success, User logged out') { - // console.debug(message) - // } } else { - console.log('Error logging out') throw new Error('Error logging out') } } catch (err) { @@ -175,7 +146,6 @@ export const AuthProvider = ({ children }) => { try { setSplashLoading(true) const userInfo = await getStoredUser() - // userInfo = JSON.parse(userInfo) if (userInfo) { setUser(userInfo) } @@ -194,7 +164,6 @@ export const AuthProvider = ({ children }) => { // queryClient.clear() // const message = await clearStoredUser() // if (message.includes('Success')) { - // // === 'Success, User logged out') { // console.debug(message) // } else { // console.log('Error logging out') @@ -205,21 +174,6 @@ export const AuthProvider = ({ children }) => { // reset() }, []) - // const authContext = useMemo( - // () => ({ - // user, - // login, - // updateUser, - // signup, - // logout, - // splashLoading, - // isSignOut, - // setIsSignOut, - // }), - // // eslint-disable-next-line react-hooks/exhaustive-deps - // [login, updateUser, signup, logout], - // ) - return {children} } diff --git a/src/hooks/useCreateFeast.js b/src/hooks/useCreateFeast.js index de31fdc..2fbc99f 100644 --- a/src/hooks/useCreateFeast.js +++ b/src/hooks/useCreateFeast.js @@ -2,19 +2,16 @@ import { Alert } from 'react-native' import { useMutation } from '@tanstack/react-query' import { queryClient } from '../lib/queryClient' import axios from 'axios' +import { apiURL } from '../lib/constants' import { useAuthContext } from '../context/AuthProvider' const createFeast = async (values, user) => { const response = await axios({ - url: 'http://localhost:3000/api/feast', + url: `${apiURL.remote}/api/feast`, method: 'post', headers: { authorization: `Bearer ${user?.token}` }, data: { values }, }) - console.warn('createFeast:', JSON.stringify(response)) - - // return data.feast - // return response.data.feast } export function useCreateFeast() { @@ -23,19 +20,4 @@ export function useCreateFeast() { return useMutation({ mutationFn: ({ ...values }) => createFeast(values, user), }) - // { - // onSuccess: (newFeast) => { - // // queryClient.setQueryData(['feasts'], newFeast) - // queryClient.invalidateQueries('feasts') - // console.log('success, you created a feast: ', newFeast) - // Alert.alert('Feast info saved successfully') - // }, - // onError: (error) => { - // console.log('error', error) - // Alert.alert('Error', 'There was an error saving your feast') - // }, - // }, - // ) - - // return mutate } diff --git a/src/hooks/useFeasts.js b/src/hooks/useFeasts.js index eeadac1..b5929cf 100644 --- a/src/hooks/useFeasts.js +++ b/src/hooks/useFeasts.js @@ -20,14 +20,14 @@ function useFeasts() { const { user } = useAuthContext() const fallback = [] - const { data: feasts = fallback, refetch } = useQuery( + const { data: feasts = fallback } = useQuery( [queryKeys.feasts], () => fetchFeasts(user), { enabled: !!user, // staleTime: 1000 * 60 * 60 * 24, // cacheTime: Infinity, - }, + } ) return feasts diff --git a/src/hooks/useVote.js b/src/hooks/useVote.js index 86ec361..bb30824 100644 --- a/src/hooks/useVote.js +++ b/src/hooks/useVote.js @@ -1,5 +1,5 @@ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query' -import { queryKeys } from '../lib/constants' +import { queryKeys, apiURL } from '../lib/constants' import axios from 'axios' import { feastState } from '../context/FeastState' import { useAuthContext } from '../context/AuthProvider' @@ -7,7 +7,7 @@ import { useAuthContext } from '../context/AuthProvider' // for when we need a query function for useQuery async function addVoteOnServer(voteData, user) { const { data } = await axios({ - url: `http://localhost:3000/api/vote`, + url: `${apiURL.remote}/api/vote`, method: 'post', data: { ...voteData }, headers: { authorization: `Bearer ${user?.token}` }, @@ -37,20 +37,8 @@ export default function useVote() { // Optimistically update to the new value queryClient.setQueryData( [queryKeys.votes, queryKeys.places, currentFeast?.id], - (old) => [...old, vote], + (old) => [...old, vote] ) - // const newPlaces = old.map((place) => { - // if (place.id === vote.placeId) { - // return { - // ...place, - // votes: [...place.votes, vote.voteType], - // } - // } - // return place - // }) - // return newPlaces - // }) - // Return a context object with the snapshotted value return { previousPlaces } }, @@ -58,7 +46,7 @@ export default function useVote() { onError: (err, newVote, context) => { queryClient.setQueryData( [queryKeys.votes, queryKeys.places, currentFeast?.id], - context.previousPlaces, + context.previousPlaces ) }, // Always refetch after error or success: @@ -69,7 +57,7 @@ export default function useVote() { currentFeast?.id, ]) }, - }, + } ) return mutate diff --git a/src/hooks/useWinner.js b/src/hooks/useWinner.js index e942d2e..9753319 100644 --- a/src/hooks/useWinner.js +++ b/src/hooks/useWinner.js @@ -4,21 +4,6 @@ import { queryKeys, apiURL } from '../lib/constants' import axios from 'axios' import { useAuthContext } from '../context/AuthProvider' -// const fetchFeastPulse = async (currentFeast, user) => { -// const { data, status } = await axios({ -// url: `http://localhost:3000/api/feast/pulse/${currentFeast?.id}`, -// method: 'get', -// headers: { authorization: `Bearer ${user?.token}` }, -// }) -// console.warn( -// 'fetchFeastPulse axios result -> DATA:', -// JSON.stringify(data), -// 'STATUS:', -// JSON.stringify(status), -// ) - -// return data.winningPlace -// } const getFeastPulse = async (currentFeast, user) => { const response = await axios( `${apiURL.local}/api/feast/pulse/${currentFeast.id}`, @@ -26,19 +11,9 @@ const getFeastPulse = async (currentFeast, user) => { method: 'GET', // prettier-ignore headers: { 'authorization': `Bearer ${user?.token}` }, - }, + } ) - // console.warn( - // 'getFeastPulse from winner screen: STATUS =>', - // JSON.stringify(response.status), - // 'DATA =>', - // JSON.stringify(response.data), - // ) - // if (!response.success) { - // console.error(`Network response was not ok -> ${response}`) - // } - return response.data } @@ -47,34 +22,14 @@ const useWinner = () => { const currentFeast = feastState.useValue() const [currentFeastWinner, setCurrentFeastWinner] = feastState.use() - // const fallback = {} - // const { data: winner } = useQuery( - // [queryKeys.winner, currentFeast?.name, user.username], - // () => fetchFeastPulse(currentFeast, user), - // { - // onSuccess: (winner) => { - // setCurrentFeastWinner(winner) - // return winner - // }, - // onError: (data, error) => { - // console.warn(`ERROR in useWinner hook: ${error}, DATA: ${data}`) - // }, - // }, - // ) const fallback = 'No winner yet' const { data: pulse = fallback } = useQuery( [queryKeys.winner, currentFeast.id], () => getFeastPulse(currentFeast, user), // { enabled: !!feastId }, - { enabled: !!currentFeast }, + { enabled: !!currentFeast } ) - // if (pulse.winningPlace) { - // setCurrentFeastWinner(pulse.winningPlace) - // return pulse - // } else { - // return 'No winner yet' - // } return pulse } export default useWinner diff --git a/src/screens/EditFeastScreen.js b/src/screens/EditFeastScreen.js index 9befd17..353eab2 100644 --- a/src/screens/EditFeastScreen.js +++ b/src/screens/EditFeastScreen.js @@ -35,264 +35,16 @@ import { import Header from '../components/Header' import { feastState } from '../context/FeastState' import EditFeastForm from '../components/EditFeastForm' - -// const feastSchema = Yup.object().shape({ -// name: Yup.string().required('Feast name required'), -// startDate: Yup.date(), -// endDate: Yup.date(), -// radius: Yup.number() -// .min(1, ({ min }) => `Radius must be at least ${min} mile`) -// .max(5, ({ max }) => `Radius cannot be more than ${max} miles`) -// .required('Radius is required'), -// location: Yup.object() -// .shape({ -// lat: Yup.number(), -// long: Yup.number(), -// }) -// .required('Location JSON object is required'), -// }) +import { queryKeys } from '../lib/constants' const EditFeastScreen = ({ navigation }) => { const queryClient = useQueryClient() const [selectedFeast, setSelectedFeast] = feastState.use() - // const createFeast = useCreateFeast() - // const queryClient = useQueryClient() - // const { user } = useAuthContext() - // const [feastName, setFeastName] = useState('') - // const [image, setImage] = useState(null) - // const [startsAt, setStartsAt] = useState(null) - // const [endsAt, setEndsAt] = useState(new Date()) - // const [location, setLocation] = useState({ lat: 0, long: 0 }) - // const [radius, setRadius] = useState(1) - - // const mutation = useMutation({ - // mutationFn: (values) => { - // return axios({ - // url: 'http://localhost:3000/api/feast', - // method: 'post', - // headers: { authorization: `Bearer ${user?.token}` }, - // data: { ...values }, - // }) - // }, - // }) - - // // const autocompleteRef = useRef() - - // // const isValid = () => { - // // return feastName && image && endsAt && radius && location - // // } - - // // const save = async () => { - // // if (!isValid) { - // // console.debug('Not valid') - // // return - // // } - // // const values = { - // // name: feastName, - // // image: image, - // // location: location, - // // endsAt: endsAt.toISOString(), - // // radius: radius, - // // } - // // console.log(values) - - // // createFeast.mutate(values, { - // // onSuccess: () => { - // // queryClient.invalidateQueries('feasts') - // // navigation.pop('Feasts') - // // }, - // // onError: (err) => { - // // console.warn(`Error saving feast: ${err.message}`) - // // }, - // // onSettled: (data, error) => {}, - // // }) - - // // // try { - // // // // onSaveClick() - // // // mutate(values) - // // // // Alert.alert('Feast info saved successfully') - // // // navigation.pop('Feasts') - // // // } catch (err) { - // // // console.warn(`Error saving feast: ${err}`) - // // // } - - // // // try { - // // // const response = await axios({ - // // // url: 'http://localhost:3000/api/feast', - // // // method: 'post', - // // // headers: { authorization: `Bearer ${authContext.user.token}` }, - // // // data: { ...values }, - // // // }) - // // // .then((res) => console.log(JSON.stringify(res))) - // // // .catch((res, err) => console.log(err, JSON.stringify(res))) - - // // // // if (response.data.success) { - // // // // queryClient.invalidateQueries('feasts') - // // // // // ctx.setCurrentFeast(response.data.feast) - // // // // // setFeasts(response.data.feasts) - // // // // // setCurrentFeast(response.data.feast) - // // // // Alert.alert('Feast info saved successfully') - // // // // navigation.navigate('Home', { feast: response.data.feast }) - // // // // } else { - // // // // console.warn('woops') - // // // // } - // // // } catch (err) { - // // // console.log(`Error saving feast: ${err}`) - // // // } - // // } - - // return ( - // - // - // Create a new feast - - // - // - - // - // { - // // 'details' is provided when fetchDetails = true - // // console.warn(data, details) - // const imageUrl = `https://maps.googleapis.com/maps/api/place/photo?parameters&maxwidth=400&photoreference=${details.photos[0].photo_reference}&key=${GOOGLE_API}` - // setImage(imageUrl) - // setLocation({ - // lat: details.geometry.location.lat, - // long: details.geometry.location.lng, - // }) - // }} - // query={{ - // key: GOOGLE_API, - // }} - // onFail={(error) => console.warn(error)} - // onNotFound={() => console.warn('no results')} - // listViewDisplayed="auto" - // listEmptyComponent={() => ( - // - // No results were found - // - // )} - // styles={{ - // container: { - // flex: 1, - // }, - // textInputContainer: { - // flexDirection: 'row', - // }, - // textInput: { - // backgroundColor: '#e13959', - // color: '#212121', - // height: 44, - // borderRadius: 20, - // paddingVertical: 16, - // paddingHorizontal: 16, - // fontSize: 16, - // flex: 1, - // }, - // listView: { - // backgroundColor: '#cfcfcf', - // borderBottomLeftRadius: 10, - // borderBottomRightRadius: 10, - // }, - // row: { - // backgroundColor: '#e13959', - // padding: 13, - // height: 44, - // flexDirection: 'row', - // borderBottomColor: 'black', - // borderBottomWidth: 1, - // }, - // separator: { - // height: 0.5, - // backgroundColor: '#c8c7cc', - // }, - // description: {}, - // loader: { - // flexDirection: 'row', - // justifyContent: 'flex-end', - // height: 20, - // }, - // }} - // /> - // - - // - // End date - // {/* */} - // { - // setEndsAt(selectedDate) - // }} - // /> - // - - // - // Radius - // - // setRadius(itemValue)}> - // - // - // - // - // - // - // - // - - // - // mutation.mutate({ - // name: feastName, - // image, - // location, - // startsAt, - // endsAt: endsAt.toISOString(), - // radius, - // }) - // } - // style={styles.button}> - // {mutation.isLoading ? 'Loading...' : 'Create Feast'} - // - // navigation.navigate('Feasts')} - // style={styles.button}> - // Cancel - // - - // {mutation.isError && {mutation.error.message}} - // - // ) const onFeastEdited = (response) => { - console.warn(JSON.stringify(response)) if (response.success) { - console.log('success, you edited a feast: ', response.data) - - queryClient.invalidateQueries('feasts') + queryClient.invalidateQueries(queryKeys.feasts) setSelectedFeast(null) - console.warn('Feast info saved successfully') - // Alert.alert('Feast info saved successfully') } navigation.goBack() } diff --git a/src/screens/HomeScreen.js b/src/screens/HomeScreen.js index 6fdea51..6a45e56 100644 --- a/src/screens/HomeScreen.js +++ b/src/screens/HomeScreen.js @@ -9,180 +9,78 @@ import { Alert, Pressable, } from 'react-native' -// import Animated from 'react-native-reanimated' import tw from 'twrnc' -import { - AntDesign, - Entypo, - Ionicons, - FontAwesome, - Fontisto, - MaterialCommunityIcons, -} from '@expo/vector-icons' -// import users from '../../assets/data/users' +import { AntDesign, Entypo, Ionicons } from '@expo/vector-icons' import Swiper from 'react-native-deck-swiper' import { rs } from '../utils/ResponsiveScreen' import PlaceCard from '../components/PlaceCard' import { useAppContext } from '../context/AppProvider' import { useAuthContext } from '../context/AuthProvider' -// import { queryClient } from '../lib/queryClient' import useFeast from '../hooks/useFeast' -// import useVote from '../hooks/useVote' import axios from 'axios' import { useQueryClient, useMutation } from '@tanstack/react-query' -import { queryKeys, VOTE } from '../lib/constants' +import { apiURL, queryKeys, VOTE } from '../lib/constants' import { LoadingIndicator } from '../components/LoadingIndicator' import Header from '../components/Header' import { feastState } from '../context/FeastState' -// import { produce } from 'immer' - -// const getFeastPulse = async (feastId, user) => { -// const response = await axios( -// `http://localhost:3000/api/feast/pulse/${feastId.id}`, -// { -// method: 'GET', -// // prettier-ignore -// headers: { 'authorization': `Bearer ${user?.token}` }, -// }, -// ) - -// // console.warn( -// // 'getFeastPulse result: STATUS =>', -// // JSON.stringify(response.status), -// // 'DATA =>', -// // JSON.stringify(response.data), -// // ) - -// return response.data.filteredPlaces -// } const HomeScreen = ({ route, navigation }) => { - const swipeRef = useRef(null) + const queryClient = useQueryClient() + const currentFeast = feastState.useValue() const { user } = useAuthContext() const feastId = route.params?.feast - const currentFeast = feastState.useValue() - // const feastId = feast.id + const swipeRef = useRef(null) const places = useFeast() - // const [places, setPlaces] = useState([]) - const [filteredPlaces, setFilteredPlaces] = useState([]) - const queryClient = useQueryClient() - // const mutate = useVote() - const globalPadding = rs(12) - const wrapperPadding = rs(12) - // const [currentIndex, setCurrentIndex] = useState(0) // mutation to submit nah vote on left swipe - const nahMutation = useMutation( - (placeSwiped) => { - return axios({ - url: `http://localhost:3000/api/vote`, - method: 'post', - headers: { authorization: `Bearer ${user.token}` }, - data: { - feastId: feastId.id, - placeId: placeSwiped.id, - voteType: VOTE.nah, - }, - }) - }, - { - onSuccess: (data, variables, context) => { - console.log('nah mutation success:', JSON.stringify(data)) + const nahMutation = useMutation((placeSwiped) => { + return axios({ + url: `${apiURL.remote}/api/vote`, + method: 'post', + headers: { authorization: `Bearer ${user.token}` }, + data: { + feastId: feastId.id, + placeId: placeSwiped.id, + voteType: VOTE.nah, }, - }, - ) + }) + }) // mutation to submit yass vote on right swipe - const yassMutation = useMutation( - (placeSwiped) => { - return axios({ - url: `http://localhost:3000/api/vote`, - method: 'post', - headers: { authorization: `Bearer ${user.token}` }, - data: { - feastId: feastId.id, - placeId: placeSwiped.id, - voteType: VOTE.yass, - }, - }) - }, - { - onSuccess: (data, variables, context) => { - console.log('yass mutation success:', JSON.stringify(data)) + const yassMutation = useMutation((placeSwiped) => { + return axios({ + url: `${apiURL.remote}/api/vote`, + method: 'post', + headers: { authorization: `Bearer ${user.token}` }, + data: { + feastId: feastId.id, + placeId: placeSwiped.id, + voteType: VOTE.yass, }, - }, - ) + }) + }) const swipeLeft = (cardIndex) => { if (!places[cardIndex]) return - // if (!filteredPlaces[cardIndex]) return - const placeSwiped = places[cardIndex] - // const placeSwiped = filteredPlaces[cardIndex] nahMutation.mutate(placeSwiped) - // console.warn('swiped NAH on: ', places[cardIndex].name) } const swipeRight = (cardIndex) => { if (!places[cardIndex]) return - // if (!filteredPlaces[cardIndex]) return - const placeSwiped = places[cardIndex] - // const placeSwiped = filteredPlaces[cardIndex] yassMutation.mutate(placeSwiped) - // console.warn('swiped YASS on: ', places[cardIndex].name) } + // check if voting is done and navigate to winner screen const onSwipedAll = () => { - Alert.alert({ - title: 'All done!', - message: "Let's check for a winner..", - }) + queryClient.invalidateQueries([queryKeys.feasts]) + navigation.push('Winner') } - // useEffect(() => { - // // let unsub - // if (places.length > 0) { - // // filter out places that have already been voted on - // const filteredPlaces = places.filter((place) => { - // return !place.votes.some((vote) => vote.userId === user.id) - // }) - // console.log('filtered places: ', filteredPlaces) - - // if (filteredPlaces.length === 0) { - // Alert.alert({ - // title: 'All done!', - // message: "Let's check for a winner..", - // }) - // navigation.navigate('Winner') - // } else { - // setNonvotedPlaces(filteredPlaces) - // } - - // console.log('nonvoted places: ', nonvotedPlaces) - // } - // }, [feastId, feast]) - - // useEffect(() => { - // async function fetchPlaces() { - // const result = await getFeastPulse(feastId, user) - // setFilteredPlaces(result) - // } - // fetchPlaces() - // }, [feastId]) - - // useEffect(() => { - // setFilteredPlaces( - // places.filter((place) => { - // return !place.votes.some((vote) => vote.userId === user.id) - // }), - // ) - // }, [places, user]) - // create a useEffect to filter out places that have already been voted on - // if (isLoading) return return ( @@ -284,7 +182,8 @@ const HomeScreen = ({ route, navigation }) => { style={[ tw`relative bg-white h-3/4 rounded-xl justify-center items-center`, styles.cardShadow, - ]}> + ]} + > No more places { swipeRef.current.swipeLeft()} - style={tw`items-center justify-center rounded-full w-16 h-16 bg-red-200`}> + style={tw`items-center justify-center rounded-full w-16 h-16 bg-red-200`} + > navigation.push('Winner', { feast: feastId })} - style={tw`items-center justify-center rounded-full w-16 h-16 bg-purple-200`}> + style={tw`items-center justify-center rounded-full w-16 h-16 bg-purple-200`} + > swipeRef.current.swipeRight()} - style={tw`items-center justify-center rounded-full w-16 h-16 bg-green-200`}> + style={tw`items-center justify-center rounded-full w-16 h-16 bg-green-200`} + > diff --git a/src/screens/NewFeastScreen.js b/src/screens/NewFeastScreen.js index acf4674..48f7ba5 100644 --- a/src/screens/NewFeastScreen.js +++ b/src/screens/NewFeastScreen.js @@ -20,268 +20,19 @@ import { import { LoadingIndicator } from '../components/LoadingIndicator' import tw from 'twrnc' import { useMutation, useQueryClient } from '@tanstack/react-query' -import useFeasts from '../hooks/useFeasts' import CreateFeastForm from '../components/CreateFeastForm' - -// const feastSchema = Yup.object().shape({ -// name: Yup.string().required('Feast name required'), -// startDate: Yup.date(), -// endDate: Yup.date(), -// radius: Yup.number() -// .min(1, ({ min }) => `Radius must be at least ${min} mile`) -// .max(5, ({ max }) => `Radius cannot be more than ${max} miles`) -// .required('Radius is required'), -// location: Yup.object() -// .shape({ -// lat: Yup.number(), -// long: Yup.number(), -// }) -// .required('Location JSON object is required'), -// }) +import { queryKeys } from '../lib/constants' const NewFeastScreen = ({ navigation }) => { const queryClient = useQueryClient() - const { refetch } = useFeasts() - // const createFeast = useCreateFeast() - // const queryClient = useQueryClient() - // const { user } = useAuthContext() - // const [feastName, setFeastName] = useState('') - // const [image, setImage] = useState(null) - // const [startsAt, setStartsAt] = useState(null) - // const [endsAt, setEndsAt] = useState(new Date()) - // const [location, setLocation] = useState({ lat: 0, long: 0 }) - // const [radius, setRadius] = useState(1) - - // const mutation = useMutation({ - // mutationFn: (values) => { - // return axios({ - // url: 'http://localhost:3000/api/feast', - // method: 'post', - // headers: { authorization: `Bearer ${user?.token}` }, - // data: { ...values }, - // }) - // }, - // }) - - // // const autocompleteRef = useRef() - - // // const isValid = () => { - // // return feastName && image && endsAt && radius && location - // // } - - // // const save = async () => { - // // if (!isValid) { - // // console.debug('Not valid') - // // return - // // } - // // const values = { - // // name: feastName, - // // image: image, - // // location: location, - // // endsAt: endsAt.toISOString(), - // // radius: radius, - // // } - // // console.log(values) - - // // createFeast.mutate(values, { - // // onSuccess: () => { - // // queryClient.invalidateQueries('feasts') - // // navigation.pop('Feasts') - // // }, - // // onError: (err) => { - // // console.warn(`Error saving feast: ${err.message}`) - // // }, - // // onSettled: (data, error) => {}, - // // }) - - // // // try { - // // // // onSaveClick() - // // // mutate(values) - // // // // Alert.alert('Feast info saved successfully') - // // // navigation.pop('Feasts') - // // // } catch (err) { - // // // console.warn(`Error saving feast: ${err}`) - // // // } - - // // // try { - // // // const response = await axios({ - // // // url: 'http://localhost:3000/api/feast', - // // // method: 'post', - // // // headers: { authorization: `Bearer ${authContext.user.token}` }, - // // // data: { ...values }, - // // // }) - // // // .then((res) => console.log(JSON.stringify(res))) - // // // .catch((res, err) => console.log(err, JSON.stringify(res))) - - // // // // if (response.data.success) { - // // // // queryClient.invalidateQueries('feasts') - // // // // // ctx.setCurrentFeast(response.data.feast) - // // // // // setFeasts(response.data.feasts) - // // // // // setCurrentFeast(response.data.feast) - // // // // Alert.alert('Feast info saved successfully') - // // // // navigation.navigate('Home', { feast: response.data.feast }) - // // // // } else { - // // // // console.warn('woops') - // // // // } - // // // } catch (err) { - // // // console.log(`Error saving feast: ${err}`) - // // // } - // // } - - // return ( - // - // - // Create a new feast - - // - // - - // - // { - // // 'details' is provided when fetchDetails = true - // // console.warn(data, details) - // const imageUrl = `https://maps.googleapis.com/maps/api/place/photo?parameters&maxwidth=400&photoreference=${details.photos[0].photo_reference}&key=${GOOGLE_API}` - // setImage(imageUrl) - // setLocation({ - // lat: details.geometry.location.lat, - // long: details.geometry.location.lng, - // }) - // }} - // query={{ - // key: GOOGLE_API, - // }} - // onFail={(error) => console.warn(error)} - // onNotFound={() => console.warn('no results')} - // listViewDisplayed="auto" - // listEmptyComponent={() => ( - // - // No results were found - // - // )} - // styles={{ - // container: { - // flex: 1, - // }, - // textInputContainer: { - // flexDirection: 'row', - // }, - // textInput: { - // backgroundColor: '#e13959', - // color: '#212121', - // height: 44, - // borderRadius: 20, - // paddingVertical: 16, - // paddingHorizontal: 16, - // fontSize: 16, - // flex: 1, - // }, - // listView: { - // backgroundColor: '#cfcfcf', - // borderBottomLeftRadius: 10, - // borderBottomRightRadius: 10, - // }, - // row: { - // backgroundColor: '#e13959', - // padding: 13, - // height: 44, - // flexDirection: 'row', - // borderBottomColor: 'black', - // borderBottomWidth: 1, - // }, - // separator: { - // height: 0.5, - // backgroundColor: '#c8c7cc', - // }, - // description: {}, - // loader: { - // flexDirection: 'row', - // justifyContent: 'flex-end', - // height: 20, - // }, - // }} - // /> - // - - // - // End date - // {/* */} - // { - // setEndsAt(selectedDate) - // }} - // /> - // - - // - // Radius - // - // setRadius(itemValue)}> - // - // - // - // - // - // - // - // - - // - // mutation.mutate({ - // name: feastName, - // image, - // location, - // startsAt, - // endsAt: endsAt.toISOString(), - // radius, - // }) - // } - // style={styles.button}> - // {mutation.isLoading ? 'Loading...' : 'Create Feast'} - // - // navigation.navigate('Feasts')} - // style={styles.button}> - // Cancel - // - - // {mutation.isError && {mutation.error.message}} - // - // ) const onFeastCreated = (response) => { - // console.warn(JSON.stringify(response)) - // if (response.success) { console.log('success, you created a feast: ', response.data) - queryClient.invalidateQueries('feasts') - // refetch() - console.debug('Feast info saved successfully') - // navigation.goBack() + // @ts-ignore + queryClient.invalidateQueries(queryKeys.feasts) + navigation.navigate('Feasts') - // } } return ( diff --git a/yarn.lock b/yarn.lock index d44aef1..95e8bbe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1097,6 +1097,13 @@ dependencies: regenerator-runtime "^0.13.11" +"@babel/runtime@^7.18.6": + version "7.20.13" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.13.tgz#7055ab8a7cff2b8f6058bf6ae45ff84ad2aded4b" + integrity sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA== + dependencies: + regenerator-runtime "^0.13.11" + "@babel/template@^7.0.0", "@babel/template@^7.18.10", "@babel/template@^7.8.6": version "7.18.10" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.18.10.tgz#6f9134835970d1dbf0835c0d100c9f38de0c5e71" @@ -1188,16 +1195,16 @@ mv "~2" safe-json-stringify "~1" -"@expo/cli@0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@expo/cli/-/cli-0.3.2.tgz#83c8587ec38f9c7361222751bc4bb829520201b8" - integrity sha512-P6yogdPCRKaoLjuH7D8jgq6kTzM4gWuQ+vssBPWhbnoymV5AClQOxvACPDHD+biKhvGsaXEQLMoi93lPQzcDlQ== +"@expo/cli@0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@expo/cli/-/cli-0.3.3.tgz#797ae9605c0556ba5159f5fbe9844a4e71380fcc" + integrity sha512-5uDbjLntXkJOPx2SOZ6Pj9MC448YWtGenBJE+jNBfAbUPaf62Fy9uIyWWeKeRWXNfSs9jmOVpIgyYLTklV1vpg== dependencies: "@babel/runtime" "^7.14.0" "@expo/code-signing-certificates" "^0.0.2" "@expo/config" "~7.0.1" "@expo/config-plugins" "~5.0.1" - "@expo/dev-server" "~0.1.120" + "@expo/dev-server" "0.1.120" "@expo/devcert" "^1.0.0" "@expo/json-file" "^8.2.35" "@expo/metro-config" "~0.4.0" @@ -1362,7 +1369,7 @@ xcode "^3.0.0" xml-js "^1.6.11" -"@expo/dev-server@~0.1.120": +"@expo/dev-server@0.1.120": version "0.1.120" resolved "https://registry.yarnpkg.com/@expo/dev-server/-/dev-server-0.1.120.tgz#0c7aff4e29d98298214129127f5df951cb7b81dd" integrity sha512-x5/jCv0EOpz6FyehXpI5bgDQTVsGZYvgISkAw7n60RhtG+aid6N2CCR9SDMCH70XaUpFnfTW9qvderpCEj7Puw== @@ -4849,6 +4856,14 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" +create-react-class@^15.7.0: + version "15.7.0" + resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.7.0.tgz#7499d7ca2e69bb51d13faf59bd04f0c65a1d6c1e" + integrity sha512-QZv4sFWG9S5RUvkTYWbflxeZX+JG7Cz0Tn33rQBJ+WFQTqTfUTjMjiv9tnfXazjsO5r0KhPs+AqCjyrQX6h2ng== + dependencies: + loose-envify "^1.3.1" + object-assign "^4.1.1" + cross-fetch@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" @@ -5993,19 +6008,6 @@ expo-application@~4.2.2: resolved "https://registry.yarnpkg.com/expo-application/-/expo-application-4.2.2.tgz#c9500819723c59eaee5ca9832bf17d1fd4139f74" integrity sha512-bFEaFRUdV6aK2iBd+HzkHNPYsyj88EAhaQW5leznmO0qQMJxpAQ3eoUXMey1hfDBh1qgkkHgSyCZ9BIgMAGJ1g== -expo-asset@~8.6.1: - version "8.6.1" - resolved "https://registry.yarnpkg.com/expo-asset/-/expo-asset-8.6.1.tgz#86355b3e231e8aa6cf68a456ce9746dff1478b48" - integrity sha512-urbUp1YtwH2J0Qc3inGQJdqTjWKML77SeMNgff+iR9MUE8gDkFqSCDjrBi7i5Oj5DDtq43mmtDg8G8ei6Vchcg== - dependencies: - blueimp-md5 "^2.10.0" - expo-constants "~13.2.2" - expo-file-system "~14.1.0" - invariant "^2.2.4" - md5-file "^3.2.3" - path-browserify "^1.0.0" - url-parse "^1.5.9" - expo-asset@~8.6.3: version "8.6.3" resolved "https://registry.yarnpkg.com/expo-asset/-/expo-asset-8.6.3.tgz#fd8e8e8d9a7bbbe3c202459a17746b923fb9bdda" @@ -6063,10 +6065,10 @@ expo-modules-autolinking@0.10.3: find-up "^5.0.0" fs-extra "^9.1.0" -expo-modules-core@0.11.8: - version "0.11.8" - resolved "https://registry.yarnpkg.com/expo-modules-core/-/expo-modules-core-0.11.8.tgz#68de1bc56a148b9a9c03f1268c67e9e264d4d4b9" - integrity sha512-goC2ghZFVaV6nXEbk+kz9oKnQmqW8fHVUCSPxC0QXhV0ay1dA9Ki6qqMPagkBJUPAz89NsNqW3bYR6DFXq7lvA== +expo-modules-core@0.11.10: + version "0.11.10" + resolved "https://registry.yarnpkg.com/expo-modules-core/-/expo-modules-core-0.11.10.tgz#84800ea62431a3842661966276747260f7e33b37" + integrity sha512-wn7bdL1AXMNuuDEFhuIeE65A+dlvBL+6nC5fGy4NO7x3TXPBR1xCgL28i8d8WWyK5evI4z4TVvJp3YYzdapbqQ== dependencies: compare-versions "^3.4.0" invariant "^2.2.4" @@ -6099,24 +6101,24 @@ expo-status-bar@~1.4.0: resolved "https://registry.yarnpkg.com/expo-status-bar/-/expo-status-bar-1.4.0.tgz#c0317de2c53878340f4b4f00ff7e4ba14399a7fb" integrity sha512-vh98g8qMIjig/2XTBsoAWS6Vo2dIIwDWjB3/GiuZ9Lazpxc9GO/APfJ4dar7MibzIDUKIrjotrcL6rLdPH13Ew== -expo@~46.0.16: - version "46.0.16" - resolved "https://registry.yarnpkg.com/expo/-/expo-46.0.16.tgz#8fe6d10207dabda34a684efac2c45c3c1c089f11" - integrity sha512-lZETkf3t+gbZjKjSceIpU7I8Rmm5nZ0ZG1WPzNBBbm+k64/+kKV96s6RqS37W1TTDpIbd+AucT9kKpvtv0JB2A== +expo@~46.0.19: + version "46.0.20" + resolved "https://registry.yarnpkg.com/expo/-/expo-46.0.20.tgz#2a3bc1aeb84388095328d1a438b1893832567793" + integrity sha512-bNvLMcByZia/JsTngCXEKmI+outPQo6/V5M896yzUo4hdLApwIwq7kV/6bZqHuWyYFSdRgem3NATJRisHQrP1A== dependencies: "@babel/runtime" "^7.14.0" - "@expo/cli" "0.3.2" + "@expo/cli" "0.3.3" "@expo/vector-icons" "^13.0.0" babel-preset-expo "~9.2.0" cross-spawn "^6.0.5" expo-application "~4.2.2" - expo-asset "~8.6.1" + expo-asset "~8.6.3" expo-constants "~13.2.4" expo-file-system "~14.1.0" expo-font "~10.2.1" expo-keep-awake "~10.2.0" expo-modules-autolinking "0.10.3" - expo-modules-core "0.11.8" + expo-modules-core "0.11.10" fbemitter "^3.0.0" getenv "^1.0.0" invariant "^2.2.4" @@ -6287,7 +6289,7 @@ fbjs@^0.8.9: setimmediate "^1.0.5" ua-parser-js "^0.7.30" -fbjs@^3.0.0: +fbjs@^3.0.0, fbjs@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.4.tgz#e1871c6bd3083bac71ff2da868ad5067d37716c6" integrity sha512-ucV0tDODnGV3JCnnkmoszb5lf4bNpzjv80K41wd4k798Etq+UYD0y0TIfalLjZoKgjive6/adkRnszwapiDgBQ== @@ -7224,11 +7226,6 @@ immer@8.0.1: resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656" integrity sha512-aqXhGP7//Gui2+UrEtvxZxSquQVXTpZ7KDxfCcKAF3Vysvw0CViVaW9RZ1j1xlIYqaaaipBoqdqeibkc18PNvA== -immer@^9.0.17: - version "9.0.17" - resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.17.tgz#7cfe8fbb8b461096444e9da7a5ec4a67c6c4adf4" - integrity sha512-+hBruaLSQvkPfxRiTLK/mi4vLH+/VQS6z2KJahdoxlleFOI8ARqzOF17uy12eFDlqWmPoygwc5evgwcp+dlHhg== - import-fresh@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546" @@ -9143,6 +9140,11 @@ node-stream-zip@^1.9.1: resolved "https://registry.yarnpkg.com/node-stream-zip/-/node-stream-zip-1.15.0.tgz#158adb88ed8004c6c49a396b50a6a5de3bca33ea" integrity sha512-LN4fydt9TqhZhThkZIVQnF9cwjU3qmUH9h78Mx/K7d3VvfRqqwthLwJEUOEL0QPZ0XQmNN7be5Ggit5+4dq3Bw== +normalize-css-color@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/normalize-css-color/-/normalize-css-color-1.0.2.tgz#02991e97cccec6623fe573afbbf0de6a1f3e9f8d" + integrity sha512-jPJ/V7Cp1UytdidsPqviKEElFQJs22hUUgK5BOPHTwOonNCk7/2qOxhhqzEajmFrWJowADFfOFh1V+aWkRfy+w== + normalize-path@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" @@ -10748,6 +10750,19 @@ react-native-url-polyfill@^1.3.0: dependencies: whatwg-url-without-unicode "8.0.0-3" +react-native-web@~0.18.7: + version "0.18.12" + resolved "https://registry.yarnpkg.com/react-native-web/-/react-native-web-0.18.12.tgz#d4bb3a783ece2514ba0508d7805b09c0a98f5a8e" + integrity sha512-fboP7yqobJ8InSr4fP+bQ3scOtSQtUoPcR+HWasH8b/fk/RO+mWcJs/8n+lewy9WTZc2D68ha7VwRDviUshEWA== + dependencies: + "@babel/runtime" "^7.18.6" + create-react-class "^15.7.0" + fbjs "^3.0.4" + inline-style-prefixer "^6.0.1" + normalize-css-color "^1.0.2" + postcss-value-parser "^4.2.0" + styleq "^0.1.2" + react-native@0.69.6: version "0.69.6" resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.69.6.tgz#cdd1a5757d902b91b165c28fdda4e518ed6f683a" @@ -11909,6 +11924,11 @@ stylehacks@^4.0.0: postcss "^7.0.0" postcss-selector-parser "^3.0.0" +styleq@^0.1.2: + version "0.1.3" + resolved "https://registry.yarnpkg.com/styleq/-/styleq-0.1.3.tgz#8efb2892debd51ce7b31dc09c227ad920decab71" + integrity sha512-3ZUifmCDCQanjeej1f6kyl/BeP/Vae5EYkQ9iJfUm/QwZvlgnZzyflqAsAWYURdtea8Vkvswu2GrC57h3qffcA== + sucrase@^3.20.0: version "3.28.0" resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.28.0.tgz#7fd8b3118d2155fcdf291088ab77fa6eefd63c4c"