-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] api 주소 수정, getDayDifference 함수 정의
- Loading branch information
Showing
6 changed files
with
86 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
import { http, HttpResponse } from "msw"; | ||
|
||
const eventParticipationDate = { | ||
dates: [ | ||
"2024-09-09T06:46:21.585Z", | ||
"2024-09-11T06:46:21.585Z", | ||
"2024-09-13T06:46:21.585Z", | ||
], | ||
}; | ||
|
||
const handlers = [ | ||
http.get("/api/v1/draw/:eventDrawId", () => | ||
HttpResponse.json(["20240909", "20240911"]), | ||
http.get("/api/v1/event/draw/:eventId/participation", () => | ||
HttpResponse.json(eventParticipationDate), | ||
), | ||
http.post("/api/v1/event/draw/:eventId/participation", () => | ||
HttpResponse.json(true), | ||
), | ||
http.post("/api/v1/draw/:eventDrawId", () => HttpResponse.json(true)), | ||
]; | ||
|
||
export default handlers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import userStore from "@main/auth/store.js"; | ||
import { EVENT_DRAW_ID } from "@common/constants.js"; | ||
import { fetchServer } from "@common/dataFetch/fetchServer.js"; | ||
import { EVENT_START_DATE } from "@common/constants"; | ||
import useEventStore from "@main/realtimeEvent/store.js"; | ||
import { getDayDifference } from "@common/utils"; | ||
|
||
export default function joinEvent(index) { | ||
const isLogin = userStore.getState().isLogin; | ||
const eventDate = EVENT_START_DATE.getTime() + index * 24 * 60 * 60 * 1000; | ||
const currentServerTime = useEventStore.getState().currentServerTime; | ||
|
||
if (isLogin && getDayDifference(eventDate, currentServerTime) === 0) { | ||
fetchServer(`/api/v1/event/draw/${EVENT_DRAW_ID}/participation`, { | ||
method: "POST", | ||
}).catch((e) => { | ||
console.log(e); | ||
}); | ||
} | ||
} |