fix ticket 12
All checks were successful
publish-main / release-image (push) Successful in 5m24s

This commit is contained in:
kuwsh1n 2024-04-26 11:23:46 +03:00
parent 749cd56dcf
commit 2abe6ef765

View File

@ -36,7 +36,8 @@ const NewForm = () => {
const [currentOptionAnswer, setCurrentOptionAnswer] = useState(""); const [currentOptionAnswer, setCurrentOptionAnswer] = useState("");
const [datetime, setDatetime] = useState(""); const [datetime, setDatetime] = useState("");
const [titleForm, setTitleForm] = useState(""); const [newTitleForm, setNewTitleForm] = useState("");
const [oldTitleFrom, setOldTitleForm] = useState("");
const [listBlock, setListBlock] = useState([]); const [listBlock, setListBlock] = useState([]);
@ -64,12 +65,15 @@ const NewForm = () => {
const responseBlock = await listFormBlockApi(cookies.token, formId); const responseBlock = await listFormBlockApi(cookies.token, formId);
if (responseBlock.status === 200 && responseBlock.data && responseForms.status === 200) { if (responseBlock.status === 200 && responseBlock.data && responseForms.status === 200) {
setListBlock(responseDataToListBlock(responseBlock.data)); setListBlock(responseDataToListBlock(responseBlock.data));
setTitleForm(responseForms.data.find(item => item.id === formId).title); const title = responseForms.data.find(item => item.id === formId).title
setNewTitleForm(title);
setOldTitleForm(title);
} }
else { else {
setListBlock([]) setListBlock([])
setTitleForm("Новыя форма") setNewTitleForm("Новыя форма");
setOldTitleForm("Новыя форма");
} }
}; };
@ -136,8 +140,6 @@ const NewForm = () => {
video: video video: video
} }
console.log(parseVKlinkVideo(video))
const response = await addFormBlockApi(cookies.token, formId, newBlock) const response = await addFormBlockApi(cookies.token, formId, newBlock)
if (response.status === 200) { if (response.status === 200) {
@ -150,7 +152,7 @@ const NewForm = () => {
}; };
async function updateTitleForm() { async function updateTitleForm() {
const response = await updateTitleFormApi(cookies.token, formId, titleForm); const response = await updateTitleFormApi(cookies.token, formId, newTitleForm);
if (response.status === 200) { if (response.status === 200) {
console.log(response) console.log(response)
@ -201,22 +203,13 @@ const NewForm = () => {
}) })
}; };
function saveForm() { async function saveForm() {
// saveFormApi("Новая форма", listBlock) if (oldTitleFrom !== newTitleForm) {
// .then((resolve, reject) => { await updateTitleForm()
// console.log(resolve); }
// setForms(
// [...forms, {
// id: nextID(forms),
// title: "Новая форма",
// questions: listBlock,
// answers: []
// }]
// );
cleanStates(); cleanStates();
navigate("/forms"); navigate("/forms");
// })
// .catch(error => console.log(error));
}; };
return ( return (
@ -230,14 +223,14 @@ const NewForm = () => {
</div> </div>
<div className={classes.header__listInput__title}> <div className={classes.header__listInput__title}>
<span>Название формы</span> <span>Название формы</span>
<input type="text" value={titleForm} onChange={event => setTitleForm(event.target.value)}/> <input type="text" value={newTitleForm} onChange={event => setNewTitleForm(event.target.value)}/>
</div> </div>
<MyButton {/* <MyButton
text={<i class="fa-solid fa-floppy-disk"></i>} text={<i class="fa-solid fa-floppy-disk"></i>}
click={() => updateTitleForm()} click={() => updateTitleForm()}
class={"main__green"} class={"main__green"}
otherStyle={{paddingLeft: "0.9rem", paddingRight: "0.9rem"}}> otherStyle={{paddingLeft: "0.9rem", paddingRight: "0.9rem"}}>
</MyButton> </MyButton> */}
</div> </div>
<div className={classes.header__listBtn}> <div className={classes.header__listBtn}>
<MyButton text={'Предпросмотр'} class={"main__white"} toggle={"modal"} target={"#previewModal"}/> <MyButton text={'Предпросмотр'} class={"main__white"} toggle={"modal"} target={"#previewModal"}/>