Merge branch 'main' into show-past-items

This commit is contained in:
mahula 2025-11-19 14:42:33 +01:00 committed by GitHub
commit b939dd9b3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 1930 additions and 422 deletions

165
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,165 @@
version: 2
updates:
# ============================================================================
# NPM ECOSYSTEM - Main Application & Library
# ============================================================================
# Main App (Frontend)
- package-ecosystem: "npm"
directory: "/app"
schedule:
interval: "weekly"
day: "wednesday"
time: "03:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 99
groups:
react-ecosystem:
patterns:
- "react"
- "react-dom"
- "@types/react"
- "@types/react-dom"
typescript-eslint:
patterns:
- "@typescript-eslint/parser"
- "@typescript-eslint/eslint-plugin"
labels:
- "dependencies"
- "javascript"
# Library (utopia-ui)
- package-ecosystem: "npm"
directory: "/lib"
schedule:
interval: "weekly"
day: "wednesday"
time: "03:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 99
groups:
react-ecosystem:
patterns:
- "react"
- "react-dom"
- "@types/react"
- "@types/react-dom"
tiptap:
patterns:
- "@tiptap/core"
- "@tiptap/extension-*"
- "@tiptap/pm"
- "@tiptap/react"
- "@tiptap/starter-kit"
typescript-eslint:
patterns:
- "@typescript-eslint/parser"
- "@typescript-eslint/eslint-plugin"
labels:
- "dependencies"
- "javascript"
# Backend Extensions
- package-ecosystem: "npm"
directory: "/backend/extensions"
schedule:
interval: "weekly"
day: "wednesday"
time: "03:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 99
labels:
- "dependencies"
- "javascript"
# Cypress E2E Tests
- package-ecosystem: "npm"
directory: "/cypress"
schedule:
interval: "weekly"
day: "wednesday"
time: "03:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 99
labels:
- "dependencies"
- "javascript"
# ============================================================================
# NPM ECOSYSTEM - Library Examples (Lower Priority)
# ============================================================================
# Example 1: Basic Map
- package-ecosystem: "npm"
directory: "/lib/examples/1-basic-map"
schedule:
interval: "weekly"
day: "wednesday"
time: "03:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 99
groups:
react-ecosystem:
patterns:
- "react"
- "react-dom"
- "@types/react"
- "@types/react-dom"
labels:
- "dependencies"
- "javascript"
# Example 2: Static Layers
- package-ecosystem: "npm"
directory: "/lib/examples/2-static-layers"
schedule:
interval: "weekly"
day: "wednesday"
time: "03:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 99
groups:
react-ecosystem:
patterns:
- "react"
- "react-dom"
- "@types/react"
- "@types/react-dom"
labels:
- "dependencies"
- "javascript"
# Example 3: Tags
- package-ecosystem: "npm"
directory: "/lib/examples/3-tags"
schedule:
interval: "weekly"
day: "wednesday"
time: "03:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 99
groups:
react-ecosystem:
patterns:
- "react"
- "react-dom"
- "@types/react"
- "@types/react-dom"
labels:
- "dependencies"
- "javascript"
# ============================================================================
# GITHUB ACTIONS ECOSYSTEM
# ============================================================================
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "wednesday"
time: "03:00"
timezone: "Europe/Berlin"
open-pull-requests-limit: 99
labels:
- "dependencies"
- "github_actions"

View File

@ -140,7 +140,7 @@ jobs:
- name: Upload test artifacts on failure
if: failure()
uses: actions/upload-artifact@2848b2cda0e5190984587ec6bb1f36730ca78d50 # v4.6.2
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v4.6.2
with:
name: cypress-test-results-${{ github.run_id }}
path: |
@ -170,7 +170,7 @@ jobs:
working-directory: ./cypress
- name: Download test artifacts
uses: actions/download-artifact@4a24838f3d5601fd639834081e118c2995d51e1c # v5.0.0
uses: actions/download-artifact@f093f21ca4cfa7c75ccbbc2be54da76a0c7e1f05 # v5.0.0
with:
name: cypress-test-results-${{ github.run_id }}
path: ./cypress
@ -191,7 +191,7 @@ jobs:
GITHUB_SHA: ${{ github.sha }}
- name: Upload consolidated test report
uses: actions/upload-artifact@2848b2cda0e5190984587ec6bb1f36730ca78d50 # v4.6.2
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v4.6.2
with:
name: e2e-test-report-${{ github.run_id }}
path: cypress/results/html/
@ -200,7 +200,7 @@ jobs:
- name: Upload raw test data (for debugging)
if: failure()
uses: actions/upload-artifact@2848b2cda0e5190984587ec6bb1f36730ca78d50 # v4.6.2
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v4.6.2
with:
name: e2e-raw-data-${{ github.run_id }}
path: |

