/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/no-unnecessary-condition */ /* eslint-disable @typescript-eslint/prefer-optional-chain */ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/restrict-plus-operands */ /* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { useCallback, useEffect, useRef, useState } from 'react' import { Link, useNavigate } from 'react-router-dom' import { useAppState } from '#components/AppShell/hooks/useAppState' import { StartEndView, TextView } from '#components/Map' import { useAddFilterTag } from '#components/Map/hooks/useFilter' import { useItems } from '#components/Map/hooks/useItems' import { ActionButton } from '#components/Profile/Subcomponents/ActionsButton' import { LinkedItemsHeaderView } from '#components/Profile/Subcomponents/LinkedItemsHeaderView' import { TagView } from '#components/Templates/TagView' import { timeAgo } from '#utils/TimeAgo' import type { Item } from '#types/Item' import type { Tag } from '#types/Tag' export const TabsView = ({ attestations, item, offers, needs, relations, updatePermission, loading, linkItem, unlinkItem, }: { attestations: any[] item: Item offers: Tag[] needs: Tag[] relations: Item[] updatePermission: boolean loading: boolean linkItem: (id: string) => Promise unlinkItem: (id: string) => Promise }) => { const addFilterTag = useAddFilterTag() const [activeTab, setActiveTab] = useState() const navigate = useNavigate() const [addItemPopupType] = useState('') const items = useItems() const appState = useAppState() const getUserProfile = (id: string) => { return items.find( (i) => i.user_created.id === id && i.layer?.itemType.name === appState.userType, ) } useEffect(() => { scroll() }, [addItemPopupType]) function scroll() { tabRef.current?.scrollIntoView() } const tabRef = useRef(null) const updateActiveTab = useCallback( (id: number) => { setActiveTab(id) const params = new URLSearchParams(window.location.search) params.set('tab', `${id}`) const newUrl = location.pathname + '?' + params.toString() window.history.pushState({}, '', newUrl) }, // eslint-disable-next-line react-hooks/exhaustive-deps [location.pathname], ) useEffect(() => { const params = new URLSearchParams(location.search) const urlTab = params.get('tab') setActiveTab(urlTab ? Number(urlTab) : 1) // eslint-disable-next-line react-hooks/exhaustive-deps }, [location.search]) return (
updateActiveTab(1)} />
{item.layer?.itemType.show_start_end && (
)}
{item.layer?.itemType.questlog && ( <> updateActiveTab(2)} />
{attestations .filter((a) => a.to.some((t) => t.directus_users_id === item.user_created.id)) .sort( (a, b) => new Date(b.date_created).getTime() - new Date(a.date_created).getTime(), ) .map((a, i) => ( ))}
{a.emoji}
{a.text}
Avatar Tailwind CSS Component
{getUserProfile(a.user_created.id)?.name}
{timeAgo(a.date_created)}
)} {item.layer?.itemType.offers_and_needs && ( <> updateActiveTab(3)} />
{offers.length > 0 ? (

Offers

{offers.map((o) => ( { addFilterTag(o) }} /> ))}
) : ( '' )} {needs.length > 0 ? (

Needs

{needs.map((n) => ( addFilterTag(n)} /> ))}
) : ( '' )}
)} {item.layer?.itemType.relations && ( <> updateActiveTab(7)} />
{relations && relations.map((i) => (
navigate('/item/' + i.id)} >
))} {updatePermission && ( )}
)}
) }