Skip to content

Commit

Permalink
Merge pull request #357 from SejongPeer/feature/18
Browse files Browse the repository at this point in the history
Feature/18
  • Loading branch information
Youjiiin authored Jul 22, 2024
2 parents 367fe30 + bd94fc9 commit 1a29152
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const App = () => {
const timeUntilLogout = expTime - cuurentTime;

setTimeout(() => {
console.log('logout');
alert('logout!')
logout();
}, timeUntilLogout);
};
Expand Down
68 changes: 60 additions & 8 deletions src/pages/study/studyModify/studyModify.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
import { useEffect, useState } from 'react';
import StudyPostWrite from '../studyPostWrite/StudyPostWrite';
import usePostStore from '../studyPostWrite/usePostStore';
import useStudyInfoStore from '../useStudyInfoStore';

const StudyModify = () => {
const studyId = 2;
const studyId = 1;
//const {studyId} = useParams();
//console.log("studyId : ",studyId);
const [studyData, setStudyData] = useState(null);

const {
title,
setTitle,
category,
setCategory,
startDate,
setStartDate,
endDate,
setEndDate,
memberNum,
setMemberNum,
selectedWay,
setSelectedWay,
selectedFrequency,
setSelectedFrequency,
questionLink,
setQuestionLink,
images,
addImage,
content,
setContent,
studyLink,
setStudyLink,
tags,
setTags
} = usePostStore();
const { studyType } = useStudyInfoStore();

useEffect(() => {
const fetchStudyData = async () => {
try {
Expand Down Expand Up @@ -37,15 +67,37 @@ const StudyModify = () => {
fetchStudyData();
}, [studyId]);

useEffect(() => {
if (studyData) {
if(studyData.data.studyFrequency === '주 1~2회') {
setSelectedFrequency("ONCE_OR_TWICE_A_WEEK");
} else if (studyData.data.studyFrequency === '주 3~4회') {
setSelectedFrequency('THREE_TO_FOUR_TIMES_A_WEEK');
} else {
setSelectedFrequency('FIVE_OR_MORE_TIMES_A_WEEK');
}

if(studyData.data.studyMethod === '대면') {
setSelectedWay("FACE_TO_FACE");
} else if (studyData.data.studyMethod === '비대면') {
setSelectedWay('NON_FACE_TO_FACE');
} else {
setSelectedWay('BOTH');
}

setTitle(studyData.data.title);
setCategory(studyData.data.categoryName);
setStartDate(studyData.data.recruitmentStart);
setEndDate(studyData.data.recruitmentEnd);
setMemberNum(studyData.data.totalRecruitmentCount);
setContent(studyData.data.content);
setQuestionLink(studyData.data.questionKakaoLink);
}
}, [studyData]);

return studyData ? (
<StudyPostWrite
title={studyData.data.title}
categoryName={studyData.data.categoryName}
recruitmentStart={studyData.data.recruitmentStart}
recruitmentEnd={studyData.data.recruitmentEnd}
numberOfApplicants={studyData.data.numberOfApplicants}
content={studyData.data.content}
imgUrl={studyData.data.imgUrl}
studyId={studyId}
/>
) : (
<div>Loading...</div>
Expand Down
7 changes: 3 additions & 4 deletions src/pages/study/studyPostWrite/StudyPostWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ const StudyPostWrite = props => {
togglePopup(errorMessage);
return;
}
const formStartDate =
startDate === format(startDate, 'yyyy-MM-dd HH:mm:ss');
const formStartDate = format(startDate, 'yyyy-MM-dd HH:mm:ss');
const formEndDate = format(endDate, 'yyyy-MM-dd HH:mm:ss');
console.log(formStartDate)
const studyData =
studyType === 'lecture'
? {
Expand Down Expand Up @@ -217,7 +217,6 @@ const StudyPostWrite = props => {
tags: tags,
images: null,
};

try {
const response = await fetch(
`${process.env.REACT_APP_BACK_SERVER}/study/${studyType}`,
Expand Down Expand Up @@ -293,4 +292,4 @@ const StudyPostWrite = props => {
);
};

export default StudyPostWrite;
export default StudyPostWrite;

0 comments on commit 1a29152

Please sign in to comment.