diff --git a/src/Components/Profile/itemFunctions.ts b/src/Components/Profile/itemFunctions.ts
index ffbd1709..309a0f18 100644
--- a/src/Components/Profile/itemFunctions.ts
+++ b/src/Components/Profile/itemFunctions.ts
@@ -20,10 +20,11 @@ export const submitNewItem = async (evt: any, type: string, item, user, setLoadi
if (!tags.find((t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) {
addTag({ id: crypto.randomUUID(), name: tag.slice(1), color: randomColor() })
}
+ return null
})
const uuid = crypto.randomUUID()
- const layer = layers.find(l => l.name.toLocaleLowerCase().replace('s', '') == addItemPopupType.toLocaleLowerCase())
+ const layer = layers.find(l => l.name.toLocaleLowerCase().replace('s', '') === addItemPopupType.toLocaleLowerCase())
let success = false
try {
@@ -43,9 +44,9 @@ export const submitNewItem = async (evt: any, type: string, item, user, setLoadi
}
export const linkItem = async (id: string, item, updateItem) => {
- const new_relations = item.relations || []
- new_relations?.push({ items_id: item.id, related_items_id: id })
- const updatedItem = { id: item.id, relations: new_relations }
+ const newRelations = item.relations || []
+ newRelations?.push({ items_id: item.id, related_items_id: id })
+ const updatedItem = { id: item.id, relations: newRelations }
let success = false
try {
@@ -55,14 +56,14 @@ export const linkItem = async (id: string, item, updateItem) => {
toast.error(error.toString())
}
if (success) {
- updateItem({ ...item, relations: new_relations })
+ updateItem({ ...item, relations: newRelations })
toast.success('Item linked')
}
}
export const unlinkItem = async (id: string, item, updateItem) => {
- const new_relations = item.relations?.filter(r => r.related_items_id !== id)
- const updatedItem = { id: item.id, relations: new_relations }
+ const newRelations = item.relations?.filter(r => r.related_items_id !== id)
+ const updatedItem = { id: item.id, relations: newRelations }
let success = false
try {
@@ -72,7 +73,7 @@ export const unlinkItem = async (id: string, item, updateItem) => {
toast.error(error.toString())
}
if (success) {
- updateItem({ ...item, relations: new_relations })
+ updateItem({ ...item, relations: newRelations })
toast.success('Item unlinked')
}
}
@@ -101,22 +102,24 @@ export const handleDelete = async (event: React.MouseEvent
, item, s
export const onUpdateItem = async (state, item, tags, addTag, setLoading, navigate, updateItem, addItem, user, params) => {
let changedItem = {} as Item
- const offer_updates: Array = []
+ const offerUpdates: Array = []
// check for new offers
await state.offers?.map(o => {
const existingOffer = item?.offers?.find(t => t.tags_id === o.id)
- existingOffer && offer_updates.push(existingOffer.id)
+ existingOffer && offerUpdates.push(existingOffer.id)
if (!existingOffer && !tags.some(t => t.id === o.id)) addTag({ ...o, offer_or_need: true })
- !existingOffer && offer_updates.push({ items_id: item?.id, tags_id: o.id })
+ !existingOffer && offerUpdates.push({ items_id: item?.id, tags_id: o.id })
+ return null
})
- const needs_updates: Array = []
+ const needsUpdates: Array = []
await state.needs?.map(n => {
const existingNeed = item?.needs?.find(t => t.tags_id === n.id)
- existingNeed && needs_updates.push(existingNeed.id)
- !existingNeed && needs_updates.push({ items_id: item?.id, tags_id: n.id })
+ existingNeed && needsUpdates.push(existingNeed.id)
+ !existingNeed && needsUpdates.push({ items_id: item?.id, tags_id: n.id })
!existingNeed && !tags.some(t => t.id === n.id) && addTag({ ...n, offer_or_need: true })
+ return null
})
// update profile item in current state
@@ -136,22 +139,24 @@ export const onUpdateItem = async (state, item, tags, addTag, setLoading, naviga
...state.markerIcon && { markerIcon: state.markerIcon },
next_appointment: state.nextAppointment,
...state.image.length > 10 && { image: state.image },
- ...state.offers.length > 0 && { offers: offer_updates },
- ...state.needs.length > 0 && { needs: needs_updates }
+ ...state.offers.length > 0 && { offers: offerUpdates },
+ ...state.needs.length > 0 && { needs: needsUpdates }
}
- const offers_state: Array = []
- const needs_state: Array = []
+ const offersState: Array = []
+ const needsState: Array = []
state.offers.map(o => {
- offers_state.push({ items_id: item?.id, tags_id: o.id })
+ offersState.push({ items_id: item?.id, tags_id: o.id })
+ return null
})
state.needs.map(n => {
- needs_state.push({ items_id: item?.id, tags_id: n.id })
+ needsState.push({ items_id: item?.id, tags_id: n.id })
+ return null
})
- changedItem = { ...changedItem, offers: offers_state, needs: needs_state }
+ changedItem = { ...changedItem, offers: offersState, needs: needsState }
setLoading(true)
@@ -159,6 +164,7 @@ export const onUpdateItem = async (state, item, tags, addTag, setLoading, naviga
if (!tags.find((t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) {
addTag({ id: crypto.randomUUID(), name: encodeTag(tag.slice(1).toLocaleLowerCase()), color: randomColor() })
}
+ return null
})
// take care that addTag request comes before item request
diff --git a/src/Components/Templates/AttestationForm.tsx b/src/Components/Templates/AttestationForm.tsx
index 52c9b6f0..0c19604b 100644
--- a/src/Components/Templates/AttestationForm.tsx
+++ b/src/Components/Templates/AttestationForm.tsx
@@ -16,8 +16,8 @@ export const AttestationForm = ({ api }:{api?:ItemsApi}) => {
useEffect(() => {
const params = new URLSearchParams(location.search)
- const to_user_ids = params.get('to')
- setUsers(items.filter(i => to_user_ids?.includes(i.id)))
+ const toUserIds = params.get('to')
+ setUsers(items.filter(i => toUserIds?.includes(i.id)))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [items, location])
diff --git a/src/Components/Templates/DateUserInfo.tsx b/src/Components/Templates/DateUserInfo.tsx
index adf3c9f8..7415923e 100644
--- a/src/Components/Templates/DateUserInfo.tsx
+++ b/src/Components/Templates/DateUserInfo.tsx
@@ -9,7 +9,7 @@ export const DateUserInfo = ({ item }: { item: Item }) => {
{
infoExpanded
- ? setInfoExpanded(false)} >{`${item.date_updated && item.date_updated != item.date_created ? 'updated' : 'posted'} ${item && item.user_created && item.user_created.first_name ? `by ${item.user_created.first_name}` : ''} ${item.date_updated ? timeAgo(item.date_updated) : timeAgo(item.date_created!)}`}
+ ? setInfoExpanded(false)} >{`${item.date_updated && item.date_updated !== item.date_created ? 'updated' : 'posted'} ${item && item.user_created && item.user_created.first_name ? `by ${item.user_created.first_name}` : ''} ${item.date_updated ? timeAgo(item.date_updated) : timeAgo(item.date_created!)}`}
: setInfoExpanded(true)}>ⓘ
}
diff --git a/src/Components/Templates/EmojiPicker.tsx b/src/Components/Templates/EmojiPicker.tsx
index e9b4102a..e08957f7 100644
--- a/src/Components/Templates/EmojiPicker.tsx
+++ b/src/Components/Templates/EmojiPicker.tsx
@@ -39,7 +39,7 @@ export const EmojiPicker = ({ selectedEmoji, selectedColor, selectedShape, setSe
<>
{selectedEmoji}
@@ -51,7 +51,7 @@ export const EmojiPicker = ({ selectedEmoji, selectedColor, selectedShape, setSe
@@ -62,7 +62,7 @@ export const EmojiPicker = ({ selectedEmoji, selectedColor, selectedShape, setSe
{shapes.map(shape => (
@@ -73,7 +73,7 @@ export const EmojiPicker = ({ selectedEmoji, selectedColor, selectedShape, setSe
{colors.map(color => (
diff --git a/src/Components/Templates/MarketView.tsx b/src/Components/Templates/MarketView.tsx
index 65adda58..2606f57b 100644
--- a/src/Components/Templates/MarketView.tsx
+++ b/src/Components/Templates/MarketView.tsx
@@ -38,11 +38,14 @@ export const MarketView = () => {
i?.layer?.itemOffersField && getValue(i, i.layer.itemOffersField)?.map(o => {
const tag = tags.find(t => t.id === o.tags_id)
tag && setOffers(current => [...current, tag])
+ return null
})
i?.layer?.itemNeedsField && getValue(i, i.layer.itemNeedsField)?.map(n => {
const tag = tags.find(t => t.id === n.tags_id)
tag && setNeeds(current => [...current, tag])
+ return null
})
+ return null
})
console.log(offers)
diff --git a/src/Components/Templates/OverlayItemsIndexPage.tsx b/src/Components/Templates/OverlayItemsIndexPage.tsx
index b2261691..456068a0 100644
--- a/src/Components/Templates/OverlayItemsIndexPage.tsx
+++ b/src/Components/Templates/OverlayItemsIndexPage.tsx
@@ -46,7 +46,7 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, plusButt
const filterTags = useFilterTags()
const getItemTags = useGetItemTags()
- const layer = layers.find(l => l.name == layerName)
+ const layer = layers.find(l => l.name === layerName)
const submitNewItem = async (evt: any) => {
evt.preventDefault()
@@ -61,6 +61,7 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, plusButt
if (!tags.find((t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) {
addTag({ id: crypto.randomUUID(), name: tag.slice(1), color: randomColor() })
}
+ return null
})
const uuid = crypto.randomUUID()
let success = false
@@ -109,7 +110,7 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, plusButt
{
items?.filter(i => i.layer?.name === layerName)
.filter(item =>
- filterTags.length == 0 ? item : filterTags.some(tag => getItemTags(item).some(filterTag => filterTag.name.toLocaleLowerCase() === tag.name.toLocaleLowerCase())))
+ filterTags.length === 0 ? item : filterTags.some(tag => getItemTags(item).some(filterTag => filterTag.name.toLocaleLowerCase() === tag.name.toLocaleLowerCase())))
?.sort((a, b) => {
// Convert date_created to milliseconds, handle undefined by converting to lowest possible date (0 milliseconds)
const dateA = a.date_updated ? new Date(a.date_updated).getTime() : a.date_created ? new Date(a.date_created).getTime() : 0
@@ -122,7 +123,7 @@ export const OverlayItemsIndexPage = ({ url, layerName, parameterField, plusButt
))
}
- {addItemPopupType == 'place' && (
+ {addItemPopupType === 'place' && (