Add vendors listing with search, category filter, grid/list, pagination

This commit is contained in:
2026-04-23 21:14:02 +04:00
parent 8dd618ce88
commit 73a0d24c4f
5 changed files with 441 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
import { useCallback, useEffect, useState } from 'react'
export function useLocalStorage<T>(key: string, initialValue: T): [T, (v: T) => void] {
const [value, setValue] = useState<T>(() => {
if (typeof window === 'undefined') return initialValue
try {
const raw = window.localStorage.getItem(key)
return raw != null ? (JSON.parse(raw) as T) : initialValue
} catch {
return initialValue
}
})
useEffect(() => {
try {
window.localStorage.setItem(key, JSON.stringify(value))
} catch {
/* storage unavailable */
}
}, [key, value])
const set = useCallback((v: T) => setValue(v), [])
return [value, set]
}