Skip to content

Commit

Permalink
Merge pull request #14 from HappyScrolls/feature/#11_dayCalendar
Browse files Browse the repository at this point in the history
Feature/#11 day calendar
  • Loading branch information
mnbvcxzyj authored Sep 24, 2024
2 parents 0393447 + 63cf0d1 commit b403577
Show file tree
Hide file tree
Showing 22 changed files with 1,765 additions and 33 deletions.
11 changes: 11 additions & 0 deletions src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import Redirect from "./pages/login/components/Redirect";
import SchedulePage from "./pages/schedule/SchedulePage";
import SignUpPage from "./pages/signup/SignUpPage";
import MainPage from "./pages/main/MainPage";
import CalendarPage from "./pages/calendar/CalendarPage";

import AddMySchedulePage from "./pages/schedule/AddMySchedulePage";

const router = createBrowserRouter([
{
Expand All @@ -31,6 +34,14 @@ const router = createBrowserRouter([
path: "/schedule/detail",
element: <SchedulePage />,
},
{
path: "/calendar/:date",
element: <CalendarPage />,
},
{
path: "calendar/:date/add",
element: <AddMySchedulePage />,
},
],
},
]);
Expand Down
5 changes: 5 additions & 0 deletions src/api/ApiResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface ApiResponse<T = any> {
data: T;
message: string;
statusCode: number;
}
28 changes: 13 additions & 15 deletions src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import axios from "axios";

export const axiosInstance = axios.create({
baseURL: "http://localhost:8084",
export const scheduleAxiosInstance = axios.create({
baseURL: "http://158.247.198.100:32000",
withCredentials: true,
timeout: 5000,
});

export const refreshInstance = axios.create({
baseURL: "http://localhost:8084",
baseURL: "http://158.247.198.100:32002",
withCredentials: true,
});

// 요청
axiosInstance.interceptors.request.use(
scheduleAxiosInstance.interceptors.request.use(
(config) => {
const token = localStorage.getItem("authToken");
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
const memberCode =
localStorage.getItem("memberCode") ||
"eyJubyI6NSwibmFtZSI6Im5hbWUiLCJhY2NvdW50IjoiYWNjb3VudCJ9";

// 임시 Member-Code 작성
config.headers["Member-Code"] =
"eyJubyI6MSwibmFtZSI6Im5hbWUiLCJhY2NvdW50IjoiYWNjb3VudCJ9";
config.headers["Member-Code"] = memberCode;
// config.headers["Content-Type"] = "application/json";

return config;
},
Expand All @@ -30,7 +29,7 @@ axiosInstance.interceptors.request.use(
);

// 응답
axiosInstance.interceptors.response.use(
scheduleAxiosInstance.interceptors.response.use(
(response) => response,
(error) => {
if (error.response && error.response.status === 401) {
Expand All @@ -40,8 +39,7 @@ axiosInstance.interceptors.response.use(
}
);


export const memberAxiosInstance = axios.create({
baseURL: "http://158.247.198.100:32002",
withCredentials: true,
baseURL: "http://158.247.198.100:32002",
withCredentials: true,
});
10 changes: 5 additions & 5 deletions src/api/query/get/useGetScheduleDetail.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { axiosInstance } from "../../axios";
import { ISchedule } from "../../../types/ISchedule";
import { scheduleAxiosInstance } from "../../axios";
import { ScheduleData } from "../../../types/ISchedule";

interface useGetScheduleDetailProps {
scheduleNo: number;
}

function useGetScheduleDetail({
scheduleNo,
}: useGetScheduleDetailProps): ISchedule | undefined {
}: useGetScheduleDetailProps): ScheduleData | undefined {
// 데이터 가져오기
const fetchSchedule = async (scheduleNo: number): Promise<ISchedule> => {
const response = await axiosInstance.get(`/schedule/${scheduleNo}`);
const fetchSchedule = async (scheduleNo: number): Promise<ScheduleData> => {
const response = await scheduleAxiosInstance.get(`/schedule/${scheduleNo}`);

return response.data;
};
Expand Down
43 changes: 43 additions & 0 deletions src/api/schedule/scheduleAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ScheduleData } from "../../types/ISchedule";
import { ApiResponse } from "../ApiResponse";
import { scheduleAxiosInstance } from "../axios";

// 일정 생성
export const createSchedule = async (
scheduleData: ScheduleData
): Promise<ApiResponse> => {
try {
const response = await scheduleAxiosInstance.post<ApiResponse>(
"/schedule",
scheduleData
);
return response.data;
} catch (error) {
console.error("일정 생성 중 오류 발생:", error);
throw error;
}
};

// 일정 삭제
export const deleteSchedule = async (scheduleNo: number) => {
try {
const response = await scheduleAxiosInstance.delete(
`/schedule/${scheduleNo}`
);
return response.data;
} catch (error) {
console.error("일정 삭제 중 오류 발생:", error);
throw error;
}
};

// 일정 조회
export const fetchSchedulesByDate = async (date: string) => {
try {
const response = await scheduleAxiosInstance.get(`/schedule?date=${date}`);
return response.data;
} catch (error) {
console.error("일정 조회 중 오류 발생:", error);
throw error;
}
};
10 changes: 10 additions & 0 deletions src/images/calendar/nophone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/images/calendar/phone.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions src/pages/calendar/CalendarPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { useState } from "react";
import { Container } from "../../components/layout/Layout";
import ViewChangeHeader from "./components/ViewChangeHeader";
import { useParams } from "react-router-dom";
import ListView from "./components/ListView";
import TimeTable from "./components/TimeTableView";
import { styled } from "styled-components";

const CalendarPage = () => {
const { date } = useParams<{ date: string }>();
console.log(date);

const [isTimetableView, setIsTimetableView] = useState(true);

const toggleView = () => {
setIsTimetableView(!isTimetableView);
};

return (
<>
<CalendarContainer>
<ViewChangeHeader
isTimetableView={isTimetableView}
toggleView={toggleView}
/>
{isTimetableView ? <TimeTable /> : <ListView />}
</CalendarContainer>
</>
);
};

export default CalendarPage;

const CalendarContainer = styled(Container)``;
Loading

0 comments on commit b403577

Please sign in to comment.