-
Notifications
You must be signed in to change notification settings - Fork 0
fix: restore main validation after PR merges #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import type { TecnicaUnificada } from '@/types/tecnica-unificada'; | ||
| import { fetchExternalData } from '@/lib/external-db'; | ||
|
|
||
| export interface TechniqueQueryOptions { | ||
| search?: string; | ||
|
|
@@ -39,6 +38,23 @@ interface PaginatedResponse<T> { | |
| status: number; | ||
| } | ||
|
|
||
| interface FetchExternalDataOptions { | ||
| url: string; | ||
| headers?: HeadersInit; | ||
| } | ||
|
Comment on lines
+41
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new local Useful? React with 👍 / 👎. |
||
|
|
||
| async function fetchExternalData<T>({ url, headers }: FetchExternalDataOptions): Promise<T> { | ||
| const response = await fetch(url, { headers }); | ||
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `External technique API request failed: ${response.status} ${response.statusText}`, | ||
| ); | ||
| } | ||
|
|
||
| return response.json() as Promise<T>; | ||
| } | ||
|
|
||
| function externalToTecnicaUnificada(row: TecnicaGravacaoExterno): TecnicaUnificada { | ||
| return { | ||
| id: row.id, | ||
|
|
@@ -77,12 +93,13 @@ export async function findAll(options: TechniqueQueryOptions = {}): Promise<Tecn | |
| let tecnicas = (data.data?.records || []).map(externalToTecnicaUnificada); | ||
|
|
||
| // Filtros pós-query | ||
| if (filters?.search) { | ||
| const search = filters.search.toLowerCase(); | ||
| tecnicas = tecnicas.filter((t: TecnicaUnificada) => | ||
| t.nome.toLowerCase().includes(search) || | ||
| t.codigo.toLowerCase().includes(search) || | ||
| t.descricao?.toLowerCase().includes(search) | ||
| if (search) { | ||
| const normalizedSearch = search.toLowerCase(); | ||
| tecnicas = tecnicas.filter( | ||
| (t: TecnicaUnificada) => | ||
| t.nome.toLowerCase().includes(normalizedSearch) || | ||
| t.codigo.toLowerCase().includes(normalizedSearch) || | ||
| t.descricao?.toLowerCase().includes(normalizedSearch), | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -121,7 +138,10 @@ export async function create(tecnica: Omit<TecnicaUnificada, 'id'>): Promise<Tec | |
| return response.json(); | ||
| } | ||
|
|
||
| export async function update(id: string, updates: Partial<TecnicaUnificada>): Promise<TecnicaUnificada> { | ||
| export async function update( | ||
| id: string, | ||
| updates: Partial<TecnicaUnificada>, | ||
| ): Promise<TecnicaUnificada> { | ||
| const response = await fetch(`${GRAVACAO_API}/tecnicas/${id}`, { | ||
| method: 'PATCH', | ||
| headers: { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exporting
useRamoAtividadeGroupsas a direct alias ofuseRamosAtividadeGroupschanges the runtime shape seen by existing callers: the aliased hook returnsdataas an object ({ groups, totalGroups, totalSegmentos }), while downstream code still treatsgroupsas an array (for example, it calls array methods/spread in the ramo filter flow). After this alias is used and the query resolves, those consumers can hit runtime failures like non-iterable/non-function errors. The alias should preserve the old contract (array data) or all consumers should be updated atomically.Useful? React with 👍 / 👎.