Commit 52f6e103 authored by Choi Ga Young's avatar Choi Ga Young
Browse files

Merge remote-tracking branch 'origin/kimpen' into rkyoung7

parents ec8f789e dbfd910e
......@@ -7,20 +7,6 @@ const getDetail = async (planId) => {
return data
}
// const addPlan = async (info, id) => {
// console.log('addPlan 확인', id)
// const url = `${baseUrl}/api/plan/addplan/${id}`
// const { data } = await axios.post(url, { info, id });
// return data
// }
// const editPlan = async (info, id) => {
// console.log('editPlan확인', id)
// const url = `${baseUrl}/api/plan/edit/${id}`
// const { data } = await axios.put(url, { info, id });
// return data
// }
const submit = async (info) => {
const url = `${baseUrl}/api/plan`
const { data } = await axios.post(url, info)
......@@ -41,8 +27,6 @@ const remove = async (planId) => {
const planApi = {
getDetail,
// addPlan,
// editPlan,
submit,
edit,
remove
......
import axios from "axios";
import baseUrl from "../utils/baseUrl";
const getTodo = async (userId, date = "", todoId = "") => {
const { data } = await axios.get(`${baseUrl}/api/todo/${userId}?todoId=${todoId}&date=${date}`)
return data
}
const submit = async (todo, userId) => {
const { data } = await axios.post(`${baseUrl}/api/todo/${userId}`, todo)
return data
}
const edit = async (todo, userId) => {
const { data } = await axios.put(`${baseUrl}/api/todo/${userId}?todoId=${todo.id}`, todo)
return data
}
const remove = async (todoId, userId) => {
const { data } = await axios.delete(`${baseUrl}/api/todo/${userId}?todoId=${todoId}`)
return data
}
const todoApi = {
getTodo,
submit,
edit,
remove
}
export default todoApi
\ No newline at end of file
import { useParams } from "react-router-dom";
import TodoModal from "../Modal/TodoModal";
import styles from "./buttons.module.scss";
const AddBtn = () => {
const { date } = useParams()
return (
<>
<i className={`bi bi-plus-circle me-2 mb-1 ${styles.icon}`} data-bs-toggle="modal" data-bs-target="#todomodal"></i>
<TodoModal />
<TodoModal curDate={date} />
</>
)
}
......
......@@ -16,6 +16,7 @@
.icon {
color: crimson;
font-size: 2.7em;
cursor: pointer;
}
.backBtn {
......
......@@ -93,6 +93,11 @@ const AdminMonthly = () => {
const weekList = ["", "", "", "", "", "", ""]
return weekList[date.dow]
}}
views={{
dayGridMonth: {
dayMaxEvents: 3
}
}}
validRange={{
start: moment(initialDate).subtract(3, 'years').format('YYYY-MM[-01]'),
end: moment(initialDate).add(3, 'years').add(1, 'months').format('YYYY-MM[-01]')
......@@ -128,6 +133,10 @@ const AdminMonthly = () => {
}}
timeZone="local"
events={scheduleList}
eventLimit={3}
moreLinkContent={function(arg) {
return arg.shortText
}}
themeSystem='bootstrap'
height='78vh'
/>
......
......@@ -88,6 +88,11 @@ const Monthly = () => {
const weekList = ["", "", "", "", "", "", ""]
return weekList[date.dow]
}}
views={{
dayGridMonth: {
dayMaxEvents: 3
}
}}
validRange={{
start: moment(initialDate).subtract(3, 'years').format('YYYY-MM[-01]'),
end: moment(initialDate).add(3, 'years').add(1, 'months').format('YYYY-MM[-01]')
......@@ -120,7 +125,13 @@ const Monthly = () => {
dateClick={({ dateStr }) => history.push(`/schedule/${dateStr}`)}
timeZone="local"
themeSystem='bootstrap'
eventLimit="3"
eventLimit={3}
moreLinkClick={function(arg) {
console.log("click..?",arg)
}}
moreLinkContent={function(arg) {
return arg.shortText
}}
height='80vh'
/>
<DatePickerModal initialDate={initialDate} changeDate={changeDate} setChangeDate={setChangeDate} show={show} setShow={setShow} />
......
......@@ -11,10 +11,8 @@ const StudyPlanEditForm = () => {
const { user } = useAuth();
const params = useParams();
const [disabled, setDisabled] = useState(true)
const [selected, setSelected] = useState("");
const [error, setError] = useState("");
const [success, setSuccess] = useState(false)
const [subjectName, setSubjectName] = useState("");
const [studyplan, setStudyplan] = useState({
studyplanTitle: "",
endDate: "",
......@@ -43,13 +41,8 @@ const StudyPlanEditForm = () => {
useEffect(() => {
getSubject(user.id)
console.log("useEffect params 확인", params)
if (params.subjectId) setStudyplan({...studyplan, selected: params.subjectId })
else if (params.planId) getInfo(params.planId);
// if (params.hasOwnProperty('planId')) {
// console.log('planId params확인');
// getInfo(params.planId);
// }
}, [])
async function getSubject(id) {
......@@ -66,29 +59,7 @@ const StudyPlanEditForm = () => {
try {
setError("")
const result = await planApi.getDetail(planId)
console.log('수정 getInfo result', result)
setStudyplan({ ...studyplan, ...result })
// setSubjectName(result.subjectName)
// if (result.endTime) {
// setStudyplan({
// studyplanTitle: result.title,
// endDate: result.endDate,
// endTime: result.endTime,
// memo: result.memo,
// deadline: result.deadline,
// selected: result.subjectId
// })
// setSubjectName(result.subjectName)
// } else {
// setStudyplan({
// studyplanTitle: result.title,
// endDate: result.endDate,
// memo: result.memo,
// deadline: result.deadline,
// selected: result.subjectId
// })
// setSubjectName(result.subjectName)
// }
} catch (error) {
catchErrors(error, setError)
}
......
......@@ -9,14 +9,14 @@ import styles from "./form.module.scss";
const SubjectForm = () => {
const { user } = useAuth();
const { subjectId } = useParams();
const [success, setSuccess] = useState(false)
const [success, setSuccess] = useState(false);
const [error, setError] = useState("");
const [disabled, setDisabled] = useState(true)
const [disabled, setDisabled] = useState(true);
const [subject, setSubject] = useState({
lectureName: "",
prof: "",
classRoom: ""
})
});
useEffect(() => {
if (subjectId) getInfo(subjectId);
......
import { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import todoApi from "../../apis/todo.api";
import { useAuth } from "../../utils/context.js";
import catchErrors from "../../utils/catchErrors";
import moment from "moment";
import styles from "./menu.module.scss";
const Menu = () => {
const { user, logout } = useAuth();
const [todoList, setTodoList] = useState([])
const [error, setError] = useState("");
useEffect(() => {
todayTodo()
}, [])
async function todayTodo() {
try {
setError("")
const result = await todoApi.getTodo(user.id, moment().format("YYYY-MM-DD"))
console.log("client resList",result)
setTodoList(result)
} catch (error) {
catchErrors(error, setError)
}
}
return (
<>
......
import { useState } from "react";
import { useState, useEffect, useRef } from "react";
import todoApi from "../../apis/todo.api";
import { useAuth } from "../../utils/context";
import catchErrors from "../../utils/catchErrors";
import moment from "moment";
import styles from "./modal.module.scss";
const TodoModal = () => {
const TodoModal = ({ curDate, selectTodo = "" }) => {
const { user } = useAuth()
const [todo, setTodo] = useState({
todoTitle: "",
todoDate: moment().format("YYYY-MM-DD")
todoDate: moment(curDate).format("YYYY-MM-DD")
})
const [error, setError] = useState("");
useEffect(() => {
setTodo({ ...todo, todoDate: curDate })
}, [curDate])
useEffect(() => {
if (selectTodo) {
console.log("selectTodo 값 변경으로 실행")
setTodo({ ...todo, ...selectTodo })
}
}, [selectTodo])
const handleChange = (e) => {
const { name, value } = e.target
setTodo({ ...todo, [name]: value })
}
const handleClick = () => {
setTodo({
todoTitle: "",
todoDate: moment().format("YYYY-MM-DD")
})
async function handleSubmit() {
try {
setError("")
if (selectTodo) {
await todoApi.edit(todo, user.id)
alert("해당 할일이 성공적으로 수정되었습니다.")
} else {
await todoApi.submit(todo, user.id)
alert("해당 할일이 성공적으로 등록되었습니다.")
}
window.location.reload()
} catch (error) {
catchErrors(error, setError)
}
}
return (
<div className="modal fade" id="todomodal" data-bs-backdrop="static" data-bs-keyboard="false" tabIndex="-1" aria-labelledby="todoLabel" aria-hidden="true">
{console.log("Modal date==", curDate, selectTodo)}
<div className="modal-dialog modal-dialog-centered">
<div className="modal-content" style={{ backgroundColor: "crimson" }}>
<div className="modal-header px-2 py-1" >
......@@ -31,7 +57,7 @@ const TodoModal = () => {
<div className="modal-body bg-white">
<input type="text" name="todoTitle"
className={`form-control border-top-0 border-end-0 border-start-0 shadow-none rounded-0 ${styles.textInput}`}
placeholder="제목" onChange={handleChange} value={todo.todoTitle} />
placeholder="제목" onChange={handleChange} value={todo.todoTitle} autoComplete="off" />
<div className="d-flex justify-content-between mt-4">
<label className="col-2 col-form-label ms-2">날짜</label>
<div className="col-8 d-flex align-items-center">
......@@ -41,8 +67,8 @@ const TodoModal = () => {
</div>
<div className="modal-footer bg-white p-1" >
<button type="button" className="btn btn-secondary btn-sm"
data-bs-dismiss="modal" onClick={handleClick}>취소</button>
<button type="button" className="btn btn-crimson btn-sm">확인</button>
data-bs-dismiss="modal" onClick={() => setTodo({ todoTitle: "", todoDate: "" })}>취소</button>
<button type="button" className="btn btn-crimson btn-sm" onClick={handleSubmit}>{selectTodo ? "수정" : "확인"}</button>
</div>
</div>
</div>
......
const TodoPostModal = () => {
const TodoPostModal = ({ handleClick }) => {
return (
<>
<div className="modal fade" id="postmodal" data-bs-backdrop="static" data-bs-keyboard="false" tabIndex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div className="modal-dialog modal-dialog-centered">
<div className="modal-content">
<div className="modal-body">
<p className="m-2 text-center" style={{ fontSize: "17px" }}>해당 일정을 내일로 미루시겠습니까?</p>
</div>
<div className="modal-footer p-1">
<button type="button" className="btn btn-crimson btn-sm"></button>
<button type="button" className="btn btn-secondary btn-sm"
data-bs-dismiss="modal">아니요</button>
</div>
<div className="modal fade" id="postmodal" data-bs-backdrop="static" data-bs-keyboard="false" tabIndex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div className="modal-dialog modal-dialog-centered">
<div className="modal-content">
<div className="modal-body">
<p className="m-2 text-center" style={{ fontSize: "17px" }}>해당 일정을 내일로 미루시겠습니까?</p>
</div>
<div className="modal-footer p-1">
<button type="button" className="btn btn-crimson btn-sm" data-bs-dismiss="modal" onClick={handleClick}></button>
<button type="button" className="btn btn-secondary btn-sm"
data-bs-dismiss="modal">아니요</button>
</div>
</div>
</div>
</>
</div>
)
}
......
import { Link } from "react-router-dom";
import styles from "../Form/form.module.scss";
import styles from "./studyplan.module.scss";
const PlanLineList = ({ subjectId, planList = [] }) => {
return (
<>
{planList.length !== 0 ? planList.map(plan => <div className="d-flex justify-content-between">
<p className="card-text mb-1">- {plan.title}</p>
<p className={`card-text mb-1 ${styles.text}`}>- {plan.title}</p>
<input className={`form-check-input shadow-none ${styles.checkBox}`} type="checkbox" />
</div>) : <Link className="text-decoration-none link-dark" to={`/studyplan/submit/${subjectId}`}>
<div className="d-flex">
......
import { Link } from "react-router-dom";
import PlanLineList from "../StudyPlan/PlanLineList";
import PlanLineList from "./PlanLineList";
const StudyPlanCard = ({ renList }) => {
......
import { useState, useEffect } from 'react';
import { Link } from "react-router-dom";
import StudyPlanCard from "./Card/StudyPlanCard";
import subjectApi from '../apis/subject.api';
import catchErrors from "../utils/catchErrors";
import { useAuth } from "../utils/context";
import styles from "./StudyPlan/studyplan.module.scss";
import StudyPlanCard from "./StudyPlanCard";
import subjectApi from '../../apis/subject.api';
import catchErrors from "../../utils/catchErrors";
import { useAuth } from "../../utils/context";
import styles from "./studyplan.module.scss";
const StudyPlanList = () => {
const { user } = useAuth();
......
......@@ -7,12 +7,18 @@
border-color: black;
&:focus {
border-color: black;
border-color: black;
}
&:checked {
border-color: crimson;
background-color: crimson;
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='currentColor' d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e");
border-color: crimson;
background-color: crimson;
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='currentColor' d='M13.854 3.646a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708 0l-3.5-3.5a.5.5 0 1 1 .708-.708L6.5 10.293l6.646-6.647a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e");
}
}
.text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
\ No newline at end of file
import { useState, useEffect } from "react";
import { useParams } from "react-router-dom";
import TodoModal from "../components/Modal/TodoModal";
import TodoPostModal from "../components/Modal/TodoPostModal";
import todoApi from "../apis/todo.api";
import { useAuth } from "../utils/context";
import catchErrors from "../utils/catchErrors";
import moment from "moment";
import styles from "../components/Form/form.module.scss";
const TodoList = () => {
const { user } = useAuth()
const { date } = useParams()
const [todoList, setTodoList] = useState([])
const [selectTodo, setSelectTodo] = useState(null)
const [error, setError] = useState("");
useEffect(() => {
getAll()
}, [date])
async function getAll() {
try {
setError("")
const resList = await todoApi.getTodo(user.id, date)
setTodoList(resList)
} catch (error) {
catchErrors(error, setError)
}
}
async function delayTodo() {
try {
setError("")
const nextDate = moment(date).add(1, 'day').format("YYYY-MM-DD")
await todoApi.edit({ id: selectTodo.id, todoDate: nextDate }, user.id)
getAll()
} catch (error) {
catchErrors(error, setError)
}
}
async function delTodo(todoId) {
try {
setError("")
await todoApi.remove(todoId, user.id)
alert("해당 할일이 성공적으로 삭제되었습니다.")
getAll()
} catch (error) {
catchErrors(error, setError)
}
}
return (
<div className="d-flex mt-3">
<div className="d-flex align-items-center" style={{ width: "75%" }}>
<input className={`form-check-input rounded-0 shadow-none mt-0 ${styles.checkBox}`} type="checkbox" />
<label className="form-check-label fs-5 ms-3 pe-2 text-nowrap" style={{ overflow: "hidden", textOverflow: "ellipsis" }}>과제03 제출하기sadsa</label>
</div>
<div className="d-flex justify-content-between" style={{ cursor: "pointer", width: "25%" }}>
<i className="bi bi-arrow-right fs-5" data-bs-toggle="modal" data-bs-target="#postmodal"><TodoPostModal /></i>
<i className="bi bi-pencil-square fs-5" data-bs-toggle="modal" data-bs-target="#todomodal"></i>
<TodoModal />
<i className="bi bi-trash fs-5"></i>
</div>
<div className={"mt-3 " + (todoList.length ? "d-flex" : "d-block")}>
{todoList.length !== 0 ?
todoList.map((todo, idx) => <>
<div className="d-flex align-items-center" style={{ width: "75%" }}>
<input className={`form-check-input rounded-0 shadow-none mt-0 ${styles.checkBox}`} type="checkbox" checked={todo.done} />
<label className="form-check-label fs-5 ms-3 pe-2 text-nowrap" style={{ overflow: "hidden", textOverflow: "ellipsis" }}>{todo.todoTitle}</label>
</div>
<div className="d-flex justify-content-between" style={{ cursor: "pointer", width: "25%" }}>
<i className="bi bi-arrow-right fs-5" data-bs-toggle="modal" data-bs-target="#postmodal" onClick={() => setSelectTodo(todo)}></i>
<i className="bi bi-pencil-square fs-5" data-bs-toggle="modal" data-bs-target="#todomodal" onClick={() => setSelectTodo(todo)}></i>
<i className="bi bi-trash fs-5" onClick={() => delTodo(todo.id)}></i>
</div>
</>) : <p className="text-center">등록된 할일이 없습니다.</p>}
<TodoPostModal handleClick={delayTodo} />
<TodoModal curDate={date} selectTodo={selectTodo} />
</div>
)
}
......
import Menu from "../components/Menu/Menu";
import HomeBtn from "../components/Buttons/HomeBtn";
import StudyPlanList from "../components/StudyPlanList";
import StudyPlanList from "../components/StudyPlan/StudyPlanList";
const StudyPlanListPage = () => {
return (
......
......@@ -6,14 +6,14 @@ import Footer from "../components/Footer";
const ToDoPage = () => {
return (
<>
<div>
<Menu />
<HomeBtn />
<h1 className="text-center">To-do</h1>
<Weekly />
<TodoList />
<Footer />
</>
</div>
)
}
......
......@@ -145,6 +145,10 @@ button {
color: #FF0000;
}
& .fc-more-popover {
display: none;
}
& .fc-dayGridDay-view {
display: none;
}
......@@ -155,6 +159,8 @@ button {
& .fc-event-title {
display: block;
text-overflow: ellipsis;
height: 15px;
padding: 0;
}
}
......
import { Plan, Subject } from "../db/index.js";
import * as ConvertDate from "./schedule.controller.js";
// const addPlan = async (req, res) => {
// console.log('server/addPlan req.body', req.body)
// try {
// let end = null;
// let tf = false;
// const { info } = req.body
// const { studyplanTitle, endDate, endTime, deadline, memo, selected } = info
// console.log('제목확인', studyplanTitle)
// if (deadline === "on") {
// end = new Date(endDate + " " + endTime)
// tf = true
// } else {
// end = new Date(endDate)
// }
// const result = await Plan.create({
// subjectId: selected,
// title: studyplanTitle,
// deadline: end,
// memo: memo,
// timeChecked: tf,
// checked: false
// })
// return res.json(result)
// } catch (error) {
// console.log(error)
// return res.status(500).send(error.message || "계획저장 에러발생")
// }
// }
// const editPlan = async (req, res) => {
// const { info, id } = req.body
// console.log('editPlan info', info, '|', id)
// try {
// let result = null
// if (info.deadline === "on") {
// result = await Plan.update({
// subjectId: info.selected,
// title: info.studyplanTitle,
// deadline: new Date(info.endDate + " " + info.endTime),
// memo: info.memo,
// timeChecked: true,
// checked: false
// }, { where: { id: id } })
// res.send(200)
// } else {
// result = await Plan.update({
// subjectId: info.selected,
// title: info.studyplanTitle,
// deadline: new Date(info.endDate),
// memo: info.memo,
// timeChecked: false,
// checked: false
// }, {
// where: { id: id }
// })
// }
// if (!result) {
// throw new Error("과목정보 수정 에러발생")
// } else {
// return res.send(200)
// }
// } catch (error) {
// console.log(error)
// return res.status(500).send(error.message || "계획수정 에러발생")
// }
// }
// const getInfo = async (req, res) => {
// console.log('server/getInfo req.params', req.params)
// try {
// let deadlineStr = null
// let endTimeStr = null
// const { planId } = req.params;
// const findInfo = await Plan.findOne({ where: { id: planId } })
// const Info = findInfo.dataValues;
// const getSubTitle = await Subject.findAll({
// attributes: ['name'],
// where: { id: Info.subjectId }
// })
// deadlineStr = ConvertDate.dateToString(Info.deadline, "full")
// endTimeStr = ConvertDate.dateToString(Info.deadline, "time")
// if (Info.timeChecked) {
// res.json({
// subjectId: Info.subjectId,
// subjectName: getSubTitle[0].dataValues.name,
// title: Info.title,
// endDate: deadlineStr,
// endTime: endTimeStr,
// deadline: "on",
// memo: Info.memo
// })
// } else {
// res.json({
// subjectId: Info.subjectId,
// subjectName: getSubTitle[0].dataValues.name,
// title: Info.title,
// endDate: deadlineStr,
// deadline: "",
// memo: Info.memo
// })
// }
// } catch (error) {
// console.log(error)
// return res.status(500).send(error.message || "계획 가져오기 에러발생")
// }
// }
import { Plan } from "../db/index.js";
import { dateToString } from "./schedule.controller.js";
const getOne = async (req, res) => {
try {
let findPlan = null
const { planId } = req.query
console.log("get One", planId)
if (planId) findPlan = await Plan.findOne({ where: { id: planId } })
let sendPlan = null
const planId = req.planId
const findPlan = await Plan.findOne({ where: { id: planId } })
if (!findPlan) throw new Error("학업 계획 정보를 찾지 못했습니다.")
return res.json(find)
else {
const { id, title, deadline, memo, timeChecked, checked, subjectId } = findPlan
const endDate = dateToString(deadline, "full")
if (timeChecked) {
const endTime = dateToString(deadline, "time")
sendPlan = { id: id, studyplanTitle: title, endDate: endDate, endTime: endTime, deadline: timeChecked ? "on" : "off", memo: memo, selected: subjectId }
} else sendPlan = { id: id, studyplanTitle: title, endDate: endDate, deadline: timeChecked ? "on" : "off", memo: memo, selected: subjectId }
}
return res.json(sendPlan)
} catch (error) {
return res.status(500).send(error.message || "학업계획 조회 중 에러 발생")
}
......@@ -151,7 +47,7 @@ const edit = async (req, res) => {
date = new Date(endDate + " " + endTime)
check_v = true
} else date = new Date(endDate)
const updated = await Plan.updated({ title: studyplanTitle, deadline: date, memo: memo, timeChecked: check_v, subjectId: selected }, { where: { id: planId } })
const updated = await Plan.update({ title: studyplanTitle, deadline: date, memo: memo, timeChecked: check_v, subjectId: selected }, { where: { id: planId } })
if (!updated) throw new Error("해당 학업계획의 일부 정보를 수정하는데 실패하였습니다.")
else return res.send(200)
} catch (error) {
......@@ -186,7 +82,4 @@ export default {
edit,
remove,
getParams
// addPlan,
// editPlan,
// getInfo
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment