Skip to content

Commit

Permalink
[Deploy/#44] 로그인 기능 추가 (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
gudusol authored Sep 26, 2024
1 parent 6e99ada commit 0c95786
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const allRoutes = [
...homeRoutes,
...orderInfoRoutes,
...experienceOrderInfoRoutes,
...adminRoutes,

...adminRoutes,
];
const router = createBrowserRouter([...allRoutes]);

Expand Down
21 changes: 21 additions & 0 deletions src/apis/domains/service/useFetchDeliveryDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { get } from "@apis/api";
import { QUERY_KEY } from "@apis/queryKeys/queryKeys";
import { useQuery } from "@tanstack/react-query";
import { ApiResponseType } from "@types";

const getDeliveryDate = async (): Promise<number | null> => {
try {
const response = await get<ApiResponseType<number>>("api/v1/delivery/max");
return response.data.data;
} catch (error) {
console.log(error);
return null;
}
};

export const useFetchDeliveryDate = () => {
return useQuery({
queryKey: [QUERY_KEY.DELIVERY_DATE_MAX],
queryFn: () => getDeliveryDate(),
});
};
1 change: 1 addition & 0 deletions src/apis/queryKeys/queryKeys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const QUERY_KEY = {
ORDER_POST: "orderPost",
DELIVERY_DATE: "deliveryDate",
DELIVERY_DATE_MAX: "deliveryDate",
PRODUCT_LIST: "productList",
PRODUCT_LIST_ALL: "productListAll",
SAILED_PRODUCT: "sailedProduct",
Expand Down
8 changes: 8 additions & 0 deletions src/components/common/CustomCalendar/CustomCalendar.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import "react-calendar/dist/Calendar.css";
import Calendar, { CalendarProps } from "react-calendar";
import { useState } from "react";
import dayjs from "dayjs";
import { useFetchDeliveryDate } from "@apis/domains/admin/useFetchDeliveryDate";

interface CustomCalendarProps {
onDateChange: (date: string) => void;
}

const CustomCalendar = ({ onDateChange }: CustomCalendarProps) => {
const today = dayjs();
const [date, setDate] = useState<Date | null>(new Date());

const { data: deliveryDate } = useFetchDeliveryDate();

const formatDay = (_locale: string | undefined, date: Date): string =>
date.getDate().toString();

Expand Down Expand Up @@ -98,6 +103,9 @@ const CustomCalendar = ({ onDateChange }: CustomCalendarProps) => {
onChange={handleDateChange}
value={date}
formatDay={formatDay}
locale="ko-KR"
minDate={today.add(3, "day").toDate()}
maxDate={today.add(deliveryDate ?? 14, "day").toDate()}
/>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/constants/routePath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const productHomePages = {
HOME: "/",
PRODUCT_HOME: "/product",
};

Expand Down
5 changes: 5 additions & 0 deletions src/routes/homeRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { routePath } from "@constants";
import { ExperienceHome, ProductHome } from "@pages/index";
import { RouteType } from "@types";
import { Navigate } from "react-router-dom";

const homeRoutes: RouteType[] = [
{
path: routePath.HOME,
element: <Navigate to={routePath.PRODUCT_HOME} />,
},
{
path: routePath.PRODUCT_HOME,
element: <ProductHome />,
Expand Down

0 comments on commit 0c95786

Please sign in to comment.