Commit 56f90932 authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

저장시 alert창 페이지 이동

parent 9ab6dda5
import React, { FormEvent, useEffect, useState } from "react"; import React, { FormEvent, useEffect, useState } from "react";
import { useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { questionApi, surveyApi } from "../apis"; import { questionApi, surveyApi } from "../apis";
import { SpinnerIcon } from "../icons"; import { SpinnerIcon } from "../icons";
import { Question } from "../questions"; import { Question } from "../questions";
...@@ -14,6 +14,7 @@ export const EditSurvey = () => { ...@@ -14,6 +14,7 @@ export const EditSurvey = () => {
const [error, setError] = useState(""); const [error, setError] = useState("");
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [success, setSuccess] = useState(false); const [success, setSuccess] = useState(false);
const navigate = useNavigate();
const [survey, setSurvey] = useState<SurveyType>({ const [survey, setSurvey] = useState<SurveyType>({
_id: surveyId, _id: surveyId,
user: {}, user: {},
...@@ -54,6 +55,8 @@ export const EditSurvey = () => { ...@@ -54,6 +55,8 @@ export const EditSurvey = () => {
const newSurvey: SurveyType = await surveyApi.editSurvey(survey); const newSurvey: SurveyType = await surveyApi.editSurvey(survey);
console.log(newSurvey); console.log(newSurvey);
setSuccess(true); setSuccess(true);
alert("저장되었습니다");
navigate("/profile");
setError(""); setError("");
} catch (error) { } catch (error) {
catchErrors(error, setError); catchErrors(error, setError);
......
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