diff --git a/frontend/src/components/DiscussionList/DiscussionListContent.tsx b/frontend/src/components/DiscussionList/DiscussionListContent.tsx index 4c67740d..4868a06f 100644 --- a/frontend/src/components/DiscussionList/DiscussionListContent.tsx +++ b/frontend/src/components/DiscussionList/DiscussionListContent.tsx @@ -2,13 +2,29 @@ import * as S from './DiscussionList.styled'; import DiscussionListItem from './DiscussionListItem'; import { Link } from 'react-router-dom'; import NoContentWithoutButton from '../common/NoContent/NoContentWithoutButton'; -import type { Discussion } from '@/types'; +import useDiscussions from '@/hooks/useDiscussions'; +import { HASHTAGS } from '@/constants/hashTags'; interface DiscussionListContentProps { - discussions: Discussion[]; + selectedMission?: string; + selectedHashTag?: string; + page: number; + onPageInfoUpdate?: (totalPage: number) => void; } -export default function DiscussionListContent({ discussions }: DiscussionListContentProps) { +export default function DiscussionListContent({ + selectedMission, + selectedHashTag, + page, + onPageInfoUpdate, +}: DiscussionListContentProps) { + const { discussions } = useDiscussions({ + mission: selectedMission ?? HASHTAGS.all, + hashTag: selectedHashTag ?? HASHTAGS.all, + page, + onPageInfoUpdate, + }); + return ( {discussions.length ? ( diff --git a/frontend/src/components/MissionList/MissionList.styled.ts b/frontend/src/components/MissionList/MissionList.styled.ts index f180e765..187090df 100644 --- a/frontend/src/components/MissionList/MissionList.styled.ts +++ b/frontend/src/components/MissionList/MissionList.styled.ts @@ -30,7 +30,7 @@ const show = keyframes` export const MissionList = styled.ul` display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 30rem)); - justify-content: center; + justify-content: start; justify-items: center; row-gap: 3.6rem; column-gap: 2rem; diff --git a/frontend/src/components/MissionList/index.tsx b/frontend/src/components/MissionList/index.tsx index 8911e80b..87741216 100644 --- a/frontend/src/components/MissionList/index.tsx +++ b/frontend/src/components/MissionList/index.tsx @@ -10,25 +10,27 @@ interface MissionListProps { export default function MissionList({ missions }: MissionListProps) { return ( - + <> {missions.length > 0 ? ( - missions.map(({ id, thumbnail, title, hashTags, summary }) => ( - - - - - - )) + + {missions.map(({ id, thumbnail, title, hashTags, summary }) => ( + + + + + + ))} + ) : ( )} - + ); } diff --git a/frontend/src/components/SolutionList/SolutionList.styled.ts b/frontend/src/components/SolutionList/SolutionList.styled.ts index bde3d8bf..d9f27923 100644 --- a/frontend/src/components/SolutionList/SolutionList.styled.ts +++ b/frontend/src/components/SolutionList/SolutionList.styled.ts @@ -14,7 +14,7 @@ const show = keyframes` export const SolutionList = styled.div` display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 30rem)); - justify-content: center; + justify-content: start; justify-items: center; row-gap: 3.6rem; column-gap: 2rem; diff --git a/frontend/src/components/SolutionList/index.tsx b/frontend/src/components/SolutionList/index.tsx index f83ffd35..0e1007f6 100644 --- a/frontend/src/components/SolutionList/index.tsx +++ b/frontend/src/components/SolutionList/index.tsx @@ -54,9 +54,9 @@ export default function SolutionList({ selectedMission, selectedHashTag }: Solut return ( <> - - {solutionSummaries.length > 0 ? ( - solutionSummaries.map(({ id, thumbnail, title, description, hashTags }) => ( + {solutionSummaries.length > 0 ? ( + + {solutionSummaries.map(({ id, thumbnail, title, description, hashTags }) => ( - )) - ) : ( - - )} - + ))} + + ) : ( + + )} {solutionSummaries.length > 0 && ( diff --git a/frontend/src/pages/DiscussionListPage/index.tsx b/frontend/src/pages/DiscussionListPage/index.tsx index e395c34a..66d334e6 100644 --- a/frontend/src/pages/DiscussionListPage/index.tsx +++ b/frontend/src/pages/DiscussionListPage/index.tsx @@ -10,7 +10,6 @@ import type { SelectedMissionType } from '@/types/mission'; import { usePagination } from '@/hooks/usePagination'; import { HASHTAGS } from '@/constants/hashTags'; import PageButtons from '@/components/common/PageButtons'; -import useDiscussions from '@/hooks/useDiscussions'; import SpinnerSuspense from '@/components/common/SpinnerSuspense'; export default function DiscussionListPage() { @@ -41,14 +40,6 @@ export default function DiscussionListPage() { prevHashTagRef.current = selectedHashTag; }, [selectedMission, selectedHashTag, handleInitializePage]); - const { discussions } = useDiscussions({ - mission: selectedMission?.title ?? HASHTAGS.all, - hashTag: selectedHashTag?.name ?? HASHTAGS.all, - page: currentPage, - onPageInfoUpdate: (totalPagesFromServer: number) => { - setTotalPages(totalPagesFromServer); - }, - }); const { data: allHashTags } = useHashTags(); const { missions } = useMissions(); @@ -72,7 +63,14 @@ export default function DiscussionListPage() { /> - + { + setTotalPages(totalPagesFromServer); + }} + /> {totalPages > 0 && (