From 866b3988fcfb5452321367d36d07f82dc9a13b3a Mon Sep 17 00:00:00 2001 From: ttiimmothy Date: Thu, 23 Nov 2023 23:03:34 -0500 Subject: [PATCH] feat: create restaurant --- .env.example | 1 - src/api/photo/photoApiIndex.ts | 3 +- src/api/restaurant/restaurantApiIndex.ts | 5 +- .../restaurantOwner/RestaurantOwnerType.ts | 4 + .../restaurantOwnerApiIndex.ts | 12 + src/api/review/reviewApiIndex.ts | 3 +- src/components/utils/cards/RestaurantCard.tsx | 12 +- src/components/utils/inputs/NumberInput.tsx | 6 +- .../utils/inputs/OpeningHoursInput.tsx | 4 +- src/components/utils/inputs/SelectInput.tsx | 4 +- .../utils/modals/CreateReviewModal.tsx | 6 +- .../utils/modals/UploadImageModal.tsx | 1 - src/pages/restaurant/CreateRestaurantPage.tsx | 601 ++++++++++-------- src/redux/photo/photoSlice.ts | 3 - .../restaurantOwner/restaurantOwnerSlice.ts | 24 + src/redux/review/reviewSlice.ts | 9 +- src/store.ts | 5 + src/utils/uploadImageService.ts | 29 +- tailwind.config.js | 6 + 19 files changed, 427 insertions(+), 311 deletions(-) create mode 100644 src/api/restaurantOwner/RestaurantOwnerType.ts create mode 100644 src/api/restaurantOwner/restaurantOwnerApiIndex.ts create mode 100644 src/redux/restaurantOwner/restaurantOwnerSlice.ts diff --git a/.env.example b/.env.example index 58832db..4ce3a03 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,4 @@ REACT_APP_API_URL=your-backend-url REACT_APP_MAPBOX_TOKEN=your-mapbox-app-token -REACT_APP_IMAGE_PREFIX=your-supabase-storage-image-folder-name REACT_APP_SUPABASE_BUCKET_PATH=your-supabae-bucket-path REACT_APP_SUPABASE_SECRET_API_KEY=your-supabase-secret-api-key \ No newline at end of file diff --git a/src/api/photo/photoApiIndex.ts b/src/api/photo/photoApiIndex.ts index 9a533e4..8cdc323 100644 --- a/src/api/photo/photoApiIndex.ts +++ b/src/api/photo/photoApiIndex.ts @@ -18,14 +18,13 @@ export const getMenuPhotos = async ( }; export const createMenuPhoto = async ( - imagePrefix: string, restaurantID: string, imageName: string, photoCategory: string ): Promise => { return apiClient.post( "", - { imagePrefix, restaurantID, imageName }, + { restaurantID, imageName }, { params: { photoCategory } } ); }; diff --git a/src/api/restaurant/restaurantApiIndex.ts b/src/api/restaurant/restaurantApiIndex.ts index 5a33a5a..c56dbb6 100644 --- a/src/api/restaurant/restaurantApiIndex.ts +++ b/src/api/restaurant/restaurantApiIndex.ts @@ -22,7 +22,8 @@ export const getRestaurantDetail = async ( }; export const createRestaurant = async ( - restaurant: CreateRestaurantType + restaurant: CreateRestaurantType, + fileExtension?: string ): Promise => { - return apiClient.post("", restaurant); + return apiClient.post("", { restaurant, fileExtension }); }; diff --git a/src/api/restaurantOwner/RestaurantOwnerType.ts b/src/api/restaurantOwner/RestaurantOwnerType.ts new file mode 100644 index 0000000..b889f27 --- /dev/null +++ b/src/api/restaurantOwner/RestaurantOwnerType.ts @@ -0,0 +1,4 @@ +export type RestaurantOwner = { + user_id: string; + restaurant_id: string; +}; diff --git a/src/api/restaurantOwner/restaurantOwnerApiIndex.ts b/src/api/restaurantOwner/restaurantOwnerApiIndex.ts new file mode 100644 index 0000000..06a2955 --- /dev/null +++ b/src/api/restaurantOwner/restaurantOwnerApiIndex.ts @@ -0,0 +1,12 @@ +import { AxiosApiClientBuilder } from "../axiosIndex"; +import { RestaurantOwner } from "./RestaurantOwnerType"; + +const apiClient = new AxiosApiClientBuilder() + .withResourceName("/restaurant/owner") + .build(); + +export const createRestaurantOwner = async ( + restaurantOwner: RestaurantOwner +): Promise => { + return apiClient.post("", restaurantOwner); +}; diff --git a/src/api/review/reviewApiIndex.ts b/src/api/review/reviewApiIndex.ts index 8b6830d..c1722d4 100644 --- a/src/api/review/reviewApiIndex.ts +++ b/src/api/review/reviewApiIndex.ts @@ -17,14 +17,13 @@ export const getReviewsByRestaurantID = async ( export const createReview = async ( createReviewDto: CreateReviewDto, - imagePrefix: string, restaurantID: string, photoCategory: string, fileExtension?: string ): Promise => { return apiClient.post( "", - { createReviewDto, imagePrefix, restaurantID, fileExtension }, + { createReviewDto, restaurantID, fileExtension }, { params: { photoCategory } } ); }; diff --git a/src/components/utils/cards/RestaurantCard.tsx b/src/components/utils/cards/RestaurantCard.tsx index 360d1e0..859a72a 100644 --- a/src/components/utils/cards/RestaurantCard.tsx +++ b/src/components/utils/cards/RestaurantCard.tsx @@ -21,11 +21,13 @@ const RestaurantCard: React.FC = (props: Restaurant) => { className="rounded-md shadow-lg hover:bg-slate-200" >
- {props.name} + {props.cover_image_url && ( + {props.name} + )}
} /> diff --git a/src/components/utils/inputs/NumberInput.tsx b/src/components/utils/inputs/NumberInput.tsx index 92c3b4b..5729237 100644 --- a/src/components/utils/inputs/NumberInput.tsx +++ b/src/components/utils/inputs/NumberInput.tsx @@ -18,10 +18,10 @@ const NumberInput: React.FC = ({ max, }) => { return ( -
- +
+ = ({ onChange, }) => { return ( -
- +
+ ) => onChange(e)} diff --git a/src/components/utils/inputs/SelectInput.tsx b/src/components/utils/inputs/SelectInput.tsx index 3541120..9ebbda4 100644 --- a/src/components/utils/inputs/SelectInput.tsx +++ b/src/components/utils/inputs/SelectInput.tsx @@ -21,8 +21,8 @@ const SelectInput: React.FC = ({ optionList, }) => { return ( -
- +
+