Skip to content

Commit 2b5cb9c

Browse files
committed
fix: 라우트 수정 및 자기 일정만 받아오게 수정
1 parent 69b664c commit 2b5cb9c

File tree

5 files changed

+53
-61
lines changed

5 files changed

+53
-61
lines changed

src/apis/personalScheduleApi.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import supabase from '@/supabase';
22
import { Events } from '@/utils/index';
33

44
export const getPersonalSchedule = async () => {
5-
const { data, error } = await supabase.from('personal_schedules').select();
5+
const { data: userData, error: userError } = await supabase.auth.getUser();
6+
7+
if (userError) {
8+
throw userError;
9+
}
10+
11+
const { data, error } = await supabase.from('personal_schedules').select('*').eq('user_id', userData.user.id);
12+
613
if (error) {
714
throw error;
815
}

src/main.tsx

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
import ReactDOM from 'react-dom/client';
22
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
33
import './styles/index.css';
4-
import App from './App.tsx';
5-
import TextInputForm from './pages/InputFormTest.tsx';
64
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
75
import ChangePasswordPage from './pages/ChangePasswordPage.tsx';
8-
import { JoinPage, LoginPage, ResetPwPage, NotFound, Policy } from './pages/index.ts';
6+
import { JoinPage, LoginPage, NotFound, Policy, ResetPwPage } from './pages/index.ts';
97
import ProtectedRoute from './providers/ProtectedRoute.tsx';
108
import EditGroupSchedule from './pages/EditGroupSchedulePage.tsx';
119
import AddGroupSchedulePage from './pages/AddGroupSchedulePage.tsx';
1210
import GroupSchedulePage from './pages/GroupSchedulePage.tsx';
1311
import ProfilePage from './pages/ProfilePage.tsx';
12+
import App from '@/App.tsx';
1413

1514
const router = createBrowserRouter([
1615
{
1716
path: '/',
17+
element: <ProtectedRoute />,
1818
children: [
1919
{
2020
index: true,
21-
element: (
22-
<ProtectedRoute>
23-
<App />
24-
</ProtectedRoute>
25-
),
21+
element: <App />,
2622
},
2723
{
2824
path: '/group/:groupId/edit/:scheduleId',
@@ -37,50 +33,42 @@ const router = createBrowserRouter([
3733
element: <AddGroupSchedulePage />,
3834
},
3935
{
40-
path: '/login',
41-
element: <LoginPage />,
42-
},
43-
{
44-
path: '/join',
45-
element: <JoinPage />,
46-
},
47-
{
48-
path: '/editPw',
49-
element: <ResetPwPage />,
50-
},
51-
{
52-
path: '/change-password',
53-
element: <ChangePasswordPage />,
54-
},
55-
{
56-
path: '*',
57-
element: <NotFound />,
58-
},
59-
{
60-
path: '/test',
61-
children: [
62-
{
63-
path: 'inputForm',
64-
element: <TextInputForm />,
65-
},
66-
],
36+
path: '/profile',
37+
element: <ProfilePage />,
6738
},
39+
],
40+
},
41+
{
42+
path: '/login',
43+
element: <LoginPage />,
44+
},
45+
{
46+
path: '/join',
47+
element: <JoinPage />,
48+
},
49+
{
50+
path: '/editPw',
51+
element: <ResetPwPage />,
52+
},
53+
{
54+
path: '/change-password',
55+
element: <ChangePasswordPage />,
56+
},
57+
{
58+
path: '*',
59+
element: <NotFound />,
60+
},
61+
62+
{
63+
path: '/policy',
64+
children: [
6865
{
69-
path: '/policy',
70-
children: [
71-
{
72-
path: 'personalInfo',
73-
element: <Policy.PersonalInfoPage />,
74-
},
75-
{
76-
path: 'usecondition',
77-
element: <Policy.UseConditionPage />,
78-
},
79-
],
66+
path: 'personalInfo',
67+
element: <Policy.PersonalInfoPage />,
8068
},
8169
{
82-
path: '/profile',
83-
element: <ProfilePage />,
70+
path: 'usecondition',
71+
element: <Policy.UseConditionPage />,
8472
},
8573
],
8674
},

src/pages/MyCalendarPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import AppBar from '@/components/common/AppBar.tsx';
22
import Calendar from '../components/common/Calendar.tsx';
33
import CreateEventDialog from '@/components/MyCalendar/CreateEventButton.tsx';
44
import HamburgerButton from '@/components/common/SideBar/HamburgerButton.tsx';
5-
import { getPersonalSchedule, deletePersonalSchedule } from '@/apis/personalScheduleApi';
5+
import { deletePersonalSchedule, getPersonalSchedule } from '@/apis/personalScheduleApi';
66
import { useEventState } from '@/stores/myEventsStore';
77
import { useEffect, useRef } from 'react';
88
import Dialog from '@/components/common/Dialog.tsx';
@@ -15,6 +15,8 @@ interface DialogElement {
1515
const MyCalendarPage: React.FC = () => {
1616
const { db_events, addDBEvents } = useEventState();
1717

18+
console.log('dv_events : ', db_events);
19+
1820
useEffect(() => {
1921
getPersonalSchedule().then((schedule) => {
2022
schedule.map((x) => {
@@ -45,7 +47,7 @@ const MyCalendarPage: React.FC = () => {
4547
return (
4648
<div className="lg:ml-80">
4749
<AppBar backButton={false} IconButton={<HamburgerButton />} calendarName="내 캘린더" />
48-
<main className="z-1 relative flex-grow">
50+
<main className="z-1 main-padding-right relative flex-grow">
4951
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
5052
<div>
5153
<Calendar db_events={db_events} onDeleteClicked={onDeleteClicked} />

src/providers/ProtectedRoute.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import { Loading } from '@/pages';
22
import { useGetSession } from '@/react-queries/useGetSession';
3-
import { FC, ReactNode } from 'react';
4-
import { useNavigate } from 'react-router-dom';
3+
import { Outlet, useNavigate } from 'react-router-dom';
54

6-
interface Props {
7-
children: ReactNode;
8-
}
9-
10-
const ProtectedRoute: FC<Props> = ({ children }) => {
5+
const ProtectedRoute = () => {
116
const { data, isError, error, isLoading } = useGetSession();
127
const navigate = useNavigate();
138

@@ -23,7 +18,7 @@ const ProtectedRoute: FC<Props> = ({ children }) => {
2318
navigate('/login');
2419
}
2520

26-
return children;
21+
return <Outlet />;
2722
};
2823

2924
export default ProtectedRoute;

src/styles/index.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ button {
7070
position: absolute;
7171
width: 100%;
7272
height: 100%;
73-
background-color: #bec00038;
73+
background-color: rgba(215, 217, 39, 0.22);
7474
top: 0;
7575
left: 0;
7676
}
7777
}
7878
}
7979

8080
@media (min-width: 1024px) {
81-
main {
81+
.main-padding-right {
8282
padding-right: 25vw;
8383
}
8484
.eventCardList {

0 commit comments

Comments
 (0)