diff --git a/src/Components/Map/UtopiaMapInner.tsx b/src/Components/Map/UtopiaMapInner.tsx
index c8f682fa..0c3b3d2b 100644
--- a/src/Components/Map/UtopiaMapInner.tsx
+++ b/src/Components/Map/UtopiaMapInner.tsx
@@ -15,7 +15,6 @@ import { toast } from 'react-toastify'
import './UtopiaMap.css'
import { containsUUID } from '#utils/ContainsUUID'
-import { getValue } from '#utils/GetValue'
import { useClusterRef, useSetClusterRef } from './hooks/useClusterRef'
import { useAddVisibleLayer } from './hooks/useFilter'
@@ -75,9 +74,10 @@ export function UtopiaMapInner({
setTimeout(() => {
toast(
<>
-
@@ -120,7 +120,6 @@ export function UtopiaMapInner({
}
let title = ''
if (item?.name) title = item.name
- else if (item?.layer?.itemNameField) title = getValue(item, item.layer.itemNameField)
document.title = `${document.title.split('-')[0]} - ${title}`
}
},
@@ -142,8 +141,6 @@ export function UtopiaMapInner({
})
let title = ''
if (ref.item.name) title = ref.item.name
- else if (ref.item.layer?.itemNameField)
- title = getValue(ref.item.name, ref.item.layer.itemNameField)
document.title = `${document.title.split('-')[0]} - ${title}`
document
.querySelector('meta[property="og:title"]')
diff --git a/src/Components/Map/hooks/useSelectPosition.tsx b/src/Components/Map/hooks/useSelectPosition.tsx
index d00fa4d9..e53e0193 100644
--- a/src/Components/Map/hooks/useSelectPosition.tsx
+++ b/src/Components/Map/hooks/useSelectPosition.tsx
@@ -63,7 +63,7 @@ function useSelectPositionManager(): {
if ('menuIcon' in selectPosition) {
mapClicked &&
mapClicked.setItemFormPopup({
- layer: selectPosition as LayerProps,
+ layer: selectPosition,
position: mapClicked.position,
})
setSelectPosition(null)
diff --git a/src/Components/Map/hooks/useTags.tsx b/src/Components/Map/hooks/useTags.tsx
index f80e96ad..4649b627 100644
--- a/src/Components/Map/hooks/useTags.tsx
+++ b/src/Components/Map/hooks/useTags.tsx
@@ -5,12 +5,8 @@
/* eslint-disable @typescript-eslint/prefer-optional-chain */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
-/* eslint-disable @typescript-eslint/no-unsafe-assignment */
-/* eslint-disable @typescript-eslint/no-unsafe-call */
-/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { useCallback, useReducer, createContext, useContext, useState } from 'react'
-import { getValue } from '#utils/GetValue'
import { hashTagRegex } from '#utils/HashTagRegex'
import type { Item } from '#types/Item'
@@ -96,8 +92,7 @@ function useTagsManager(initialTags: Tag[]): {
const getItemTags = useCallback(
(item: Item) => {
- const text =
- item.layer?.itemTextField && item ? getValue(item, item.layer.itemTextField) : undefined
+ const text = item.text
const itemTagStrings = text?.match(hashTagRegex)
const itemTags: Tag[] = []
itemTagStrings?.map((tag) => {
@@ -108,18 +103,15 @@ function useTagsManager(initialTags: Tag[]): {
}
return null
})
- item.layer?.itemOffersField &&
- getValue(item, item.layer.itemOffersField)?.map((o) => {
- const offer = tags.find((t) => t.id === o.tags_id)
- offer && itemTags.push(offer)
- return null
- })
- item.layer?.itemNeedsField &&
- getValue(item, item.layer.itemNeedsField)?.map((n) => {
- const need = tags.find((t) => t.id === n.tags_id)
- need && itemTags.push(need)
- return null
- })
+ // Could be refactored as it occurs in multiple places
+ item.offers?.forEach((o) => {
+ const offer = tags.find((t) => t.id === o.tags_id)
+ offer && itemTags.push(offer)
+ })
+ item.needs?.forEach((n) => {
+ const need = tags.find((t) => t.id === n.tags_id)
+ need && itemTags.push(need)
+ })
return itemTags
},
diff --git a/src/Components/Profile/ProfileForm.tsx b/src/Components/Profile/ProfileForm.tsx
index c5339657..806d1a05 100644
--- a/src/Components/Profile/ProfileForm.tsx
+++ b/src/Components/Profile/ProfileForm.tsx
@@ -1,8 +1,5 @@
-/* eslint-disable @typescript-eslint/no-unsafe-member-access */
-/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
-/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { useEffect, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
@@ -14,7 +11,6 @@ import { useLayers } from '#components/Map/hooks/useLayers'
import { useHasUserPermission } from '#components/Map/hooks/usePermissions'
import { useAddTag, useGetItemTags, useTags } from '#components/Map/hooks/useTags'
import { MapOverlayPage } from '#components/Templates'
-import { getValue } from '#utils/GetValue'
import { linkItem, onUpdateItem, unlinkItem } from './itemFunctions'
import { FormHeader } from './Subcomponents/FormHeader'
@@ -23,11 +19,12 @@ import { OnepagerForm } from './Templates/OnepagerForm'
import { SimpleForm } from './Templates/SimpleForm'
import { TabsForm } from './Templates/TabsForm'
+import type { FormState } from '#types/FormState'
import type { Item } from '#types/Item'
import type { Tag } from '#types/Tag'
export function ProfileForm() {
- const [state, setState] = useState({
+ const [state, setState] = useState
({
color: '',
id: '',
group_type: 'wuerdekompass',
@@ -91,11 +88,9 @@ export function ProfileForm() {
useEffect(() => {
const newColor =
- item.layer?.itemColorField && getValue(item, item.layer.itemColorField)
- ? getValue(item, item.layer.itemColorField)
- : getItemTags(item) && getItemTags(item)[0]?.color
- ? getItemTags(item)[0].color
- : item.layer?.markerDefaultColor
+ (item.color ?? (getItemTags(item) && getItemTags(item)[0]?.color))
+ ? getItemTags(item)[0].color
+ : item.layer?.markerDefaultColor
const offers = (item.offers ?? []).reduce((acc: Tag[], o) => {
const offer = tags.find((t) => t.id === o.tags_id)
@@ -116,7 +111,7 @@ export function ProfileForm() {
}, [])
setState({
- color: newColor,
+ color: newColor ?? '',
id: item?.id ?? '',
group_type: item?.group_type ?? '',
status: item?.status ?? '',
@@ -127,7 +122,8 @@ export function ProfileForm() {
telephone: item?.telephone ?? '',
next_appointment: item?.next_appointment ?? '',
image: item?.image ?? '',
- marker_icon: item?.marker_icon ?? '',
+ // Do we actually mean marker_icon here?
+ marker_icon: item?.markerIcon ?? '',
offers,
needs,
relations,
@@ -140,7 +136,7 @@ export function ProfileForm() {
const [template, setTemplate] = useState('')
useEffect(() => {
- setTemplate(item.layer?.itemType.template || appState.userType)
+ setTemplate(item.layer?.itemType.template ?? appState.userType)
}, [appState.userType, item])
return (
@@ -198,7 +194,8 @@ export function ProfileForm() {
className={loading ? ' tw-loading tw-btn tw-float-right' : 'tw-btn tw-float-right'}
type='submit'
style={{
- backgroundColor: `${item.layer?.itemColorField && getValue(item, item.layer?.itemColorField) ? getValue(item, item.layer?.itemColorField) : getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item?.layer?.markerDefaultColor}`,
+ // We could refactor this, it is used several times at different locations
+ backgroundColor: `${(item.color ?? (getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color)) ? getItemTags(item)[0].color : item?.layer?.markerDefaultColor}`,
color: '#fff',
}}
>
diff --git a/src/Components/Profile/ProfileView.tsx b/src/Components/Profile/ProfileView.tsx
index 76c42aec..b4b05b5e 100644
--- a/src/Components/Profile/ProfileView.tsx
+++ b/src/Components/Profile/ProfileView.tsx
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
-/* eslint-disable @typescript-eslint/await-thenable */
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
-/* eslint-disable @typescript-eslint/no-floating-promises */
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import { LatLng } from 'leaflet'
@@ -21,7 +21,6 @@ import { useSelectPosition, useSetSelectPosition } from '#components/Map/hooks/u
import { useTags } from '#components/Map/hooks/useTags'
import { HeaderView } from '#components/Map/Subcomponents/ItemPopupComponents/HeaderView'
import { MapOverlayPage } from '#components/Templates'
-import { getValue } from '#utils/GetValue'
import { handleDelete, linkItem, unlinkItem } from './itemFunctions'
import { FlexView } from './Templates/FlexView'
@@ -32,6 +31,7 @@ import { TabsView } from './Templates/TabsView'
import type { Item } from '#types/Item'
import type { ItemsApi } from '#types/ItemsApi'
import type { Tag } from '#types/Tag'
+import type { Marker } from 'leaflet'
export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi }) {
const [item, setItem] = useState- ()
@@ -88,30 +88,25 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi
setNeeds([])
setRelations([])
- item?.layer?.itemOffersField &&
- getValue(item, item.layer.itemOffersField)?.map((o) => {
- const tag = tags.find((t) => t.id === o.tags_id)
- tag && setOffers((current) => [...current, tag])
- return null
- })
- item?.layer?.itemNeedsField &&
- getValue(item, item.layer.itemNeedsField)?.map((n) => {
- const tag = tags.find((t) => t.id === n.tags_id)
- tag && setNeeds((current) => [...current, tag])
- return null
- })
- item?.relations?.map((r) => {
+ item?.offers?.forEach((o) => {
+ const tag = tags.find((t) => t.id === o.tags_id)
+ tag && setOffers((current) => [...current, tag])
+ })
+ item?.needs?.forEach((n) => {
+ const tag = tags.find((t) => t.id === n.tags_id)
+ tag && setNeeds((current) => [...current, tag])
+ })
+ item?.relations?.forEach((r) => {
const item = items.find((i) => i.id === r.related_items_id)
item && setRelations((current) => [...current, item])
- return null
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [item, items])
useEffect(() => {
- const setMap = async (marker, x) => {
- await map.setView(
+ const setMap = (marker: Marker, x: number) => {
+ map.setView(
new LatLng(item?.position?.coordinates[1]!, item?.position?.coordinates[0]! + x / 4),
undefined,
)
@@ -164,7 +159,7 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi
}, [selectPosition])
useEffect(() => {
- setTemplate(item?.layer?.itemType.template || appState.userType)
+ setTemplate(item?.layer?.itemType.template ?? appState.userType)
}, [appState.userType, item])
return (
diff --git a/src/Components/Profile/Subcomponents/ActionsButton.tsx b/src/Components/Profile/Subcomponents/ActionsButton.tsx
index 7eea5e44..e08a2652 100644
--- a/src/Components/Profile/Subcomponents/ActionsButton.tsx
+++ b/src/Components/Profile/Subcomponents/ActionsButton.tsx
@@ -10,7 +10,6 @@ import { useHasUserPermission } from '#components/Map/hooks/usePermissions'
import { useGetItemTags } from '#components/Map/hooks/useTags'
import { HeaderView } from '#components/Map/Subcomponents/ItemPopupComponents/HeaderView'
import DialogModal from '#components/Templates/DialogModal'
-import { getValue } from '#utils/GetValue'
import type { Item } from '#types/Item'
@@ -20,7 +19,6 @@ export function ActionButton({
triggerItemSelected,
existingRelations,
itemType,
- colorField,
collection = 'items',
customStyle,
}: {
@@ -28,7 +26,6 @@ export function ActionButton({
triggerItemSelected?: any
existingRelations: Item[]
itemType?: string
- colorField?: string
collection?: string
customStyle?: string
item: Item
@@ -58,7 +55,7 @@ export function ActionButton({
setModalOpen(true)
}}
style={{
- backgroundColor: `${colorField && getValue(item, colorField) ? getValue(item, colorField) : getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item.layer?.markerDefaultColor}`,
+ backgroundColor: `${(item.color ?? (getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color)) ? getItemTags(item)[0].color : item.layer?.markerDefaultColor}`,
color: '#fff',
}}
>
@@ -82,7 +79,7 @@ export function ActionButton({
triggerAddButton()
}}
style={{
- backgroundColor: `${colorField && getValue(item, colorField) ? getValue(item, colorField) : getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color ? getItemTags(item)[0].color : item.layer?.markerDefaultColor}`,
+ backgroundColor: `${(item.color ?? (getItemTags(item) && getItemTags(item)[0] && getItemTags(item)[0].color)) ? getItemTags(item)[0].color : item.layer?.markerDefaultColor}`,
color: '#fff',
}}
>
diff --git a/src/Components/Profile/Subcomponents/ContactInfoView.tsx b/src/Components/Profile/Subcomponents/ContactInfoView.tsx
index a8368d24..34e6b8fa 100644
--- a/src/Components/Profile/Subcomponents/ContactInfoView.tsx
+++ b/src/Components/Profile/Subcomponents/ContactInfoView.tsx
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
-/* eslint-disable @typescript-eslint/restrict-template-expressions */
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/restrict-plus-operands */
import { useEffect, useState } from 'react'
diff --git a/src/Components/Profile/Subcomponents/LinkedItemsHeaderView.tsx b/src/Components/Profile/Subcomponents/LinkedItemsHeaderView.tsx
index 57dd0ce9..7fc88804 100644
--- a/src/Components/Profile/Subcomponents/LinkedItemsHeaderView.tsx
+++ b/src/Components/Profile/Subcomponents/LinkedItemsHeaderView.tsx
@@ -4,46 +4,29 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/restrict-plus-operands */
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
-/* eslint-disable @typescript-eslint/no-unsafe-assignment */
+
import { useEffect } from 'react'
import { useAppState } from '#components/AppShell/hooks/useAppState'
-import { getValue } from '#utils/GetValue'
import type { Item } from '#types/Item'
export function LinkedItemsHeaderView({
item,
unlinkCallback,
- itemNameField,
- itemAvatarField,
loading,
unlinkPermission,
- itemSubnameField,
}: {
item: Item
unlinkCallback?: any
- itemNameField?: string
- itemAvatarField?: string
- itemSubnameField?: string
loading?: boolean
unlinkPermission: boolean
}) {
const appState = useAppState()
- const avatar =
- itemAvatarField && getValue(item, itemAvatarField)
- ? appState.assetsApi.url + getValue(item, itemAvatarField)
- : item.layer?.itemAvatarField &&
- item &&
- getValue(item, item.layer?.itemAvatarField) &&
- appState.assetsApi.url + getValue(item, item.layer?.itemAvatarField)
- const title = itemNameField
- ? getValue(item, itemNameField)
- : item.layer?.itemNameField && item && getValue(item, item.layer.itemNameField)
- const subtitle = itemSubnameField
- ? getValue(item, itemSubnameField)
- : item.layer?.itemSubnameField && item && getValue(item, item.layer.itemSubnameField)
+ const avatar = appState.assetsApi.url + item.avatar
+ const title = item.name
+ const subtitle = item.subname
useEffect(() => {}, [item])
diff --git a/src/Components/Profile/Subcomponents/ProfileTextForm.tsx b/src/Components/Profile/Subcomponents/ProfileTextForm.tsx
index 1d72a3b3..2620aecd 100644
--- a/src/Components/Profile/Subcomponents/ProfileTextForm.tsx
+++ b/src/Components/Profile/Subcomponents/ProfileTextForm.tsx
@@ -5,7 +5,6 @@
import { useEffect, useState } from 'react'
import { TextAreaInput } from '#components/Input'
-import { getValue } from '#utils/GetValue'
import { MarkdownHint } from './MarkdownHint'
@@ -14,6 +13,7 @@ import type { FormState } from '#types/FormState'
export const ProfileTextForm = ({
state,
setState,
+ // Is this really used?
dataField,
heading,
size,
@@ -49,7 +49,8 @@ export const ProfileTextForm = ({