diff --git a/src/assets/styles/tokensForm.module.scss b/src/assets/styles/tokensForm.module.scss new file mode 100644 index 0000000..4cec3d0 --- /dev/null +++ b/src/assets/styles/tokensForm.module.scss @@ -0,0 +1,172 @@ +.main { + width: 100%; + height: 100%; +} + +.wrapper { + width: 100%; + height: 100%; + display: flex; + justify-content: center; + align-items: center; +} + +.loading__wrapper { + width: 100%; + height: 80%; + display: flex; + justify-content: center; + align-items: center; + &__body { + // margin-top: 100px; + span { + + } + } +} + + +.answers { + width: 70%; + height: 70%; + box-shadow: 0 0 5px 1px rgb(200, 200, 200); + padding: 1.5%; + &__linkAdmin { + position: absolute; + bottom: 103%; + left: 10px; + span { + font-size: 15px; + font-family: "Montserrat", sans-serif; + color: rgb(100, 100, 100); + cursor: pointer; + &:hover { + text-decoration: underline; + color: rgb(66, 68, 189); + } + } + } + &__wrapper { + width: 100%; + height: 100%; + &__header { + width: 100%; + height: 15%; + display: flex; + justify-content: start; + align-items: center; + margin-bottom: 10px; + display: flex; + justify-content: space-between; + align-items: center; + h3 { + font-size: 25px; + font-family: "Montserrat", sans-serif; + color: rgb(100, 100, 100); + display: block; + } + + } + &__body { + width: 100%; + height: 85%; + overflow-y: auto; + border-bottom: 1px solid rgb(200, 200, 200); + &::-webkit-scrollbar { + width: 7px; + } + &::-webkit-scrollbar-thumb { + background-color: rgb(200, 200, 200); + } + &__column { + font-size: 15px; + width: 100%; + font-family: "Montserrat", sans-serif; + padding: 5px 30px 5px 5px; + border-bottom: 1px solid rgb(200, 200, 200); + &__wrapper { + display: flex; + justify-content: space-between; + align-items: center; + width: 90%; + } + } + &__item { + padding: 0 30px 0 5px; + // border-bottom: 1px solid rgb(200, 200, 200); + font-size: 15px; + font-family: "Montserrat", sans-serif; + height: 20%; + width: 100%; + display: flex; + justify-content: space-between; + align-items: center; + &:hover { + background-color: rgba(230, 230, 230, 0.6); + } + &__wrapper { + display: flex; + justify-content: space-between; + align-items: center; + width: 90%; + height: 100%; + &__title { + cursor: pointer; + &:hover { + text-decoration: underline; + } + } + &__token { + + } + } + &__btn { + width: 10%; + display: flex; + justify-content: space-around; + align-items: center; + padding: 0 5px; + font-size: 13px; + i { + display: block; + cursor: pointer; + } + i:first-child:hover { + color: rgb(42, 64, 187); + } + i:last-child:hover { + color: rgb(199, 73, 73); + } + } + } + } + } +} + +.myModal { + &__item { + padding: 5px; + border-bottom: 1px solid rgb(200, 200, 200); + font-size: 15px; + font-family: "Montserrat", sans-serif; + cursor: pointer; + &__question { + &__text { + font-size: 15px; + font-family: "Montserrat", sans-serif; + } + &__comment { + font-size: 11px; + font-family: "Montserrat", sans-serif; + font-style: italic; + color: rgb(200, 200, 200); + } + } + &__answer { + &__text { + font-size: 15px; + font-family: "Montserrat", sans-serif; + } + } + } +} \ No newline at end of file diff --git a/src/hooks/api/formApi.js b/src/hooks/api/formApi.js index 30c6de4..fc4b09e 100644 --- a/src/hooks/api/formApi.js +++ b/src/hooks/api/formApi.js @@ -33,10 +33,11 @@ async function addFormBlockApi(token, formId, data) { } }; -async function updateBlockApi(token, formId, data) { +async function updateBlockApi(token, formId, data, order) { try { const response = await axios.post(`https://api.minerva.krbl.ru/formBuilder/edit/${formId}/set`, { + order: order, data: data }, { @@ -51,6 +52,25 @@ async function updateBlockApi(token, formId, data) { } }; +async function removeBlockApi(token, formId, order) { + try { + const response = await axios.post(`https://api.minerva.krbl.ru/formBuilder/edit/${formId}/set`, + { + order: order, + delete_flag: true + }, + { + headers: { + "Authorization": `Token ${token}`, + } + }) + return response + } + catch (e) { + return e + } +}; + async function updateOrderBlockApi(token, formId, data) { try { const response = await axios.post(`https://api.minerva.krbl.ru/formBuilder/edit/${formId}/moveTo`, @@ -133,4 +153,4 @@ async function getAnswersApi(token, formToken) { } }; -export { addFormBlockApi, listFormBlockApi, saveFormApi, updateBlockApi, updateOrderBlockApi, listFormBlockByTokenApi, saveAnswersApi, getAnswersApi } \ No newline at end of file +export { addFormBlockApi, listFormBlockApi, saveFormApi, updateBlockApi, updateOrderBlockApi, listFormBlockByTokenApi, saveAnswersApi, getAnswersApi, removeBlockApi } \ No newline at end of file diff --git a/src/hooks/api/listFormsApi.js b/src/hooks/api/listFormsApi.js index 4471f63..c8cac56 100644 --- a/src/hooks/api/listFormsApi.js +++ b/src/hooks/api/listFormsApi.js @@ -95,4 +95,22 @@ async function listFormsByTokenApi(token, formId) { } }; -export { listFormsApi, createFormApi, removeFormApi, updateTitleFormApi, newFormTokenApi, listFormsByTokenApi }; \ No newline at end of file +async function removeTokenFormApi(token, formId, formToken) { + try { + const response = await axios.post(`https://api.minerva.krbl.ru/formBuilder/edit/${formId}/access/revoke`, + { + "token_id": formToken + }, + { + headers: { + "Authorization": `Token ${token}` + } + }) + return response + } + catch (e) { + return e + } +} + +export { listFormsApi, createFormApi, removeFormApi, updateTitleFormApi, newFormTokenApi, listFormsByTokenApi, removeTokenFormApi }; \ No newline at end of file diff --git a/src/pages/Forms.jsx b/src/pages/Forms.jsx index fdecb80..236ee7e 100644 --- a/src/pages/Forms.jsx +++ b/src/pages/Forms.jsx @@ -119,6 +119,7 @@ const Forms = () => {
diff --git a/src/pages/NewForm.jsx b/src/pages/NewForm.jsx index 00ec8e8..41015bd 100644 --- a/src/pages/NewForm.jsx +++ b/src/pages/NewForm.jsx @@ -7,7 +7,7 @@ import AnswerModal from "../components/AnswerModal.jsx"; import PreviewModal from "../components/PreviewModal.jsx" import { FormsData, TypeAnswerData } from "../context"; import { listFormsApi, updateTitleFormApi } from "../hooks/api/listFormsApi.js"; -import { saveFormApi, addFormBlockApi, listFormBlockApi, updateBlockApi, updateOrderBlockApi } from "../hooks/api/formApi.js"; +import { saveFormApi, addFormBlockApi, listFormBlockApi, updateBlockApi, updateOrderBlockApi, removeBlockApi } from "../hooks/api/formApi.js"; import { responseDataToListBlock } from "../hooks/sundry/parseListBlock.js"; import MyInput from "../components/MyInput.jsx"; @@ -89,7 +89,7 @@ const NewForm = () => { setCurrentOptionAnswer(""); }; - function editAnswerByForm(id) { + function editAnswerByForm(id, order) { const obj = listBlock.find(item => item.id === id); setQuestion(obj.question); setComment(obj.comment); @@ -112,7 +112,12 @@ const NewForm = () => { typeAnswer: currentTypeAnswer, } - const response = await updateBlockApi(cookies.token, formId, data); + const response = await updateBlockApi( + cookies.token, + formId, + data, + listBlock.find(item => item.id === stateModal).order + ); console.log(response) if (response.status === 200) { @@ -130,6 +135,17 @@ const NewForm = () => { cleanStates(); }; + async function removeBlock(order) { + const response = await removeBlockApi(cookies.token, formId, order) + + if (response.status === 200) { + setListBlock([...listBlock.filter(item => item.order !== order)]); + } + else { + console.log(response) + } + } + async function addFormBlock() { const newBlock = { question: question, @@ -304,7 +320,7 @@ const NewForm = () => {