mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-12 19:55:19 +02:00
- Introduced billing error patterns to match specific error messages and display appropriate user prompts in the ChatSidebar. - Enhanced SidebarContentPanel and AccountSettings components to reflect subscription status, including trial expiration details. - Updated button actions to direct users to the app URL for subscription management and upgrades. - Added a new Payment section in AccountSettings for managing invoices and payment methods, with conditional rendering based on subscription status.
39 lines
1,022 B
TypeScript
39 lines
1,022 B
TypeScript
import { useState, useEffect, useCallback } from 'react'
|
|
|
|
interface BillingInfo {
|
|
userEmail: string | null
|
|
userId: string | null
|
|
subscriptionPlan: string | null
|
|
subscriptionStatus: string | null
|
|
trialExpiresAt: string | null
|
|
sanctionedCredits: number
|
|
availableCredits: number
|
|
}
|
|
|
|
export function useBilling(isRowboatConnected: boolean) {
|
|
const [billing, setBilling] = useState<BillingInfo | null>(null)
|
|
const [isLoading, setIsLoading] = useState(false)
|
|
|
|
const fetchBilling = useCallback(async () => {
|
|
if (!isRowboatConnected) {
|
|
setBilling(null)
|
|
return
|
|
}
|
|
try {
|
|
setIsLoading(true)
|
|
const result = await window.ipc.invoke('billing:getInfo', null)
|
|
setBilling(result)
|
|
} catch (error) {
|
|
console.error('Failed to fetch billing info:', error)
|
|
setBilling(null)
|
|
} finally {
|
|
setIsLoading(false)
|
|
}
|
|
}, [isRowboatConnected])
|
|
|
|
useEffect(() => {
|
|
fetchBilling()
|
|
}, [fetchBilling])
|
|
|
|
return { billing, isLoading, refresh: fetchBilling }
|
|
}
|