Продолжение

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 LinesApiService from '../service/LinesApiService';
import LinesItemForm from '../form/LinesItemForm.jsx';
// linesChangeHandle изменять состояние => при вызове изменения linesChangeHandle
// должно все перерисовываться
const UpdateNews = () => {
const [news, setNews] = useState([]);

View File

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