/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/prefer-optional-chain */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/restrict-plus-operands */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable react/prop-types */ import { useCallback, useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' import { TextAreaInput } from '#components/Input' import { useUpdateItem } from '#components/Map/hooks/useItems' import { PopupStartEndInput, TextView } from '#components/Map/Subcomponents/ItemPopupComponents' import { ActionButton } from '#components/Profile/Subcomponents/ActionsButton' import { LinkedItemsHeaderView } from '#components/Profile/Subcomponents/LinkedItemsHeaderView' import { TagsWidget } from '#components/Profile/Subcomponents/TagsWidget' export const TabsForm = ({ item, state, setState, updatePermission, linkItem, unlinkItem, loading, setUrlParams, }) => { const [activeTab, setActiveTab] = useState(1) const navigate = useNavigate() const updateItem = useUpdateItem() 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) setUrlParams(params) }, // 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_input && ( setState((prevState) => ({ ...prevState, end: e, })) } updateStartValue={(s) => setState((prevState) => ({ ...prevState, start: s, })) } > )} setState((prevState) => ({ ...prevState, text: v, })) } containerStyle='tw:grow' inputStyle={`tw:h-full ${!item.layer.itemType.show_start_end_input && 'tw:border-t-0 tw:rounded-tl-none'}`} /> setState((prevState) => ({ ...prevState, contact: c, })) } inputStyle='' containerStyle='tw:pt-4 tw:h-24 tw:flex-none' required={false} />
{item.layer?.itemType.offers_and_needs && ( <> updateActiveTab(3)} />
setState((prevState) => ({ ...prevState, offers: v, })) } placeholder='enter your offers' containerStyle='tw:bg-transparent tw:w-full tw:h-full tw:mt-3 tw:text-xs tw:h-[calc(100%-1rem)] tw:min-h-[5em] tw:pb-2 tw:overflow-auto' />
setState((prevState) => ({ ...prevState, needs: v, })) } placeholder='enter your needs' containerStyle='tw:bg-transparent tw:w-full tw:h-full tw:mt-3 tw:text-xs tw:h-[calc(100%-1rem)] tw:min-h-[5em] tw:pb-2 tw:overflow-auto' />
)} {item.layer?.itemType.relations && ( <> updateActiveTab(7)} />
{state.relations && state.relations.map((i) => (
navigate('/item/' + i.id)} > unlinkItem(id, item, updateItem)} loading={loading} />
))} {updatePermission && ( linkItem(id, item, updateItem)} > )}
)}
) }