Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create restaurant #33

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions src/api/photo/photoApiIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ export const getMenuPhotos = async (
};

export const createMenuPhoto = async (
imagePrefix: string,
restaurantID: string,
imageName: string,
photoCategory: string
): Promise<MenuPhoto> => {
return apiClient.post(
"",
{ imagePrefix, restaurantID, imageName },
{ restaurantID, imageName },
{ params: { photoCategory } }
);
};
5 changes: 3 additions & 2 deletions src/api/restaurant/restaurantApiIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const getRestaurantDetail = async (
};

export const createRestaurant = async (
restaurant: CreateRestaurantType
restaurant: CreateRestaurantType,
fileExtension?: string
): Promise<Restaurant> => {
return apiClient.post("", restaurant);
return apiClient.post("", { restaurant, fileExtension });
};
4 changes: 4 additions & 0 deletions src/api/restaurantOwner/RestaurantOwnerType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type RestaurantOwner = {
user_id: string;
restaurant_id: string;
};
12 changes: 12 additions & 0 deletions src/api/restaurantOwner/restaurantOwnerApiIndex.ts
Original file line number Diff line number Diff line change
@@ -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<RestaurantOwner> => {
return apiClient.post("", restaurantOwner);
};
3 changes: 1 addition & 2 deletions src/api/review/reviewApiIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ export const getReviewsByRestaurantID = async (

export const createReview = async (
createReviewDto: CreateReviewDto,
imagePrefix: string,
restaurantID: string,
photoCategory: string,
fileExtension?: string
): Promise<Review> => {
return apiClient.post(
"",
{ createReviewDto, imagePrefix, restaurantID, fileExtension },
{ createReviewDto, restaurantID, fileExtension },
{ params: { photoCategory } }
);
};
Expand Down
12 changes: 7 additions & 5 deletions src/components/utils/cards/RestaurantCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ const RestaurantCard: React.FC<Restaurant> = (props: Restaurant) => {
className="rounded-md shadow-lg hover:bg-slate-200"
>
<div className="w-full h-48 overflow-hidden">
<img
src={props.cover_image_url}
alt={props.name}
className="w-[100%] h-[100%] object-cover rounded-tl-md rounded-tr-md hover:scale-110 duration-300"
/>
{props.cover_image_url && (
<img
src={props.cover_image_url}
alt={props.name}
className="w-[100%] h-[100%] object-cover rounded-tl-md rounded-tr-md hover:scale-110 duration-300"
/>
)}
</div>
<div className="p-4">
<RestaurantRow text={props.name} icon={<IoRestaurant />} />
Expand Down
6 changes: 3 additions & 3 deletions src/components/utils/inputs/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const NumberInput: React.FC<NumberInputProps> = ({
max,
}) => {
return (
<div className="flex flex-col">
<label>{label}</label>
<div className="flex flex-col gap-1">
<label className="text-sm font-semibold">{label}</label>
<input
className="border border-gray-400 rounded-md p-2 mt-1"
className="border border-gray-400 rounded-md p-2"
type="number"
step={step}
placeholder={placeholder}
Expand Down
4 changes: 2 additions & 2 deletions src/components/utils/inputs/OpeningHoursInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const OpeningHoursInput: React.FC<OpeningHoursInputProps> = ({
onChange,
}) => {
return (
<div className="flex flex-col">
<label>{label}</label>
<div className="flex flex-col gap-1">
<label className="text-sm font-semibold">{label}</label>
<DatePicker
placeholderText={placeholder}
onChange={(date, e: React.ChangeEvent<HTMLInputElement>) => onChange(e)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/utils/inputs/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const SelectInput: React.FC<SelectInputProps> = ({
optionList,
}) => {
return (
<div className="flex flex-col">
<label>{label}</label>
<div className="flex flex-col gap-1">
<label className="text-sm font-semibold">{label}</label>
<Select
isClearable
placeholder={placeholder}
Expand Down
6 changes: 2 additions & 4 deletions src/components/utils/modals/CreateReviewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ interface CreateReviewModalProps {
restaurant_id?: string;
}

export type ReviewForm = {
export interface ReviewForm {
rating: number;
title: string;
visit_date: string;
content: string;
spending: number;
photo?: any;
};
}

const CreateReviewModal: React.FC<CreateReviewModalProps> = (props) => {
const navigate = useNavigate();
Expand Down Expand Up @@ -63,7 +63,6 @@ const CreateReviewModal: React.FC<CreateReviewModalProps> = (props) => {
user_id: user?.user_id,
visit_date: new Date(review.visit_date),
},
process.env.REACT_APP_IMAGE_PREFIX as string,
props.restaurant_id as string,
"Review",
fileTypeToExtension[review.photo?.type]
Expand Down Expand Up @@ -93,7 +92,6 @@ const CreateReviewModal: React.FC<CreateReviewModalProps> = (props) => {
user_id: user?.user_id,
visit_date: new Date(review.visit_date),
},
imagePrefix: process.env.REACT_APP_IMAGE_PREFIX as string,
restaurantID: props.restaurant_id as string,
photoCategory: "Review",
})
Expand Down
1 change: 0 additions & 1 deletion src/components/utils/modals/UploadImageModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const UploadImageModal: React.FC<UploadImageModalProps> = ({

dispatch(
createMenuPhotoThunk({
imagePrefix: process.env.REACT_APP_IMAGE_PREFIX as string,
restaurantID: restaurant_id as string,
imageName,
photoCategory: "Menu",
Expand Down
Loading