mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-25 00:16:29 +02:00
Fix billing card not showing on launch
- Listen for oauth:didConnect event to fetch billing immediately on connect - Make trialDaysRemaining optional in IPC schema for backward compatibility - Default trialDaysRemaining to null when not present in API response Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
62ef1efc82
commit
6a1f83288e
2 changed files with 16 additions and 2 deletions
|
|
@ -25,7 +25,10 @@ export function useBilling(isRowboatConnected: boolean) {
|
|||
try {
|
||||
setIsLoading(true)
|
||||
const result = await window.ipc.invoke('billing:getInfo', null)
|
||||
setBilling(result)
|
||||
setBilling({
|
||||
...result,
|
||||
trialDaysRemaining: result.trialDaysRemaining ?? null,
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch billing info:', error)
|
||||
setBilling(null)
|
||||
|
|
@ -34,6 +37,7 @@ export function useBilling(isRowboatConnected: boolean) {
|
|||
}
|
||||
}, [isRowboatConnected])
|
||||
|
||||
// Fetch on mount / when connection state changes, and poll every 5 minutes
|
||||
useEffect(() => {
|
||||
fetchBilling()
|
||||
|
||||
|
|
@ -54,5 +58,15 @@ export function useBilling(isRowboatConnected: boolean) {
|
|||
}
|
||||
}, [fetchBilling, isRowboatConnected])
|
||||
|
||||
// Also refetch when OAuth connection completes (e.g. on app launch auto-reconnect)
|
||||
useEffect(() => {
|
||||
const cleanup = window.ipc.on('oauth:didConnect', (event) => {
|
||||
if (event.provider === 'rowboat') {
|
||||
fetchBilling()
|
||||
}
|
||||
})
|
||||
return cleanup
|
||||
}, [fetchBilling])
|
||||
|
||||
return { billing, isLoading, refresh: fetchBilling }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ const ipcSchemas = {
|
|||
userId: z.string().nullable(),
|
||||
subscriptionPlan: z.string().nullable(),
|
||||
subscriptionStatus: z.string().nullable(),
|
||||
trialDaysRemaining: z.number().nullable(),
|
||||
trialDaysRemaining: z.number().nullable().optional(),
|
||||
sanctionedCredits: z.number(),
|
||||
availableCredits: z.number(),
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue