mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
chore(onboarding): delete mock/cookie/preview/sso-gate files — replaced by real implementation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import { redirect } from "next/navigation";
|
||||
import { currentUser } from "@/lib/auth/current-user";
|
||||
import { isOnboardingDone } from "@/features/onboarding/onboarding-cookie";
|
||||
import { isOnboardingDone } from "@/features/onboarding/is-onboarding-done";
|
||||
import { AuthLogoSection } from "@/features/auth/auth-logo-section";
|
||||
import { Heart } from "lucide-react";
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
|
||||
import { AppSidebar } from "@/features/layout/app-sidebar";
|
||||
import { Header } from "@/features/layout/header";
|
||||
import { currentUser } from "@/lib/auth/current-user";
|
||||
import { isOnboardingDone } from "@/features/onboarding/onboarding-cookie";
|
||||
import { isOnboardingDone } from "@/features/onboarding/is-onboarding-done";
|
||||
import { ThemeMetaUpdater } from "@/features/theme/theme-meta-updater";
|
||||
import { ModeToggle } from "@/features/theme/mode-toggle";
|
||||
import { UpdateNotification } from "@/features/updates/update-notification";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { getCurrentOrganizationSlug } from "@/features/organizations/organization-cookie";
|
||||
import { currentUser } from "@/lib/auth/current-user";
|
||||
import { isOnboardingDone } from "@/features/onboarding/onboarding-cookie";
|
||||
import { isOnboardingDone } from "@/features/onboarding/is-onboarding-done";
|
||||
|
||||
export default async function Index() {
|
||||
if (!(await isOnboardingDone())) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import "server-only";
|
||||
|
||||
import { db } from "@/db";
|
||||
|
||||
export async function isOnboardingDone(): Promise<boolean> {
|
||||
const settings = await db.query.setting.findFirst();
|
||||
return settings?.onboarding ?? false;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
'use server';
|
||||
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
const COOKIE_NAME = 'portabase_onboarding';
|
||||
const DONE_VALUE = 'done';
|
||||
|
||||
export async function isOnboardingDone() {
|
||||
return (await cookies()).get(COOKIE_NAME)?.value === DONE_VALUE;
|
||||
}
|
||||
|
||||
export async function markOnboardingDone() {
|
||||
(await cookies()).set(COOKIE_NAME, DONE_VALUE, {
|
||||
path: '/',
|
||||
maxAge: 60 * 60 * 24 * 365,
|
||||
});
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useOnboarding } from "@onboardjs/react";
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
const DASHBOARD_PREVIEW_STEP_IDS = [
|
||||
"account-info",
|
||||
"security",
|
||||
"preferences",
|
||||
"org-create",
|
||||
];
|
||||
|
||||
export const OnboardingPreview = () => {
|
||||
const { state } = useOnboarding();
|
||||
const stepId = state?.currentStep?.id;
|
||||
|
||||
if (stepId === "agent-waiting") {
|
||||
return (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<Loader2 className="size-10 animate-spin text-primary" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (stepId === "finish") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const org = state?.context.flowData.org as { name?: string; logoDataUrl?: string } | undefined;
|
||||
const preferences = state?.context.flowData.preferences as { theme?: string; avatarDataUrl?: string } | undefined;
|
||||
|
||||
const isDashboardPreview = typeof stepId === "string" && DASHBOARD_PREVIEW_STEP_IDS.includes(stepId);
|
||||
|
||||
return (
|
||||
<div className="flex h-full w-full items-center justify-center p-6">
|
||||
<div
|
||||
className={`w-full max-w-sm rounded-lg border border-white/10 overflow-hidden ${preferences?.theme === "light" ? "bg-white text-black" : "bg-zinc-900 text-white"}`}
|
||||
>
|
||||
<div className="flex items-center gap-2 border-b border-white/10 px-4 py-3">
|
||||
{org?.logoDataUrl ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img src={org.logoDataUrl} alt="" className="size-5 rounded" />
|
||||
) : (
|
||||
<div className="size-5 rounded bg-primary" />
|
||||
)}
|
||||
<span className="text-sm font-medium">{org?.name || "Your organisation"}</span>
|
||||
</div>
|
||||
{isDashboardPreview && (
|
||||
<div className="flex">
|
||||
<div className="w-16 border-r border-white/10 p-2 flex flex-col gap-2">
|
||||
{[...Array(5)].map((_, i) => (
|
||||
<div key={i} className="h-2 rounded bg-white/10" />
|
||||
))}
|
||||
</div>
|
||||
<div className="flex-1 p-3 flex flex-col gap-2">
|
||||
<div className="h-3 w-1/2 rounded bg-white/10" />
|
||||
<div className="h-16 rounded bg-white/5" />
|
||||
<div className="h-16 rounded bg-white/5" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
import { OnboardingMockDatabase, OnboardingSsoConfig } from '@/features/onboarding/onboarding.types';
|
||||
|
||||
export const mockSsoConfig: OnboardingSsoConfig = {
|
||||
providers: [
|
||||
{ id: 'google', label: 'Google' },
|
||||
{ id: 'github', label: 'GitHub' },
|
||||
],
|
||||
forced: false,
|
||||
passkeyEnabled: true,
|
||||
};
|
||||
|
||||
export const mockDatabases: OnboardingMockDatabase[] = [
|
||||
{ id: 'db-primary', name: 'primary', engine: 'postgres' },
|
||||
{ id: 'db-analytics', name: 'analytics', engine: 'postgres' },
|
||||
];
|
||||
|
||||
export function simulateAgentPing(): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, 2000));
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { mockDatabases } from "@/features/onboarding/onboarding.mock";
|
||||
import { OnboardingDbSettings, OnboardingProjectData } from "@/features/onboarding/onboarding.types";
|
||||
|
||||
export const StepDbSettings = () => {
|
||||
@@ -30,7 +29,8 @@ export const StepDbSettings = () => {
|
||||
}
|
||||
|
||||
const currentDbId = databaseIds[index];
|
||||
const currentDb = mockDatabases.find((db) => db.id === currentDbId);
|
||||
// Database info is available from state flowData if needed
|
||||
// For now, just use the ID
|
||||
|
||||
const saveCurrent = (): Record<string, OnboardingDbSettings> => {
|
||||
if (applyToAll) {
|
||||
@@ -60,7 +60,7 @@ export const StepDbSettings = () => {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold">Configure {currentDb?.name}</h1>
|
||||
<h1 className="text-2xl font-semibold">Configure database</h1>
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
Database {index + 1} of {databaseIds.length}
|
||||
</p>
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useOnboarding } from "@onboardjs/react";
|
||||
import { Globe } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { mockSsoConfig } from "@/features/onboarding/onboarding.mock";
|
||||
|
||||
export const StepSsoGate = () => {
|
||||
const { next, updateContext, state } = useOnboarding();
|
||||
|
||||
const chooseProvider = async (providerId: string) => {
|
||||
await updateContext({ flowData: { ...state?.context.flowData, sso: { providerId } } });
|
||||
await next();
|
||||
};
|
||||
|
||||
const continueWithEmail = async () => {
|
||||
await next();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold">Welcome to Portabase</h1>
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
Sign in with your organisation provider, or continue with email.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
{mockSsoConfig.providers.map((provider) => (
|
||||
<button
|
||||
key={provider.id}
|
||||
type="button"
|
||||
onClick={() => chooseProvider(provider.id)}
|
||||
className="flex items-center gap-3 rounded-lg border border-border p-3 text-sm hover:bg-accent/50 hover:border-primary/20 transition-colors w-full"
|
||||
>
|
||||
<div className="size-9 rounded-md border bg-muted/50 shadow-sm flex items-center justify-center shrink-0">
|
||||
<Globe className="size-4 text-muted-foreground" />
|
||||
</div>
|
||||
<span>Continue with {provider.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{!mockSsoConfig.forced && (
|
||||
<Button type="button" onClick={continueWithEmail}>
|
||||
Continue with email
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user