From 4efa682b06a9cfff170a27ebda67ae013392c286 Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 24 Dec 2023 03:02:06 +0100 Subject: [PATCH] changed ItemFormPopup --- src/Components/Map/Subcomponents/ItemFormPopup.tsx | 9 ++++++--- .../Subcomponents/ItemPopupComponents/PopupTextInput.tsx | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index 69deea26..cbcacb2f 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -11,6 +11,7 @@ import { useResetFilterTags } from '../hooks/useFilter' import { hashTagRegex } from '../../../Utils/HashTagRegex' import { randomColor } from '../../../Utils/RandomColor' import { useAddTag, useTags } from '../hooks/useTags' +import { useAuth } from '../../Auth' export interface ItemFormPopupProps { position: LatLng, @@ -36,6 +37,8 @@ export function ItemFormPopup(props: ItemFormPopupProps) { const resetFilterTags = useResetFilterTags(); + const { user } = useAuth(); + const handleSubmit = async (evt: any) => { const formItem: Item = {} as Item; @@ -76,13 +79,13 @@ export function ItemFormPopup(props: ItemFormPopupProps) { let success = false; try { - await props.layer.api?.createItem!({...formItem, id: crypto.randomUUID()}); + await props.layer.api?.createItem!({...formItem, id: crypto.randomUUID() }); success = true; } catch (error) { toast.error(error.toString()); } if(success) { - addItem({...formItem, id: crypto.randomUUID(), layer: props.layer}); + addItem({...formItem, id: crypto.randomUUID(), layer: props.layer, user_created: user}); toast.success("New item created"); resetFilterTags(); } @@ -118,7 +121,6 @@ export function ItemFormPopup(props: ItemFormPopupProps) { :
New {props.layer.name}
} - {props.children ? @@ -129,6 +131,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) { : <> + } diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextInput.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextInput.tsx index e302ef48..89630493 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextInput.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextInput.tsx @@ -11,6 +11,6 @@ export const PopupTextInput = ({ dataField, placeholder, style, item }: }) => { return ( - + ) }