Commit 06176fc6 authored by jang dong hyeok's avatar jang dong hyeok
Browse files

route 변경

parent f3c4f117
......@@ -17,9 +17,9 @@ export const SurveyRouter = () => {
<Route index element={<Home />} />
<Route path="login" element={<Login />} />
<Route path="signup" element={<SignUp />} />
<Route path="surveys/edit/" element={<EditResultButton />}>
<Route path=":surveyId" element={<EditSurvey />} />
<Route path=":surveyId/result" element />
<Route path="surveys/:surveyId/" element={<EditResultButton />}>
<Route path="edit" element={<EditSurvey />} />
<Route path="result" element />
</Route>
<Route path="survey" element={<SurveyForm />} />
<Route
......
......@@ -8,11 +8,11 @@ export const createSurvey = async (survey: SurveyType) => {
};
export const getSurvey = async (surveyId: string) => {
const { data } = await axios.get(`${baseUrl}/surveys/edit/${surveyId}`);
const { data } = await axios.get(`${baseUrl}/surveys/${surveyId}/edit`);
return data;
};
export const getASurvey = async (surveyId: string) => {
const { data } = await axios.get(`${baseUrl}/surveys/edit/${surveyId}`);
const { data } = await axios.get(`${baseUrl}/surveys/${surveyId}/edit`);
return data;
};
//동혁
......@@ -23,13 +23,13 @@ export const getSurveys = async () => {
export const editSurvey = async (survey: SurveyType) => {
const { data } = await axios.put(
`${baseUrl}/surveys/edit/${survey._id}`,
`${baseUrl}/surveys/${survey._id}/edit`,
survey
);
return data;
};
export const deleteSurvey = async (surveyId: string) => {
const { data } = await axios.delete(`${baseUrl}/surveys/delete/${surveyId}`);
const { data } = await axios.delete(`${baseUrl}/surveys/${surveyId}/delete`);
return data;
};
......@@ -15,7 +15,7 @@ export const MySurveyCard = ({ data }: Props) => {
const [success, setSuccess] = useState(false);
const editSurvey = () => {
navigate(`/surveys/edit/${data._id}`, {
navigate(`/surveys/${data._id}/edit`, {
replace: true,
});
};
......
......@@ -6,7 +6,7 @@ export const EditResultButton = () => {
const navigate = useNavigate();
function editButtonClick(e: React.MouseEvent<HTMLButtonElement>) {
navigate(`/surveys/edit/${surveyId}`);
navigate(`/surveys/${surveyId}/edit`);
}
return (
<div>
......
......@@ -4,15 +4,18 @@ import { authCtrl, surveyCtrl, questionCtrl } from "../controllers";
const router = express.Router();
router.route("/").get(authCtrl.requireLogin, surveyCtrl.getSurveys);
router.route("/:surveyId").get(surveyCtrl.getSurveyById);
router.route("/:surveyId")
.get(surveyCtrl.getSurveyById);
router.route("/create").post(authCtrl.requireLogin, surveyCtrl.createSurvey);
router
.route("/edit/:surveyId")
.route("/:surveyId/edit")
.get(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.getSurveyById)
.put(authCtrl.requireLogin, authCtrl.authenticate, surveyCtrl.updateSurvey);
router
.route("/delete/:surveyId")
.route("/:surveyId/delete")
.delete(
authCtrl.requireLogin,
authCtrl.authenticate,
......
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