Skip to content

Commit

Permalink
Merge pull request #319 from boostcampwm2023/feature/backlog-finished…
Browse files Browse the repository at this point in the history
…-page

feat: 완료된 스토리 페이지 구현
  • Loading branch information
surinkwon authored Jul 31, 2024
2 parents d9d44e9 + 5105635 commit 0a2f9ec
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
3 changes: 2 additions & 1 deletion frontend/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import LandingPage from "./pages/landing/LandingPage";
import InvitePage from "./pages/invite/InvitePage";
import UnfinishedStoryPage from "./pages/backlog/UnfinishedStoryPage";
import BacklogPage from "./pages/backlog/BacklogPage";
import FinishedStoryPage from "./pages/backlog/FinishedStoryPage";

type RouteType = "PRIVATE" | "PUBLIC";

Expand Down Expand Up @@ -89,7 +90,7 @@ const router = createBrowserRouter([
},
{
path: ROUTER_URL.BACKLOG.COMPLETED,
element: <div>backlog completed story Page</div>,
element: <FinishedStoryPage />,
},
],
element: <BacklogPage />,
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/backlog/StoryBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface StoryBlockProps {
children: React.ReactNode;
taskExist: boolean;
epicList: EpicCategoryDTO[];
finished?: boolean;
}

const StoryBlock = ({
Expand All @@ -41,6 +42,7 @@ const StoryBlock = ({
status,
taskExist,
epicList,
finished = false,
children,
}: StoryBlockProps) => {
const { socket }: { socket: Socket } = useOutletContext();
Expand Down Expand Up @@ -277,7 +279,7 @@ const StoryBlock = ({
<TaskContainer>
<TaskHeader />
{children}
<TaskCreateBlock storyId={id} />
{!finished && <TaskCreateBlock storyId={id} />}
</TaskContainer>
)}
</>
Expand Down
52 changes: 52 additions & 0 deletions frontend/src/pages/backlog/FinishedStoryPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { useOutletContext } from "react-router-dom";
import { BacklogDTO } from "../../types/DTO/backlogDTO";
import { useMemo } from "react";
import StoryBlock from "../../components/backlog/StoryBlock";
import changeEpicListToStoryList from "../../utils/changeEpicListToStoryList";
import TaskBlock from "../../components/backlog/TaskBlock";

const FinishedStoryPage = () => {
const { backlog }: { backlog: BacklogDTO } = useOutletContext();
const storyList = useMemo(
() =>
changeEpicListToStoryList(backlog.epicList).filter(
({ status }) => status === "완료"
),
[backlog.epicList]
);
const epicCategoryList = useMemo(
() => backlog.epicList.map(({ id, name, color }) => ({ id, name, color })),
[backlog.epicList]
);

return (
<div className="flex flex-col items-center gap-4">
<div className="w-full border-b">
{...storyList.map(({ id, epic, title, point, status, taskList }) => {
const progress = taskList.length
? Math.round(
(taskList.filter(({ status }) => status === "완료").length /
taskList.length) *
100
)
: 0;

return (
<StoryBlock
{...{ id, title, point, status }}
epic={epic}
progress={progress}
taskExist={taskList.length > 0}
epicList={epicCategoryList}
finished={true}
>
{...taskList.map((task) => <TaskBlock {...task} />)}
</StoryBlock>
);
})}
</div>
</div>
);
};

export default FinishedStoryPage;
24 changes: 15 additions & 9 deletions frontend/src/stores/useMemberStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { create } from "zustand";
import { LandingMemberDTO, MemberStatus } from "../types/DTO/landingDTO";
import { createJSONStorage, persist } from "zustand/middleware";

interface InitialMemberState {
myInfo: LandingMemberDTO;
Expand All @@ -18,14 +19,19 @@ const initialState: InitialMemberState = {
memberList: [],
};

const useMemberStore = create<MemberState>((set) => ({
...initialState,
updateMyInfo: (newMyInfo) => set(() => ({ myInfo: newMyInfo })),
updateMyStatus: (status) =>
set((state) => ({ myInfo: { ...state.myInfo, status } })),
updateMemberList: (newMember) => set({ memberList: newMember }),
addMember: (member) =>
set((state) => ({ memberList: [...state.memberList, member] })),
}));
const useMemberStore = create<MemberState>()(
persist(
(set) => ({
...initialState,
updateMyInfo: (newMyInfo) => set(() => ({ myInfo: newMyInfo })),
updateMyStatus: (status) =>
set((state) => ({ myInfo: { ...state.myInfo, status } })),
updateMemberList: (newMember) => set({ memberList: newMember }),
addMember: (member) =>
set((state) => ({ memberList: [...state.memberList, member] })),
}),
{ name: "member-storage", storage: createJSONStorage(() => sessionStorage) }
)
);

export default useMemberStore;

0 comments on commit 0a2f9ec

Please sign in to comment.