Skip to content

Commit c3a1bf4

Browse files
authored
chore: unify updating steps (#1204)
* move updating download page to invite * unify updating steps * remove import
1 parent 6152b43 commit c3a1bf4

File tree

4 files changed

+2
-73
lines changed

4 files changed

+2
-73
lines changed

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

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import { Button, LogoBadge } from "@cap/ui";
44
import { useDetectPlatform } from "hooks/useDetectPlatform";
55
import { Clapperboard, Zap } from "lucide-react";
66
import { useRouter } from "next/navigation";
7-
import { startTransition, useEffect, useState } from "react";
8-
import { toast } from "sonner";
9-
import { useEffectMutation } from "@/lib/EffectRuntime";
10-
import { withRpc } from "@/lib/Rpcs";
117
import {
128
getDownloadButtonText,
139
getDownloadUrl,
@@ -39,35 +35,6 @@ export function DownloadPage() {
3935
const { platform, isIntel } = useDetectPlatform();
4036
const loading = platform === null;
4137
const router = useRouter();
42-
const [clickedContinue, setClickedContinue] = useState(false);
43-
44-
useEffect(() => {
45-
startTransition(() => {
46-
onboardingRequest.mutate();
47-
router.refresh();
48-
});
49-
}, []);
50-
51-
const onboardingRequest = useEffectMutation({
52-
mutationFn: () =>
53-
withRpc((r) => {
54-
return r.UserCompleteOnboardingStep({
55-
step: "download",
56-
data: undefined,
57-
});
58-
}),
59-
onSuccess: () => {
60-
if (clickedContinue) {
61-
startTransition(() => {
62-
router.push("/dashboard/caps");
63-
router.refresh();
64-
});
65-
}
66-
},
67-
onError: () => {
68-
toast.error("An error occurred, please try again");
69-
},
70-
});
7138

7239
return (
7340
<div className="flex flex-col gap-12 justify-center items-center min-h-fit lg:gap-20">
@@ -109,12 +76,7 @@ export function DownloadPage() {
10976
{getDownloadButtonText(platform, loading, isIntel)}
11077
</Button>
11178
<Button
112-
onClick={() => {
113-
setClickedContinue(true);
114-
onboardingRequest.mutate();
115-
}}
116-
spinner={onboardingRequest.isPending && clickedContinue}
117-
disabled={onboardingRequest.isPending && clickedContinue}
79+
onClick={() => router.push("/dashboard/caps")}
11880
className="min-w-[120px]"
11981
variant="dark"
12082
size="lg"

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

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -172,33 +172,12 @@ export class UsersOnboarding extends Effect.Service<UsersOnboarding>()(
172172
onboardingSteps: {
173173
...user.onboardingSteps,
174174
inviteTeam: true,
175+
download: true,
175176
},
176177
})
177178
.where(Dz.eq(Db.users.id, currentUser.id)),
178179
);
179180
}),
180-
181-
download: Effect.fn("Onboarding.download")(function* () {
182-
const currentUser = yield* CurrentUser;
183-
184-
const [user] = yield* db.use((db) =>
185-
db
186-
.select()
187-
.from(Db.users)
188-
.where(Dz.eq(Db.users.id, currentUser.id)),
189-
);
190-
191-
yield* db.use((db) =>
192-
db
193-
.update(Db.users)
194-
.set({
195-
onboardingSteps: { ...user.onboardingSteps, download: true },
196-
onboarding_completed_at: new Date(),
197-
})
198-
.where(Dz.eq(Db.users.id, currentUser.id)),
199-
);
200-
}),
201-
202181
skipToDashboard: Effect.fn("Onboarding.skipToDashboard")(function* () {
203182
const currentUser = yield* CurrentUser;
204183

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ export const UsersRpcsLive = User.UserRpcs.toLayer(
2727
case "inviteTeam":
2828
yield* onboarding.inviteTeam();
2929
return { step: "inviteTeam" as const, data: undefined };
30-
31-
case "download":
32-
yield* onboarding.download();
33-
return { step: "download" as const, data: undefined };
3430
case "skipToDashboard":
3531
yield* onboarding.skipToDashboard();
3632
return { step: "skipToDashboard" as const, data: undefined };

packages/web-domain/src/User.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ export const OnboardingStepPayload = Schema.Union(
3737
step: Schema.Literal("inviteTeam"),
3838
data: Schema.Void,
3939
}),
40-
Schema.Struct({
41-
step: Schema.Literal("download"),
42-
data: Schema.Void,
43-
}),
4440
Schema.Struct({
4541
step: Schema.Literal("skipToDashboard"),
4642
data: Schema.Void,
@@ -66,10 +62,6 @@ export const OnboardingStepResult = Schema.Union(
6662
step: Schema.Literal("inviteTeam"),
6763
data: Schema.Void,
6864
}),
69-
Schema.Struct({
70-
step: Schema.Literal("download"),
71-
data: Schema.Void,
72-
}),
7365
Schema.Struct({
7466
step: Schema.Literal("skipToDashboard"),
7567
data: Schema.Void,

0 commit comments

Comments
 (0)