From 34d7e45ad674b3b40ffb4d465756268c34c1fb5e Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Wed, 19 Feb 2025 14:14:14 +0000 Subject: [PATCH] started --- src/Components/Map/Layer.tsx | 6 +++--- src/Components/Map/Subcomponents/ItemFormPopup.tsx | 8 ++++---- src/Components/Map/Subcomponents/ItemViewPopup.tsx | 8 ++++---- src/types/LayerProps.d.ts | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Components/Map/Layer.tsx b/src/Components/Map/Layer.tsx index a5071cb7..f9861925 100644 --- a/src/Components/Map/Layer.tsx +++ b/src/Components/Map/Layer.tsx @@ -48,7 +48,7 @@ export const Layer = ({ markerDefaultColor2 = 'RGBA(35, 31, 32, 0.2)', api, itemType, - onlyOnePerOwner = false, + userProfileLayer = false, customEditLink, customEditParameter, // eslint-disable-next-line camelcase @@ -100,7 +100,7 @@ export const Layer = ({ markerDefaultColor2, api, itemType, - onlyOnePerOwner, + userProfileLayer, // Can we just use editCallback for all cases? customEditLink, customEditParameter, @@ -126,7 +126,7 @@ export const Layer = ({ markerDefaultColor2, api, itemType, - onlyOnePerOwner, + userProfileLayer, customEditLink, customEditParameter, // eslint-disable-next-line camelcase diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index 48f9e0ff..fa574e24 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -93,10 +93,10 @@ export function ItemFormPopup(props: ItemFormPopupProps) { const uuid = crypto.randomUUID() let success = false try { - props.layer.onlyOnePerOwner && + props.layer.userProfileLayer && item && (await props.layer.api?.updateItem!({ ...formItem, id: item.id })) - ;(!props.layer.onlyOnePerOwner || !item) && + ;(!props.layer.userProfileLayer || !item) && (await props.layer.api?.createItem!({ ...formItem, id: uuid, @@ -108,8 +108,8 @@ export function ItemFormPopup(props: ItemFormPopupProps) { toast.error(error.toString()) } if (success) { - if (props.layer.onlyOnePerOwner && item) updateItem({ ...item, ...formItem }) - if (!props.layer.onlyOnePerOwner || !item) { + if (props.layer.userProfileLayer && item) updateItem({ ...item, ...formItem }) + if (!props.layer.userProfileLayer || !item) { addItem({ ...formItem, name: (formItem.name ? formItem.name : user?.first_name) ?? '', diff --git a/src/Components/Map/Subcomponents/ItemViewPopup.tsx b/src/Components/Map/Subcomponents/ItemViewPopup.tsx index 735a7bbb..4f4583c8 100644 --- a/src/Components/Map/Subcomponents/ItemViewPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemViewPopup.tsx @@ -60,9 +60,9 @@ export const ItemViewPopup = forwardRef((props: ItemViewPopupProps, ref: any) => setLoading(true) let success = false try { - !props.item.layer?.onlyOnePerOwner && + !props.item.layer?.userProfileLayer && (await props.item.layer?.api?.deleteItem!(props.item.id)) - props.item.layer?.onlyOnePerOwner && + props.item.layer?.userProfileLayer && (await props.item.layer.api?.updateItem!({ id: props.item.id, position: null })) success = true // eslint-disable-next-line no-catch-all/no-catch-all @@ -71,8 +71,8 @@ export const ItemViewPopup = forwardRef((props: ItemViewPopupProps, ref: any) => toast.error(error.toString()) } if (success) { - !props.item.layer?.onlyOnePerOwner && removeItem(props.item) - props.item.layer?.onlyOnePerOwner && updadateItem({ ...props.item, position: undefined }) + !props.item.layer?.userProfileLayer && removeItem(props.item) + props.item.layer?.userProfileLayer && updadateItem({ ...props.item, position: undefined }) toast.success('Item deleted') } setLoading(false) diff --git a/src/types/LayerProps.d.ts b/src/types/LayerProps.d.ts index e1b94b8b..44f55a95 100644 --- a/src/types/LayerProps.d.ts +++ b/src/types/LayerProps.d.ts @@ -21,7 +21,7 @@ export interface LayerProps { // eslint-disable-next-line @typescript-eslint/no-explicit-any api?: ItemsApi itemType: ItemType - onlyOnePerOwner?: boolean + userProfileLayer?: boolean customEditLink?: string customEditParameter?: string public_edit_items?: boolean