improvement: account setting added to header in order to choose organizations/subscribtions/etc
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// src/lib/api/auth.ts
|
||||
import { apiClient } from './client';
|
||||
import { AuthResponse, TrialRegistrationData, LoginData } from '@/types';
|
||||
import { AuthResponse, TrialRegistrationData, LoginData, SubscriptionAlertData } from '@/types';
|
||||
|
||||
export const authApi = {
|
||||
// Register a new trial organization
|
||||
@@ -21,6 +21,15 @@ export const authApi = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/** Owner-only meaningful data; staff always gets showWarning: false */
|
||||
getSubscriptionAlert: async (): Promise<{
|
||||
success: boolean;
|
||||
data: SubscriptionAlertData;
|
||||
}> => {
|
||||
const response = await apiClient.get('/auth/subscription-alert');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Select organization
|
||||
selectOrganization: async (organizationId: string): Promise<any> => {
|
||||
const response = await apiClient.post('/auth/select-organization', { organizationId });
|
||||
|
||||
@@ -218,7 +218,13 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
|
||||
localStorage.setItem('currentOrganizationId', organization.id);
|
||||
|
||||
setCurrentOrganization(organization);
|
||||
setCurrentOrganization({
|
||||
id: organization.id,
|
||||
name: organization.name,
|
||||
type: organization.type as Organization['type'],
|
||||
isOwner: Boolean((organization as { isOwner?: boolean }).isOwner),
|
||||
plan: (organization as { plan?: Organization['plan'] }).plan,
|
||||
});
|
||||
|
||||
router.push('/today');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user