Skip to Content
Housr AppFeaturesWallet Feature

Wallet Feature

Token management, event tickets, QR codes, and Apple/Google Wallet integration.

Location

  • Feature module: src/features/wallet/
  • Route: src/app/(tabs)/promotions/(tabs)/wallet.tsx

Overview

The wallet combines two types of items:

  1. Perk Tokens — Redeemed perks with codes/QR codes
  2. Event Tickets — Tickets from event applications with QR codes, barcodes, or letter-based entry

Items are sorted by creation date (newest first).

API Functions

FileFunctionAPIEndpointDescription
api/get-tokens.tsgetWalletTokens()v2GET perks/tokensFetch perk tokens
api/get-event-tickets.tsgetEventTickets()v2GET events/ticketsFetch event tickets
api/redeem-token.tsredeemToken()Redeem a perk token

Event Ticket Transform

The getEventTickets function transforms snake_case API responses to camelCase:

interface EventTicket { externalId: string; status: string; type: string; redeemUrl: string; createdAt: string; event: Event; tokenType: 'event' | 'barcode'; metadata: { letter: string; barcode: string; barcodeFormat: string; } | null; redeemedAt: string; }

Hooks

HookFileDescription
useWalletQueryhooks/use-wallet-query.tsCombines tokens + tickets via React Query
useInvalidateWallethooks/use-wallet-query.tsReturns function to invalidate wallet cache

useWalletQuery

export const useWalletQuery = (enabled: boolean = true) => { return useQuery({ queryKey: walletQueryKeys.all, // ['wallet'] queryFn: fetchWalletData, // merges tokens + tickets, sorted by date enabled, staleTime: 5 * 60 * 1000, }); };

The fetchWalletData function fetches tokens and tickets in sequence, combines them into a single array, and sorts by createdAt.

Components

ComponentFileDescription
PerkTokenItemcomponents/perk-token-item.tsxPerk token display
EventTicketItemcomponents/event-ticket-item.tsxEvent ticket display
EventQrCodecomponents/event-qr-code.tsxQR code for event entry
TokenRedeemModalcomponents/token-redeem-modal.tsxToken redemption modal
AddToWalletcomponents/add-to-wallet.tsxApple/Google Wallet integration
EmptyWalletcomponents/empty-wallet.tsxNo items state
CircleRowcomponents/circle-row.tsxDecorative circle row
TriangleRowcomponents/triangle-row.tsxDecorative triangle row

Apple/Google Wallet

The AddToWallet component uses @giulio987/expo-wallet and react-native-wallet-manager for adding tickets to native wallets.

Strategy Pattern

The wallet uses a strategy pattern (strategies/) for rendering different wallet item types:

  • strategies/types.ts — Strategy interface
  • strategies/default.tsx — Default rendering strategy
  • strategies/index.ts — Strategy registry

Query Keys

// constants/query-keys.ts export const walletQueryKeys = { all: ['wallet'] as const, };

Utilities

  • utils/deep-link-helpers.ts — Deep link handling for wallet items
Last updated on