Skip to content

Commit

Permalink
feat: board create button 추가 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
selfishAltruism committed Mar 2, 2024
1 parent cc17de7 commit 32c2ce0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/pages/board/boardList/BoardListPage.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import { useEffect } from 'react';

import { PageUiStoreImpl } from './BoardListPageUiStore';
import { Boards } from './components';
import { Boards, BoardCreateButton } from './components';

import { UniformLogo } from '@/assets';
import { BodyScreen, GNB, Header, PageBody, PageStoreHOC } from '@/components';
import { usePageUiStore } from '@/hooks';
import { useRootStore } from '@/stores/RootStore';

const BoardListPage: React.FC = () => {
const { fetch } = usePageUiStore<PageUiStore.BoardList>();
const { fetchBoards } = usePageUiStore<PageUiStore.BoardList>();
const {
auth: { fetch, me },
} = useRootStore();

useEffect(() => {
fetch();
fetchBoards();
}, [fetch]);

return (
<>
<Header title="게시판 목록" RightComponent={<UniformLogo />} />
{me?.isAdmin || me?.isCircleLeader || me?.isPresident ? (
<Header title="게시판 목록" RightComponent={<BoardCreateButton />} />
) : (
<Header title="게시판 목록" RightComponent={<UniformLogo />} />
)}

<PageBody>
<BodyScreen>
<Boards />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/board/boardList/BoardListPageUiStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class BoardListPageUiStore {
}

// 생성한 게시판의 카테고리가 이미 있으면 그 카테고리 안에 넣고, 없으면 새로 생성
*fetch(): Generator {
*fetchBoards(): Generator {
const boards = (yield Repo.fetch()) as Model.Board[];
this.boards = new Map();

Expand Down
26 changes: 26 additions & 0 deletions src/pages/board/boardList/components/BoardCreateButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import styled from '@emotion/styled';
import CreateIcon from '@mui/icons-material/Create';
import { observer } from 'mobx-react-lite';
import { generatePath, useParams } from 'react-router-dom';

import { ClearLink, RightButtonWrapper } from '@/components';
import { PAGE_URL, PostParams } from '@/configs/path';
import { usePageUiStore } from '@/hooks';

export const BoardCreateButton: React.FC = observer(() => {
return (
<Wrapper to={generatePath(PAGE_URL.BoardCreate)}>
<Icon />
</Wrapper>
);
});

const Wrapper = styled(ClearLink)`
${RightButtonWrapper}
`;

const Icon = styled(CreateIcon)`
position: absolute;
top: 14px;
right: 20px;
`;
1 change: 1 addition & 0 deletions src/pages/board/boardList/components/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { Boards } from './Boards';
export { BoardCreateButton } from './BoardCreateButton';

0 comments on commit 32c2ce0

Please sign in to comment.