Skip to content

Commit

Permalink
[⏪ revert] getServerSideProps 내에서 new Date() 사용 테스트 원복
Browse files Browse the repository at this point in the history
23763a5에서 작업 후 확인했을 때 로컬에서의 모집 마감일 계산과 배포에서의 모집 마감일 계산 결과가 달라 이의 원인을 azure 프론트 서버 시간으로 추측했는데 문제 동일하여 코드 원복
  • Loading branch information
sryung1225 committed Apr 15, 2024
1 parent b090209 commit 9823b03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 31 deletions.
25 changes: 8 additions & 17 deletions src/components/home/RecruitingChallengeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ import Link from 'next/link';
import IRecruitingChallenge from '@/types/recruitingChallenge';
import VERIFICATION_TYPE from '@/constants/verificationType';
import screenSize from '@/constants/screenSize';
import calculatePeriod from '@/utils/calculatePeriod';
import calculateDDay from '@/utils/calculateDDay';

export default function RecruitingChallengeCard({
challengeGroupId,
groupTitle,
imageUrl,
verificationType,
participantCount,
startDate,
endDate,
isFree,
dateDiff,
}: IRecruitingChallenge) {
const calculateRecruitDDay = (day: number) => {
const dDay = day - 1;
const calculateRecruitDDay = (date: string) => {
const dDay = calculateDDay(date) - 1;
let dDayStr;
if (dDay < 0) {
dDayStr = '모집 마감';
Expand All @@ -24,16 +27,6 @@ export default function RecruitingChallengeCard({
}
return dDayStr;
};
const calculateProgressePeroid = (day: number) => {
const days = Math.abs(day) + 1;
let periodStr = '';
if (days % 7 === 0) {
periodStr = `${days / 7}주`;
} else {
periodStr = `${days}일`;
}
return periodStr;
};
return (
<SChallengeCard>
<Link href={`/challenge/${challengeGroupId}`}>
Expand All @@ -47,16 +40,14 @@ export default function RecruitingChallengeCard({
priority
/>
<SParticipant>{participantCount}</SParticipant>
<SRecruitDDay>
{calculateRecruitDDay(dateDiff.startToToday)}
</SRecruitDDay>
<SRecruitDDay>{calculateRecruitDDay(startDate)}</SRecruitDDay>
</SThumbnail>
<STitle>{groupTitle}</STitle>
<SChips>
<dt className="a11yHidden">챌린지 인증 빈도</dt>
<dd>매일</dd>
<dt className="a11yHidden">챌린지 진행 기한</dt>
<dd>{calculateProgressePeroid(dateDiff.startToEnd)}</dd>
<dd>{calculatePeriod(startDate, endDate)}</dd>
<dt className="a11yHidden">챌린지 인증 방식</dt>
<dd>{VERIFICATION_TYPE[verificationType]}</dd>
{isFree && (
Expand Down
10 changes: 1 addition & 9 deletions src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import getRecruitingChallengeApi from '@/lib/axios/home/api';
import createServerInstance from '@/lib/axios/serverInstance';
import serverErrorCatch from '@/lib/axios/serverErrorCatch';
import { IAuthResponse } from '@/lib/axios/instance';
import calculateDDay from '@/utils/calculateDDay';

RecoilEnv.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED = false;

Expand Down Expand Up @@ -233,17 +232,10 @@ async function getServerSidePropsFunction(
return response.data;
};
const recruitingChallenges = await fetchRecruitingChallenges();
const enhancedChallenges = recruitingChallenges.map((challenge) => ({
...challenge,
dateDiff: {
startToToday: calculateDDay(challenge.startDate),
startToEnd: calculateDDay(challenge.startDate, challenge.endDate),
},
}));

return {
props: {
recruitingChallenges: enhancedChallenges,
recruitingChallenges,
isLogined,
},
};
Expand Down
6 changes: 1 addition & 5 deletions src/types/recruitingChallenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ interface IRecruitingChallenge {
groupTitle: string;
imageUrl: string;
verificationType: TVerificationType;
isFree: boolean;
participantCount: number;
startDate: string;
endDate: string;
dateDiff: {
startToToday: number;
startToEnd: number;
};
isFree: boolean;
}

export default IRecruitingChallenge;

0 comments on commit 9823b03

Please sign in to comment.