Commit 72d4eb09 authored by jang dong hyeok's avatar jang dong hyeok
Browse files

.

parent 1f7641e8
......@@ -8,6 +8,7 @@ import { Home } from "./home";
import { Profile } from "./profile";
import { EditResultButton } from "./survey";
import { EditSurvey } from "./survey/EditSurvey";
import { ResultSurvey } from "./survey/ResultSurvey";
export const SurveyRouter = () => {
return (
......@@ -19,7 +20,7 @@ export const SurveyRouter = () => {
<Route path="signup" element={<SignUp />} />
<Route path="surveys/:surveyId/" element={<EditResultButton />}>
<Route path="edit" element={<EditSurvey />} />
<Route path="result" element />
<Route path="result" element={<ResultSurvey />} />
</Route>
<Route path="survey" element={<SurveyForm />} />
<Route
......
......@@ -30,6 +30,13 @@ export const editSurvey = async (survey: SurveyType) => {
);
return data;
};
export const resultSurvey = async (survey: SurveyType) => {
const { data } = await axios.put(
`${baseUrl}/surveys/${survey._id}/result`,
survey
);
return data;
};
export const deleteSurvey = async (surveyId: string) => {
const { data } = await axios.delete(`${baseUrl}/surveys/${surveyId}/delete`);
......
......@@ -64,13 +64,6 @@ export const MySurveyCard = ({ data }: Props) => {
</div>
</button>
<div className="flex justify-end pt-1">
{/*<button
type="button"
className="bg-themeColor rounded text-white py-1 px-1.5 mr-1"
onClick={editSurvey}
>
수정
</button>*/}
<button
type="button"
className="bg-themeColor rounded text-white py-1 px-1.5 ml-1"
......
import React from "react";
import { NavLink } from "react-router-dom";
import { Outlet, useNavigate, useParams } from "react-router-dom";
export const EditResultButton = () => {
let { surveyId } = useParams<{ surveyId: string }>();
const navigate = useNavigate();
function editButtonClick(e: React.MouseEvent<HTMLButtonElement>) {
/*function editButtonClick(e: React.MouseEvent<HTMLButtonElement>) {
navigate(`/surveys/${surveyId}/edit`);
}
function resultButtonClick(e: React.MouseEvent<HTMLButtonElement>) {
navigate(`/surveys/${surveyId}/result`);
}*/
return (
<div>
<div className="flex place-content-center">
<button
className="text-xl m-3 underline decoration-4"
onClick={editButtonClick}
<NavLink
to={`/surveys/${surveyId}/edit`}
style={({ isActive }) =>
isActive ? { color: "#58ACFA" } : { color: "black" }
}
>
설문지 수정
</button>
<button
className="text-xl m-3 underline"
/*onClick={}*/
<div className="text-xl m-3 underline">설문지 수정</div>
</NavLink>
<NavLink
to={`/surveys/${surveyId}/result`}
style={({ isActive }) =>
isActive ? { color: "#58ACFA" } : { color: "black" }
}
>
응답결과
</button>
<div className="text-xl m-3 underline">응답결과</div>
</NavLink>
</div>
<Outlet />
</div>
......
import React from "react";
export const ResultSurvey = () => {
return (
<div className="flex flex-col place-items-center">
<div className="flex flex-col container place-items-center mt-4">
<div className="font-bold text-4xl text-center m-2 border-b-2">
설문지 제목
</div>
<div className="font-bold text-1xl text-center m-2 resize-none">
설문조사 설명
</div>
</div>
<div className="w-11/12 h-16 rounded border-2 hover:border-themeColor">
1번 질문
</div>
</div>
);
};
......@@ -14,7 +14,7 @@ router
.route("/:surveyId")
.get(surveyCtrl.getSurveyById);
router
.route("/edit/:surveyId")
.route("/:surveyId/edit")
.get(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.getSurveyById)
.put(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.updateSurvey);
router
......
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