1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-04 10:25:17 +02:00

Moved entityInUpdate to app state. It applies for apps, categories and bookmarks

This commit is contained in:
Paweł Malak 2021-11-22 14:36:00 +01:00
parent d110d9b732
commit dfdd49cf4a
15 changed files with 197 additions and 81 deletions

View file

@ -1,22 +1,26 @@
// Typescript
import { Bookmark, Category } from '../../../interfaces';
import { ContentType } from '../Bookmarks';
// Utils
import { CategoryForm } from './CategoryForm';
import { BookmarksForm } from './BookmarksForm';
import { Fragment } from 'react';
import { useSelector } from 'react-redux';
import { State } from '../../../store/reducers';
import { bookmarkTemplate, categoryTemplate } from '../../../utility';
interface Props {
modalHandler: () => void;
contentType: ContentType;
inUpdate?: boolean;
category?: Category;
bookmark?: Bookmark;
}
export const Form = (props: Props): JSX.Element => {
const { modalHandler, contentType, inUpdate, category, bookmark } = props;
const { categoryInEdit, bookmarkInEdit } = useSelector(
(state: State) => state.bookmarks
);
const { modalHandler, contentType, inUpdate } = props;
return (
<Fragment>
@ -33,9 +37,15 @@ export const Form = (props: Props): JSX.Element => {
// form: update
<Fragment>
{contentType === ContentType.category ? (
<CategoryForm modalHandler={modalHandler} category={category} />
<CategoryForm
modalHandler={modalHandler}
category={categoryInEdit || categoryTemplate}
/>
) : (
<BookmarksForm modalHandler={modalHandler} bookmark={bookmark} />
<BookmarksForm
modalHandler={modalHandler}
bookmark={bookmarkInEdit || bookmarkTemplate}
/>
)}
</Fragment>
)}