feat(ui): add A1 dashboard and resumable onboarding
This commit is contained in:
@@ -3,6 +3,7 @@ export type WidgetSize = 'standard' | 'full';
|
||||
export const WIDGETS = [
|
||||
{ id: 'cards', titleKey: 'dashboardSummaryCards', defaultSize: 'full', sizes: ['full'] },
|
||||
{ id: 'attention', titleKey: 'dashboardTodayTitle', defaultSize: 'standard', sizes: ['standard', 'full'] },
|
||||
{ id: 'agenda', titleKey: 'dashboardYourWeek', defaultSize: 'standard', sizes: ['standard', 'full'] },
|
||||
{ id: 'funnel', titleKey: 'dashboardCurrentPipeline', defaultSize: 'standard', sizes: ['standard', 'full'] },
|
||||
{ id: 'activity', titleKey: 'dashboardApplicationActivity', defaultSize: 'full', sizes: ['standard', 'full'] },
|
||||
{ id: 'stageAge', titleKey: 'dashboardStageAge', defaultSize: 'standard', sizes: ['standard', 'full'] },
|
||||
@@ -29,8 +30,12 @@ export function arrangeDashboardWidgets(widgets: DashboardWidget[]): DashboardWi
|
||||
}
|
||||
|
||||
export function defaultDashboardLayout(): DashboardLayout {
|
||||
return { version: 2, revision: 0, widgets: arrangeDashboardWidgets(WIDGETS.map(w => ({ id: w.id, visible: true, size: w.defaultSize,
|
||||
x: 0, y: 0, w: w.defaultSize === 'full' ? 12 : 6, h: w.id === 'cards' ? 5 : 8 }))) };
|
||||
const order: WidgetId[] = ['attention', 'agenda', 'funnel', 'cards', 'activity', 'stageAge', 'sources', 'salary', 'companies', 'skills'];
|
||||
return { version: 2, revision: 0, widgets: arrangeDashboardWidgets(order.map(id => {
|
||||
const definition = WIDGETS.find(widget => widget.id === id)!;
|
||||
const w = id === 'attention' ? 12 : id === 'agenda' ? 8 : id === 'funnel' ? 4 : definition.defaultSize === 'full' ? 12 : 6;
|
||||
return { id, visible: true, size: w === 12 ? 'full' : 'standard', x: 0, y: 0, w, h: id === 'cards' ? 5 : id === 'attention' ? 9 : 8 };
|
||||
})) };
|
||||
}
|
||||
|
||||
export function normalizeDashboardLayout(input: unknown): DashboardLayout {
|
||||
@@ -54,8 +59,8 @@ export function normalizeDashboardLayout(input: unknown): DashboardLayout {
|
||||
size: w === 12 ? 'full' : 'standard', x: valid ? item.x : 0, y: valid ? item.y : 0, w,
|
||||
h: valid ? item.h : definition.id === 'cards' ? 5 : 8 });
|
||||
}
|
||||
for (const definition of WIDGETS) {
|
||||
if (!seen.has(definition.id)) widgets.push({ ...defaultDashboardLayout().widgets.find(w => w.id === definition.id)!, visible: revision === 0 });
|
||||
for (const widget of defaultDashboardLayout().widgets) {
|
||||
if (!seen.has(widget.id)) widgets.push({ ...widget, visible: revision === 0 });
|
||||
}
|
||||
return { version: 2, revision, widgets: value.version === 1 ? arrangeDashboardWidgets(widgets) : widgets };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user