Skip to content

Commit

Permalink
refactor(member): MainPage 새로운 프로젝트 구조 적용 (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwansikk committed Sep 20, 2024
1 parent d81233d commit f50a123
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Image from '@components/common/Image/Image';
import { useActivityPhoto } from '@hooks/queries';
import { createImageUrl } from '@utils/api';

const MainBanner = () => {
const ActivityPhotoBanner = () => {
const { data } = useActivityPhoto();

if (data.totalItems === 0) {
Expand All @@ -30,4 +30,4 @@ const MainBanner = () => {
);
};

export default MainBanner;
export default ActivityPhotoBanner;
26 changes: 26 additions & 0 deletions apps/member/src/components/common/ErrorSection/ErrorSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Button } from '@clab-platforms/design-system';
import { HighPriorityColor } from '@clab-platforms/icon';

interface Props {
reset: () => void;
}

const ErrorSection = ({ reset }: Props) => {
return (
<div className="m-auto flex flex-col items-center justify-center gap-4">
<HighPriorityColor width={64} height={64} />
<div className="text-clab-main text-center font-semibold">

Check warning on line 12 in apps/member/src/components/common/ErrorSection/ErrorSection.tsx

View workflow job for this annotation

GitHub Actions / quality-and-build (lint)

Invalid Tailwind CSS classnames order
<h1 className="text-2xl">
불편을 드려 죄송합니다. 오류가 발생했어요. 😭
</h1>
</div>
<div className="break-keep text-center text-gray-500">
<p>만약 같은 문제가 지속적으로 발생할 경우 문의 해주시기 바랍니다.</p>
<p>감사합니다.</p>
</div>
<Button onClick={reset}>재시도</Button>
</div>
);
};

export default ErrorSection;
2 changes: 1 addition & 1 deletion apps/member/src/components/common/Image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Image = ({
<img
className={cn(
{
'animate-pulse bg-gray-200': status === 'loading',
'animate-pulse bg-gray-200/50': status === 'loading',
'bg-gray-50': status === 'error',
},
_width,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { useState } from 'react';

import { Button, Input } from '@clab-platforms/design-system';

import ActivityPhotoBanner from '@components/common/ActivityPhotoBanner/ActivityPhotoBanner';
import Hr from '@components/common/Hr/Hr';
import { Section } from '@components/common/Section';
import Uploader from '@components/common/Uploader/Uploader';
import MainBanner from '@components/main/MainBanner/MainBanner';

import { PostActivityPhotoParams } from '@api/activity';
import { ERROR_MESSAGE } from '@constants/message';
Expand Down Expand Up @@ -89,7 +89,7 @@ const ManageBannerSection = () => {
<Button className="w-full">활동 사진 변경하기</Button>
</form>
<Hr>현재 활동 사진</Hr>
<MainBanner />
<ActivityPhotoBanner />
</Section.Body>
</Section>
);
Expand Down
55 changes: 0 additions & 55 deletions apps/member/src/pages/MainPage/MainPage.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ import { createImageUrl } from '@utils/api';
import { formatMemberName } from '@utils/string';
import dayjs from 'dayjs';

interface BirthdayCardProps {
id: string;
name: string;
imageUrl: string | null;
birth: string;
}

const BirthdaySection = () => {
export function BirthdaySection() {
const { data } = useBirthday();

return (
Expand All @@ -26,15 +19,22 @@ const BirthdaySection = () => {
</p>
) : (
data.items.map(({ id, ...props }) => (
<BirthdayCard key={id} id={id} {...props} />
<Card key={id} id={id} {...props} />
))
)}
</Section.Body>
</Section>
);
};
}

const BirthdayCard = ({ id, name, imageUrl, birth }: BirthdayCardProps) => {
interface CardProps {
id: string;
name: string;
imageUrl: string | null;
birth: string;
}

const Card = ({ id, name, imageUrl, birth }: CardProps) => {
return (
<div className="flex flex-col items-center gap-4 rounded-lg px-4 pt-2">
<Image
Expand All @@ -53,5 +53,3 @@ const BirthdayCard = ({ id, name, imageUrl, birth }: BirthdayCardProps) => {
</div>
);
};

export default BirthdaySection;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { COMMUNITY_MESSAGE } from '@constants/message';
import { PATH_FINDER } from '@constants/path';
import { useBlog } from '@hooks/queries';

const BlogSection = () => {
export function BlogSection() {
const { data } = useBlog();

return (
Expand All @@ -29,6 +29,4 @@ const BlogSection = () => {
</Section.Body>
</Section>
);
};

export default BlogSection;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ import { DATE_FORMAT } from '@constants/state';
import { useSchedule } from '@hooks/queries';
import { now } from '@utils/date';

const MainNoticeSection = () => {
export function NoticeSection() {
const [open, setOpen] = useState(false);

const { data } = useSchedule({
startDate: now().format(DATE_FORMAT.WITH_TIME),
});

const [open, setOpen] = useState(false);
/**
* 일정이 없을 경우 렌더링하지 않습니다.
*/
if (data.items.length === 0) {
// 일정이 없을 경우 렌더링하지 않습니다.
return null;
}

Expand Down Expand Up @@ -63,6 +62,4 @@ const MainNoticeSection = () => {
</div>
</Section>
);
};

export default MainNoticeSection;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { COMMUNITY_MESSAGE } from '@constants/message';
import { PATH_FINDER } from '@constants/path';
import { useBoardByCategory } from '@hooks/queries';

const OrganizationNewsSection = () => {
export function OrganizationNewsSection() {
const { data } = useBoardByCategory({ category: 'organization' });

return (
Expand All @@ -29,6 +29,4 @@ const OrganizationNewsSection = () => {
</Section.Body>
</Section>
);
};

export default OrganizationNewsSection;
}
70 changes: 70 additions & 0 deletions apps/member/src/pages/MainPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Suspense } from 'react';

import { QueryErrorResetBoundary } from '@tanstack/react-query';

import ActivityPhotoBanner from '@components/common/ActivityPhotoBanner/ActivityPhotoBanner';
import Content from '@components/common/Content/Content';
import ErrorSection from '@components/common/ErrorSection/ErrorSection';
import {
HireBoard,
NewsBoard,
NoticeBoard,
QnABoard,
} from '@components/community/Board';
import { BoardSection } from '@components/community/BoardSection';

import { ErrorBoundary } from '@suspensive/react';

import { BirthdaySection } from './components/BirthdaySection';
import { BlogSection } from './components/BlogSection';
import { NoticeSection } from './components/NoticeSection';
import { OrganizationNewsSection } from './components/OrganizationNewsSection';

export default function MainPage() {
return (
<QueryErrorResetBoundary>
{({ reset }) => (
<ErrorBoundary
onReset={reset}
fallback={({ reset }) => <ErrorSection reset={reset} />}
>
<Content>
<Suspense>
<NoticeSection />
</Suspense>

<Suspense>
<ActivityPhotoBanner />
</Suspense>

<Suspense>
<OrganizationNewsSection />
</Suspense>

<Suspense>
<BoardSection>
<NoticeBoard />
<QnABoard />
</BoardSection>
</Suspense>

<Suspense>
<BirthdaySection />
</Suspense>

<Suspense>
<BlogSection />
</Suspense>

<Suspense>
<BoardSection>
<NewsBoard />
<HireBoard />
</BoardSection>
</Suspense>
</Content>
</ErrorBoundary>
)}
</QueryErrorResetBoundary>
);
}
6 changes: 5 additions & 1 deletion apps/member/src/pages/MyPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { QueryErrorResetBoundary } from '@tanstack/react-query';
import { Grid } from '@clab-platforms/design-system';

import Content from '@components/common/Content/Content';
import ErrorSection from '@components/common/ErrorSection/ErrorSection';
import { Section } from '@components/common/Section';

import { ErrorBoundary } from '@suspensive/react';
Expand All @@ -18,7 +19,10 @@ export default function MyPage() {
return (
<QueryErrorResetBoundary>
{({ reset }) => (
<ErrorBoundary onReset={reset} fallback={<></>}>
<ErrorBoundary
onReset={reset}
fallback={({ reset }) => <ErrorSection reset={reset} />}
>
<Suspense fallback={<Skeleton />}>
<Content>
<Suspense>
Expand Down
2 changes: 1 addition & 1 deletion apps/member/src/pages/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SectionSkeleton } from '@components/common/Section';
import ProtectAuth from '@components/router/ProtectAuth';

import { PATH } from '@constants/path';
import MainPage from '@pages/MainPage/MainPage';
import MainPage from '@pages/MainPage';

import { GlobalErrorPage } from './GlobalErrorPage';
import { PageLayout } from './PageLayout';
Expand Down
7 changes: 5 additions & 2 deletions apps/member/src/pages/SupportPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { Suspense } from 'react';
import { QueryErrorResetBoundary } from '@tanstack/react-query';

import Content from '@components/common/Content/Content';
import ErrorSection from '@components/common/ErrorSection/ErrorSection';
import Header from '@components/common/Header/Header';
import {
SupportHistorySection,
SupportHistorySectionSkeleton,
} from '@components/support/SupportHistorySection';

import { GlobalErrorPage } from '@pages/GlobalErrorPage';
import { ErrorBoundary } from '@suspensive/react';

import { IntroduceSection } from './components/IntroduceSection';
Expand All @@ -19,7 +19,10 @@ export default function SupportPage() {
return (
<QueryErrorResetBoundary>
{({ reset }) => (
<ErrorBoundary onReset={reset} fallback={<GlobalErrorPage />}>
<ErrorBoundary
onReset={reset}
fallback={({ reset }) => <ErrorSection reset={reset} />}
>
<Content>
<Header title="회비" />
<IntroduceSection />
Expand Down

0 comments on commit f50a123

Please sign in to comment.