diff --git a/src/pages/studyRecruitDetail.js b/src/pages/studyRecruitDetail.js index a7209c2..6ae465e 100644 --- a/src/pages/studyRecruitDetail.js +++ b/src/pages/studyRecruitDetail.js @@ -1,20 +1,20 @@ -import axios from 'axios'; -import { useCallback, useEffect, useState } from 'react'; -import { Link, useParams } from 'react-router-dom'; +import axios from "axios"; +import { useCallback, useEffect, useState } from "react"; +import { Link, useParams } from "react-router-dom"; -import isLogin from '../utils/isLogin'; -import '../statics/css/studyRecruitDetail.css'; -import Modal from '../components/modal'; +import isLogin from "../utils/isLogin"; +import "../statics/css/studyRecruitDetail.css"; +import Modal from "../components/modal"; export default function StudyRecruitDetail() { - const TOKEN = localStorage.getItem('accessToken'); + const TOKEN = localStorage.getItem("accessToken"); const { studyseq } = useParams(); const [data, setData] = useState([]); const [todayDate, setTodayDate] = useState(new Date()); const [isSuccess, setIsSuccess] = useState(false); - const [userSeq, setUserSeq] = useState(''); - const [hostSeq, setHostSeq] = useState(''); - const [profileImg, setProfileImg] = useState(''); + const [userSeq, setUserSeq] = useState(""); + const [hostSeq, setHostSeq] = useState(""); + const [profileImg, setProfileImg] = useState(""); // 모달창 const [modalOpen, setModalOpen] = useState(false); @@ -48,14 +48,18 @@ export default function StudyRecruitDetail() { // yyyy-mm-dd function changeDateFormat() { if (setTodayDate === null) { - console.log('no date'); + console.log("no date"); } return ( todayDate.getFullYear() + - '-' + - (todayDate.getMonth() + 1 > 9 ? (todayDate.getMonth() + 1).toString() : '0' + (todayDate.getMonth() + 1)) + - '-' + - (todayDate.getDate() > 9 ? todayDate.getDate().toString() : '0' + todayDate.getDate().toString()) + "-" + + (todayDate.getMonth() + 1 > 9 + ? (todayDate.getMonth() + 1).toString() + : "0" + (todayDate.getMonth() + 1)) + + "-" + + (todayDate.getDate() > 9 + ? todayDate.getDate().toString() + : "0" + todayDate.getDate().toString()) ); } @@ -64,7 +68,7 @@ export default function StudyRecruitDetail() { // test(); if (isLogin) { axios - .get(process.env.REACT_APP_SERVER_URL + '/users', { + .get(process.env.REACT_APP_SERVER_URL + "/users", { headers: { Authorization: `Bearer ${TOKEN}`, }, @@ -73,7 +77,7 @@ export default function StudyRecruitDetail() { setUserSeq(res.data.user.userSeq); }); axios - .get(process.env.REACT_APP_SERVER_URL + '/studies/' + studyseq, { + .get(process.env.REACT_APP_SERVER_URL + "/studies/" + studyseq, { headers: { Authorization: `Bearer ${TOKEN}`, }, @@ -89,30 +93,30 @@ export default function StudyRecruitDetail() { }); } }, []); - const imageURL = 'https://i6a301.p.ssafy.io:8080/images/' + profileImg; + const imageURL = "https://i6a301.p.ssafy.io:8080/images/" + profileImg; // 요일 숫자를 이름으로 바꿔주기 const numberToDay = (num) => { if (num === 1) { - return '월'; + return "월"; } if (num === 2) { - return '화'; + return "화"; } if (num === 3) { - return '수'; + return "수"; } if (num === 4) { - return '목'; + return "목"; } if (num === 5) { - return '금'; + return "금"; } if (num === 6) { - return '토'; + return "토"; } if (num === 7) { - return '일'; + return "일"; } }; @@ -143,7 +147,7 @@ export default function StudyRecruitDetail() { const deleteStudy = useCallback(() => { axios .patch( - '/users/studies/' + studyseq + '/end', + "/users/studies/" + studyseq + "/end", {}, { headers: { @@ -165,7 +169,7 @@ export default function StudyRecruitDetail() { const recruitStudy = useCallback(() => { axios .patch( - '/users/studies/' + studyseq + '/recruit-end', + "/users/studies/" + studyseq + "/recruit-end", {}, { headers: { @@ -189,7 +193,7 @@ export default function StudyRecruitDetail() { openDeleteModal(); }; function handleClick(e) { - window.location.href = '/studyrecruit'; + window.location.href = "/studyrecruit"; } const sendData = { @@ -199,31 +203,47 @@ export default function StudyRecruitDetail() { return (
스터디 일정 | ++ 스터디 일정 + | {data.apidata && data.apidata.day.map((days) => (
-
{numberToDay(days.dayNumber)}
+
+ {numberToDay(days.dayNumber)}
+
- {days.timeStart.slice(0, 5)} ~{' '}
+ {days.timeStart.slice(0, 5)} ~{" "}
+
+
+ {days.timeEnd.slice(0, 5)}
- {days.timeEnd.slice(0, 5)}
- {days.timeEnd.slice(0, 5)}
|
))}
@@ -320,7 +365,9 @@ export default function StudyRecruitDetail() {
모집 기간 | ++ 모집 기간 + | {data.apidata && ({changeDateFormat()} ~ {data.apidata.studyRecruitEnd} @@ -331,31 +378,52 @@ export default function StudyRecruitDetail() { |