diff --git a/client/src/components/Apps/AppForm/AppForm.tsx b/client/src/components/Apps/AppForm/AppForm.tsx index 8a71b4e..0674cd0 100644 --- a/client/src/components/Apps/AppForm/AppForm.tsx +++ b/client/src/components/Apps/AppForm/AppForm.tsx @@ -3,11 +3,11 @@ import { connect } from 'react-redux'; import { addApp, updateApp } from '../../../store/actions'; import { App, NewApp } from '../../../interfaces/App'; -import classes from './AppForm.module.css'; -import Icon from '../../UI/Icons/Icon/Icon'; +import ModalForm from '../../UI/Forms/ModalForm/ModalForm'; +import InputGroup from '../../UI/Forms/InputGroup/InputGroup'; interface ComponentProps { - modalHandler: Function; + modalHandler: () => void; addApp: (formData: NewApp) => any; updateApp: (id: number, formData: NewApp) => any; app?: App; @@ -30,7 +30,6 @@ const AppForm = (props: ComponentProps): JSX.Element => { useEffect(() => { if (props.app) { - console.log('app'); setFormData({ name: props.app.name, url: props.app.url, @@ -39,10 +38,6 @@ const AppForm = (props: ComponentProps): JSX.Element => { } }, [props.app]) - const _modalHandler = () => { - props.modalHandler(); - } - const inputChangeHandler = (e: ChangeEvent): void => { setFormData({ ...formData, @@ -50,7 +45,7 @@ const AppForm = (props: ComponentProps): JSX.Element => { }) } - const formSubmitHandler = (e: SyntheticEvent): void => { + const formSubmitHandler = (e: SyntheticEvent): void => { e.preventDefault(); if (!props.app) { @@ -68,63 +63,61 @@ const AppForm = (props: ComponentProps): JSX.Element => { } return ( -
-
- -
-
formSubmitHandler(e)}> -
- - inputChangeHandler(e)} - ref={inputRef} - /> -
-
- - inputChangeHandler(e)} - /> - Use URL without protocol -
-
- - inputChangeHandler(e)} - /> - - Use icon name from MDI. - - {' '}Click here for reference - - -
- {!props.app - ? - : - } -
-
+ + + + inputChangeHandler(e)} + ref={inputRef} + /> + + + + inputChangeHandler(e)} + /> + Use URL without protocol + + + + inputChangeHandler(e)} + /> + + Use icon name from MDI. + + {' '}Click here for reference + + + + {!props.app + ? + : + } + ) } diff --git a/client/src/components/Apps/AppForm/AppForm.module.css b/client/src/components/UI/Forms/InputGroup/InputGroup.module.css similarity index 57% rename from client/src/components/Apps/AppForm/AppForm.module.css rename to client/src/components/UI/Forms/InputGroup/InputGroup.module.css index 7a451ea..d8b9fca 100644 --- a/client/src/components/Apps/AppForm/AppForm.module.css +++ b/client/src/components/UI/Forms/InputGroup/InputGroup.module.css @@ -1,24 +1,3 @@ -.AppForm { - background-color: var(--color-background); - color: var(--color-primary); - border-radius: 6px; - width: 60%; - position: relative; - /* height: 50vh; */ - padding: 50px 50px; -} - -.AppFormIcon { - width: 40px; - position: absolute; - right: 5px; - top: 5px; -} - -.AppFormIcon:hover { - cursor: pointer; -} - .InputGroup { margin-bottom: 15px; } diff --git a/client/src/components/UI/Forms/InputGroup/InputGroup.tsx b/client/src/components/UI/Forms/InputGroup/InputGroup.tsx new file mode 100644 index 0000000..d39f139 --- /dev/null +++ b/client/src/components/UI/Forms/InputGroup/InputGroup.tsx @@ -0,0 +1,15 @@ +import classes from './InputGroup.module.css'; + +interface ComponentProps { + children: JSX.Element | JSX.Element[]; +} + +const InputGroup = (props: ComponentProps): JSX.Element => { + return ( +
+ {props.children} +
+ ) +} + +export default InputGroup; \ No newline at end of file diff --git a/client/src/components/UI/Forms/ModalForm/ModalForm.module.css b/client/src/components/UI/Forms/ModalForm/ModalForm.module.css new file mode 100644 index 0000000..641d68c --- /dev/null +++ b/client/src/components/UI/Forms/ModalForm/ModalForm.module.css @@ -0,0 +1,20 @@ +.ModalForm { + background-color: var(--color-background); + color: var(--color-primary); + border-radius: 6px; + width: 60%; + position: relative; + /* height: 50vh; */ + padding: 50px 50px; +} + +.ModalFormIcon { + width: 40px; + position: absolute; + right: 5px; + top: 5px; +} + +.ModalFormIcon:hover { + cursor: pointer; +} \ No newline at end of file diff --git a/client/src/components/UI/Forms/ModalForm/ModalForm.tsx b/client/src/components/UI/Forms/ModalForm/ModalForm.tsx new file mode 100644 index 0000000..7ab2eac --- /dev/null +++ b/client/src/components/UI/Forms/ModalForm/ModalForm.tsx @@ -0,0 +1,31 @@ +import { SyntheticEvent } from 'react'; + +import classes from './ModalForm.module.css'; +import Icon from '../../Icons/Icon/Icon'; + +interface ComponentProps { + children: JSX.Element | JSX.Element[]; + modalHandler?: () => void; + formHandler: (e: SyntheticEvent) => void; +} + +const ModalForm = (props: ComponentProps): JSX.Element => { + const _modalHandler = (): void => { + if (props.modalHandler) { + props.modalHandler(); + } + } + + return ( +
+
+ +
+
props.formHandler(e)}> + {props.children} +
+
+ ) +} + +export default ModalForm; \ No newline at end of file