Skip to content

Commit

Permalink
[feat/#54] Fix: modify assignment req(date -> string)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjms0214 committed Aug 26, 2023
1 parent 3482f0a commit cc1be07
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/components/LecturePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export type LectureType = {
enroll: Boolean | null;
};

let page: number | null;

const LecturePage: FC = () => {
const location = useLocation();
const user_id = location.state.user_id;
Expand All @@ -29,6 +31,7 @@ const LecturePage: FC = () => {
setIsProfessor(false);
}
});
page = lectureList.length
}, [lectureList, isProfessor]);
return (
<>
Expand Down Expand Up @@ -73,7 +76,7 @@ const LecturePage: FC = () => {
))}
{
lectureList != null && (
<Paging count={lectureList.length} />
<Paging data={page} />
)
}
</div>
Expand Down
14 changes: 8 additions & 6 deletions src/components/NewAssignment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ const newAssignment: FC = () => {
const [dueDate, setDueDate] = useState<Date | null>(null);
const submitData = (data: any) => {
let params = {
lecture_id: location.state.lecture_id,
professor_id: location.state.user_id,
title: data.title,
start_date: startDate,
due_date: dueDate,
description: data.description,
lecture_id: location.state.lecture_id,
professor_id: location.state.user_id,
title: data.title,
start_date: startDate!.toISOString(),
due_date: dueDate!.toISOString(),
description: data.description,
};

setUserId(location.state.user_id);


console.log(params);
// TODO 서버 나오면 디버깅 필요
api.client
Expand Down
4 changes: 3 additions & 1 deletion src/components/Paging.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { useState } from "react";
import Pagination from "react-js-pagination";
import "../style/Paging.css";

const Paging = (count:any) => {
const Paging = (props:any) => {
const [page, setPage] = useState(1);
const count = props.data
console.log(props.data)

const handlePageChange = (page: number) => {
setPage(page);
Expand Down
5 changes: 3 additions & 2 deletions src/props/Lecture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from "axios";
import {useLocation} from "react-router-dom";
import { useNavigate } from "react-router";
import { LectureType } from "../components/LecturePage";
import api from "../utils/api";

type LectureProps = {
// 부모 컴포넌트에 import 해온 타입을 재사용
Expand All @@ -21,8 +22,8 @@ const Lecture = ({ lecture, isProfessor }: LectureProps) => {
};
console.log(params);

axios
.post("http://moaroom-back.duckdns.org:8080/lectures/students/enroll", params)
api.client
.post("/lectures/students/enroll", params)
.then(function(response) {
console.log(response)
if (response.data === "강의 신청 완료") {
Expand Down

0 comments on commit cc1be07

Please # to comment.