Enhance billing and subscription management: Added payment method checks in ProtectedRoute, improved error handling in billing components, and optimized API calls to reduce throttling. Updated user account handling in various components to ensure accurate plan and subscription data display.
This commit is contained in:
@@ -25,6 +25,7 @@ interface User {
|
||||
slug: string;
|
||||
credits: number;
|
||||
status: string;
|
||||
plan?: any; // plan info is optional but required for access gating
|
||||
};
|
||||
}
|
||||
|
||||
@@ -143,11 +144,15 @@ export const useAuthStore = create<AuthState>()(
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
// Store user and JWT tokens
|
||||
// Store user and JWT tokens (handle nested tokens structure)
|
||||
const responseData = data.data || data;
|
||||
const tokens = responseData.tokens || {};
|
||||
const userData = responseData.user || data.user;
|
||||
|
||||
set({
|
||||
user: data.user,
|
||||
token: data.data?.access || data.access || null,
|
||||
refreshToken: data.data?.refresh || data.refresh || null,
|
||||
user: userData,
|
||||
token: tokens.access || responseData.access || data.access || null,
|
||||
refreshToken: tokens.refresh || responseData.refresh || data.refresh || null,
|
||||
isAuthenticated: true,
|
||||
loading: false
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user