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

대시보드 리팩토링 #103

Merged
merged 10 commits into from
Oct 28, 2024
44 changes: 30 additions & 14 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { Routes, Route } from 'react-router-dom';
import MainPage from './pages/MainPage';
// import MainPage from './pages/MainPage';
import LoginPage from './pages/LoginPage';
import MyPage from './pages/MyPage';
import CreateBoard from './pages/CreateBoardPage';
Expand Down Expand Up @@ -31,12 +31,11 @@ import { useMediaQuery } from 'react-responsive';
import Flex from './components/Flex';
import { MobileDisplay } from './styles/ErrorPageStyled';
import RouteChangeTracker from './components/RouteChangeTracker';
import PersonalDashBoard from './components/PersonalDashboard';
import PersonalDashboard from './components/PersonalDashboard';
import TeamDashBoard from './components/TeamDashboard';

const queryClient = new QueryClient();

// 로그인 상태를 체크하는 함수
const useAuth = () => {
const [isLoggedIn, setIsLoggedIn] = useState<boolean>(false);
const [loading, setLoading] = useState<boolean>(true);
Expand All @@ -58,8 +57,6 @@ const App = () => {
const isMobile = useMediaQuery({ query: '(max-width: 1000px)' });
const { isLoggedIn, loading } = useAuth();

RouteChangeTracker();

if (loading) {
return <div>Loading...</div>;
}
Expand Down Expand Up @@ -90,44 +87,63 @@ const App = () => {
theme="light"
style={{ width: '21.875rem', lineHeight: '1.5rem' }}
/>

<Routes>
<Route path="/" element={<LoginPage />} />
<Route path="/api/oauth2/callback/:provider" element={<OAuthRedirectHandler />} />
<Route path="/error/403" element={<Error403Page />} />
<Route path="*" element={<Error404Page />} />

<Route
path="/personal/:id"
element={
<ProtectedRoute>
<PersonalDashBoard />
<PersonalDashboard />
</ProtectedRoute>
}
/>
<Route
path="/team/:id"
>
<Route
path=":blockId"
element={
<ProtectedRoute>
<SidePage />
</ProtectedRoute>
}
/>
</Route>
{/* <Route
path="/personalBlock/:blockId"
element={
<ProtectedRoute>
<TeamDashBoard />
<SidePage />
</ProtectedRoute>
}
/>
/> */}
<Route
path="/:id"
path="/team/:id"
element={
<ProtectedRoute>
<MainPage />
<TeamDashBoard />
</ProtectedRoute>
}
>
<Route
path="personalBlock/:blockId"
path=":blockId"
element={
<ProtectedRoute>
<SidePage />
</ProtectedRoute>
}
/>
</Route>
{/* <Route
path="/:id"
element={
<ProtectedRoute>
<MainPage />
</ProtectedRoute>
}
/> */}

<Route
path="/createBoard"
Expand Down
4 changes: 2 additions & 2 deletions src/api/PersonalBlockApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { BlockListResDto, BlockOrder } from '../types/PersonalBlock';
import { BlockListResDto, BlockOrder, DeletedBlockList } from '../types/PersonalBlock';
import { axiosInstance } from '../utils/apiConfig';

// 블록 생성 post
Expand Down Expand Up @@ -70,7 +70,7 @@ export const getDeleteBlock = async (dashboardId: string, page?: number, size?:
const response = await axiosInstance.get(
`/blocks/deleted?dashboardId=${dashboardId}&page=0&size=10`
);
return response.data.data;
return response.data.data as DeletedBlockList;
} catch (error) {
console.log('Error fetching data:', error);
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ const Block = ({
const navigate = useNavigate();

const clickHandler = () => {
// navigate(`personalBlock/${blockId}`);
navigate(`personalBlock/${blockId}`, {
navigate(`${blockId}`, {
state: { highlightColor, progress },
});
};
Expand Down
19 changes: 3 additions & 16 deletions src/components/CompletedDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const CompletedDashboard = ({ list, id, dashboardId, onLoadMore }: Props) => {
// console.log(blockId);

const { highlightColor, progress } = settings;
navigate(`personalBlock/${blockId}`, { state: { highlightColor, progress, blockId } });
navigate(`${blockId}`, {
state: { highlightColor, progress, blockId },
});
};

// 세로 무한 스크롤
Expand Down Expand Up @@ -77,20 +79,6 @@ const CompletedDashboard = ({ list, id, dashboardId, onLoadMore }: Props) => {
className="container"
{...provided.droppableProps}
>
{/* {list?.map((block, index) => (
<Block
dashboardId={dashboardId}
key={block.blockId}
index={index}
title={block.title ?? ''}
dDay={block.dDay ?? 0}
contents={block.contents ?? ''}
blockId={block.blockId ?? '0'}
dType={block.dType ?? 'TeamDashboard'}
name={block.nickname ?? '이름 없음'}
picture={block.picture ?? ''}
/>
))} */}
{list?.map((block, index) => {
const isLastBlock = index === list.length - 1;
return (
Expand All @@ -115,7 +103,6 @@ const CompletedDashboard = ({ list, id, dashboardId, onLoadMore }: Props) => {
</S.BoxContainer>
)}
</Droppable>
<Outlet />
</S.CardContainer>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/DeleteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BlockListResDto, DeletedBlockList } from '../types/PersonalBlock';

interface Props {
id: string;
list: DeletedBlockList;
list: BlockListResDto[];
removeValue: boolean;
}
const DeleteButton = ({ id, list, removeValue }: Props) => {
Expand All @@ -30,7 +30,7 @@ const DeleteButton = ({ id, list, removeValue }: Props) => {
<S.DeleteDiv ref={provided.innerRef} className="container" {...provided.droppableProps}>
<h1>휴지통</h1>
<S.BoxContainer>
{list.blockListResDto.map(
{list.map(
(
{ title, blockId, contents, dDay, dashboardId, dType, nickname, picture },
index
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {
const Header = ({ mainTitle, subTitle, blockProgress, dashboardType }: Props) => {
const navigate = useNavigate();
const location = useLocation();
const dashboardId = location.pathname.split('/')[1];
const dashboardId = location.pathname.split('/')[2];

// URL에 "teamdocument"가 포함되어 있는지 확인하는 함수
// => 전역 변수로 개인 대시보드인지 팀 대시보드인지 확인할 예정이라 주석 처리
Expand Down
17 changes: 1 addition & 16 deletions src/components/InProgressDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const InProgressDashboard = ({ list, id, dashboardId, onLoadMore }: Props) => {
// console.log(blockId);

const { highlightColor, progress } = settings;
navigate(`personalBlock/${blockId}`, {
navigate(`${blockId}`, {
state: { highlightColor, progress, blockId },
});
};
Expand Down Expand Up @@ -82,20 +82,6 @@ const InProgressDashboard = ({ list, id, dashboardId, onLoadMore }: Props) => {
className="container"
{...provided.droppableProps}
>
{/* {list?.map((block, index) => (
<Block
dashboardId={dashboardId}
key={block.blockId}
index={index}
title={block.title ?? ''}
dDay={block.dDay ?? 0}
contents={block.contents ?? ''}
blockId={block.blockId ?? '0'}
dType={block.dType ?? 'TeamDashboard'}
name={block.nickname ?? '이름 없음'}
picture={block.picture ?? ''}
/>
))} */}
{list?.map((block, index) => {
const isLastBlock = index === list.length - 1;
return (
Expand All @@ -120,7 +106,6 @@ const InProgressDashboard = ({ list, id, dashboardId, onLoadMore }: Props) => {
</S.BoxContainer>
)}
</Droppable>
<Outlet />
</S.CardContainer>
);
};
Expand Down
4 changes: 1 addition & 3 deletions src/components/NotStartedDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import main3 from '../img/main3.png';
import { BlockListResDto } from '../types/PersonalBlock';
import { useInView } from 'react-intersection-observer';
import { useEffect } from 'react';
import { progress } from 'framer-motion';

type Props = {
list: BlockListResDto[];
Expand Down Expand Up @@ -45,7 +44,7 @@ const NotStartedDashboard = ({ list, id, dashboardId, onLoadMore }: Props) => {
const blockId = await createPersonalBlock(data);

const { highlightColor, progress } = settings;
navigate(`personalBlock/${blockId}`, {
navigate(`${blockId}`, {
state: { highlightColor, progress, blockId },
});
};
Expand Down Expand Up @@ -104,7 +103,6 @@ const NotStartedDashboard = ({ list, id, dashboardId, onLoadMore }: Props) => {
</S.BoxContainer>
)}
</Droppable>
<Outlet />
</S.CardContainer>
);
};
Expand Down
Loading