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

.

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