Move working documents to its own area, rename dashboard

This commit is contained in:
2026-04-29 01:21:16 +12:00
parent 7e9663fa06
commit 761ebb050d
32 changed files with 1779 additions and 526 deletions
+153 -8
View File
@@ -8,6 +8,46 @@ import type {
Scenario
} from '$lib/types';
const MODULE_PERMISSIONS = {
superadmin: {
dashboard: 'edit',
raw_materials: 'edit',
mix_master: 'edit',
products: 'edit',
scenarios: 'edit',
powerbi_export: 'edit',
client_access: 'manage'
},
operator: {
dashboard: 'edit',
raw_materials: 'edit',
mix_master: 'edit',
products: 'edit',
scenarios: 'edit',
powerbi_export: 'none',
client_access: 'none'
},
viewer: {
dashboard: 'view',
raw_materials: 'none',
mix_master: 'none',
products: 'view',
scenarios: 'none',
powerbi_export: 'view',
client_access: 'none'
}
} as const;
const MODULE_DETAILS = [
['dashboard', 'Dashboard', 'workspace', 'Top-level operational dashboard'],
['raw_materials', 'Raw Materials', 'costing', 'Maintain live material costs and versions'],
['mix_master', 'Mix Master', 'costing', 'Create and maintain mix worksheets'],
['products', 'Products', 'pricing', 'Review finished product pricing'],
['scenarios', 'Scenarios', 'planning', 'Run scenario overrides and comparisons'],
['powerbi_export', 'Power BI Export', 'reporting', 'Expose client access data to BI consumers'],
['client_access', 'Client Access', 'administration', 'Manage user access, module permissions, and audit history']
] as const;
export const mockRawMaterials: RawMaterial[] = [
{
id: 1,
@@ -117,19 +157,31 @@ export const mockClientAccess: ClientAccessAccount[] = [
created_at: '2026-04-20T09:00:00',
active_user_count: 1,
new_user_count: 1,
enabled_feature_count: 6,
total_feature_count: 6,
enabled_feature_count: 7,
total_feature_count: 7,
users: [
{
id: 1,
client_account_id: 1,
full_name: 'Amelia Hart',
email: 'operator@example.com',
role: 'admin',
role: 'superadmin',
status: 'active',
is_new_user: false,
last_login_at: '2026-04-24T11:30:00',
created_at: '2026-04-20T09:00:00'
created_at: '2026-04-20T09:00:00',
module_permissions: MODULE_DETAILS.map(([module_key, module_name, module_group, description], index) => ({
id: index + 1,
client_account_id: 1,
client_user_id: 1,
module_key,
module_name,
module_group,
description,
access_level: MODULE_PERMISSIONS.superadmin[module_key],
updated_at: '2026-04-24T15:00:00',
created_at: '2026-04-20T09:00:00'
}))
},
{
id: 2,
@@ -140,7 +192,19 @@ export const mockClientAccess: ClientAccessAccount[] = [
status: 'invited',
is_new_user: true,
last_login_at: null,
created_at: '2026-04-24T15:00:00'
created_at: '2026-04-24T15:00:00',
module_permissions: MODULE_DETAILS.map(([module_key, module_name, module_group, description], index) => ({
id: index + 101,
client_account_id: 1,
client_user_id: 2,
module_key,
module_name,
module_group,
description,
access_level: MODULE_PERMISSIONS.operator[module_key],
updated_at: '2026-04-24T15:00:00',
created_at: '2026-04-24T15:00:00'
}))
}
],
features: [
@@ -209,6 +273,33 @@ export const mockClientAccess: ClientAccessAccount[] = [
enabled: true,
updated_at: '2026-04-24T15:00:00',
created_at: '2026-04-20T09:00:00'
},
{
id: 13,
client_account_id: 1,
feature_key: 'client_access',
feature_name: 'Client Access',
feature_group: 'administration',
description: 'Manage user access, module permissions, and audit history',
enabled: true,
updated_at: '2026-04-24T15:00:00',
created_at: '2026-04-20T09:00:00'
}
],
audit_history: [
{
id: 1,
client_account_id: 1,
actor_type: 'lean_admin',
actor_name: 'Lean 101 Seeder',
actor_email: 'system@lean101.local',
actor_role: 'system',
action: 'client_access.seeded',
target_type: 'client_account',
target_id: 1,
module_key: 'client_access',
summary: 'Initial client access controls, module permissions, and feature flags were seeded.',
created_at: '2026-04-20T09:00:00'
}
]
},
@@ -224,7 +315,7 @@ export const mockClientAccess: ClientAccessAccount[] = [
active_user_count: 1,
new_user_count: 0,
enabled_feature_count: 3,
total_feature_count: 6,
total_feature_count: 7,
users: [
{
id: 3,
@@ -235,7 +326,19 @@ export const mockClientAccess: ClientAccessAccount[] = [
status: 'active',
is_new_user: false,
last_login_at: '2026-04-22T09:10:00',
created_at: '2026-04-21T10:00:00'
created_at: '2026-04-21T10:00:00',
module_permissions: MODULE_DETAILS.map(([module_key, module_name, module_group, description], index) => ({
id: index + 201,
client_account_id: 2,
client_user_id: 3,
module_key,
module_name,
module_group,
description,
access_level: MODULE_PERMISSIONS.viewer[module_key],
updated_at: '2026-04-22T09:10:00',
created_at: '2026-04-21T10:00:00'
}))
}
],
features: [
@@ -304,8 +407,20 @@ export const mockClientAccess: ClientAccessAccount[] = [
enabled: true,
updated_at: '2026-04-22T09:10:00',
created_at: '2026-04-21T10:00:00'
},
{
id: 14,
client_account_id: 2,
feature_key: 'client_access',
feature_name: 'Client Access',
feature_group: 'administration',
description: 'Manage user access, module permissions, and audit history',
enabled: false,
updated_at: '2026-04-22T09:10:00',
created_at: '2026-04-21T10:00:00'
}
]
],
audit_history: []
}
];
@@ -349,5 +464,35 @@ export const mockClientAccessExport: ClientAccessPowerBiExport = {
updated_at: feature.updated_at
}))
),
permission_rows: mockClientAccess.flatMap((client) =>
client.users.flatMap((user) =>
user.module_permissions.map((permission) => ({
client_id: client.id,
client_name: client.name,
user_id: user.id,
user_email: user.email,
module_key: permission.module_key,
module_name: permission.module_name,
module_group: permission.module_group,
access_level: permission.access_level,
updated_at: permission.updated_at
}))
)
),
audit_rows: mockClientAccess.flatMap((client) =>
client.audit_history.map((event) => ({
client_id: client.id,
client_name: client.name,
event_id: event.id,
actor_email: event.actor_email,
actor_role: event.actor_role,
action: event.action,
target_type: event.target_type,
target_id: event.target_id,
module_key: event.module_key,
summary: event.summary,
created_at: event.created_at
}))
),
clients: mockClientAccess
};