View File

@ -32,6 +32,8 @@ jobs:
backend
app
lib
deps
deps-dev
docu
docker
release
@ -76,4 +78,4 @@ jobs:
# special "[WIP]" prefix to indicate this state. This will avoid the
# validation of the PR title and the pull request checks remain pending.
# Note that a second check will be reported if this is enabled.
wip: true
wip: true

View File

@ -23,8 +23,23 @@ Utopia Map is made for networks and initiatives that aim to connect people in r
Clone the repository and get started with the following commands:
**Start docker**
```bash
npm install
docker compose up -d
```
**Initialize backend**
```bash
sudo chmod 777 -R ./data/
cd backend/
./push.sh
./seed.sh
```
After this the frontend is running on http://localhost:8080 and the backend on http://localhost:8055
**Start dev server**
```bash
cd app/
npm run dev
```

83
app/package-lock.json generated
View File

@ -23,7 +23,7 @@
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
"@types/node": "^22.15.28",
"@types/node": "^24.10.1",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@typescript-eslint/eslint-plugin": "^5.62.0",
@ -47,7 +47,7 @@
"eslint-plugin-yml": "^1.14.0",
"postcss": "^8.4.30",
"tailwindcss": "^4.0.15",
"typescript": "^5.0.2",
"typescript": "^5.9.3",
"vite": "^6.2.0",
"vite-plugin-pwa": "^0.21.1"
},
@ -1660,6 +1660,7 @@
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.4.3.tgz",
"integrity": "sha512-4m62DuCE07lw01soJwPiBGC0nAww0Q+RY70VZ+n49yDIO13yyinhbWCeNnaob0lakDtWQzSdtNWzJeOJt2ma+g==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -1671,6 +1672,7 @@
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.4.3.tgz",
"integrity": "sha512-pBPWdu6MLKROBX05wSNKcNb++m5Er+KQ9QkB+WVM+pW2Kx9hoSrVTnu3BdkI5eBLZoKu/J6mW/B6i6bJB2ytXQ==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -1681,6 +1683,7 @@
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.0.2.tgz",
"integrity": "sha512-5n3nTJblwRi8LlXkJ9eBzu+kZR8Yxcc7ubakyQTFzPMtIhFpUBRbsnc2Dv88IZDIbCDlBiWrknhB4Lsz7mg6BA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -2321,6 +2324,7 @@
"version": "0.2.10",
"resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-0.2.10.tgz",
"integrity": "sha512-bCsCyeZEwVErsGmyPNSzwfwFn4OdxBj0mmv6hOFucB/k81Ojdu68RbZdxYsRQUPc9l6SU5F/cG+bXgWs3oUgsQ==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -3016,6 +3020,60 @@
"node": ">=14.0.0"
}
},
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": {
"version": "1.4.3",
"inBundle": true,
"license": "MIT",
"optional": true,
"dependencies": {
"@emnapi/wasi-threads": "1.0.2",
"tslib": "^2.4.0"
}
},
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": {
"version": "1.4.3",
"inBundle": true,
"license": "MIT",
"optional": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": {
"version": "1.0.2",
"inBundle": true,
"license": "MIT",
"optional": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": {
"version": "0.2.11",
"inBundle": true,
"license": "MIT",
"optional": true,
"dependencies": {
"@emnapi/core": "^1.4.3",
"@emnapi/runtime": "^1.4.3",
"@tybys/wasm-util": "^0.9.0"
}
},
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": {
"version": "0.9.0",
"inBundle": true,
"license": "MIT",
"optional": true,
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": {
"version": "2.8.0",
"inBundle": true,
"license": "0BSD",
"optional": true
},
"node_modules/@tailwindcss/oxide-win32-arm64-msvc": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.1.11.tgz",
@ -3548,6 +3606,7 @@
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.9.0.tgz",
"integrity": "sha512-6+7nlbMVX/PVDCwaIQ8nTOPveOcFLSt8GcXdx8hD0bt39uWxYT88uXzqTd4fTvqta7oeUJqudepapKNt2DYJFw==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -3690,13 +3749,13 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "22.15.28",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.28.tgz",
"integrity": "sha512-I0okKVDmyKR281I0UIFV7EWAWRnR0gkuSKob5wVcByyyhr7Px/slhkQapcYX4u00ekzNWaS1gznKZnuzxwo4pw==",
"version": "24.10.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz",
"integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==",
"devOptional": true,
"license": "MIT",
"dependencies": {
"undici-types": "~6.21.0"
"undici-types": "~7.16.0"
}
},
"node_modules/@types/prop-types": {
@ -11175,9 +11234,9 @@
}
},
"node_modules/typescript": {
"version": "5.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"devOptional": true,
"license": "Apache-2.0",
"bin": {
@ -11214,9 +11273,9 @@
}
},
"node_modules/undici-types": {
"version": "6.21.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
"version": "7.16.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
"integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
"devOptional": true,
"license": "MIT"
},

