Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor, chore] 인터랙션 페이지 유저플로우에 맞게 수정 #94

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import InteractionModal from "../modal/InteractionModal";
import openModal from "@common/modal/openModal.js";
import { padNumber } from "@common/utils.js";
import { EVENT_START_DATE } from "@common/constants";

function getEventDate(index) {
const day = ["일", "월", "화", "수", "목", "금", "토"];
const fullDate = new Date(2024, 8, 9 + index);
const fullDate = new Date(EVENT_START_DATE.getTime() + index * 24 * 60 * 60 * 1000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24 * 60 * 60 * 1000은 매직 넘버이므로, 별도의 상수로 분리해 주세요.


const month = fullDate.getMonth() + 1;
const date = fullDate.getDate();
Expand Down
25 changes: 10 additions & 15 deletions src/mainPage/features/interactions/modal/InteractionAnswer.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useState } from "react";

import scrollTo from "@main/scroll/scrollTo.js";
import { COMMENT_SECTION } from "@main/scroll/constants.js";
Expand All @@ -23,7 +23,8 @@ export default function InteractionAnswer({
const currentServerTime = useEventStore((state) => state.currentServerTime);
const eventDate = EVENT_START_DATE.getTime() + index * 24 * 60 * 60 * 1000;
const [isAniPlaying, setIsAniPlaying] = useState(false);
const [isJoined, setIsJoined] = useState(false);
const isEventToday =
getEventDateState(currentServerTime, eventDate) === "active";
const authModal = (
<AuthModal
onComplete={() => {
Expand All @@ -33,7 +34,6 @@ export default function InteractionAnswer({
})
.then((res) => {
console.log(res);
setIsJoined(true);
})
.catch((e) => {
console.log(e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 기능이 빠졌어요

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

향후 해당부분 기능 체크리스트에 저장해두었다가 나중에 추가해주시면 감사하겠습니다

Expand All @@ -42,12 +42,6 @@ export default function InteractionAnswer({
/>
);

useEffect(() => {
if (getEventDateState(currentServerTime, eventDate) === "active") {
setIsJoined(true);
}
}, [currentServerTime, eventDate]);

async function onClickWrite() {
await close();
scrollTo(COMMENT_SECTION);
Expand Down Expand Up @@ -107,19 +101,19 @@ export default function InteractionAnswer({
</div>

<div className="absolute bottom-10 flex flex-col items-center gap-10">
{isLogin ? (
{isLogin || !isEventToday ? (
<>
<span className="text-body-m text-green-400 font-bold">
{isJoined
{isEventToday
? "오늘 응모가 완료되었습니다!"
: "응모 기간이 지났습니다!"}
</span>

<div className="flex gap-4 items-end">
<div className="flex flex-col gap-2">
<div
className={`${isJoined ? "" : "hidden"} relative flex flex-col items-center animate-bounce`}
>
<div
className={`${isEventToday ? "flex" : "hidden"} flex-col gap-2}`}
>
<div className="flex relative flex-col items-center animate-bounce">
<span className=" bg-green-400 text-nowrap text-body-s xl:text-body-m text-neutral-800 rounded-full px-4 xl:px-8 py-1 xl:py-2 font-bold">
당첨확률 UP!
</span>
Expand All @@ -136,6 +130,7 @@ export default function InteractionAnswer({
기대평 작성하기
</Button>
</div>

<Button
onClick={onClickShare}
styleType="ghost"
Expand Down