mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
feat(onboarding): add cookie helper, types and mock data
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
'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,
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
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));
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
export type OnboardingSsoConfig = {
|
||||||
|
providers: { id: string; label: string }[];
|
||||||
|
forced: boolean;
|
||||||
|
passkeyEnabled: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingAccountData = {
|
||||||
|
name: string;
|
||||||
|
email: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingSecurityData = {
|
||||||
|
method: 'passkey' | 'two-factor' | 'skipped';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingPreferencesData = {
|
||||||
|
theme: 'light' | 'dark';
|
||||||
|
avatarDataUrl?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingOrgData = {
|
||||||
|
name: string;
|
||||||
|
logoDataUrl?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingMember = {
|
||||||
|
email: string;
|
||||||
|
role: 'member' | 'admin';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingChannel = {
|
||||||
|
id: string;
|
||||||
|
provider: string;
|
||||||
|
label: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingDefaultsData = {
|
||||||
|
notifierId?: string;
|
||||||
|
storageId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingAgent = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
notifierId?: string;
|
||||||
|
storageId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingMockDatabase = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
engine: 'postgres' | 'mysql' | 'mongodb';
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingDbSettings = {
|
||||||
|
retentionDays: number;
|
||||||
|
notifierId?: string;
|
||||||
|
storageId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingProjectData = {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
databaseIds: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type OnboardingFlowData = {
|
||||||
|
sso?: { providerId: string };
|
||||||
|
account?: OnboardingAccountData;
|
||||||
|
security?: OnboardingSecurityData;
|
||||||
|
preferences?: OnboardingPreferencesData;
|
||||||
|
org?: OnboardingOrgData;
|
||||||
|
members?: OnboardingMember[];
|
||||||
|
notifiers?: OnboardingChannel[];
|
||||||
|
storages?: OnboardingChannel[];
|
||||||
|
defaults?: OnboardingDefaultsData;
|
||||||
|
agents?: OnboardingAgent[];
|
||||||
|
project?: OnboardingProjectData;
|
||||||
|
dbSettings?: Record<string, OnboardingDbSettings>;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user