mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-21 04:19:37 +02:00
Split categories and bookmarks forms into separate files. Added visibility functionality to categories and bookmarks
This commit is contained in:
parent
f127a354ef
commit
d83e3056c6
16 changed files with 484 additions and 369 deletions
|
@ -14,7 +14,7 @@ interface Props {
|
|||
app?: App;
|
||||
}
|
||||
|
||||
export const AppForm = (props: Props): JSX.Element => {
|
||||
export const AppForm = ({ app, modalHandler }: Props): JSX.Element => {
|
||||
const dispatch = useDispatch();
|
||||
const { addApp, updateApp } = bindActionCreators(actionCreators, dispatch);
|
||||
|
||||
|
@ -23,14 +23,14 @@ export const AppForm = (props: Props): JSX.Element => {
|
|||
const [formData, setFormData] = useState<NewApp>(newAppTemplate);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.app) {
|
||||
if (app) {
|
||||
setFormData({
|
||||
...props.app,
|
||||
...app,
|
||||
});
|
||||
} else {
|
||||
setFormData(newAppTemplate);
|
||||
}
|
||||
}, [props.app]);
|
||||
}, [app]);
|
||||
|
||||
const inputChangeHandler = (
|
||||
e: ChangeEvent<HTMLInputElement | HTMLSelectElement>,
|
||||
|
@ -61,11 +61,12 @@ export const AppForm = (props: Props): JSX.Element => {
|
|||
}
|
||||
data.append('name', formData.name);
|
||||
data.append('url', formData.url);
|
||||
data.append('isPublic', `${formData.isPublic}`);
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
if (!props.app) {
|
||||
if (!app) {
|
||||
if (customIcon) {
|
||||
const data = createFormData();
|
||||
addApp(data);
|
||||
|
@ -75,10 +76,10 @@ export const AppForm = (props: Props): JSX.Element => {
|
|||
} else {
|
||||
if (customIcon) {
|
||||
const data = createFormData();
|
||||
updateApp(props.app.id, data);
|
||||
updateApp(app.id, data);
|
||||
} else {
|
||||
updateApp(props.app.id, formData);
|
||||
props.modalHandler();
|
||||
updateApp(app.id, formData);
|
||||
modalHandler();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,10 +87,7 @@ export const AppForm = (props: Props): JSX.Element => {
|
|||
};
|
||||
|
||||
return (
|
||||
<ModalForm
|
||||
modalHandler={props.modalHandler}
|
||||
formHandler={formSubmitHandler}
|
||||
>
|
||||
<ModalForm modalHandler={modalHandler} formHandler={formSubmitHandler}>
|
||||
{/* NAME */}
|
||||
<InputGroup>
|
||||
<label htmlFor="name">App Name</label>
|
||||
|
@ -184,7 +182,7 @@ export const AppForm = (props: Props): JSX.Element => {
|
|||
</select>
|
||||
</InputGroup>
|
||||
|
||||
{!props.app ? (
|
||||
{!app ? (
|
||||
<Button>Add new application</Button>
|
||||
) : (
|
||||
<Button>Update application</Button>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue