mirror of
https://github.com/pawelmalak/flame.git
synced 2026-02-28 09:23:12 +08:00
Fixed custom icons not updating
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user