Skip to content

Commit

Permalink
feat: save modal content
Browse files Browse the repository at this point in the history
  • Loading branch information
topliceanurazvan committed May 20, 2022
1 parent 7c14f42 commit bcb16eb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/components/organisms/FiltersPresetModal/FiltersPresetModal.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import {Modal} from 'antd';
import React, {Suspense} from 'react';

import {Form, Modal, Skeleton} from 'antd';

import {useAppDispatch, useAppSelector} from '@redux/hooks';
import {closeFiltersPresetModal} from '@redux/reducers/ui';

const SaveModalContent = React.lazy(() => import('./SaveModalContent'));

const FiltersPresetModal: React.FC = () => {
const dispatch = useAppDispatch();
const uiState = useAppSelector(state => state.ui.filtersPresetModal);

const [form] = Form.useForm();

if (!uiState) {
return null;
}
Expand All @@ -16,7 +22,13 @@ const FiltersPresetModal: React.FC = () => {
};

const onOk = () => {
dispatch(closeFiltersPresetModal());
form.validateFields().then(values => {
const {name} = values;

console.log(name);

dispatch(closeFiltersPresetModal());
});
};

return (
Expand All @@ -26,7 +38,10 @@ const FiltersPresetModal: React.FC = () => {
onCancel={onCancel}
onOk={onOk}
>
<div>Test</div>
<Suspense fallback={<Skeleton />}>
{uiState.type === 'load' && null}
{uiState.type === 'save' && <SaveModalContent form={form} />}
</Suspense>
</Modal>
);
};
Expand Down
19 changes: 19 additions & 0 deletions src/components/organisms/FiltersPresetModal/SaveModalContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Form, FormInstance, Input} from 'antd';

interface IProps {
form: FormInstance<any>;
}

const SaveModalContent: React.FC<IProps> = props => {
const {form} = props;

return (
<Form form={form} layout="vertical">
<Form.Item name="name" label="Preset name" rules={[{required: true, message: 'Preset name is required'}]}>
<Input id="filters-preset-name-input" placeholder="Enter preset name" />
</Form.Item>
</Form>
);
};

export default SaveModalContent;

0 comments on commit bcb16eb

Please sign in to comment.