Skip to content

Commit

Permalink
Fix: handle cases when today is not event day
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyogyeong8 committed Sep 23, 2024
1 parent 085b0f8 commit 6905230
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import WhiteContainer from "@/components/WhiteContainer";
import alertAtom from "@/atoms/alert";
import { useSetRecoilState } from "recoil";

import moment, { getToday } from "@/tools/moment";
import theme from "@/tools/theme";

const WhiteContainerSuggestShareEvent = () => {
Expand All @@ -21,6 +22,11 @@ const WhiteContainerSuggestShareEvent = () => {
const axios = useAxios();
const setAlert = useSetRecoilState(alertAtom);

const today = getToday();
const startDate = moment("2024-09-06", "YYYY-MM-DD");
const endDate = moment("2024-09-24", "YYYY-MM-DD");
const isEventDay = today.isBefore(endDate) && today.isAfter(startDate, "day");

const styleText = {
...theme.font14,
marginBottom: "12px",
Expand All @@ -32,7 +38,7 @@ const WhiteContainerSuggestShareEvent = () => {
};

useEffect(() => {
if (isAgreeOnTermsOfEvent)
if (isAgreeOnTermsOfEvent && isEventDay)
axios({
url: `/events/2024fall/invites/create`,
method: "post",
Expand All @@ -59,10 +65,13 @@ const WhiteContainerSuggestShareEvent = () => {
css={styleButton}
onClick={() => {
if (inviteUrl) setIsOpenShare(true);
else
else if (isEventDay) {
setAlert(
"이벤트를 공유하기 위해서는 이벤트에 참여해야 합니다."
);
} else {
setAlert("이벤트 기간이 아닙니다.");
}
}}
>
이벤트 공유하기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ const ModalEvent2024FallDailyAttendance = ({
...theme.font16_bold,
}}
>
오늘자 출석이 완료되었습니다.
{isEventDay
? "오늘자 출석이 완료되었습니다. "
: "이벤트 기간이 아닙니다. "}
</Button>
</Modal>
);
Expand Down
13 changes: 11 additions & 2 deletions packages/web/src/pages/Event/Event2024Fall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import WhiteContainer from "@/components/WhiteContainer";
import alertAtom from "@/atoms/alert";
import { useSetRecoilState } from "recoil";

import moment, { getToday } from "@/tools/moment";
import theme from "@/tools/theme";

import { ReactComponent as TaxiLogoIcon } from "@/static/assets/sparcsLogos/TaxiLogo.svg";
Expand All @@ -37,8 +38,13 @@ const Event2024Fall = () => {
useValueRecoilState("event2024FallInfo") || {};
const axios = useAxios();

const today = getToday();
const startDate = moment("2024-09-06", "YYYY-MM-DD");
const endDate = moment("2024-09-24", "YYYY-MM-DD");
const isEventDay = today.isBefore(endDate) && today.isAfter(startDate, "day");

useEffect(() => {
if (isAgreeOnTermsOfEvent)
if (isAgreeOnTermsOfEvent && isEventDay)
axios({
url: `/events/2024fall/invites/create`,
method: "post",
Expand Down Expand Up @@ -277,10 +283,13 @@ const Event2024Fall = () => {
}}
onClick={() => {
if (inviteUrl) setIsOpenShare(true);
else
else if (isEventDay) {
setAlert(
"이벤트를 공유하기 위해서는 이벤트에 참여해야 합니다."
);
} else {
setAlert("이벤트 기간이 아닙니다. ");
}
}}
>
이벤트 공유하기
Expand Down
8 changes: 6 additions & 2 deletions packages/web/src/pages/Event/Event2024FallDailyAttendance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Footer from "@/components/Footer";
import HeaderWithLeftNav from "@/components/Header/HeaderWithLeftNav";
import WhiteContainer from "@/components/WhiteContainer";

import { getToday } from "@/tools/moment";
import moment, { getToday } from "@/tools/moment";
import theme from "@/tools/theme";

import { ReactComponent as DailyAttendance } from "@/static/events/2024fallDailyAttendance.svg";
Expand All @@ -28,6 +28,8 @@ const DateSection = (props: DateSectionProps) => {

const Event2024FallMissions = () => {
const today = getToday();
const endDate = moment("2024-09-24", "YYYY-MM-DD");
const isEventDay = today.isBefore(endDate);

const [valueDate, setDate] = useState<Array<Nullable<number>>>([
today.year(),
Expand Down Expand Up @@ -65,7 +67,9 @@ const Event2024FallMissions = () => {
...theme.font16_bold,
}}
>
오늘자 출석이 완료되었습니다.
{isEventDay
? "오늘자 출석이 완료되었습니다. "
: "이벤트 기간이 아닙니다. "}
</Button>

<Footer type="event-2024fall" />
Expand Down

0 comments on commit 6905230

Please sign in to comment.