From ba00ff0655a3561d527adb24615fcc3ac6c7df7e Mon Sep 17 00:00:00 2001 From: Florian Leroux <10078837+floriaaan@users.noreply.github.com> Date: Sat, 29 Jun 2024 12:27:00 +0200 Subject: [PATCH] feat(mobile): add remaining pages (#117) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [REFACTO]: Update de restaurant selection * [REFACTO]: Use reals data and fix handle empty arrays in the mobile app * [REFACTO]: Remove test variables * [FEATURE]: Add new pages * [FEATURE]: Add logout btn * [FEATURE]: Refresh location * [FEATURE]: Add checkout page * [FEATURE]: Add module declaration * [FEATURE] Reorder imports and remove duplicates imports * [FEATURE]: Add progress bar package * [FEATURE] Add stripe intent rpc methods * [FEATURE]: Add payment methods for mobile * [FEATURE] Fix payment service * [FEATURE]: Fix mobile payment * [FEATURE] Add payment on mobile * [REFACTO] Remove useless custom stripe components * [FEATURE] Add delivery index page * fix: fix order creation * chore: Update order.proto and order.ts to use camelCase for createdAt and updatedAt fields * feat(list): add product list page * feat(header): change header to have selected restaurant instead of user address * feat(address): add a way to change user main address * feat(order): refactor order page * feat(step-indicator): what are you doing step indicator (👉👈) * feat(checkout): change button for better ux * fix(lint): fix lint issues * feat(restaurant): add restaurant id page * feat(basket): improve empty basket message and display restaurant opening hours * feat: Improve empty basket message and display restaurant opening hours * feat: Update checkout screen button for better UX --------- Co-authored-by: Anatole-Godard Co-authored-by: anatole-g --- apps/mobile/.env.example | 3 + apps/mobile/README.md | 3 +- apps/mobile/app.json | 8 +- apps/mobile/app/(app)/basket.tsx | 55 - apps/mobile/app/(app)/basket/index.tsx | 99 + apps/mobile/app/(app)/basket/taxes.tsx | 28 + apps/mobile/app/(app)/checkout/index.tsx | 47 + .../app/(app)/checkout/selection/index.tsx | 62 + apps/mobile/app/(app)/delivery/index.tsx | 0 apps/mobile/app/(app)/home.tsx | 182 +- apps/mobile/app/(app)/orders/[id]/index.tsx | 368 +- apps/mobile/app/(app)/orders/index.tsx | 50 +- apps/mobile/app/(app)/products/[id].tsx | 59 +- apps/mobile/app/(app)/products/list.tsx | 89 + apps/mobile/app/(app)/restaurants/[id].tsx | 145 + apps/mobile/app/(app)/restaurants/index.tsx | 67 + .../mobile/app/(app)/users/change-address.tsx | 137 + apps/mobile/app/(app)/users/index.tsx | 89 + apps/mobile/app/(auth)/login.tsx | 12 +- apps/mobile/app/(onboarding)/first.tsx | 7 + apps/mobile/app/_layout.tsx | 24 +- apps/mobile/assets/images/delivery_icon.png | Bin 0 -> 2199 bytes apps/mobile/assets/images/restaurant_icon.png | Bin 0 -> 1920 bytes apps/mobile/assets/images/user_icon.png | Bin 0 -> 1918 bytes apps/mobile/babel.config.js | 7 +- apps/mobile/components/basket/header.tsx | 11 +- .../components/basket/step-indicator.tsx | 92 + .../components/checkout/CheckoutScreen.tsx | 114 + apps/mobile/components/order/list/item.tsx | 17 +- apps/mobile/components/product/basket.tsx | 63 +- apps/mobile/components/product/card.tsx | 30 +- apps/mobile/components/product/skeleton.tsx | 19 + apps/mobile/components/restaurant/card.tsx | 55 +- apps/mobile/components/ui/(app)/drawer.tsx | 21 +- apps/mobile/components/ui/button/back.tsx | 19 + apps/mobile/components/ui/button/index.tsx | 9 +- apps/mobile/components/ui/header.tsx | 73 +- apps/mobile/components/ui/header/category.tsx | 19 +- apps/mobile/components/ui/stepProgressBar.tsx | 28 + apps/mobile/components/user/location.tsx | 110 +- apps/mobile/constants/data.ts | 1 + apps/mobile/declaration.d.ts | 1 + apps/mobile/expo-env.d.ts | 4 +- apps/mobile/hooks/useAuth.tsx | 28 +- apps/mobile/hooks/useBasket.tsx | 175 +- apps/mobile/hooks/useLocation.tsx | 32 +- apps/mobile/hooks/useNative.tsx | 11 + apps/mobile/lib/fetchAPI.ts | 2 + .../lib/fetchers/externals/google-maps.ts | 102 + apps/mobile/lib/fetchers/externals/mapbox.ts | 2 +- apps/mobile/lib/product/toProduct.tsx | 57 - apps/mobile/lib/restaurant/index.ts | 27 + .../use-persisted-state/createGlobalState.ts | 39 - .../lib/use-persisted-state/createStorage.ts | 23 - apps/mobile/lib/use-persisted-state/index.ts | 36 - .../use-persisted-state/usePersistedState.ts | 55 - apps/mobile/nativewind-env.d.ts | 1 + apps/mobile/package-lock.json | 7343 ++++++++++------- apps/mobile/package.json | 52 +- apps/mobile/tsconfig.json | 12 +- apps/mobile/types/order.ts | 6 +- requests/payment/get payments by user :id.bru | 2 +- services/docker-compose.yml | 1 - .../src/controller/order/order.controller.ts | 119 +- .../controller/payment/payment.controller.ts | 1 - .../controller/payment/stripe.controller.ts | 72 +- .../controller/user/mainAddress.controller.ts | 6 +- services/gateway/src/lib/payment.ts | 27 + .../stripe/create-checkout-session.ts | 71 +- services/payment/src/handlers/stripe/index.ts | 12 +- services/payment/src/types/stripe.d.ts | 21 +- services/proto/order.proto | 4 + services/proto/payment.proto | 20 + 73 files changed, 6722 insertions(+), 3864 deletions(-) create mode 100644 apps/mobile/.env.example delete mode 100644 apps/mobile/app/(app)/basket.tsx create mode 100644 apps/mobile/app/(app)/basket/index.tsx create mode 100644 apps/mobile/app/(app)/basket/taxes.tsx create mode 100644 apps/mobile/app/(app)/checkout/index.tsx create mode 100644 apps/mobile/app/(app)/checkout/selection/index.tsx create mode 100644 apps/mobile/app/(app)/delivery/index.tsx create mode 100644 apps/mobile/app/(app)/products/list.tsx create mode 100644 apps/mobile/app/(app)/restaurants/[id].tsx create mode 100644 apps/mobile/app/(app)/restaurants/index.tsx create mode 100644 apps/mobile/app/(app)/users/change-address.tsx create mode 100644 apps/mobile/app/(app)/users/index.tsx create mode 100644 apps/mobile/assets/images/delivery_icon.png create mode 100644 apps/mobile/assets/images/restaurant_icon.png create mode 100644 apps/mobile/assets/images/user_icon.png create mode 100644 apps/mobile/components/basket/step-indicator.tsx create mode 100644 apps/mobile/components/checkout/CheckoutScreen.tsx create mode 100644 apps/mobile/components/product/skeleton.tsx create mode 100644 apps/mobile/components/ui/button/back.tsx create mode 100644 apps/mobile/components/ui/stepProgressBar.tsx create mode 100644 apps/mobile/declaration.d.ts create mode 100644 apps/mobile/lib/fetchers/externals/google-maps.ts delete mode 100644 apps/mobile/lib/product/toProduct.tsx create mode 100644 apps/mobile/lib/restaurant/index.ts delete mode 100644 apps/mobile/lib/use-persisted-state/createGlobalState.ts delete mode 100644 apps/mobile/lib/use-persisted-state/createStorage.ts delete mode 100644 apps/mobile/lib/use-persisted-state/index.ts delete mode 100644 apps/mobile/lib/use-persisted-state/usePersistedState.ts create mode 100644 apps/mobile/nativewind-env.d.ts create mode 100644 services/gateway/src/lib/payment.ts diff --git a/apps/mobile/.env.example b/apps/mobile/.env.example new file mode 100644 index 00000000..a1eeb307 --- /dev/null +++ b/apps/mobile/.env.example @@ -0,0 +1,3 @@ +EXPO_PUBLIC_GOOGLE_MAPS_APIKEY="" +EXPO_PUBLIC_API_URL="" +EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY="" \ No newline at end of file diff --git a/apps/mobile/README.md b/apps/mobile/README.md index 64ad4a1f..8d61d279 100644 --- a/apps/mobile/README.md +++ b/apps/mobile/README.md @@ -28,9 +28,8 @@ You can use the following tools to help you with the setup: 3. Run `npm install` to install the necessary dependencies. **(make sure to use "npm install" and not "pnpm install")** 4. Run `npm run start` or `npx expo start` to start the microservice. **(make sure to use "npm run start" and not "pnpm run start")** - ### 2. Running the app on a physical or virtual device + To test the app on a physical device, scan the QR code displayed in the Expo Developer Tools using the Expo Go app on your Android or iOS device. To test the app on a virtual device, follow the instructions provided in the Expo Developer Tools to launch the app on an Android Emulator or iOS Simulator. - diff --git a/apps/mobile/app.json b/apps/mobile/app.json index 8b714587..4041540d 100644 --- a/apps/mobile/app.json +++ b/apps/mobile/app.json @@ -12,9 +12,7 @@ "resizeMode": "contain", "backgroundColor": "#ffffff" }, - "assetBundlePatterns": [ - "**/*" - ], + "assetBundlePatterns": ["**/*"], "ios": { "supportsTablet": true }, @@ -29,9 +27,7 @@ "output": "static", "favicon": "./assets/images/favicon.png" }, - "plugins": [ - "expo-router" - ], + "plugins": ["expo-router", [ "@stripe/stripe-react-native", { "enableGooglePay": true }]], "experiments": { "tsconfigPaths": true, "typedRoutes": true diff --git a/apps/mobile/app/(app)/basket.tsx b/apps/mobile/app/(app)/basket.tsx deleted file mode 100644 index 45173b08..00000000 --- a/apps/mobile/app/(app)/basket.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { useNavigation } from "expo-router"; -import { FlatList, Text, View } from "react-native"; -import { SafeAreaView } from "react-native-safe-area-context"; - -import { BasketHeader } from "@/components/basket/header"; -import { ProductBasketCard } from "@/components/product/basket"; -import { Button } from "@/components/ui/button"; -import { AppHeader } from "@/components/ui/header"; -import { productList } from "@/constants/data"; -import { useBasket } from "@/hooks/useBasket"; -import { Product } from "@/types/product"; - -export default function Basket() { - const { basket } = useBasket(); - const basketProductList = Object.keys(basket).map( - (id) => productList.find((product) => product.id === id) as Product, - ); - const { goBack } = useNavigation(); - return ( - - - - - - - - - - - } - ItemSeparatorComponent={() => } - ListFooterComponent={() => ( - - Footer - - )} - /> - - - - -