mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
feat(onboarding): add settings.onboarding column + markOnboardingDoneAction
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
eade74be6e
commit
9183d6dfcb
@@ -0,0 +1 @@
|
||||
ALTER TABLE "settings" ADD COLUMN "onboarding" boolean DEFAULT false NOT NULL;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -435,6 +435,13 @@
|
||||
"when": 1780822414802,
|
||||
"tag": "0061_illegal_mole_man",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 62,
|
||||
"version": "7",
|
||||
"when": 1781772995082,
|
||||
"tag": "0062_clear_shiva",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -20,6 +20,7 @@ export const setting = pgTable("settings", {
|
||||
defaultStorageChannelId: uuid('default_storage_channel_id')
|
||||
.references(() => storageChannel.id, {onDelete: "set null"}),
|
||||
encryption: boolean("encryption").default(false),
|
||||
onboarding: boolean("onboarding").default(false).notNull(),
|
||||
...timestamps
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"use server";
|
||||
|
||||
import { userAction } from "@/lib/safe-actions/actions";
|
||||
import { z } from "zod";
|
||||
import { db } from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
||||
export const markOnboardingDoneAction = userAction
|
||||
.schema(z.object({}))
|
||||
.action(async () => {
|
||||
const settings = await db.query.setting.findFirst();
|
||||
if (!settings) {
|
||||
throw new Error("Settings not found");
|
||||
}
|
||||
await db
|
||||
.update(drizzleDb.schemas.setting)
|
||||
.set({ onboarding: true })
|
||||
.where(eq(drizzleDb.schemas.setting.id, settings.id));
|
||||
return { done: true };
|
||||
});
|
||||
@@ -2,14 +2,24 @@
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useOnboarding } from "@onboardjs/react";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import confetti from "canvas-confetti";
|
||||
import { CheckCircle2 } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { markOnboardingDoneAction } from "@/features/onboarding/actions/onboarding-mark-done.action";
|
||||
|
||||
export const StepFinish = () => {
|
||||
const { next } = useOnboarding();
|
||||
const fired = useRef(false);
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
const result = await markOnboardingDoneAction({});
|
||||
if (!result?.data) throw new Error("Failed to mark onboarding done");
|
||||
return result.data;
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (fired.current) return;
|
||||
fired.current = true;
|
||||
@@ -21,7 +31,14 @@ export const StepFinish = () => {
|
||||
<CheckCircle2 className="size-16 text-green-500" />
|
||||
<h1 className="text-2xl font-semibold">You're all set!</h1>
|
||||
<p className="text-sm text-muted-foreground">Your workspace is ready to use.</p>
|
||||
<Button type="button" onClick={async () => { await next(); }}>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={mutation.isPending}
|
||||
onClick={async () => {
|
||||
await mutation.mutateAsync();
|
||||
await next();
|
||||
}}
|
||||
>
|
||||
Go to dashboard
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user