All files / src/features/babies/api invites.api.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                      6x 6x         4x 1x    
import { httpClient } from '@/lib/http-client'
 
import {
  invitePreviewSchema,
  redeemInviteResponseSchema,
  type InvitePreview,
  type RedeemInviteResponse,
} from './invites.schemas'
 
/** Public endpoint — no session required, used by InviteRedeemRoute for logged-out visitors. */
export async function fetchInvitePreview(code: string): Promise<InvitePreview> {
  const response = await httpClient.get<unknown>(`/invites/${code}`)
  return invitePreviewSchema.parse(response)
}
 
/** Requires an authenticated session — callers must check auth state before invoking this. */
export async function redeemInvite(code: string): Promise<RedeemInviteResponse> {
  const response = await httpClient.post<unknown>(`/invites/${code}/redeem`)
  return redeemInviteResponseSchema.parse(response)
}