@krak-stack/auth 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,14 @@ type OrganizationSwitcherProps = {
4
4
  side?: ComponentProps<typeof DropdownMenuContent>["side"];
5
5
  className?: string;
6
6
  renderUnauthenticated?: () => ReactNode;
7
+ onChange?: (organization: OrganizationSummary) => void | Promise<void>;
7
8
  locked?: boolean;
8
9
  };
9
- export declare function OrganizationSwitcher({ side, className, renderUnauthenticated, locked, }: OrganizationSwitcherProps): import("react").JSX.Element;
10
+ type OrganizationSummary = {
11
+ id: string;
12
+ name: string;
13
+ slug: string;
14
+ metadata?: unknown;
15
+ };
16
+ export declare function OrganizationSwitcher({ side, className, renderUnauthenticated, onChange, locked, }: OrganizationSwitcherProps): import("react").JSX.Element;
10
17
  export {};
@@ -149,7 +149,7 @@ const organizationMetadataFromForm = async (value) => {
149
149
  }
150
150
  return { translations };
151
151
  };
152
- export function OrganizationSwitcher({ side = "bottom", className, renderUnauthenticated, locked = false, }) {
152
+ export function OrganizationSwitcher({ side = "bottom", className, renderUnauthenticated, onChange, locked = false, }) {
153
153
  const session = centralAuthClient.useSession();
154
154
  const organizations = centralAuthClient.useListOrganizations();
155
155
  const activeOrganization = centralAuthClient.useActiveOrganization();
@@ -180,8 +180,10 @@ export function OrganizationSwitcher({ side = "bottom", className, renderUnauthe
180
180
  const result = await centralAuthClient.organization.setActive({
181
181
  organizationId: organization.id,
182
182
  });
183
- if (!result.error)
183
+ if (!result.error) {
184
184
  await refresh();
185
+ await onChange?.(organization);
186
+ }
185
187
  }, children: _jsx(AppBrand, { to: null, label: display.name, subtitle: display.subtitle, icon: Building2, className: "w-full text-left [&>div:first-child]:size-7", ...(display.logo ? { imageSrc: display.logo } : {}) }) }, organization.id));
186
188
  })) : !locked && !organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: active
187
189
  ? m.organization_switcher_no_other_organizations()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/auth",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Effect HttpApi clients and schemas for KrakStack Auth.",
5
5
  "license": "MIT",
6
6
  "files": [