fix ticket 10
All checks were successful
publish-main / release-image (push) Successful in 6m47s

This commit is contained in:
kuwsh1n 2024-04-25 13:03:34 +03:00
parent cb7d0587e8
commit 949a1b7ed5
5 changed files with 50 additions and 5 deletions

View File

@ -38,7 +38,6 @@ const App = () => {
useEffect(() => { useEffect(() => {
async function verifyUser() { async function verifyUser() {
const response = await verifyUserApi(cookies.token); const response = await verifyUserApi(cookies.token);
console.log("app", user);
if (response.status === 200) { if (response.status === 200) {
setUser(response.data); setUser(response.data);

View File

@ -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 (
<div class="modal fade" tabindex="-1" id="checkModal" tabIndex="-1" aria-labelledby="exampleModalLabel" data-bs-backdrop="static" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
{/* <h5 class="modal-title">Modal title</h5> */}
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" onClick={action.cancel}></button>
</div>
<div class="modal-body">
<p>{message}</p>
</div>
<div class="modal-footer">
<MyButton text={"Отмена"} dismiss={"modal"} class={"main__white"} click={action.cancel}/>
<MyButton
text={"Да, удалить"}
backgroundColor={"rgb(229, 87, 87)"}
otherStyle={{color: "white"}}
dismiss={"modal"}
click={action.execute}
/>
</div>
</div>
</div>
</div>
)
}
export default CheckModal;

View File

@ -5,6 +5,7 @@ import classes from "../assets/styles/forms.module.scss"
import MyButton from "../components/MyButton.jsx"; import MyButton from "../components/MyButton.jsx";
import MyInput from "../components/MyInput.jsx"; import MyInput from "../components/MyInput.jsx";
import { FormsData, UserData } from "../context"; import { FormsData, UserData } from "../context";
import CheckModal from "../components/CheckModal.jsx";
import { listFormsApi, createFormApi, removeFormApi, newFormTokenApi, listFormsByTokenApi } from "../hooks/api/listFormsApi.js"; import { listFormsApi, createFormApi, removeFormApi, newFormTokenApi, listFormsByTokenApi } from "../hooks/api/listFormsApi.js";
const Forms = () => { const Forms = () => {
@ -12,6 +13,7 @@ const Forms = () => {
const {forms, setForms} = useContext(FormsData); const {forms, setForms} = useContext(FormsData);
const {user, setUser} = useContext(UserData); const {user, setUser} = useContext(UserData);
const [stateLoading, setStateLoading] = useState(false); const [stateLoading, setStateLoading] = useState(false);
const [removeIdForm, setRemoveIdForm] = useState(false);
const [cookies, _, __] = useCookies(["user"]); const [cookies, _, __] = useCookies(["user"]);
@ -42,7 +44,6 @@ const Forms = () => {
const token = await newFormTokenApi(cookies.token, response.data.id) const token = await newFormTokenApi(cookies.token, response.data.id)
navigate(`/forms/${response.data.id}/edit`) navigate(`/forms/${response.data.id}/edit`)
// navigate(`/forms/1/edit`)
} }
else { else {
console.log(response) console.log(response)
@ -60,8 +61,10 @@ const Forms = () => {
setForms([...forms.filter(item => item.id !== id)]); setForms([...forms.filter(item => item.id !== id)]);
} }
else { else {
console.log(response) console.log(response);
} }
setRemoveIdForm(false);
}; };
async function openFormView(formId) { async function openFormView(formId) {
@ -114,8 +117,16 @@ const Forms = () => {
<li><a class="dropdown-item" onClick={() => openFormView(item.id)}>Открыть</a></li> <li><a class="dropdown-item" onClick={() => openFormView(item.id)}>Открыть</a></li>
<li><a class="dropdown-item" onClick={() => navigate(`/forms/${item.id}/answers`)}>Ответы</a></li> <li><a class="dropdown-item" onClick={() => navigate(`/forms/${item.id}/answers`)}>Ответы</a></li>
<li><a class="dropdown-item" onClick={() => copyLinkToFormView(item.id)}>Скопировать ссылку</a></li> <li><a class="dropdown-item" onClick={() => copyLinkToFormView(item.id)}>Скопировать ссылку</a></li>
<li><a class="dropdown-item" onClick={() => removeForm(item.id)}>Удалить</a></li> <li><a class="dropdown-item" data-bs-toggle="modal" data-bs-target="#checkModal" onClick={() => setRemoveIdForm(item.id)}>Удалить</a></li>
</ul> </ul>
<CheckModal
message={`Вы хотетите удалить форму <${item.title}>?`}
action={{
execute: () => removeForm(removeIdForm),
cancel: () => setRemoveIdForm(false)
}}
/>
</div> </div>
)} )}
</div> </div>

View File

@ -279,7 +279,8 @@ const NewForm = () => {
addFormBlock={addFormBlock} addFormBlock={addFormBlock}
addOptionAnswer={addOptionAnswer} addOptionAnswer={addOptionAnswer}
updateBlock={updateBlock} updateBlock={updateBlock}
setCurrentTypeAnswer={setCurrentTypeAnswer}/> setCurrentTypeAnswer={setCurrentTypeAnswer}
/>
<div className={classes.content__newForm}> <div className={classes.content__newForm}>
<div className={classes.content__newForm__title}> <div className={classes.content__newForm__title}>