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) { :