diff --git a/src/components/Schedule/diary-refac.js b/src/components/Schedule/diary-refac.js
index 39a9bec..04ecd98 100644
--- a/src/components/Schedule/diary-refac.js
+++ b/src/components/Schedule/diary-refac.js
@@ -1,28 +1,33 @@
-import { Row, Col } from 'react-bootstrap';
-import React, { useEffect, useState } from 'react';
-import axios from 'axios';
-import '../../statics/css/diary.css';
-import { useSelector } from 'react-redux';
-import DiaryImage from './diaryImage';
-import DiaryText from './diaryText';
+import { Row, Col } from "react-bootstrap";
+import React, { useEffect, useState } from "react";
+import axios from "axios";
+import "../../statics/css/diary.css";
+import { useSelector } from "react-redux";
+import DiaryImage from "./diaryImage";
+import DiaryText from "./diaryText";
function DiaryRefac() {
- const token = localStorage.getItem('accessToken');
+ const token = localStorage.getItem("accessToken");
const selectedDay = useSelector((state) => state.schedule.selectedDay);
const [wantEdit, setWantEdit] = useState(false); // 수정여부
const [data, setData] = useState(new FormData()); // 전송할 데이터
- const [imgFile, setImgFile] = useState(''); // 이미지 파일
- const [content, setContent] = useState(''); // 글 내용
- const [imgURL, setImgURL] = useState(''); // 서버에서 불러올 img url
- const [preview, setPreview] = useState('');
- const [diarySeq, setDiarySeq] = useState('');
+ const [imgFile, setImgFile] = useState(""); // 이미지 파일
+ const [content, setContent] = useState(""); // 글 내용
+ const [imgURL, setImgURL] = useState(""); // 서버에서 불러올 img url
+ const [preview, setPreview] = useState("");
+ const [diarySeq, setDiarySeq] = useState("");
const getData = async () => {
await axios
- .get(process.env.REACT_APP_SERVER_URL + '/diaries?date=' + JSON.parse(selectedDay), {
- headers: {
- Authorization: `Bearer ${token}`,
- },
- })
+ .get(
+ process.env.REACT_APP_SERVER_URL +
+ "/diaries?date=" +
+ JSON.parse(selectedDay),
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ )
.then((response) => {
setData(() => response.data.diary);
});
@@ -37,39 +42,49 @@ function DiaryRefac() {
const createDiary = async () => {
let createData = new FormData();
if (imgFile) {
- createData.append('image', imgFile);
+ createData.append("image", imgFile);
}
- createData.append('dateInfo.date', JSON.parse(selectedDay));
- createData.append('contentInfo.content', content);
+ createData.append("dateInfo.date", JSON.parse(selectedDay));
+ createData.append("contentInfo.content", content);
axios
- .post(process.env.REACT_APP_SERVER_URL + '/diaries?date=' + JSON.parse(selectedDay), createData, {
- headers: {
- Authorization: `Bearer ${token}`,
- },
- })
+ .post(
+ process.env.REACT_APP_SERVER_URL +
+ "/diaries?date=" +
+ JSON.parse(selectedDay),
+ createData,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ )
.then((response) => getData())
.catch((err) => console.log(err));
};
const updateDiary = async () => {
let updateData = new FormData();
if (imgFile) {
- updateData.append('image', imgFile);
+ updateData.append("image", imgFile);
}
- updateData.append('contentInfo.content', content);
+ updateData.append("contentInfo.content", content);
axios
- .patch(process.env.REACT_APP_SERVER_URL + `/diaries/${diarySeq}`, updateData, {
- headers: {
- Authorization: `Bearer ${token}`,
- },
- })
+ .patch(
+ process.env.REACT_APP_SERVER_URL + `/diaries/${diarySeq}`,
+ updateData,
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ )
.then((response) => getData())
.catch((err) => console.log(err));
};
const changeDay = () => {
- setPreview(() => '');
- setImgURL(() => '');
- setContent(() => '');
- setDiarySeq(() => '');
+ setPreview(() => "");
+ setImgURL(() => "");
+ setContent(() => "");
+ setDiarySeq(() => "");
setWantEdit(() => false);
setImgFile(() => null);
};
@@ -90,7 +105,7 @@ function DiaryRefac() {
setPreview={setPreview}
/>
-
+
{
@@ -8,21 +8,33 @@ function DiaryImage({ wantEdit, imgURL, setImgFile, preview, setPreview }) {
setImgFile(() => e.target.files[0]);
};
return (
- <>
- {wantEdit ? : null}
+
+ {wantEdit ? (
+
+ ) : null}
{!preview && !imgURL ? (
-
-
사진을 남겨주세요
+
+
+ 오늘 하루를 기록할 수 있는 사진을 남겨주세요
+
) : null}
{!preview && imgURL ? (
-
+
) : null}
{preview ?
: null}
- >
+
);
}
export default React.memo(DiaryImage);
diff --git a/src/components/Schedule/todaystudy.js b/src/components/Schedule/todaystudy.js
index 265f049..1269ea3 100644
--- a/src/components/Schedule/todaystudy.js
+++ b/src/components/Schedule/todaystudy.js
@@ -1,9 +1,9 @@
-import { useState, useEffect } from 'react';
-import { Row, Col, Container } from 'react-bootstrap';
-import { useSelector } from 'react-redux';
-import { Link } from 'react-router-dom';
-import '../../statics/css/todayStudy.css';
-import Modal from '../modal';
+import { useState, useEffect } from "react";
+import { Row, Col, Container } from "react-bootstrap";
+import { useSelector } from "react-redux";
+import { Link } from "react-router-dom";
+import "../../statics/css/todayStudy.css";
+import Modal from "../modal";
export default function Todaystudy({ weekly }) {
const selectedDay = useSelector((state) => state.schedule.selectedDay);
@@ -17,7 +17,10 @@ export default function Todaystudy({ weekly }) {
};
useEffect(() => {
try {
- setDailyStudies(weekly.filter((daily) => daily.date === JSON.parse(selectedDay))[0].studySchedules);
+ setDailyStudies(
+ weekly.filter((daily) => daily.date === JSON.parse(selectedDay))[0]
+ .studySchedules
+ );
} catch {
setDailyStudies([]);
}
@@ -35,19 +38,31 @@ export default function Todaystudy({ weekly }) {
sm={6}
md={6}
lg={6}
- style={{ cursor: 'pointer' }}
+ style={{ cursor: "pointer" }}
onClick={openModal}
>
- {localStorage.setItem('studySeq', study.studySeq)}
+ {localStorage.setItem("studySeq", study.studySeq)}
- {study.categoryName}
- {study.title}
+
+ {study.categoryName}
+
+
+ {study.title}
+
+
+
+ {study.shortDescription}
-
{study.shortDescription}
-