Initial commit — eLegal Software monorepo
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
import { api, type ApiError } from '@/lib/api';
|
||||
|
||||
export interface BillingStatus {
|
||||
configured: boolean;
|
||||
plan: 'starter' | 'pro' | 'lifetime';
|
||||
hasSubscription: boolean;
|
||||
hasCustomer: boolean;
|
||||
}
|
||||
|
||||
export function useBillingStatus() {
|
||||
return useQuery<BillingStatus>({
|
||||
queryKey: ['billing', 'status'],
|
||||
queryFn: () => api.get('/api/billing/status'),
|
||||
});
|
||||
}
|
||||
|
||||
export function useStartCheckout() {
|
||||
return useMutation<{ url: string }, ApiError, { plan: 'pro' | 'lifetime' }>({
|
||||
mutationFn: (body) => api.post('/api/billing/checkout', body),
|
||||
});
|
||||
}
|
||||
|
||||
export function useOpenPortal() {
|
||||
return useMutation<{ url: string }, ApiError, void>({
|
||||
mutationFn: () => api.post('/api/billing/portal'),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user