Skip to content

Commit

Permalink
Merge pull request #834 from sparcs-kaist/dev
Browse files Browse the repository at this point in the history
Main branch update from Dev branch
  • Loading branch information
kmc7468 authored Sep 23, 2024
2 parents 9f05b8e + bdad0d0 commit 8f6a6da
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ const getCalendarDates = () => {
for (let i = 0; i < 7; i++) {
let available = null;
let checked = false;
const isEventDay =
date.isBefore(endDate) && date.isAfter(startDate, "day");

if (date.isSame(today)) {
available = "today";
if (isEventDay) checked = true; // FIXME: 이벤트 완료 API호출은 되지만 UI로는 스탬프가 안 찍히는 버그를 하드 픽스함
} else if (date.isAfter(startDate) && date.isBefore(today)) {
available = "past";
} else if (date.isBefore(endDate) && date.isAfter(startDate, "day")) {
} else if (isEventDay) {
available = true;
}

Expand Down
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 @@ -37,6 +37,9 @@ const ModalEvent2024FallDailyAttendance = ({
onChangeIsOpen,
}: ModalEvent2024FallDailyAttendanceProps) => {
const today = getToday();
// const today = moment("2024-09-23", "YYYY-MM-DD"); // FIXME: 배포 전에 수정
const endDate = moment("2024-09-24", "YYYY-MM-DD");
const isEventDay = today.isBefore(endDate);

const [valueDate, setDate] = useState<Array<Nullable<number>>>([
today.year(),
Expand All @@ -55,7 +58,8 @@ const ModalEvent2024FallDailyAttendance = ({
);

useEffect(() => {
const modalOpened = isAgreeOnTermsOfEvent && todayInitial.length === 0;
const modalOpened =
isEventDay && isAgreeOnTermsOfEvent && todayInitial.length === 0;

if (onChangeIsOpen && modalOpened) {
onChangeIsOpen(modalOpened); // 모달 열기 상태 변경
Expand Down Expand Up @@ -85,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 8f6a6da

Please sign in to comment.