refactor : merge Inventory_frontend submodule into frontend/ directory
Merges the full git history of Inventory_frontend into the monorepo under frontend/. Removes the submodule in favor of a unified repo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
16
frontend/app/shared/utils/apiHelpers.ts
Normal file
16
frontend/app/shared/utils/apiHelpers.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Shared API response helpers.
|
||||
*
|
||||
* Extracted from 10+ composables/components that each had an identical local
|
||||
* copy of extractCollection (parsing hydra:member / member / data / array).
|
||||
*/
|
||||
|
||||
export function extractCollection<T = any>(payload: unknown): T[] {
|
||||
if (Array.isArray(payload)) return payload as T[]
|
||||
const p = payload as Record<string, unknown> | null
|
||||
if (Array.isArray(p?.member)) return p!.member as T[]
|
||||
if (Array.isArray(p?.['hydra:member'])) return p!['hydra:member'] as T[]
|
||||
if (Array.isArray(p?.items)) return p!.items as T[]
|
||||
if (Array.isArray(p?.data)) return p!.data as T[]
|
||||
return []
|
||||
}
|
||||
Reference in New Issue
Block a user