Продолжение

This commit is contained in:
DyCTaTOR 2023-12-22 16:30:44 +04:00
parent 4e0eb5ccfa
commit 77bb8d1170
3 changed files with 33 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,8 @@ import useLinesDeleteModal from '../hooks/LinesDeleteModalHook';
import useLinesFormModal from '../hooks/LinesFormModalHook'; import useLinesFormModal from '../hooks/LinesFormModalHook';
import LinesApiService from '../service/LinesApiService'; import LinesApiService from '../service/LinesApiService';
import LinesItemForm from '../form/LinesItemForm.jsx'; import LinesItemForm from '../form/LinesItemForm.jsx';
// linesChangeHandle изменять состояние => при вызове изменения linesChangeHandle
// должно все перерисовываться
const UpdateNews = () => { const UpdateNews = () => {
const [news, setNews] = useState([]); const [news, setNews] = useState([]);

View File

@ -7,6 +7,8 @@ import useLinesItem from './LinesItemHook';
const useLinesItemForm = (id, linesChangeHandle) => { const useLinesItemForm = (id, linesChangeHandle) => {
const { item, setItem } = useLinesItem(id); const { item, setItem } = useLinesItem(id);
const [modified, setModified] = useState(false);
const [validated, setValidated] = useState(false); const [validated, setValidated] = useState(false);
const resetValidity = () => { const resetValidity = () => {
@ -22,9 +24,9 @@ const useLinesItemForm = (id, linesChangeHandle) => {
}; };
const getLineObject = (formData) => { const getLineObject = (formData) => {
const date = getRealDate; const date = getRealDate();
const name = toString(formData.description); const name = formData.name.toString();
const description = toString(formData.description); const description = formData.description.toString();
const image = formData.image.startsWith('data:image') ? formData.image : ''; const image = formData.image.startsWith('data:image') ? formData.image : '';
return { return {
date: date.toString(), date: date.toString(),
@ -69,6 +71,7 @@ const useLinesItemForm = (id, linesChangeHandle) => {
} }
if (linesChangeHandle) linesChangeHandle(); if (linesChangeHandle) linesChangeHandle();
toast.success('Элемент успешно сохранен', { id: 'LinesTable' }); toast.success('Элемент успешно сохранен', { id: 'LinesTable' });
setModified(true);
return true; return true;
} }
setValidated(true); setValidated(true);
@ -81,6 +84,7 @@ const useLinesItemForm = (id, linesChangeHandle) => {
handleSubmit, handleSubmit,
handleChange, handleChange,
resetValidity, resetValidity,
isModified: modified,
}; };
}; };