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.categoryName}} + {data.apidata && ( + + {data.apidata.categoryName} + + )}
- {data.apidata &&
{data.apidata.studyTitle}
} {data.apidata && ( -
{data.apidata.categoryName}
+
+ {data.apidata.studyTitle} +
+ )} + {data.apidata && ( +
+ {data.apidata.categoryName} +
)}
{userSeq === hostSeq && (
{/* [TODO]: update, delete 페이지로 링크 필요 */} @@ -232,23 +252,35 @@ export default function StudyRecruitDetail() { 삭제 - + {checkAxios && (
삭제되었습니다
-
)} {!checkAxios && (
-
스터디 호스트가 아닙니다
-
@@ -287,11 +319,19 @@ export default function StudyRecruitDetail() { - {data.apidata.hostImg !== null && } + {data.apidata.hostImg !== null && ( + + )}
)} {data.apidata && ( -
{data.apidata.hostNickName}
+
+ {data.apidata.hostNickName} +
)}

@@ -300,17 +340,22 @@ export default function StudyRecruitDetail() { - + {data.apidata && data.apidata.day.map((days) => ( ))} @@ -320,7 +365,9 @@ export default function StudyRecruitDetail() {
스터디 일정 + 스터디 일정 +
-
{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)}
- + {data.apidata && (
모집 기간 + 모집 기간 + {changeDateFormat()} ~ {data.apidata.studyRecruitEnd} @@ -331,31 +378,52 @@ export default function StudyRecruitDetail() {
{data.apidata && ( -
{data.apidata.studyShortDesc}
+
+ {data.apidata.studyShortDesc} +
+ )} + {data.apidata && ( +
+ {data.apidata.studyDesc} +
)} - {data.apidata &&
{data.apidata.studyDesc}
}
{userSeq !== hostSeq && (
- - {isSuccess &&
신청이 완료되었습니다
} - {!isSuccess &&
이미 신청한 스터디입니다
} + {isSuccess && ( +
+ 신청이 완료되었습니다 +
+ )} + {!isSuccess && ( +
+ 이미 신청한 스터디입니다 +
+ )} - +
)} {userSeq === hostSeq && (
- +
)}