Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API URL 수정 #59

Merged
merged 1 commit into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 104 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions src/components/Assignment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import "../style/home.css";
import Modal from "../props/Modal";
import Navbar from "./Navbar";
import { navPropsType } from "./Navbar";
import axios from "axios";
import { stringify } from "querystring";
import api from "../utils/api";

const Assignment: FC = () => {
interface UrlResp {
Expand All @@ -32,16 +31,16 @@ const Assignment: FC = () => {
const [isProfessor, setIsProfessor] = useState<boolean>(false);

useEffect(() => {
axios
.get("http://moaroom-back.duckdns.org:8080/url/" + user_id)
api.client
.get("/urls/" + user_id)
.then((response) => {
setUrl(response.data.containerAddress);
});
}, []);

useEffect(() => {
axios
.get("http://moaroom-back.duckdns.org:8080/user/" + user_id)
api.client
.get("/users/" + user_id)
.then((response) => {
if (response.data.role == 2) {
setIsProfessor(true);
Expand Down
12 changes: 6 additions & 6 deletions src/components/AssignmentPage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { FC, useState, useCallback, useEffect } from "react";
import { useNavigate, useLocation } from "react-router-dom";
import { useForm } from "react-hook-form";
import axios from "axios";
import "../style/LecturePage.css";
import Paging from "../components/Paging";
import Assignment from "../props/Assignment";
import AssignmentModal from "../props/AssignmentModal";
import Navbar from "./Navbar";
import { navPropsType } from "./Navbar";
import api from "../utils/api";

export type AssignmentType = {
lecture_id: string;
Expand Down Expand Up @@ -56,8 +56,8 @@ const AssignmentPage: FC = () => {
};
const deleteAssignment = (data: any) => {
const title = data.title;
axios
.delete("http://moaroom-back.duckdns.org:8080/assignment/" + title)
api.client
.delete("/assignments/" + title)
.then(function(response) {
if (response.data == "삭제 성공") {
alert("과제가 삭제되었습니다.");
Expand All @@ -74,8 +74,8 @@ const AssignmentPage: FC = () => {

useEffect(() => {
var tmpList: AssignmentPropType[] = [];
axios
.get("http://moaroom-back.duckdns.org:8080/assignment/all/" + user_id)
api.client
.get("/assignments/users/" + user_id)
.then((response) => {
for (let i = 0; i < response.data.length; i++) {
if (lecture_id == response.data[i].lecture_id) {
Expand Down Expand Up @@ -202,7 +202,7 @@ const AssignmentPage: FC = () => {
)}
{
assignmentPropsList == null &&(
<Paging />
<Paging count={assignmentList.length}/>
)
}
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import { navPropsType } from "./Navbar";
import { useLocation } from "react-router-dom";
const Home: FC = () => {
const location = useLocation();
const user_id = location.state.user_id;
const isProfessor = location.state.isProfessor;
var user_id = null;
var isProfessor = null;
if(localStorage.getItem("isLogin")){
user_id = location.state.user_id;
isProfessor = location.state.isProfessor;
}
return (
<>
<div className="background">
Expand Down
10 changes: 5 additions & 5 deletions src/components/LecturePage.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React, { FC, useEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import "../style/LecturePage.css";
import axios from "axios";
import Lecture from "../props/Lecture";
import Paging from "../components/Paging";
import Navbar from "./Navbar";
import { navPropsType } from "./Navbar";
import api from "../utils/api";

export type LectureType = {
lecture_id: string;
title: string;
professor_name: string;
room: number;
professor_name: string;
enroll: Boolean | null;
};

Expand All @@ -21,8 +21,8 @@ const LecturePage: FC = () => {
const [lectureList, setLectureList] = useState<LectureType[]>([]);
const [isProfessor, setIsProfessor] = useState<Boolean>(true);
useEffect(() => {
axios
.get("http://moaroom-back.duckdns.org:8080/lecture/all/" + user_id)
api.client
.get("/lectures/users/" + user_id)
.then((response) => {
setLectureList(response.data);
if (response.data.length != 0 && response.data[0].enroll != null) {
Expand Down Expand Up @@ -73,7 +73,7 @@ const LecturePage: FC = () => {
))}
{
lectureList != null && (
<Paging />
<Paging count={lectureList.length} />
)
}
</div>
Expand Down
12 changes: 5 additions & 7 deletions src/components/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { FC, useState, useEffect } from "react";
import { useForm } from "react-hook-form";
import "../style/home.css";
import axios from "axios";
import { ToastContainer, toast, Flip } from "react-toastify";
import "react-toastify/dist/ReactToastify.min.css";
import { useNavigate } from "react-router";
import Navbar from "./Navbar";
import navPropsType from "./Navbar";
import api from "../utils/api";
const Login: FC = (): JSX.Element => {
const navigate = useNavigate();
const [loginInfo, setLoginInfo] = useState({
Expand All @@ -33,8 +32,8 @@ const Login: FC = (): JSX.Element => {
});
};
useEffect(() => {
axios
.get("http://moaroom-back.duckdns.org:8080/user/" + user_id)
api.client
.get("/users/" + user_id)
.then((response) => {
if (response.data.role == 2) {
setIsProfessor(true);
Expand All @@ -49,9 +48,8 @@ const Login: FC = (): JSX.Element => {
};
console.log(params);

// TODO 서버 나오면 디버깅 필요
axios
.post("http://moaroom-back.duckdns.org:8080/login", params)
api.client
.post("/login", params)
.then(function(response) {
if (response.data === "") {
alert("로그인 정보가 없습니다. 다시 로그인 해주세요.");
Expand Down
Loading