Select {selectNewItemPosition.name} position!
diff --git a/src/Components/Map/hooks/useSetItemPosition.tsx b/src/Components/Map/hooks/useSetItemPosition.tsx
new file mode 100644
index 00000000..d0f86219
--- /dev/null
+++ b/src/Components/Map/hooks/useSetItemPosition.tsx
@@ -0,0 +1,35 @@
+import { createContext, useContext, useState } from "react";
+import { Item, LayerProps } from '../../../types';
+
+type UseSelectPositionManagerResult = ReturnType
;
+
+const SelectPositionContext = createContext({
+ selectPosition: null,
+ setSelectPosition: () => { },
+});
+
+function useSelectPositionManager(): {
+ selectPosition: Item | LayerProps | null;
+ setSelectPosition: React.Dispatch>;
+} {
+ const [selectPosition, setSelectPosition] = useState(null);
+ return { selectPosition, setSelectPosition };
+}
+
+export const SelectPositionProvider: React.FunctionComponent<{
+ children?: React.ReactNode
+}> = ({ children }) => (
+
+ {children}
+
+);
+
+export const useSelectPosition = (): Item | LayerProps | null => {
+ const { selectPosition } = useContext(SelectPositionContext);
+ return selectPosition;
+};
+
+export const useSetSelectPosition = (): UseSelectPositionManagerResult["setSelectPosition"] => {
+ const { setSelectPosition } = useContext(SelectPositionContext);
+ return setSelectPosition;
+}
\ No newline at end of file
diff --git a/src/Components/Map/setItemLocation.tsx b/src/Components/Map/setItemLocation.tsx
new file mode 100644
index 00000000..e904a9e6
--- /dev/null
+++ b/src/Components/Map/setItemLocation.tsx
@@ -0,0 +1,10 @@
+import { useMap } from "react-leaflet"
+
+export const setItemLocation = () => {
+
+ const map = useMap();
+
+ return (
+
+ )
+}
diff --git a/src/Components/Profile/OverlayItemProfile.tsx b/src/Components/Profile/OverlayItemProfile.tsx
index de6c0692..5c829f94 100644
--- a/src/Components/Profile/OverlayItemProfile.tsx
+++ b/src/Components/Profile/OverlayItemProfile.tsx
@@ -3,7 +3,6 @@ import { useAddItem, useItems, useRemoveItem, useUpdateItem } from '../Map/hooks
import { useLocation, useNavigate } from 'react-router-dom'
import { useEffect, useRef, useState } from 'react';
import { Item } from '../../types';
-import { getValue } from '../../Utils/GetValue';
import { useMap } from 'react-leaflet';
import { LatLng } from 'leaflet';
import { PopupStartEndInput, StartEndView, TextView } from '../Map';
@@ -20,6 +19,8 @@ import { useLayers } from '../Map/hooks/useLayers';
import { ActionButton } from './ActionsButton';
import { LinkedItemsHeaderView } from './LinkedItemsHeaderView';
import { HeaderView } from '../Map/Subcomponents/ItemPopupComponents/HeaderView';
+import { useSelectPosition } from '../Map/hooks/useSetItemPosition';
+import { useLeafletRefs } from '../Map/hooks/useLeafletRefs';
export function OverlayItemProfile() {
@@ -33,6 +34,7 @@ export function OverlayItemProfile() {
const [updatePermission, setUpdatePermission] = useState(false);
const layers = useLayers();
+ const selectPosition = useSelectPosition();
const removeItem = useRemoveItem();
@@ -97,9 +99,9 @@ export function OverlayItemProfile() {
}, [location, items, activeTab])
- useEffect(() => {
+ useEffect(() => {
let params = new URLSearchParams(location.search);
- let urlTab = params.get("tab");
+ let urlTab = params.get("tab");
urlTab ? setActiveTab(Number(urlTab)) : setActiveTab(1);
}, [location])
@@ -119,6 +121,14 @@ export function OverlayItemProfile() {
}, [item])
+ const [selecting, setSelecting] = useState(false);
+
+ useEffect(() => {
+ selectPosition && map.closePopup();
+ }, [selectPosition])
+
+
+
const submitNewItem = async (evt: any, type: string) => {
evt.preventDefault();
const formItem: Item = {} as Item;
@@ -203,129 +213,133 @@ export function OverlayItemProfile() {
setLoading(true);
let success = false;
try {
- await item.layer?.api?.deleteItem!(item.id)
- success = true;
+ await item.layer?.api?.deleteItem!(item.id)
+ success = true;
} catch (error) {
- toast.error(error.toString());
+ toast.error(error.toString());
}
if (success) {
- removeItem(item);
- toast.success("Item deleted");
+ removeItem(item);
+ toast.success("Item deleted");
}
setLoading(false);
map.closePopup();
let params = new URLSearchParams(window.location.search);
window.history.pushState({}, "", "/" + `${params ? `?${params}` : ""}`);
navigate("/");
- }
-
-
+ }
+
+
return (
-
- {item &&
- <>
- navigate("/edit-item/"+item.id)} big/>
+ <>
+ {item &&
+
+
+ <>
+ navigate("/edit-item/" + item.id)} big />
-
+
-
-
updateActiveTab(1)} />
-
-
-
+
+
updateActiveTab(1)} />
+
+
+
-
updateActiveTab(2)} />
-
-
-
- {relations && relations.map(i => {
- if (i.type == 'project') return (
+
updateActiveTab(2)} />
+
+
+
+ {relations && relations.map(i => {
+ if (i.type == 'project') return (
-
navigate('/item/' + i.id)}>
-
+
navigate('/item/' + i.id)}>
+
-
-
- )
- else return null
- })}
- {addItemPopupType == "project" ?
-
-
-
updateActiveTab(3)} />
-
-
-
- {relations && relations.map(i => {
- if (i.type == 'event') return (
+
updateActiveTab(3)} />
+
+
+
+ {relations && relations.map(i => {
+ if (i.type == 'event') return (
-
navigate('/item/' + i.id)}>
-
-
-
-
+
navigate('/item/' + i.id)}>
+
+
+
+
+
-
- )
- else return null
- })}
- {addItemPopupType == "event" ?
-
-
-
updateActiveTab(4)} />
-
+
updateActiveTab(4)} />
+
+
-
- >
+ >
+
+
}
-
+ >
)
}
diff --git a/src/Components/Templates/ItemsIndexPage.tsx b/src/Components/Templates/ItemsIndexPage.tsx
index eb17d34f..780e75a6 100644
--- a/src/Components/Templates/ItemsIndexPage.tsx
+++ b/src/Components/Templates/ItemsIndexPage.tsx
@@ -14,7 +14,6 @@ import { hashTagRegex } from '../../Utils/HashTagRegex';
import { randomColor } from '../../Utils/RandomColor';
import { useAuth } from '../Auth';
import { useLayers } from '../Map/hooks/useLayers';
-import { PermissionsProvider } from '../Map/hooks/usePermissions';
import { HeaderView } from '../Map/Subcomponents/ItemPopupComponents/HeaderView';