diff --git a/src/Components/Input/TextAreaInput.tsx b/src/Components/Input/TextAreaInput.tsx
index 3f9959e8..f0d21c17 100644
--- a/src/Components/Input/TextAreaInput.tsx
+++ b/src/Components/Input/TextAreaInput.tsx
@@ -63,7 +63,7 @@ export function TextAreaInput({ labelTitle, dataField, labelStyle, containerStyl
{labelTitle ? : ""}
-
+
)
}
diff --git a/src/Components/Input/TextInput.tsx b/src/Components/Input/TextInput.tsx
index 4370da9d..11cf066e 100644
--- a/src/Components/Input/TextInput.tsx
+++ b/src/Components/Input/TextInput.tsx
@@ -22,7 +22,7 @@ export function TextInput({labelTitle, labelStyle, type, dataField, containerSty
{labelTitle}
: " "}
- updateFormValue&& updateFormValue(e.target.value)}className={`tw-input tw-input-bordered tw-w-full ${inputStyle ? inputStyle : ""}`} />
+ updateFormValue&& updateFormValue(e.target.value)}className={`tw-input tw-input-bordered tw-w-full ${inputStyle ? inputStyle : ""}`} />
)
}
diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx
index 67618dd9..137f7904 100644
--- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx
+++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx
@@ -9,6 +9,7 @@ import { TextInput } from '../../Input/TextInput'
import { hashTagRegex } from '../../../Utils/HashTagRegex'
import { useAddTag } from '../hooks/useTags'
import { randomColor } from '../../../Utils/RandomColor'
+import { toast } from 'react-toastify'
export interface ItemFormPopupProps {
position: LatLng,
@@ -29,7 +30,6 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
const addItem = useAddItem();
const updateItem = useUpdateItem();
- const addTag = useAddTag();
const handleSubmit = async (evt: any) => {
const formItem: Item = {} as Item;
@@ -42,17 +42,29 @@ export function ItemFormPopup(props: ItemFormPopupProps) {
evt.preventDefault();
setSpinner(true);
- formItem.text.toLocaleLowerCase().match(hashTagRegex)?.map(tag=> {
- addTag({id: tag.slice(1), color: randomColor()})
- });
if (props.item) {
- await updateItem({...props.item, ...formItem});
+ let success = false;
+ try {
+ await props.layer.api?.updateItem!({...formItem, id: props.item.id});
+ success = true;
+ } catch (error) {
+ console.log();
+ }
+ success&&updateItem({...props.item, ...formItem});
setSpinner(false);
map.closePopup();
}
else {
- await addItem({...formItem, id: crypto.randomUUID(), layer: props.layer});
+
+ let success = false;
+ try {
+ await props.layer.api?.createItem!({...formItem, id: crypto.randomUUID()});
+ success = true;
+ } catch (error) {
+ toast.error(error.toString);
+ }
+ success&&addItem({...formItem, id: crypto.randomUUID(), layer: props.layer});
setSpinner(false);
map.closePopup();
}
diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx
index ac95e4bd..d025fda2 100644
--- a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx
+++ b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx
@@ -13,6 +13,8 @@ export const TextView = ({ item }: { item?: Item }) => {
const tags = useTags();
const addTag = useAddTag();
+ const groupRef = useRef(null);
+
const addFilterTag = useAddFilterTag();
const resetFilterTags = useResetFilterTags();
@@ -64,7 +66,8 @@ export const TextView = ({ item }: { item?: Item }) => {
return (
{
addFilterTag(tag!);
- map.closePopup();
+ // map.fitBounds(items)
+ // map.closePopup();
}}>{match}
)
})
diff --git a/src/Components/Map/hooks/useItems.tsx b/src/Components/Map/hooks/useItems.tsx
index d6ebfa9e..f159a922 100644
--- a/src/Components/Map/hooks/useItems.tsx
+++ b/src/Components/Map/hooks/useItems.tsx
@@ -107,8 +107,7 @@ function useItemsManager(initialItems: Item[]): {
}, []);
- const addItem = useCallback(async (item: Item) => {
- await item.layer.api?.createItem!(item);
+ const addItem = useCallback(async (item: Item) => {
dispatch({
type: "ADD",
item,
@@ -117,7 +116,6 @@ function useItemsManager(initialItems: Item[]): {
}, []);
const updateItem = useCallback(async (item: Item) => {
- await item.layer.api?.updateItem!(item);
dispatch({
type: "UPDATE",
item,