Продолжение
This commit is contained in:
parent
4e0eb5ccfa
commit
77bb8d1170
File diff suppressed because one or more lines are too long
@ -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([]);
|
||||||
|
@ -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,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user