mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-27 06:49:37 +02:00
Fixed bug where user could create empty app or bookmark which was causing page to go blank
This commit is contained in:
parent
668edb03d3
commit
0b3eb2e87f
5 changed files with 29 additions and 7 deletions
|
@ -18,10 +18,8 @@ export const AppForm = ({ modalHandler }: Props): JSX.Element => {
|
|||
const { appInUpdate } = useSelector((state: State) => state.apps);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const { addApp, updateApp, setEditApp } = bindActionCreators(
|
||||
actionCreators,
|
||||
dispatch
|
||||
);
|
||||
const { addApp, updateApp, setEditApp, createNotification } =
|
||||
bindActionCreators(actionCreators, dispatch);
|
||||
|
||||
const [useCustomIcon, toggleUseCustomIcon] = useState<boolean>(false);
|
||||
const [customIcon, setCustomIcon] = useState<File | null>(null);
|
||||
|
@ -58,6 +56,17 @@ export const AppForm = ({ modalHandler }: Props): JSX.Element => {
|
|||
const formSubmitHandler = (e: SyntheticEvent<HTMLFormElement>): void => {
|
||||
e.preventDefault();
|
||||
|
||||
for (let field of ['name', 'url', 'icon'] as const) {
|
||||
if (/^ +$/.test(formData[field])) {
|
||||
createNotification({
|
||||
title: 'Error',
|
||||
message: `Field cannot be empty: ${field}`,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const createFormData = (): FormData => {
|
||||
const data = new FormData();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue