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

route 변경

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