diff --git a/src/App.jsx b/src/App.jsx index 22b0149..b2659cf 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -38,7 +38,6 @@ const App = () => { useEffect(() => { async function verifyUser() { const response = await verifyUserApi(cookies.token); - console.log("app", user); if (response.status === 200) { setUser(response.data); diff --git a/src/assets/styles/components/checkModal.module.scss b/src/assets/styles/components/checkModal.module.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/components/CheckModal.jsx b/src/components/CheckModal.jsx new file mode 100644 index 0000000..1b860cd --- /dev/null +++ b/src/components/CheckModal.jsx @@ -0,0 +1,34 @@ +import React from "react"; +import classes from "../assets/styles/components/checkModal.module.scss"; +import MyButton from "./MyButton.jsx"; + +const CheckModal = ({message, action}) => { + + return ( + + ) +} + +export default CheckModal; \ No newline at end of file diff --git a/src/pages/Forms.jsx b/src/pages/Forms.jsx index b502d22..ed5aac9 100644 --- a/src/pages/Forms.jsx +++ b/src/pages/Forms.jsx @@ -5,6 +5,7 @@ import classes from "../assets/styles/forms.module.scss" import MyButton from "../components/MyButton.jsx"; import MyInput from "../components/MyInput.jsx"; import { FormsData, UserData } from "../context"; +import CheckModal from "../components/CheckModal.jsx"; import { listFormsApi, createFormApi, removeFormApi, newFormTokenApi, listFormsByTokenApi } from "../hooks/api/listFormsApi.js"; const Forms = () => { @@ -12,6 +13,7 @@ const Forms = () => { const {forms, setForms} = useContext(FormsData); const {user, setUser} = useContext(UserData); const [stateLoading, setStateLoading] = useState(false); + const [removeIdForm, setRemoveIdForm] = useState(false); const [cookies, _, __] = useCookies(["user"]); @@ -42,7 +44,6 @@ const Forms = () => { const token = await newFormTokenApi(cookies.token, response.data.id) navigate(`/forms/${response.data.id}/edit`) - // navigate(`/forms/1/edit`) } else { console.log(response) @@ -60,8 +61,10 @@ const Forms = () => { setForms([...forms.filter(item => item.id !== id)]); } else { - console.log(response) + console.log(response); } + + setRemoveIdForm(false); }; async function openFormView(formId) { @@ -114,8 +117,16 @@ const Forms = () => {
  • openFormView(item.id)}>Открыть
  • navigate(`/forms/${item.id}/answers`)}>Ответы
  • copyLinkToFormView(item.id)}>Скопировать ссылку
  • -
  • removeForm(item.id)}>Удалить
  • +
  • setRemoveIdForm(item.id)}>Удалить
  • + + ?`} + action={{ + execute: () => removeForm(removeIdForm), + cancel: () => setRemoveIdForm(false) + }} + /> )} diff --git a/src/pages/NewForm.jsx b/src/pages/NewForm.jsx index 37f66d1..fde4e55 100644 --- a/src/pages/NewForm.jsx +++ b/src/pages/NewForm.jsx @@ -279,7 +279,8 @@ const NewForm = () => { addFormBlock={addFormBlock} addOptionAnswer={addOptionAnswer} updateBlock={updateBlock} - setCurrentTypeAnswer={setCurrentTypeAnswer}/> + setCurrentTypeAnswer={setCurrentTypeAnswer} + />