From 5593ee6d927380273e4855f5bcc0397b5efb6e62 Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Fri, 17 Apr 2026 00:50:51 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20company=20detail=20crash=20=E2=80=94=20p?= =?UTF-8?q?atterns=20API=20returns=20object=20not=20array?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /api/patterns/{ticker} returns {ticker, patterns, count} but useHistoricalPatterns typed its response as HistoricalPattern[]. The .map() call on the object caused 'e.map is not a function'. Fixed by unwrapping resp.patterns in the hook's queryFn. --- frontend/src/api/hooks.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/api/hooks.ts b/frontend/src/api/hooks.ts index a624608..880d8c9 100644 --- a/frontend/src/api/hooks.ts +++ b/frontend/src/api/hooks.ts @@ -556,7 +556,14 @@ export function useHistoricalPatterns(ticker: string | undefined, params?: { cat if (params?.catalyst_type) qs.set('catalyst_type', params.catalyst_type); if (params?.time_horizon) qs.set('time_horizon', params.time_horizon); const path = `/api/patterns/${ticker}${qs.toString() ? '?' + qs : ''}`; - return useGet(['historical-patterns', ticker, params], 'query', path, !!ticker); + return useQuery({ + queryKey: ['historical-patterns', ticker, params], + queryFn: async () => { + const resp = await apiGet<{ patterns: HistoricalPattern[] }>('query', path); + return resp.patterns ?? []; + }, + enabled: !!ticker, + }); } // ---------------------------------------------------------------------------