96 lines
2.6 KiB
TypeScript
96 lines
2.6 KiB
TypeScript
"use client";
|
|
|
|
import type {
|
|
HousekeepingRouteDefinition,
|
|
HousekeepingSurface,
|
|
} from "../../../foundation/contracts";
|
|
import type { HousekeepingPreferences } from "../../../foundation/preferences/schema";
|
|
import type { HousekeepingWidgetLoadResult } from "../../../foundation/registry";
|
|
import { Favorites } from "../../../foundation/shell/favorites";
|
|
import { WidgetGrid } from "../../../foundation/shell/widget-grid";
|
|
import {
|
|
type HousekeepingPreferenceSaver,
|
|
WidgetSettings,
|
|
} from "../../../foundation/shell/widget-settings";
|
|
import type { OperationsWidgetOption } from "../personalization-model";
|
|
|
|
export interface OperationsPersonalizationLabels {
|
|
readonly favorites: {
|
|
readonly title: string;
|
|
readonly pin: string;
|
|
readonly unpin: string;
|
|
readonly error: string;
|
|
readonly reorderInstructions: string;
|
|
};
|
|
readonly widgetSettings: {
|
|
readonly title: string;
|
|
readonly mandatory: string;
|
|
readonly error: string;
|
|
};
|
|
readonly widgets: {
|
|
readonly title: string;
|
|
readonly partial: string;
|
|
readonly error: string;
|
|
readonly reorderInstructions: string;
|
|
};
|
|
}
|
|
|
|
const persistPreferences: HousekeepingPreferenceSaver = async (preferences) => {
|
|
const { saveHousekeepingPreferences } = await import(
|
|
"@/actions/housekeeping-preferences"
|
|
);
|
|
return saveHousekeepingPreferences(preferences);
|
|
};
|
|
|
|
export function OperationsPersonalization({
|
|
preferences,
|
|
routes,
|
|
widgets,
|
|
widgetResult,
|
|
surface,
|
|
labels,
|
|
routeTitles,
|
|
widgetTitles,
|
|
savePreferences = persistPreferences,
|
|
}: {
|
|
readonly preferences: HousekeepingPreferences;
|
|
readonly routes: readonly HousekeepingRouteDefinition[];
|
|
readonly widgets: readonly OperationsWidgetOption[];
|
|
readonly widgetResult: HousekeepingWidgetLoadResult;
|
|
readonly surface: HousekeepingSurface;
|
|
readonly labels: OperationsPersonalizationLabels;
|
|
readonly routeTitles: Readonly<Record<string, string>>;
|
|
readonly widgetTitles: Readonly<Record<string, string>>;
|
|
readonly savePreferences?: HousekeepingPreferenceSaver;
|
|
}) {
|
|
return (
|
|
<>
|
|
<div className="grid gap-6 xl:grid-cols-2">
|
|
<Favorites
|
|
preferences={preferences}
|
|
routes={routes}
|
|
surface={surface}
|
|
savePreferences={savePreferences}
|
|
labels={labels.favorites}
|
|
titles={routeTitles}
|
|
/>
|
|
<WidgetSettings
|
|
preferences={preferences}
|
|
widgets={widgets}
|
|
savePreferences={savePreferences}
|
|
labels={labels.widgetSettings}
|
|
titles={widgetTitles}
|
|
/>
|
|
</div>
|
|
|
|
<WidgetGrid
|
|
preferences={preferences}
|
|
result={widgetResult}
|
|
savePreferences={savePreferences}
|
|
labels={labels.widgets}
|
|
titles={widgetTitles}
|
|
/>
|
|
</>
|
|
);
|
|
}
|