Extract vendor page subcomponents; structured Directus errors

Split the 316-line vendors index into VendorToolbar, VendorGrid,
VendorList, and PerPageSelector under components/vendors/. Page now
owns only search-param state and query orchestration.

Replace generic Error throws in lib/directus.ts with a DirectusError
class carrying status, statusText, collection, url, and parsed body.
Surface useLocalStorage read/write failures via console.warn instead
of swallowing them.
This commit is contained in:
2026-04-23 21:52:15 +04:00
parent f5f167549f
commit b481531301
8 changed files with 351 additions and 217 deletions

View File

@@ -6,7 +6,8 @@ export function useLocalStorage<T>(key: string, initialValue: T): [T, (v: T) =>
try {
const raw = window.localStorage.getItem(key)
return raw != null ? (JSON.parse(raw) as T) : initialValue
} catch {
} catch (err) {
console.warn(`useLocalStorage: failed to read "${key}"`, err)
return initialValue
}
})
@@ -14,8 +15,8 @@ export function useLocalStorage<T>(key: string, initialValue: T): [T, (v: T) =>
useEffect(() => {
try {
window.localStorage.setItem(key, JSON.stringify(value))
} catch {
/* storage unavailable */
} catch (err) {
console.warn(`useLocalStorage: failed to write "${key}"`, err)
}
}, [key, value])