Skip to content

Commit

Permalink
Merge pull request #25 from openrice-canada/feat/restaurant
Browse files Browse the repository at this point in the history
feat: restaurant
  • Loading branch information
ttiimmothy authored Nov 21, 2023
2 parents dd07cc6 + 78ba706 commit 08e57b1
Show file tree
Hide file tree
Showing 34 changed files with 491 additions and 123 deletions.
31 changes: 20 additions & 11 deletions src/api/restaurant/RestaurantType.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
export interface Restaurant {
restaurant_id: string;
name: string;
address: string;
district_id: string;
latitude: string;
longitude: string;
postal_code: string;
phone: string;
intro: string;
opening_hours: string;
cover_image?: string;
averageRating: number;
reviewCount: number;
active: boolean;
created_at: Date;
modified_at: Date;
}

export type SearchRestaurantQuery = {
name?: string;
limit?: number;
offset?: number;
};

export type Restaurant = {
export type CreateRestaurantType = {
address: string;
latitude: string;
longitude: string;
Expand All @@ -31,13 +50,3 @@ export type Restaurant = {
rating?: number;
coverImageUrl?: string;
};

export type RestaurantDish = {
restaurant_id: string;
dish_id: string;
};

export type RestaurantPaymentMethod = {
restaurant_id: string;
payment_method_id: string;
};
19 changes: 3 additions & 16 deletions src/api/restaurant/restaurantApiIndex.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AxiosApiClientBuilder } from "../axiosIndex";
import {
Restaurant,
RestaurantDish,
RestaurantPaymentMethod,
CreateRestaurantType,
SearchRestaurantQuery,
} from "./RestaurantType";

Expand All @@ -22,20 +21,8 @@ export const getRestaurantDetail = async (
return apiClient.get(restaurantId);
};

export const postRestaurant = async (
restaurant: Restaurant
export const createRestaurant = async (
restaurant: CreateRestaurantType
): Promise<Restaurant> => {
return apiClient.post("", restaurant);
};

export const postRestaurantDIsh = async (
dish: RestaurantDish
): Promise<RestaurantDish> => {
return apiClient.post("/dish", dish);
};

export const postRestaurantPaymentMethod = async (
paymentMethod: RestaurantPaymentMethod
): Promise<RestaurantPaymentMethod> => {
return apiClient.post("/payment", paymentMethod);
};
4 changes: 4 additions & 0 deletions src/api/restaurantDish/RestaurantDishType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type RestaurantDish = {
restaurant_id: string;
dish_id: string;
};
12 changes: 12 additions & 0 deletions src/api/restaurantDish/restaurantDishApiIndex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AxiosApiClientBuilder } from "../axiosIndex";
import { RestaurantDish } from "./RestaurantDishType";

const apiClient = new AxiosApiClientBuilder()
.withResourceName("/restaurant-dish")
.build();

export const createRestaurantDish = async (
restaurantDish: RestaurantDish
): Promise<RestaurantDish> => {
return apiClient.post("/restaurant-dish", restaurantDish);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type RestaurantPaymentMethod = {
restaurant_id: string;
payment_method_id: string;
};
12 changes: 12 additions & 0 deletions src/api/restaurantPaymentMethod/restaurantPaymentMethodApiIndex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AxiosApiClientBuilder } from "../axiosIndex";
import { RestaurantPaymentMethod } from "./RestaurantPaymentMethodType";

const apiClient = new AxiosApiClientBuilder()
.withResourceName("/restaurant-payment")
.build();

export const createRestaurantPaymentMethod = async (
restaurantPaymentMethod: RestaurantPaymentMethod
): Promise<RestaurantPaymentMethod> => {
return apiClient.post("/restaurant-payment", restaurantPaymentMethod);
};
4 changes: 2 additions & 2 deletions src/api/review/ReviewType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export type Review = {
export type CreateReviewRequest = {
user_id: string;
restaurant_id: string;
rating: number;
title: string;
visit_date: Date;
content: string;
rating: number;
spending: number;
visit_date: Date;
};
2 changes: 1 addition & 1 deletion src/api/review/reviewApiIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const getReviewsByRestaurantID = async (
return apiClient.get("", { params: { restaurantId } });
};

export const postReview = async (
export const createReview = async (
input: CreateReviewRequest
): Promise<Review> => {
return apiClient.post("", input);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from "react-router-dom";
import { Restaurant } from "../../api/restaurant/RestaurantType";
import { Restaurant } from "../../../api/restaurant/RestaurantType";
import { IoLocation, IoReorderThree, IoRestaurant } from "react-icons/io5";

const RestaurantCard: React.FC<Restaurant> = (props: Restaurant) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link } from "react-router-dom";
import { Review } from "../../api/review/ReviewType";
import { Review } from "../../../api/review/ReviewType";
import {
IoRestaurant,
IoChatbubbleEllipsesSharp,
Expand Down
30 changes: 30 additions & 0 deletions src/components/utils/inputs/FileInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
type FileInputProps = {
label: string;
placeholder: string;
value?: string | number;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
type: React.HTMLInputTypeAttribute;
className: string;
};

const FileInput = ({
label,
placeholder,
onChange,
type,
className,
}: FileInputProps) => {
return (
<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 ${className}`}
type={type}
placeholder={placeholder}
onChange={onChange}
/>
</div>
);
};

export default FileInput;
37 changes: 37 additions & 0 deletions src/components/utils/inputs/NumberInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
type NumberInputProps = {
label: string;
placeholder: string;
value: number;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
step: string;
min?: number;
max?: number;
};

const TextInput = ({
label,
placeholder,
value,
onChange,
step,
min,
max,
}: NumberInputProps) => {
return (
<div className="flex flex-col">
<label>{label}</label>
<input
className="border border-gray-400 rounded-md p-2 mt-1"
type="number"
step={step}
placeholder={placeholder}
value={value}
onChange={onChange}
min={min}
max={max}
/>
</div>
);
};

export default TextInput;
29 changes: 29 additions & 0 deletions src/components/utils/inputs/OpeningHoursInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import DatePicker from "react-datepicker";
import "react-datepicker/dist/react-datepicker.css";

type DateInputProps = {
label: string;
placeholder: string;
value: Date;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
};

const DateInput = ({ label, placeholder, value, onChange }: DateInputProps) => {
return (
<div className="flex flex-col">
<label>{label}</label>
<DatePicker
placeholderText={placeholder}
onChange={(date, e: React.ChangeEvent<HTMLInputElement>) => onChange(e)}
selected={value}
showTimeSelect
showTimeSelectOnly
timeIntervals={15}
timeCaption="Time"
dateFormat="h:mm aa"
/>
</div>
);
};

export default DateInput;
30 changes: 30 additions & 0 deletions src/components/utils/inputs/SearchInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { IoSearch } from "react-icons/io5";

type SearchInputProps = {
placeholder?: string;
value: string;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
type: React.HTMLInputTypeAttribute;
};

const SearchInput: React.FC<SearchInputProps> = (props) => {
return (
<div className="flex items-center h-12 w-full">
<input
className="border border-gray-400 rounded-tl-md rounded-bl-md px-4 outline-none h-full w-full"
type={props.type}
placeholder={props.placeholder || ""}
value={props.value}
onChange={props.onChange}
/>
<button
type="submit"
className="bg-gray-700 h-full w-14 flex justify-center items-center rounded-tr-md rounded-br-md"
>
<IoSearch color="#FFFFFF" />
</button>
</div>
);
};

export default SearchInput;
40 changes: 40 additions & 0 deletions src/components/utils/inputs/SelectInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Select from 'react-select';

interface ICategory {
value: string;
label: string;
}

type SelectInputProps = {
label: string;
placeholder: string;
value: string;
onChange: (...event: unknown[]) => void
optionList: ICategory[];
};

const TextInput = ({
label,
placeholder,
value,
onChange,
optionList,
}: SelectInputProps) => {
return (
<div className="flex flex-col">
<label>{label}</label>
<Select
isClearable
placeholder={placeholder}
options={optionList}
value={optionList.find(c => c.value === value)}
onChange={e => {
onChange(e?.value);
}}
/>
</div>
);
};

export default TextInput;

30 changes: 30 additions & 0 deletions src/components/utils/inputs/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
type TextInputProps = {
label: string;
placeholder: string;
value: string | number;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
type: React.HTMLInputTypeAttribute;
};

const TextInput = ({
label,
placeholder,
value,
onChange,
type,
}: TextInputProps) => {
return (
<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"
type={type}
placeholder={placeholder}
value={value}
onChange={onChange}
/>
</div>
);
};

export default TextInput;
28 changes: 28 additions & 0 deletions src/components/utils/inputs/TextareaInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
interface TextareaInputProps {
label?: string;
placeholder: string;
value: string | number;
onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
type?: React.HTMLInputTypeAttribute;
className: string;
}

export const TextareaInput = ({
label,
placeholder,
value,
onChange,
className,
}: TextareaInputProps) => {
return (
<div className="flex flex-col gap-1">
{label && <label className="text-sm font-semibold">{label}</label>}
<textarea
className={className}
placeholder={placeholder}
value={value}
onChange={onChange}
/>
</div>
);
};
Loading

0 comments on commit 08e57b1

Please sign in to comment.