UNPKG

@dbs-portal/module-tenant-management

Version:

Tenant management and multi-tenancy support module

62 lines 1.57 kB
/** * Tenant Context Hook for Multi-tenancy Support */ import React from 'react'; import type { ReactNode } from 'react'; import type { Tenant, TenantLookupDto, TenantContext } from '../types'; /** * Tenant Provider Props */ export interface TenantProviderProps { children: ReactNode; defaultTenantId?: string; onTenantChange?: (tenant: Tenant | undefined) => void; } /** * Tenant Provider Component */ export declare const TenantProvider: React.FC<TenantProviderProps>; /** * Hook to use tenant context */ export declare function useTenantContext(): TenantContext; /** * Hook to get current tenant */ export declare function useCurrentTenant(): { currentTenant: Tenant | undefined; isLoading: boolean; }; /** * Hook to switch tenant */ export declare function useTenantSwitcher(): { switchTenant: (tenantId: import("@dbs-portal/core-shared").ID) => Promise<void>; availableTenants: TenantLookupDto[]; currentTenant: Tenant | undefined; isLoading: boolean; canSwitch: boolean; }; /** * Higher-order component to ensure tenant context */ export declare function withTenantContext<P extends object>(Component: React.ComponentType<P>): React.ComponentType<P & { tenantId?: string; }>; /** * Hook to ensure tenant is selected */ export declare function useRequireTenant(): { tenant: null; isLoading: boolean; error: null; } | { tenant: null; isLoading: boolean; error: Error; } | { tenant: Tenant; isLoading: boolean; error: null; }; //# sourceMappingURL=use-tenant-context.d.ts.map