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:
@@ -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])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user