Map the tips payload onto the shape the client declares
Tips rendered as blank cards with unresolved placeholder text in their accessibility labels. getTips was the one entity fetch in the client with no translation from the wire's snake_case, so every tip arrived without the key that selects its title and body, and the lookup silently missed. The mapper now matches its siblings in that file. A test drives a card through all eleven message keys the tips engine emits, so a twelfth added later fails loudly instead of rendering an empty card, and two older tests that stubbed the tips response as an empty object rather than an empty list have been corrected.
This commit is contained in:
@@ -205,6 +205,22 @@ function toPlannedLeaveDay(raw: RawPlannedLeaveDay): PlannedLeaveDay {
|
||||
}
|
||||
}
|
||||
|
||||
export interface RawTip {
|
||||
id: string
|
||||
severity: 'info' | 'warning' | 'action'
|
||||
message_key: string
|
||||
data: Record<string, unknown>
|
||||
}
|
||||
|
||||
function toTip(raw: RawTip): Tip {
|
||||
return {
|
||||
id: raw.id,
|
||||
severity: raw.severity,
|
||||
messageKey: raw.message_key,
|
||||
data: raw.data,
|
||||
}
|
||||
}
|
||||
|
||||
interface RawLeaveWish {
|
||||
id: string
|
||||
workspace_id: string
|
||||
@@ -926,7 +942,8 @@ export async function removeWorkspaceParent(
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export async function getTips(workspaceId: string): Promise<Tip[]> {
|
||||
return apiFetch(`/tips/${workspaceId}`)
|
||||
const raw = (await apiFetch(`/tips/${workspaceId}`)) as RawTip[]
|
||||
return raw.map(toTip)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user