From bdec672593b6639876488e0f0daa4311fb5308c3 Mon Sep 17 00:00:00 2001 From: rivertw777 <105557972+rivertw777@users.noreply.github.com> Date: Fri, 17 Jan 2025 01:15:23 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20=EC=9E=91=EC=97=85=EC=97=B4=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20TTL=20=EC=97=B0=EC=9E=A5=20API=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ticketping/src/pages/SelectSchedule.js | 91 ++++++++++++++++---------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/ticketping/src/pages/SelectSchedule.js b/ticketping/src/pages/SelectSchedule.js index 663fb1f..1ab92c6 100644 --- a/ticketping/src/pages/SelectSchedule.js +++ b/ticketping/src/pages/SelectSchedule.js @@ -1,10 +1,10 @@ import React, { useEffect, useState } from "react"; import { useParams, useNavigate, useLocation } from "react-router-dom"; -import { useCheckExpiredToken } from "../component/CheckExpiredToken"; +import { useCheckExpiredToken } from "../component/CheckExpiredToken"; import { axiosInstance } from "../api"; import { useAppContext } from "../store"; -import { Calendar, Button } from 'antd'; -import dayjs from 'dayjs'; +import { Calendar, Button } from "antd"; +import dayjs from "dayjs"; import "../style/SelectSchedule.css"; export default function SelectSchedule() { @@ -14,28 +14,51 @@ export default function SelectSchedule() { const { performance } = location.state || {}; const { checkExpiredToken } = useCheckExpiredToken(); - const { store: { jwtToken } } = useAppContext(); + const { + store: { jwtToken }, + } = useAppContext(); const headers = { Authorization: jwtToken }; const [schedules, setSchedules] = useState([]); const [selectedDateId, setSelectedDateId] = useState(null); + useEffect(() => { + const extendWorkingQueueTokenTTL = async () => { + try { + await axiosInstance.post( + `/api/v1/working-queue/extend-ttl?performanceId=${performance.id}`, + {}, + { headers } + ); + } catch (err) { + checkExpiredToken(err.response.data); + } + }; + + extendWorkingQueueTokenTTL(); + }, []); + useEffect(() => { const fetchSchedules = async () => { try { - const response = await axiosInstance.get(`/api/v1/performances/${id}/schedules`, { headers }); + const response = await axiosInstance.get( + `/api/v1/performances/${id}/schedules`, + { headers } + ); setSchedules(response.data.data); } catch (err) { checkExpiredToken(err.response.data); - } + } }; fetchSchedules(); }, []); const disabledDate = (current) => { - const hasSchedule = schedules.some(schedule => schedule.startDate.startsWith(current.format('YYYY-MM-DD'))); - return !hasSchedule; + const hasSchedule = schedules.some((schedule) => + schedule.startDate.startsWith(current.format("YYYY-MM-DD")) + ); + return !hasSchedule; }; const monthCellRender = (value) => { @@ -43,22 +66,20 @@ export default function SelectSchedule() { const year = value.year(); const daysWithSchedules = schedules - .filter(schedule => { + .filter((schedule) => { const scheduleDate = dayjs(schedule.startDate); - return ( - scheduleDate.year() === year && - scheduleDate.month() === month - ); + return scheduleDate.year() === year && scheduleDate.month() === month; }) - .map(schedule => schedule.date()); + .map((schedule) => schedule.date()); return (