mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-21 04:19:37 +02:00
Fixed custom icons not updating
This commit is contained in:
parent
f93659b661
commit
1fbe0746a4
6 changed files with 76 additions and 15 deletions
|
@ -8,12 +8,11 @@ import classes from './AppForm.module.css';
|
|||
import ModalForm from '../../UI/Forms/ModalForm/ModalForm';
|
||||
import InputGroup from '../../UI/Forms/InputGroup/InputGroup';
|
||||
import Button from '../../UI/Buttons/Button/Button';
|
||||
import axios from 'axios';
|
||||
|
||||
interface ComponentProps {
|
||||
modalHandler: () => void;
|
||||
addApp: (formData: NewApp | FormData) => any;
|
||||
updateApp: (id: number, formData: NewApp) => any;
|
||||
updateApp: (id: number, formData: NewApp | FormData) => any;
|
||||
app?: App;
|
||||
}
|
||||
|
||||
|
@ -66,21 +65,32 @@ const AppForm = (props: ComponentProps): JSX.Element => {
|
|||
const formSubmitHandler = (e: SyntheticEvent<HTMLFormElement>): void => {
|
||||
e.preventDefault();
|
||||
|
||||
const createFormData = (): FormData => {
|
||||
const data = new FormData();
|
||||
if (customIcon) {
|
||||
data.append('icon', customIcon);
|
||||
}
|
||||
data.append('name', formData.name);
|
||||
data.append('url', formData.url);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
if (!props.app) {
|
||||
if (customIcon) {
|
||||
const data = new FormData();
|
||||
data.append('icon', customIcon);
|
||||
|
||||
data.append('name', formData.name);
|
||||
data.append('url', formData.url);
|
||||
|
||||
const data = createFormData();
|
||||
props.addApp(data);
|
||||
} else {
|
||||
props.addApp(formData);
|
||||
}
|
||||
} else {
|
||||
props.updateApp(props.app.id, formData);
|
||||
props.modalHandler();
|
||||
if (customIcon) {
|
||||
const data = createFormData();
|
||||
props.updateApp(props.app.id, data);
|
||||
} else {
|
||||
props.updateApp(props.app.id, formData);
|
||||
props.modalHandler();
|
||||
}
|
||||
}
|
||||
|
||||
setFormData({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue