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