View File

@ -28,7 +28,7 @@
},
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
"@types/node": "^22.15.28",
"@types/node": "^24.10.1",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@typescript-eslint/eslint-plugin": "^5.62.0",
@ -52,7 +52,7 @@
"eslint-plugin-yml": "^1.14.0",
"postcss": "^8.4.30",
"tailwindcss": "^4.0.15",
"typescript": "^5.0.2",
"typescript": "^5.9.3",
"vite": "^6.2.0",
"vite-plugin-pwa": "^0.21.1"
}

View File

@ -28,7 +28,7 @@
"name": "zoom_offset",
"table": "maps",
"data_type": "integer",
"default_value": -1,
"default_value": 0,
"max_length": null,
"numeric_precision": 32,
"numeric_scale": 0,

1065
cypress/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,14 +24,14 @@
"@eslint/js": "^9.36.0",
"@types/mochawesome": "^6.2.4",
"@types/node": "^24.5.2",
"cypress": "^15.3.0",
"cypress-split": "^1.24.23",
"eslint": "^9.36.0",
"eslint-plugin-cypress": "^5.1.1",
"cypress": "^15.6.0",
"cypress-split": "^1.24.25",
"eslint": "^9.39.1",
"eslint-plugin-cypress": "^5.2.0",
"mochawesome": "^7.1.4",
"mochawesome-merge": "^4.3.0",
"mochawesome-report-generator": "^6.2.0",
"typescript": "^5.9.2",
"mochawesome-report-generator": "^6.3.2",
"typescript": "^5.9.3",
"typescript-eslint": "^8.44.1"
}
}

702
lib/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -60,7 +60,7 @@
"@typescript-eslint/parser": "^5.62.0",
"@vitejs/plugin-react": "^4.3.4",
"@vitest/coverage-v8": "^3.0.5",
"cypress": "^14.0.3",
"cypress": "^15.6.0",
"daisyui": "^5.2.3",
"eslint": "^8.24.0",
"eslint-config-prettier": "^9.1.0",
@ -125,7 +125,7 @@
"react-colorful": "^5.6.1",
"react-dropzone": "^14.3.8",
"react-icons": "^5.5.0",
"react-image-crop": "^10.1.8",
"react-image-crop": "^11.0.10",
"react-inlinesvg": "^4.2.0",
"react-leaflet": "^4.2.1",
"react-leaflet-cluster": "^2.1.0",

View File

