mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-03 01:45:17 +02:00
Merge branch 'master' of https://github.com/pawelmalak/flame into merge_upstream_2020-12-06
This commit is contained in:
commit
021bd4e85a
266 changed files with 13470 additions and 7067 deletions
54
client/src/components/Bookmarks/Form/Form.tsx
Normal file
54
client/src/components/Bookmarks/Form/Form.tsx
Normal file
|
@ -0,0 +1,54 @@
|
|||
import { Fragment } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
|
||||
import { State } from '../../../store/reducers';
|
||||
import { bookmarkCategoryTemplate, bookmarkTemplate } from '../../../utility';
|
||||
import { ContentType } from '../Bookmarks';
|
||||
import { BookmarksForm } from './BookmarksForm';
|
||||
import { CategoryForm } from './CategoryForm';
|
||||
|
||||
// Typescript
|
||||
// Utils
|
||||
interface Props {
|
||||
modalHandler: () => void;
|
||||
contentType: ContentType;
|
||||
inUpdate?: boolean;
|
||||
}
|
||||
|
||||
export const Form = (props: Props): JSX.Element => {
|
||||
const { categoryInEdit, bookmarkInEdit } = useSelector(
|
||||
(state: State) => state.bookmarks
|
||||
);
|
||||
|
||||
const { modalHandler, contentType, inUpdate } = props;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{!inUpdate ? (
|
||||
// form: add new
|
||||
<Fragment>
|
||||
{contentType === ContentType.category ? (
|
||||
<CategoryForm modalHandler={modalHandler} />
|
||||
) : (
|
||||
<BookmarksForm modalHandler={modalHandler} />
|
||||
)}
|
||||
</Fragment>
|
||||
) : (
|
||||
// form: update
|
||||
<Fragment>
|
||||
{contentType === ContentType.category ? (
|
||||
<CategoryForm
|
||||
modalHandler={modalHandler}
|
||||
category={categoryInEdit || bookmarkCategoryTemplate}
|
||||
/>
|
||||
) : (
|
||||
<BookmarksForm
|
||||
modalHandler={modalHandler}
|
||||
bookmark={bookmarkInEdit || bookmarkTemplate}
|
||||
/>
|
||||
)}
|
||||
</Fragment>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue