Skip to content

Commit d7d8e5c

Browse files
authored
Merge pull request #121 from sipe-team/develop
fix: 메인페이지 현황 컴포넌트에 CSR과 skeleton 적용 (resolves both CLS, hydration issue)
2 parents 49abb0d + a8aaeff commit d7d8e5c

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed

src/components/atoms/Timer/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ function Timer({ dates, hours, minutes, seconds, isRecruiting }: Props) {
1414
return (
1515
<div className={styles.wrapper}>
1616
<div className={styles.time}>
17-
{isRecruiting ? formattedTime(dates) : 0}
17+
{isRecruiting ? formattedTime(dates) : ''}
1818
</div>
1919
<div className={styles.text}></div>
2020
<div className={styles.time}>
21-
{isRecruiting ? formattedTime(hours) : 0}
21+
{isRecruiting ? formattedTime(hours) : ''}
2222
</div>
2323
<div className={styles.text}>시간</div>
2424
<div className={styles.time}>
25-
{isRecruiting ? formattedTime(minutes) : 0}
25+
{isRecruiting ? formattedTime(minutes) : ''}
2626
</div>
2727
<div className={styles.text}></div>
2828
<div className={styles.time}>
29-
{isRecruiting ? formattedTime(seconds) : 0}
29+
{isRecruiting ? formattedTime(seconds) : ''}
3030
</div>
3131
<div className={styles.text}></div>
3232
</div>

src/components/organisms/home/RecruitmentStatusSection/index.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
'use client';
22

3+
import dynamic from 'next/dynamic';
4+
35
import { sendGAEvent } from '@next/third-parties/google';
46

57
import Button from '@/components/molecules/Button';
6-
import RecruitmentSummary from '@/components/organisms/home/RecruitmentSummary';
8+
import RecruitmentSummarySkeleton from '@/components/organisms/home/RecruitmentSummarySkeleton';
79
import useCopy from '@/hook/useCopyToClipboard';
810
import { displayApplication, getCurrentStatus } from '@/libs/utils/recruit';
911

1012
import styles from './index.module.scss';
1113

14+
const now = Date.now();
15+
16+
const RecruitmentSummary = dynamic(
17+
() => import('@/components/organisms/home/RecruitmentSummary'),
18+
{
19+
ssr: false,
20+
loading: () => (
21+
<RecruitmentSummarySkeleton currentStatus={getCurrentStatus(now)} />
22+
),
23+
},
24+
);
25+
1226
function RecruitmentStatusSection() {
13-
const now = Date.now();
1427
const currentStatus = getCurrentStatus(now);
1528
const currentApplicationDetail = displayApplication[currentStatus];
1629
const { copyToClipboard } = useCopy();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.timerWrapper {
2+
display: flex;
3+
flex-direction: column;
4+
align-items: center;
5+
gap: 1rem;
6+
7+
.timerDescription {
8+
font-size: 1.4rem;
9+
font-weight: 500;
10+
color: #fff;
11+
}
12+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import Timer from '@/components/atoms/Timer';
2+
import SummaryCard from '@/components/organisms/home/SummaryCards';
3+
4+
import styles from './index.module.scss';
5+
6+
type Props = {
7+
currentStatus: 'before' | 'ongoing' | 'after';
8+
};
9+
10+
function RecruitmentSummary({ currentStatus }: Props) {
11+
const elements = {
12+
before: () => (
13+
<div className={styles.timerWrapper}>
14+
<div className={styles.timerDescription}>모집 시작까지</div>
15+
<Timer
16+
dates={0}
17+
hours={0}
18+
minutes={0}
19+
seconds={0}
20+
isRecruiting={false}
21+
/>
22+
</div>
23+
),
24+
ongoing: () => (
25+
<div className={styles.timerWrapper}>
26+
<div className={styles.timerDescription}>모집 마감까지</div>
27+
<Timer
28+
dates={0}
29+
hours={0}
30+
minutes={0}
31+
seconds={0}
32+
isRecruiting={false}
33+
/>
34+
</div>
35+
),
36+
after: () => <SummaryCard />,
37+
};
38+
39+
return elements[currentStatus]();
40+
}
41+
42+
export default RecruitmentSummary;

0 commit comments

Comments
 (0)