@ -44,7 +44,7 @@ export function RichTextEditor({
const regex = /!\[.*?\]\(.*?\)/g
newValue = newValue.replace(regex, (match: string) => match + '\n\n')
if (updateFormValue && newValue) {
if (updateFormValue) {
updateFormValue(newValue)
}
}

View File

@ -5,7 +5,6 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
/* eslint-disable @typescript-eslint/prefer-optional-chain */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { LatLng } from 'leaflet'
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 { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
import { timeAgo } from '#utils/TimeAgo'
import { removeItemFromUrl } from '#utils/UrlHelper'
import { HeaderView } from './ItemPopupComponents/HeaderView'
import { TextView } from './ItemPopupComponents/TextView'
@ -80,8 +80,7 @@ export const ItemViewPopup = forwardRef((props: ItemViewPopupProps, ref: any) =>
}
setLoading(false)
map.closePopup()
const params = new URLSearchParams(window.location.search)
window.history.pushState({}, '', '/' + `${params ? `?${params}` : ''}`)
removeItemFromUrl()
navigate('/')
}

View File

@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/restrict-plus-operands */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
@ -15,6 +14,12 @@ import { toast } from 'react-toastify'
import { useSetAppState } from '#components/AppShell/hooks/useAppState'
import { useTheme } from '#components/AppShell/hooks/useTheme'
import { containsUUID } from '#utils/ContainsUUID'
import {
removeItemFromUrl,
resetMetaTags as resetMetaTagsUtil,
setItemInUrl,
updateMetaTags,
} from '#utils/UrlHelper'
import { useClusterRef, useSetClusterRef } from './hooks/useClusterRef'
import {
@ -152,21 +157,45 @@ export function UtopiaMapInner({
return null
}
// Track if we're currently switching popups to prevent URL cleanup
const popupCloseTimeoutRef = useRef<NodeJS.Timeout | null>(null)
useMapEvents({
popupopen: (e) => {
const item = Object.entries(leafletRefs).find((r) => r[1].popup === e.popup)?.[1].item
if (window.location.pathname.split('/')[1] !== item?.id) {
const params = new URLSearchParams(window.location.search)
if (!location.pathname.includes('/item/')) {
window.history.pushState(
{},
'',
`/${item?.id}` + `${params.toString() !== '' ? `?${params}` : ''}`,
)
// Cancel any pending popup close URL cleanup - we're opening a new popup
if (popupCloseTimeoutRef.current) {
clearTimeout(popupCloseTimeoutRef.current)
popupCloseTimeoutRef.current = null
}
// Only update URL if no profile is open
if (!location.pathname.includes('/item/')) {
if (window.location.pathname.split('/')[1] !== item?.id && item?.id) {
setItemInUrl(item.id)
}
let title = ''
if (item?.name) title = item.name
document.title = `${document.title.split('-')[0]} - ${title}`
if (item?.name) {
updateMetaTags(item.name, item.text)
}
}
// If profile is open, don't change URL but still update meta tags
else if (item?.name) {
updateMetaTags(item.name, item.text)
}
},
popupclose: () => {
// Only remove UUID from URL if no profile is open
if (!location.pathname.includes('/item/')) {
// Wait briefly to see if another popup is being opened
// If so, the popupopen handler will cancel this timeout
popupCloseTimeoutRef.current = setTimeout(() => {
if (containsUUID(window.location.pathname)) {
removeItemFromUrl()
resetMetaTagsUtil()
}
popupCloseTimeoutRef.current = null
}, 50)
}
},
})
@ -185,15 +214,9 @@ export function UtopiaMapInner({
clusterRef?.zoomToShowLayer(ref.marker, () => {
ref.marker.openPopup()
})
let title = ''
if (ref.item.name) title = ref.item.name
document.title = `${document.title.split('-')[0]} - ${title}`
document
.querySelector('meta[property="og:title"]')
?.setAttribute('content', ref.item.name ?? '')
document
.querySelector('meta[property="og:description"]')
?.setAttribute('content', ref.item.text ?? '')
if (ref.item.name) {
updateMetaTags(ref.item.name, ref.item.text)
}
}
}
}
@ -205,18 +228,10 @@ export function UtopiaMapInner({
}, [leafletRefs, location])
const resetMetaTags = () => {
const params = new URLSearchParams(window.location.search)
if (!containsUUID(window.location.pathname)) {
window.history.pushState({}, '', '/' + `${params.toString() !== '' ? `?${params}` : ''}`)
if (containsUUID(window.location.pathname)) {
removeItemFromUrl()
}
document.title = document.title.split('-')[0]
document.querySelector('meta[property="og:title"]')?.setAttribute('content', document.title)
document
.querySelector('meta[property="og:description"]')
?.setAttribute(
'content',
`${document.querySelector('meta[name="description"]')?.getAttribute('content')}`,
)
resetMetaTagsUtil()
}
const onEachFeature = (feature: Feature<GeoJSONGeometry, any>, layer: L.Layer) => {

View File

@ -17,6 +17,7 @@ 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 { setUrlParam } from '#utils/UrlHelper'
import type { Item } from '#types/Item'
import type { Tag } from '#types/Tag'
@ -67,11 +68,7 @@ export const TabsView = ({
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)
setUrlParam('tab', `${id}`)
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[location.pathname],

View File

@ -14,6 +14,7 @@ import { toast } from 'react-toastify'
import { encodeTag } from '#utils/FormatTags'
import { hashTagRegex } from '#utils/HashTagRegex'
import { randomColor } from '#utils/RandomColor'
import { removeItemFromUrl } from '#utils/UrlHelper'
import type { FormState } from '#types/FormState'
import type { Item } from '#types/Item'
@ -185,8 +186,7 @@ export const handleDelete = async (
toast.success('Item deleted')
map.closePopup()
const params = new URLSearchParams(window.location.search)
window.history.pushState({}, '', '/' + `${params ? `?${params}` : ''}`)
removeItemFromUrl()
navigate('/')
} catch (error) {
toast.error(error instanceof Error ? error.message : String(error))
@ -273,7 +273,7 @@ export const onUpdateItem = async (
setLoading(true)
state.text
.toLocaleLowerCase()
?.toLocaleLowerCase()
.match(hashTagRegex)
?.map((tag) => {
if (!tags.find((t) => t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) {

View File

@ -0,0 +1,74 @@
/**
* Utility functions for managing browser URL and history
*/
/**
* Updates the browser URL with an item ID while preserving query parameters
* @param itemId - The item UUID to add to the URL
*/
export function setItemInUrl(itemId: string): void {
const params = new URLSearchParams(window.location.search)
const paramsString = params.toString()
const newUrl = `/${itemId}${paramsString !== '' ? `?${paramsString}` : ''}`
window.history.pushState({}, '', newUrl)
}
/**
* Removes the item ID from the browser URL while preserving query parameters
*/
export function removeItemFromUrl(): void {
const params = new URLSearchParams(window.location.search)
const paramsString = params.toString()
const newUrl = `/${paramsString !== '' ? `?${paramsString}` : ''}`
window.history.pushState({}, '', newUrl)
}
/**
* Updates a specific query parameter in the URL while preserving the path
* @param key - The parameter key
* @param value - The parameter value
*/
export function setUrlParam(key: string, value: string): void {
const params = new URLSearchParams(window.location.search)
params.set(key, value)
const newUrl = window.location.pathname + '?' + params.toString()
window.history.pushState({}, '', newUrl)
}
/**
* Removes a specific query parameter from the URL
* @param key - The parameter key to remove
*/
export function removeUrlParam(key: string): void {
const params = new URLSearchParams(window.location.search)
params.delete(key)
const paramsString = params.toString()
const newUrl = window.location.pathname + (paramsString !== '' ? `?${paramsString}` : '')
window.history.pushState({}, '', newUrl)
}
/**
* Resets page title and OpenGraph meta tags to default values
*/
export function resetMetaTags(): void {
document.title = document.title.split('-')[0].trim()
document.querySelector('meta[property="og:title"]')?.setAttribute('content', document.title)
const description = document.querySelector('meta[name="description"]')?.getAttribute('content')
if (description) {
document.querySelector('meta[property="og:description"]')?.setAttribute('content', description)
}
}
/**
* Updates page title and OpenGraph meta tags with item information
* @param itemName - The name of the item
* @param itemText - The text/description of the item
*/
export function updateMetaTags(itemName: string, itemText?: string): void {
const baseTitle = document.title.split('-')[0].trim()
document.title = `${baseTitle} - ${itemName}`
document.querySelector('meta[property="og:title"]')?.setAttribute('content', itemName)
if (itemText) {
document.querySelector('meta[property="og:description"]')?.setAttribute('content', itemText)
}
}

113
package-lock.json generated
View File

@ -120,7 +120,7 @@
"@typescript-eslint/parser": "^5.62.0",
"@vitejs/plugin-react": "^4.3.4",
"@vitest/coverage-v8": "^3.0.5",
"cypress": "^14.0.3",
"cypress": "^15.6.0",
"daisyui": "^5.2.3",
"eslint": "^8.24.0",
"eslint-config-prettier": "^9.1.0",
@ -4776,6 +4776,13 @@
"@types/geojson": "*"
}
},
"node_modules/@types/tmp": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.2.6.tgz",
"integrity": "sha512-chhaNf2oKHlRkDGt+tiKE2Z5aJ6qalm7Z9rlLdBwmOiAAf09YQvvoLXjWK4HWPF1xU/fqvMgfNfpVoBscA/tKA==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/trusted-types": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
@ -6448,16 +6455,6 @@
"node": ">= 16"
}
},
"node_modules/check-more-types": {
"version": "2.24.0",
"resolved": "https://registry.npmjs.org/check-more-types/-/check-more-types-2.24.0.tgz",
"integrity": "sha512-Pj779qHxV2tuapviy1bSZNEL1maXr13bPYpsvSDB68HlYcYuhlDrmGd63i0JHMCLKzc7rUSNIrpdJlhVlNwrxA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/chownr": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
@ -6937,9 +6934,9 @@
"license": "MIT"
},
"node_modules/cypress": {
"version": "14.5.4",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-14.5.4.tgz",
"integrity": "sha512-0Dhm4qc9VatOcI1GiFGVt8osgpPdqJLHzRwcAB5MSD/CAAts3oybvPUPawHyvJZUd8osADqZe/xzMsZ8sDTjXw==",
"version": "15.6.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-15.6.0.tgz",
"integrity": "sha512-Vqo66GG1vpxZ7H1oDX9umfmzA3nF7Wy80QAc3VjwPREO5zTY4d1xfQFNPpOWleQl9vpdmR2z1liliOcYlRX6rQ==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
@ -6948,13 +6945,13 @@
"@cypress/xvfb": "^1.2.4",
"@types/sinonjs__fake-timers": "8.1.1",
"@types/sizzle": "^2.3.2",
"@types/tmp": "^0.2.3",
"arch": "^2.2.0",
"blob-util": "^2.0.2",
"bluebird": "^3.7.2",
"buffer": "^5.7.1",
"cachedir": "^2.3.0",
"chalk": "^4.1.0",
"check-more-types": "^2.24.0",
"ci-info": "^4.1.0",
"cli-cursor": "^3.1.0",
"cli-table3": "0.6.1",
@ -6969,10 +6966,8 @@
"extract-zip": "2.0.1",
"figures": "^3.2.0",
"fs-extra": "^9.1.0",
"getos": "^3.2.1",
"hasha": "5.2.2",
"is-installed-globally": "~0.4.0",
"lazy-ass": "^1.6.0",
"listr2": "^3.8.3",
"lodash": "^4.17.21",
"log-symbols": "^4.0.0",
@ -6984,7 +6979,8 @@
"request-progress": "^3.0.0",
"semver": "^7.7.1",
"supports-color": "^8.1.1",
"tmp": "~0.2.3",
"systeminformation": "5.27.7",
"tmp": "~0.2.4",
"tree-kill": "1.2.2",
"untildify": "^4.0.0",
"yauzl": "^2.10.0"
@ -6993,7 +6989,7 @@
"cypress": "bin/cypress"
},
"engines": {
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
"node": "^20.1.0 || ^22.0.0 || >=24.0.0"
}
},
"node_modules/cypress/node_modules/proxy-from-env": {
@ -9043,16 +9039,6 @@
"url": "https://github.com/privatenumber/get-tsconfig?sponsor=1"
}
},
"node_modules/getos": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/getos/-/getos-3.2.1.tgz",
"integrity": "sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"async": "^3.2.0"
}
},
"node_modules/getpass": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
@ -9206,9 +9192,9 @@
"license": "MIT"
},
"node_modules/happy-dom": {
"version": "20.0.0",
"resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-20.0.0.tgz",
"integrity": "sha512-GkWnwIFxVGCf2raNrxImLo397RdGhLapj5cT3R2PT7FwL62Ze1DROhzmYW7+J3p9105DYMVenEejEbnq5wA37w==",
"version": "20.0.10",
"resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-20.0.10.tgz",
"integrity": "sha512-6umCCHcjQrhP5oXhrHQQvLB0bwb1UzHAHdsXy+FjtKoYjUhmNZsQL8NivwM1vDvNEChJabVrUYxUnp/ZdYmy2g==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -10355,9 +10341,9 @@
"license": "MIT"
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -10526,16 +10512,6 @@
"json-buffer": "3.0.1"
}
},
"node_modules/lazy-ass": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/lazy-ass/-/lazy-ass-1.6.0.tgz",
"integrity": "sha512-cc8oEVoctTvsFZ/Oje/kGnHbpWHYBe8IAJe4C0QNc3t8uM/0Y8+erSz/7Y1ALuXTEZTMvxXwO6YbX1ey3ujiZw==",
"dev": true,
"license": "MIT",
"engines": {
"node": "> 0.8"
}
},
"node_modules/leaflet": {
"version": "1.9.4",
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz",
@ -15293,6 +15269,33 @@
"url": "https://opencollective.com/synckit"
}
},
"node_modules/systeminformation": {
"version": "5.27.7",
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.27.7.tgz",
"integrity": "sha512-saaqOoVEEFaux4v0K8Q7caiauRwjXC4XbD2eH60dxHXbpKxQ8kH9Rf7Jh+nryKpOUSEFxtCdBlSUx0/lO6rwRg==",
"dev": true,
"license": "MIT",
"os": [
"darwin",
"linux",
"win32",
"freebsd",
"openbsd",
"netbsd",
"sunos",
"android"
],
"bin": {
"systeminformation": "lib/cli.js"
},
"engines": {
"node": ">=8.0.0"
},
"funding": {
"type": "Buy me a coffee",
"url": "https://www.buymeacoffee.com/systeminfo"
}
},
"node_modules/tailwindcss": {
"version": "4.1.14",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.14.tgz",
@ -15313,10 +15316,10 @@
}
},
"node_modules/tar": {
"version": "7.5.1",
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.1.tgz",
"integrity": "sha512-nlGpxf+hv0v7GkWBK2V9spgactGOp0qvfWRxUMjqHyzrt3SgwE48DIv/FhqPHJYLHpgW1opq3nERbz5Anq7n1g==",
"license": "ISC",
"version": "7.5.2",
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.2.tgz",
"integrity": "sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==",
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/fs-minipass": "^4.0.0",
"chownr": "^3.0.0",
@ -15431,9 +15434,9 @@
}
},
"node_modules/test-exclude/node_modules/glob": {
"version": "10.4.5",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz",
"integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==",
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz",
"integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==",
"dev": true,
"license": "ISC",
"dependencies": {
@ -16345,9 +16348,9 @@
}
},
"node_modules/vite": {
"version": "6.3.6",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.6.tgz",
"integrity": "sha512-0msEVHJEScQbhkbVTb/4iHZdJ6SXp/AvxL2sjwYQFfBqleHtnCqv1J3sa9zbWz/6kW1m9Tfzn92vW+kZ1WV6QA==",
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.4.1.tgz",
"integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==",
"license": "MIT",
"dependencies": {
"esbuild": "^0.25.0",