Skip to content

Commit a193e84

Browse files
authored
web: fix org setup when skipping to dashboard during onboarding (#1255)
* fix skip to dashboard with org setup * adjust spinner color * type
1 parent 4262364 commit a193e84

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

apps/web/app/(org)/onboarding/components/Bottom.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export const Bottom = () => {
4343
<Button
4444
className="px-0 w-fit"
4545
variant="transparent"
46-
spinner={skipToDashboard.isPending}
46+
spinner={true}
47+
spinnerColor="black"
48+
spinnerBorderColor="rgba(0, 0, 0, 0.2)"
4749
disabled={skipToDashboard.isPending || skipToDashboard.isSuccess}
4850
size="sm"
4951
onClick={() => skipToDashboard.mutate()}

packages/ui/src/components/Button.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export interface ButtonProps
4949
asChild?: boolean;
5050
spinner?: boolean;
5151
href?: string;
52+
spinnerColor?: string;
53+
spinnerBorderColor?: `rgba(${number},${number},${number},${number})`;
5254
spinnerClassName?: string;
5355
kbd?: string;
5456
icon?: React.ReactNode;
@@ -63,6 +65,8 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
6365
size,
6466
asChild = false,
6567
spinner = false,
68+
spinnerColor = "white",
69+
spinnerBorderColor = "rgba(255, 255, 255, 0.2)",
6670
spinnerClassName,
6771
href,
6872
kbd,
@@ -84,6 +88,8 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
8488
{spinner && (
8589
<LoadingSpinner
8690
className={classNames("mr-1", spinnerClassName)}
91+
color={spinnerColor}
92+
borderColor={spinnerBorderColor}
8793
size={16}
8894
/>
8995
)}

packages/ui/src/components/LoadingSpinner.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
export const LoadingSpinner = ({
22
size = 36,
33
color = "white",
4+
borderColor = "rgba(255, 255, 255, 0.2)",
45
thickness = 3,
56
speed = 1.5,
67
className,
78
}: {
89
size?: number;
910
color?: string;
11+
borderColor?: string;
1012
thickness?: number;
1113
speed?: number;
1214
className?: string;
@@ -16,7 +18,7 @@ export const LoadingSpinner = ({
1618
minWidth: `${size}px`,
1719
height: `${size}px`,
1820
minHeight: `${size}px`,
19-
border: `${thickness}px solid rgba(255, 255, 255, 0.2)`,
21+
border: `${thickness}px solid ${borderColor}`,
2022
borderTop: `${thickness}px solid ${color}`,
2123
borderRadius: "50%",
2224
animation: `spin ${1 / speed}s linear infinite`,

packages/web-backend/src/Users/UsersOnboarding.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,26 @@ export class UsersOnboarding extends Effect.Service<UsersOnboarding>()(
287287
Dz.eq(Db.organizations.id, currentUser.activeOrganizationId),
288288
);
289289

290-
if (!existingOrg || !user.onboardingSteps?.organizationSetup) {
290+
if (!existingOrg) {
291+
const newOrgId = Organisation.OrganisationId.make(nanoId());
292+
await tx.insert(Db.organizations).values({
293+
id: newOrgId,
294+
name: orgName,
295+
ownerId: currentUser.id,
296+
});
297+
await tx.insert(Db.organizationMembers).values({
298+
id: nanoId(),
299+
organizationId: newOrgId,
300+
userId: currentUser.id,
301+
role: "owner",
302+
});
291303
await tx
292-
.update(Db.organizations)
304+
.update(Db.users)
293305
.set({
294-
name: orgName,
306+
activeOrganizationId: newOrgId,
307+
defaultOrgId: newOrgId,
295308
})
296-
.where(
297-
Dz.eq(
298-
Db.organizations.id,
299-
currentUser.activeOrganizationId,
300-
),
301-
);
309+
.where(Dz.eq(Db.users.id, currentUser.id));
302310
}
303311
}),
304312
);

0 commit comments

Comments
 (0)