mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2026-04-06 01:25:33 +00:00
Refactor: Use UrlHelper utilities in more components
Co-authored-by: antontranelis <31516529+antontranelis@users.noreply.github.com>
This commit is contained in:
parent
683d12b99f
commit
9092241461
@ -5,7 +5,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
||||||
/* eslint-disable @typescript-eslint/prefer-optional-chain */
|
/* eslint-disable @typescript-eslint/prefer-optional-chain */
|
||||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
import { LatLng } from 'leaflet'
|
import { LatLng } from 'leaflet'
|
||||||
import { forwardRef, useState } from 'react'
|
import { forwardRef, useState } from 'react'
|
||||||
@ -17,6 +16,7 @@ import { useRemoveItem, useUpdateItem } from '#components/Map/hooks/useItems'
|
|||||||
import { usePopupForm } from '#components/Map/hooks/usePopupForm'
|
import { usePopupForm } from '#components/Map/hooks/usePopupForm'
|
||||||
import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
|
import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
|
||||||
import { timeAgo } from '#utils/TimeAgo'
|
import { timeAgo } from '#utils/TimeAgo'
|
||||||
|
import { removeItemFromUrl } from '#utils/UrlHelper'
|
||||||
|
|
||||||
import { HeaderView } from './ItemPopupComponents/HeaderView'
|
import { HeaderView } from './ItemPopupComponents/HeaderView'
|
||||||
import { TextView } from './ItemPopupComponents/TextView'
|
import { TextView } from './ItemPopupComponents/TextView'
|
||||||
@ -80,8 +80,7 @@ export const ItemViewPopup = forwardRef((props: ItemViewPopupProps, ref: any) =>
|
|||||||
}
|
}
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
map.closePopup()
|
map.closePopup()
|
||||||
const params = new URLSearchParams(window.location.search)
|
removeItemFromUrl()
|
||||||
window.history.pushState({}, '', '/' + `${params ? `?${params}` : ''}`)
|
|
||||||
navigate('/')
|
navigate('/')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import { ActionButton } from '#components/Profile/Subcomponents/ActionsButton'
|
|||||||
import { LinkedItemsHeaderView } from '#components/Profile/Subcomponents/LinkedItemsHeaderView'
|
import { LinkedItemsHeaderView } from '#components/Profile/Subcomponents/LinkedItemsHeaderView'
|
||||||
import { TagView } from '#components/Templates/TagView'
|
import { TagView } from '#components/Templates/TagView'
|
||||||
import { timeAgo } from '#utils/TimeAgo'
|
import { timeAgo } from '#utils/TimeAgo'
|
||||||
|
import { setUrlParam } from '#utils/UrlHelper'
|
||||||
|
|
||||||
import type { Item } from '#types/Item'
|
import type { Item } from '#types/Item'
|
||||||
import type { Tag } from '#types/Tag'
|
import type { Tag } from '#types/Tag'
|
||||||
@ -67,11 +68,7 @@ export const TabsView = ({
|
|||||||
const updateActiveTab = useCallback(
|
const updateActiveTab = useCallback(
|
||||||
(id: number) => {
|
(id: number) => {
|
||||||
setActiveTab(id)
|
setActiveTab(id)
|
||||||
|
setUrlParam('tab', `${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
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
[location.pathname],
|
[location.pathname],
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { toast } from 'react-toastify'
|
|||||||
import { encodeTag } from '#utils/FormatTags'
|
import { encodeTag } from '#utils/FormatTags'
|
||||||
import { hashTagRegex } from '#utils/HashTagRegex'
|
import { hashTagRegex } from '#utils/HashTagRegex'
|
||||||
import { randomColor } from '#utils/RandomColor'
|
import { randomColor } from '#utils/RandomColor'
|
||||||
|
import { removeItemFromUrl } from '#utils/UrlHelper'
|
||||||
|
|
||||||
import type { FormState } from '#types/FormState'
|
import type { FormState } from '#types/FormState'
|
||||||
import type { Item } from '#types/Item'
|
import type { Item } from '#types/Item'
|
||||||
@ -185,8 +186,7 @@ export const handleDelete = async (
|
|||||||
toast.success('Item deleted')
|
toast.success('Item deleted')
|
||||||
|
|
||||||
map.closePopup()
|
map.closePopup()
|
||||||
const params = new URLSearchParams(window.location.search)
|
removeItemFromUrl()
|
||||||
window.history.pushState({}, '', '/' + `${params ? `?${params}` : ''}`)
|
|
||||||
navigate('/')
|
navigate('/')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error(error instanceof Error ? error.message : String(error))
|
toast.error(error instanceof Error ? error.message : String(error))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user