diff --git a/src/Components/Map/Subcomponents/FilterControl.tsx b/src/Components/Map/Subcomponents/FilterControl.tsx index 6fdf08d9..68f9f86a 100644 --- a/src/Components/Map/Subcomponents/FilterControl.tsx +++ b/src/Components/Map/Subcomponents/FilterControl.tsx @@ -3,6 +3,11 @@ import { useFilterTags, useRemoveFilterTag, useSetSearchPhrase } from '../hooks/ +function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); + } + + export const FilterControl = () => { const filterTags = useFilterTags(); const removeFilterTag = useRemoveFilterTag(); @@ -16,7 +21,7 @@ export const FilterControl = () => {
-
#{tag.id} +
#{capitalizeFirstLetter(tag.id)} ) } diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index 1a47c8ab..fc295bee 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -63,7 +63,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) { await props.layer.api?.updateItem!({...formItem, id: props.item.id}); success = true; } catch (error) { - toast.error(error.toString); + toast.error(error.toString()); } if(success) { updateItem({...props.item, ...formItem}); @@ -79,7 +79,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) { await props.layer.api?.createItem!({...formItem, id: crypto.randomUUID()}); success = true; } catch (error) { - toast.error(error.toString); + toast.error(error.toString()); } if(success) { addItem({...formItem, id: crypto.randomUUID(), layer: props.layer}); diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx index a19f9665..b7d8ae77 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx @@ -4,6 +4,7 @@ import { useMap } from "react-leaflet"; import { ItemFormPopupProps } from "../ItemFormPopup"; import { LatLng } from "leaflet"; import { Item } from "../../../../types"; +import { toast } from "react-toastify"; @@ -17,13 +18,21 @@ export function HeaderView({ item, setItemFormPopup }: { const map = useMap(); - const removeItemFromMap = (event: React.MouseEvent) => { + const removeItemFromMap = async (event: React.MouseEvent) => { setLoading(true); - item.layer.api?.deleteItem!(item.id) - .then(() => removeItem(item)) - .then(() => map.closePopup()) - .then(()=>setLoading(false)) - .catch(err => console.log(err)); + let success = false; + try { + await item.layer.api?.deleteItem!(item.id) + success = true; + } catch (error) { + toast.error(error.toString()); + } + if(success) { + removeItem(item); + toast.success("Item deleted"); + } + setLoading(false); + map.closePopup(); event.stopPropagation(); } @@ -43,7 +52,7 @@ export function HeaderView({ item, setItemFormPopup }: {
{item.layer.api &&
-