@open-mercato/core 0.6.4-develop.4210.1.d412061cfe → 0.6.4-develop.4236.1.9fa6806b34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/staff_time_entry/index.js +37 -0
- package/dist/generated/entities/staff_time_entry/index.js.map +7 -0
- package/dist/generated/entities/staff_time_entry_segment/index.js +23 -0
- package/dist/generated/entities/staff_time_entry_segment/index.js.map +7 -0
- package/dist/generated/entities/staff_time_project/index.js +35 -0
- package/dist/generated/entities/staff_time_project/index.js.map +7 -0
- package/dist/generated/entities/staff_time_project_member/index.js +29 -0
- package/dist/generated/entities/staff_time_project_member/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +5 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +64 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/timesheetFixtures.js +50 -0
- package/dist/helpers/integration/timesheetFixtures.js.map +7 -0
- package/dist/modules/attachments/api/library/[id]/route.js +20 -16
- package/dist/modules/attachments/api/library/[id]/route.js.map +2 -2
- package/dist/modules/attachments/api/route.js +18 -14
- package/dist/modules/attachments/api/route.js.map +2 -2
- package/dist/modules/auth/api/roles/acl/route.js +10 -4
- package/dist/modules/auth/api/roles/acl/route.js.map +2 -2
- package/dist/modules/auth/api/sidebar/preferences/route.js +27 -20
- package/dist/modules/auth/api/sidebar/preferences/route.js.map +2 -2
- package/dist/modules/auth/api/users/acl/route.js +16 -11
- package/dist/modules/auth/api/users/acl/route.js.map +2 -2
- package/dist/modules/auth/commands/users.js +87 -71
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/auth/services/sidebarPreferencesService.js +39 -30
- package/dist/modules/auth/services/sidebarPreferencesService.js.map +2 -2
- package/dist/modules/catalog/commands/categories.js +61 -12
- package/dist/modules/catalog/commands/categories.js.map +2 -2
- package/dist/modules/catalog/commands/products.js +79 -54
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/commands/variants.js +29 -16
- package/dist/modules/catalog/commands/variants.js.map +2 -2
- package/dist/modules/currencies/commands/currencies.js +15 -8
- package/dist/modules/currencies/commands/currencies.js.map +2 -2
- package/dist/modules/customer_accounts/api/admin/users.js +27 -26
- package/dist/modules/customer_accounts/api/admin/users.js.map +2 -2
- package/dist/modules/customer_accounts/api/password/reset-confirm.js +5 -5
- package/dist/modules/customer_accounts/api/password/reset-confirm.js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/users/[id]/roles.js +11 -10
- package/dist/modules/customer_accounts/api/portal/users/[id]/roles.js.map +2 -2
- package/dist/modules/customers/commands/addresses.js +35 -21
- package/dist/modules/customers/commands/addresses.js.map +2 -2
- package/dist/modules/customers/commands/companies.js +163 -162
- package/dist/modules/customers/commands/companies.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +3 -4
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/commands/interactions.js +19 -22
- package/dist/modules/customers/commands/interactions.js.map +2 -2
- package/dist/modules/customers/commands/people.js +18 -15
- package/dist/modules/customers/commands/people.js.map +2 -2
- package/dist/modules/customers/commands/personCompanyLinks.js +105 -94
- package/dist/modules/customers/commands/personCompanyLinks.js.map +2 -2
- package/dist/modules/customers/commands/pipeline-stages.js +30 -23
- package/dist/modules/customers/commands/pipeline-stages.js.map +2 -2
- package/dist/modules/customers/commands/pipelines.js +27 -20
- package/dist/modules/customers/commands/pipelines.js.map +2 -2
- package/dist/modules/customers/commands/tags.js +13 -5
- package/dist/modules/customers/commands/tags.js.map +2 -2
- package/dist/modules/dashboards/api/users/widgets/route.js +0 -1
- package/dist/modules/dashboards/api/users/widgets/route.js.map +2 -2
- package/dist/modules/dashboards/api/widgets/data/route.js +29 -1
- package/dist/modules/dashboards/api/widgets/data/route.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-engine.js +4 -4
- package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
- package/dist/modules/data_sync/lib/sync-run-service.js +51 -27
- package/dist/modules/data_sync/lib/sync-run-service.js.map +2 -2
- package/dist/modules/directory/commands/organizations.js +192 -158
- package/dist/modules/directory/commands/organizations.js.map +3 -3
- package/dist/modules/inbox_ops/api/emails/[id]/reprocess/route.js +22 -16
- package/dist/modules/inbox_ops/api/emails/[id]/reprocess/route.js.map +2 -2
- package/dist/modules/messages/commands/messages.js +77 -75
- package/dist/modules/messages/commands/messages.js.map +2 -2
- package/dist/modules/messages/commands/shared.js +132 -132
- package/dist/modules/messages/commands/shared.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/route.js +37 -26
- package/dist/modules/perspectives/api/[tableId]/route.js.map +2 -2
- package/dist/modules/resources/commands/resources.js +125 -117
- package/dist/modules/resources/commands/resources.js.map +2 -2
- package/dist/modules/resources/commands/tags.js +7 -3
- package/dist/modules/resources/commands/tags.js.map +2 -2
- package/dist/modules/sales/api/quotes/send/route.js +12 -11
- package/dist/modules/sales/api/quotes/send/route.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +629 -478
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/commands/payments.js +146 -146
- package/dist/modules/sales/commands/payments.js.map +2 -2
- package/dist/modules/sales/commands/returns.js +68 -60
- package/dist/modules/sales/commands/returns.js.map +2 -2
- package/dist/modules/staff/acl.js +10 -1
- package/dist/modules/staff/acl.js.map +2 -2
- package/dist/modules/staff/analytics.js +33 -0
- package/dist/modules/staff/analytics.js.map +7 -0
- package/dist/modules/staff/api/guards.js +31 -0
- package/dist/modules/staff/api/guards.js.map +7 -0
- package/dist/modules/staff/api/interceptors.js +96 -0
- package/dist/modules/staff/api/interceptors.js.map +7 -0
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js +170 -0
- package/dist/modules/staff/api/timesheets/my-projects/[projectId]/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/my-projects/route.js +103 -0
- package/dist/modules/staff/api/timesheets/my-projects/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js +147 -0
- package/dist/modules/staff/api/timesheets/projects/kpis/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js +171 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js +180 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/segments/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js +155 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js +173 -0
- package/dist/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js +260 -0
- package/dist/modules/staff/api/timesheets/time-entries/bulk/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-entries/route.js +188 -0
- package/dist/modules/staff/api/timesheets/time-entries/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-projects/[id]/employees/route.js +159 -0
- package/dist/modules/staff/api/timesheets/time-projects/[id]/employees/route.js.map +7 -0
- package/dist/modules/staff/api/timesheets/time-projects/route.js +230 -0
- package/dist/modules/staff/api/timesheets/time-projects/route.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/page.js +710 -0
- package/dist/modules/staff/backend/staff/timesheets/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/page.meta.js +22 -0
- package/dist/modules/staff/backend/staff/timesheets/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.js +125 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js +418 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.js +79 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.meta.js +16 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/create/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js +602 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.meta.js +25 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/page.meta.js.map +7 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/projectFormConfig.js +123 -0
- package/dist/modules/staff/backend/staff/timesheets/projects/projectFormConfig.js.map +7 -0
- package/dist/modules/staff/cli.js +38 -1
- package/dist/modules/staff/cli.js.map +2 -2
- package/dist/modules/staff/commands/index.js +2 -0
- package/dist/modules/staff/commands/index.js.map +2 -2
- package/dist/modules/staff/commands/leave-requests.js +30 -28
- package/dist/modules/staff/commands/leave-requests.js.map +3 -3
- package/dist/modules/staff/commands/team-members.js +21 -20
- package/dist/modules/staff/commands/team-members.js.map +2 -2
- package/dist/modules/staff/commands/timesheets-entries.js +409 -0
- package/dist/modules/staff/commands/timesheets-entries.js.map +7 -0
- package/dist/modules/staff/commands/timesheets-projects.js +618 -0
- package/dist/modules/staff/commands/timesheets-projects.js.map +7 -0
- package/dist/modules/staff/data/enrichers.js +104 -0
- package/dist/modules/staff/data/enrichers.js.map +7 -0
- package/dist/modules/staff/data/entities.js +226 -1
- package/dist/modules/staff/data/entities.js.map +2 -2
- package/dist/modules/staff/data/validators.js +113 -1
- package/dist/modules/staff/data/validators.js.map +2 -2
- package/dist/modules/staff/events.js +13 -1
- package/dist/modules/staff/events.js.map +2 -2
- package/dist/modules/staff/lib/crud.js +7 -1
- package/dist/modules/staff/lib/crud.js.map +2 -2
- package/dist/modules/staff/lib/staffMemberResolver.js +15 -0
- package/dist/modules/staff/lib/staffMemberResolver.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectHoursTrend.js +60 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectHoursTrend.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectsKpis.js +260 -0
- package/dist/modules/staff/lib/timesheets-projects/computeProjectsKpis.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/dateBuckets.js +41 -0
- package/dist/modules/staff/lib/timesheets-projects/dateBuckets.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/initials.js +10 -0
- package/dist/modules/staff/lib/timesheets-projects/initials.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/kpiMath.js +12 -0
- package/dist/modules/staff/lib/timesheets-projects/kpiMath.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects/listProjectMembersPreview.js +55 -0
- package/dist/modules/staff/lib/timesheets-projects/listProjectMembersPreview.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/HoursSparkline.js +66 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/HoursSparkline.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectCard.js +81 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectCard.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectMembersAvatarStack.js +58 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectMembersAvatarStack.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectsKpiStrip.js +152 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ProjectsKpiStrip.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.js +37 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ViewModeToggle.js +57 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/ViewModeToggle.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/useProjectsViewMode.js +50 -0
- package/dist/modules/staff/lib/timesheets-projects-ui/useProjectsViewMode.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/AddRowDropdown.js +163 -0
- package/dist/modules/staff/lib/timesheets-ui/AddRowDropdown.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js +209 -0
- package/dist/modules/staff/lib/timesheets-ui/CalendarPicker.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ColorPicker.js +52 -0
- package/dist/modules/staff/lib/timesheets-ui/ColorPicker.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/CreateProjectDialog.js +77 -0
- package/dist/modules/staff/lib/timesheets-ui/CreateProjectDialog.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ListView.js +173 -0
- package/dist/modules/staff/lib/timesheets-ui/ListView.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ProjectColorDot.js +32 -0
- package/dist/modules/staff/lib/timesheets-ui/ProjectColorDot.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/TimerBar.js +270 -0
- package/dist/modules/staff/lib/timesheets-ui/TimerBar.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/ViewSwitcher.js +57 -0
- package/dist/modules/staff/lib/timesheets-ui/ViewSwitcher.js.map +7 -0
- package/dist/modules/staff/lib/timesheets-ui/colors.js +43 -0
- package/dist/modules/staff/lib/timesheets-ui/colors.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260326135612.js +24 -0
- package/dist/modules/staff/migrations/Migration20260326135612.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260413102715.js +23 -0
- package/dist/modules/staff/migrations/Migration20260413102715.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260413111602.js +13 -0
- package/dist/modules/staff/migrations/Migration20260413111602.js.map +7 -0
- package/dist/modules/staff/migrations/Migration20260511112759.js +19 -0
- package/dist/modules/staff/migrations/Migration20260511112759.js.map +7 -0
- package/dist/modules/staff/search.js +35 -0
- package/dist/modules/staff/search.js.map +2 -2
- package/dist/modules/staff/setup.js +15 -1
- package/dist/modules/staff/setup.js.map +2 -2
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/config.js +16 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/config.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.js +126 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.js +26 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/config.js +15 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/config.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.js +238 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.js.map +7 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.js +26 -0
- package/dist/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.js.map +7 -0
- package/dist/modules/staff/widgets/injection/timer-sidebar-indicator/widget.js +145 -0
- package/dist/modules/staff/widgets/injection/timer-sidebar-indicator/widget.js.map +7 -0
- package/dist/modules/staff/widgets/injection-table.js +12 -0
- package/dist/modules/staff/widgets/injection-table.js.map +7 -0
- package/dist/modules/sync_excel/api/import/route.js +19 -17
- package/dist/modules/sync_excel/api/import/route.js.map +2 -2
- package/dist/modules/translations/commands/translations.js +22 -19
- package/dist/modules/translations/commands/translations.js.map +2 -2
- package/generated/entities/staff_time_entry/index.ts +17 -0
- package/generated/entities/staff_time_entry_segment/index.ts +10 -0
- package/generated/entities/staff_time_project/index.ts +16 -0
- package/generated/entities/staff_time_project_member/index.ts +13 -0
- package/generated/entities.ids.generated.ts +5 -1
- package/generated/entity-fields-registry.ts +64 -0
- package/package.json +7 -7
- package/src/helpers/integration/timesheetFixtures.ts +61 -0
- package/src/modules/attachments/api/library/[id]/route.ts +24 -17
- package/src/modules/attachments/api/route.ts +20 -14
- package/src/modules/auth/api/roles/acl/route.ts +11 -5
- package/src/modules/auth/api/sidebar/preferences/route.ts +33 -24
- package/src/modules/auth/api/users/acl/route.ts +17 -12
- package/src/modules/auth/commands/users.ts +96 -80
- package/src/modules/auth/services/sidebarPreferencesService.ts +40 -32
- package/src/modules/catalog/commands/categories.ts +61 -12
- package/src/modules/catalog/commands/products.ts +93 -60
- package/src/modules/catalog/commands/variants.ts +29 -16
- package/src/modules/currencies/commands/currencies.ts +27 -14
- package/src/modules/customer_accounts/api/admin/users.ts +31 -26
- package/src/modules/customer_accounts/api/password/reset-confirm.ts +5 -6
- package/src/modules/customer_accounts/api/portal/users/[id]/roles.ts +14 -13
- package/src/modules/customers/commands/addresses.ts +35 -23
- package/src/modules/customers/commands/companies.ts +166 -165
- package/src/modules/customers/commands/deals.ts +2 -4
- package/src/modules/customers/commands/interactions.ts +20 -26
- package/src/modules/customers/commands/people.ts +18 -15
- package/src/modules/customers/commands/personCompanyLinks.ts +109 -100
- package/src/modules/customers/commands/pipeline-stages.ts +31 -27
- package/src/modules/customers/commands/pipelines.ts +29 -23
- package/src/modules/customers/commands/tags.ts +13 -5
- package/src/modules/dashboards/api/users/widgets/route.ts +0 -1
- package/src/modules/dashboards/api/widgets/data/route.ts +36 -1
- package/src/modules/data_sync/lib/sync-engine.ts +4 -5
- package/src/modules/data_sync/lib/sync-run-service.ts +57 -28
- package/src/modules/directory/commands/organizations.ts +203 -166
- package/src/modules/inbox_ops/api/emails/[id]/reprocess/route.ts +26 -18
- package/src/modules/messages/commands/messages.ts +82 -80
- package/src/modules/messages/commands/shared.ts +138 -133
- package/src/modules/perspectives/api/[tableId]/route.ts +38 -27
- package/src/modules/resources/commands/resources.ts +127 -117
- package/src/modules/resources/commands/tags.ts +7 -3
- package/src/modules/sales/api/quotes/send/route.ts +17 -12
- package/src/modules/sales/commands/documents.ts +673 -481
- package/src/modules/sales/commands/payments.ts +158 -152
- package/src/modules/sales/commands/returns.ts +74 -63
- package/src/modules/staff/acl.ts +11 -0
- package/src/modules/staff/analytics.ts +30 -0
- package/src/modules/staff/api/guards.ts +59 -0
- package/src/modules/staff/api/interceptors.ts +122 -0
- package/src/modules/staff/api/timesheets/my-projects/[projectId]/route.ts +191 -0
- package/src/modules/staff/api/timesheets/my-projects/route.ts +115 -0
- package/src/modules/staff/api/timesheets/projects/kpis/route.ts +159 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/[segmentId]/route.ts +187 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/segments/route.ts +191 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-start/route.ts +168 -0
- package/src/modules/staff/api/timesheets/time-entries/[id]/timer-stop/route.ts +191 -0
- package/src/modules/staff/api/timesheets/time-entries/bulk/route.ts +292 -0
- package/src/modules/staff/api/timesheets/time-entries/route.ts +193 -0
- package/src/modules/staff/api/timesheets/time-projects/[id]/employees/route.ts +167 -0
- package/src/modules/staff/api/timesheets/time-projects/route.ts +244 -0
- package/src/modules/staff/backend/staff/timesheets/page.meta.ts +20 -0
- package/src/modules/staff/backend/staff/timesheets/page.tsx +899 -0
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/edit/page.tsx +141 -0
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/timesheets/projects/[id]/page.tsx +579 -0
- package/src/modules/staff/backend/staff/timesheets/projects/create/page.meta.ts +12 -0
- package/src/modules/staff/backend/staff/timesheets/projects/create/page.tsx +90 -0
- package/src/modules/staff/backend/staff/timesheets/projects/page.meta.ts +23 -0
- package/src/modules/staff/backend/staff/timesheets/projects/page.tsx +765 -0
- package/src/modules/staff/backend/staff/timesheets/projects/projectFormConfig.ts +138 -0
- package/src/modules/staff/cli.ts +40 -1
- package/src/modules/staff/commands/index.ts +2 -0
- package/src/modules/staff/commands/leave-requests.ts +37 -29
- package/src/modules/staff/commands/team-members.ts +25 -20
- package/src/modules/staff/commands/timesheets-entries.ts +504 -0
- package/src/modules/staff/commands/timesheets-projects.ts +699 -0
- package/src/modules/staff/data/enrichers.ts +134 -0
- package/src/modules/staff/data/entities.ts +198 -0
- package/src/modules/staff/data/validators.ts +129 -0
- package/src/modules/staff/events.ts +13 -0
- package/src/modules/staff/i18n/de.json +209 -1
- package/src/modules/staff/i18n/en.json +209 -1
- package/src/modules/staff/i18n/es.json +209 -1
- package/src/modules/staff/i18n/pl.json +209 -1
- package/src/modules/staff/lib/crud.ts +8 -0
- package/src/modules/staff/lib/staffMemberResolver.ts +22 -0
- package/src/modules/staff/lib/timesheets-projects/computeProjectHoursTrend.ts +89 -0
- package/src/modules/staff/lib/timesheets-projects/computeProjectsKpis.ts +311 -0
- package/src/modules/staff/lib/timesheets-projects/dateBuckets.ts +37 -0
- package/src/modules/staff/lib/timesheets-projects/initials.ts +6 -0
- package/src/modules/staff/lib/timesheets-projects/kpiMath.ts +8 -0
- package/src/modules/staff/lib/timesheets-projects/listProjectMembersPreview.ts +83 -0
- package/src/modules/staff/lib/timesheets-projects-ui/HoursSparkline.tsx +75 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectCard.tsx +110 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectMembersAvatarStack.tsx +73 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ProjectsKpiStrip.tsx +185 -0
- package/src/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.tsx +53 -0
- package/src/modules/staff/lib/timesheets-projects-ui/ViewModeToggle.tsx +63 -0
- package/src/modules/staff/lib/timesheets-projects-ui/useProjectsViewMode.ts +63 -0
- package/src/modules/staff/lib/timesheets-ui/AddRowDropdown.tsx +188 -0
- package/src/modules/staff/lib/timesheets-ui/CalendarPicker.tsx +229 -0
- package/src/modules/staff/lib/timesheets-ui/ColorPicker.tsx +65 -0
- package/src/modules/staff/lib/timesheets-ui/CreateProjectDialog.tsx +99 -0
- package/src/modules/staff/lib/timesheets-ui/ListView.tsx +230 -0
- package/src/modules/staff/lib/timesheets-ui/ProjectColorDot.tsx +40 -0
- package/src/modules/staff/lib/timesheets-ui/TimerBar.tsx +327 -0
- package/src/modules/staff/lib/timesheets-ui/ViewSwitcher.tsx +60 -0
- package/src/modules/staff/lib/timesheets-ui/colors.ts +58 -0
- package/src/modules/staff/migrations/.snapshot-open-mercato.json +1148 -0
- package/src/modules/staff/migrations/Migration20260326135612.ts +26 -0
- package/src/modules/staff/migrations/Migration20260413102715.ts +25 -0
- package/src/modules/staff/migrations/Migration20260413111602.ts +13 -0
- package/src/modules/staff/migrations/Migration20260511112759.ts +21 -0
- package/src/modules/staff/search.ts +35 -0
- package/src/modules/staff/setup.ts +15 -0
- package/src/modules/staff/widgets/dashboard/timesheets-hours-by-project/config.ts +17 -0
- package/src/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.client.tsx +158 -0
- package/src/modules/staff/widgets/dashboard/timesheets-hours-by-project/widget.ts +25 -0
- package/src/modules/staff/widgets/dashboard/timesheets-time-reporting/config.ts +15 -0
- package/src/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.client.tsx +297 -0
- package/src/modules/staff/widgets/dashboard/timesheets-time-reporting/widget.ts +25 -0
- package/src/modules/staff/widgets/injection/timer-sidebar-indicator/widget.tsx +161 -0
- package/src/modules/staff/widgets/injection-table.ts +10 -0
- package/src/modules/sync_excel/api/import/route.ts +23 -18
- package/src/modules/translations/commands/translations.ts +49 -41
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
+
|
|
3
|
+
export class Migration20260326135612 extends Migration {
|
|
4
|
+
|
|
5
|
+
override async up(): Promise<void> {
|
|
6
|
+
this.addSql(`create table "staff_time_entries" ("id" uuid not null default gen_random_uuid(), "tenant_id" uuid not null, "organization_id" uuid not null, "staff_member_id" uuid not null, "date" date not null, "duration_minutes" int not null default 0, "started_at" timestamptz null, "ended_at" timestamptz null, "notes" text null, "time_project_id" uuid null, "customer_id" uuid null, "deal_id" uuid null, "order_id" uuid null, "source" text check ("source" in ('manual', 'timer', 'kiosk', 'mobile')) not null default 'manual', "created_at" timestamptz not null, "updated_at" timestamptz not null, "deleted_at" timestamptz null, constraint "staff_time_entries_pkey" primary key ("id"));`);
|
|
7
|
+
this.addSql(`create index "staff_time_entries_project_date_idx" on "staff_time_entries" ("organization_id", "time_project_id", "date");`);
|
|
8
|
+
this.addSql(`create index "staff_time_entries_member_date_idx" on "staff_time_entries" ("organization_id", "staff_member_id", "date");`);
|
|
9
|
+
this.addSql(`create index "staff_time_entries_tenant_org_idx" on "staff_time_entries" ("tenant_id", "organization_id");`);
|
|
10
|
+
|
|
11
|
+
this.addSql(`create table "staff_time_entry_segments" ("id" uuid not null default gen_random_uuid(), "tenant_id" uuid not null, "organization_id" uuid not null, "time_entry_id" uuid not null, "started_at" timestamptz not null, "ended_at" timestamptz null, "segment_type" text check ("segment_type" in ('work', 'break')) not null default 'work', "created_at" timestamptz not null, "updated_at" timestamptz not null, "deleted_at" timestamptz null, constraint "staff_time_entry_segments_pkey" primary key ("id"));`);
|
|
12
|
+
this.addSql(`create index "staff_time_entry_segments_entry_idx" on "staff_time_entry_segments" ("time_entry_id");`);
|
|
13
|
+
this.addSql(`create index "staff_time_entry_segments_tenant_org_idx" on "staff_time_entry_segments" ("tenant_id", "organization_id");`);
|
|
14
|
+
|
|
15
|
+
this.addSql(`create table "staff_time_projects" ("id" uuid not null default gen_random_uuid(), "tenant_id" uuid not null, "organization_id" uuid not null, "name" text not null, "customer_id" uuid null, "code" text not null, "description" text null, "project_type" text null, "status" text check ("status" in ('active', 'on_hold', 'completed')) not null default 'active', "owner_user_id" uuid null, "cost_center" text null, "start_date" date null, "created_at" timestamptz not null, "updated_at" timestamptz not null, "deleted_at" timestamptz null, constraint "staff_time_projects_pkey" primary key ("id"));`);
|
|
16
|
+
this.addSql(`create index "staff_time_projects_code_unique_idx" on "staff_time_projects" ("organization_id", "tenant_id", "code");`);
|
|
17
|
+
this.addSql(`create index "staff_time_projects_tenant_org_idx" on "staff_time_projects" ("tenant_id", "organization_id");`);
|
|
18
|
+
|
|
19
|
+
this.addSql(`create table "staff_time_project_members" ("id" uuid not null default gen_random_uuid(), "tenant_id" uuid not null, "organization_id" uuid not null, "time_project_id" uuid not null, "staff_member_id" uuid not null, "role" text null, "status" text check ("status" in ('active', 'inactive')) not null default 'active', "assigned_start_date" date not null, "assigned_end_date" date null, "created_at" timestamptz not null, "updated_at" timestamptz not null, "deleted_at" timestamptz null, constraint "staff_time_project_members_pkey" primary key ("id"));`);
|
|
20
|
+
this.addSql(`create index "staff_time_project_members_unique_idx" on "staff_time_project_members" ("organization_id", "tenant_id", "time_project_id", "staff_member_id");`);
|
|
21
|
+
this.addSql(`create index "staff_time_project_members_member_idx" on "staff_time_project_members" ("organization_id", "staff_member_id");`);
|
|
22
|
+
this.addSql(`create index "staff_time_project_members_project_idx" on "staff_time_project_members" ("organization_id", "time_project_id");`);
|
|
23
|
+
this.addSql(`create index "staff_time_project_members_tenant_org_idx" on "staff_time_project_members" ("tenant_id", "organization_id");`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
+
|
|
3
|
+
export class Migration20260413102715 extends Migration {
|
|
4
|
+
|
|
5
|
+
override async up(): Promise<void> {
|
|
6
|
+
this.addSql(`alter table "staff_time_project_members" add column "show_in_grid" boolean not null default false;`);
|
|
7
|
+
// Backfill: preserve grid visibility for memberships that already have time entries,
|
|
8
|
+
// so existing users don't lose rows the first time the new visibility filter is applied.
|
|
9
|
+
this.addSql(`
|
|
10
|
+
update "staff_time_project_members" m
|
|
11
|
+
set "show_in_grid" = true
|
|
12
|
+
where exists (
|
|
13
|
+
select 1 from "staff_time_entries" e
|
|
14
|
+
where e."time_project_id" = m."time_project_id"
|
|
15
|
+
and e."staff_member_id" = m."staff_member_id"
|
|
16
|
+
and e."deleted_at" is null
|
|
17
|
+
);
|
|
18
|
+
`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override async down(): Promise<void> {
|
|
22
|
+
this.addSql(`alter table "staff_time_project_members" drop column "show_in_grid";`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
+
|
|
3
|
+
export class Migration20260413111602 extends Migration {
|
|
4
|
+
|
|
5
|
+
override async up(): Promise<void> {
|
|
6
|
+
this.addSql(`alter table "staff_time_projects" add column "color" varchar(20) null;`);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
override async down(): Promise<void> {
|
|
10
|
+
this.addSql(`alter table "staff_time_projects" drop column "color";`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations';
|
|
2
|
+
|
|
3
|
+
export class Migration20260511112759 extends Migration {
|
|
4
|
+
|
|
5
|
+
override async up(): Promise<void> {
|
|
6
|
+
this.addSql(`drop index if exists "staff_time_projects_code_unique_idx";`);
|
|
7
|
+
this.addSql(`create unique index "staff_time_projects_code_unique_idx" on "staff_time_projects" ("organization_id", "tenant_id", "code") where "deleted_at" is null;`);
|
|
8
|
+
|
|
9
|
+
this.addSql(`drop index if exists "staff_time_project_members_unique_idx";`);
|
|
10
|
+
this.addSql(`create unique index "staff_time_project_members_unique_idx" on "staff_time_project_members" ("organization_id", "tenant_id", "time_project_id", "staff_member_id") where "deleted_at" is null;`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override async down(): Promise<void> {
|
|
14
|
+
this.addSql(`drop index if exists "staff_time_project_members_unique_idx";`);
|
|
15
|
+
this.addSql(`create index "staff_time_project_members_unique_idx" on "staff_time_project_members" ("organization_id", "tenant_id", "time_project_id", "staff_member_id");`);
|
|
16
|
+
|
|
17
|
+
this.addSql(`drop index if exists "staff_time_projects_code_unique_idx";`);
|
|
18
|
+
this.addSql(`create index "staff_time_projects_code_unique_idx" on "staff_time_projects" ("organization_id", "tenant_id", "code");`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
@@ -188,6 +188,41 @@ export const searchConfig: SearchModuleConfig = {
|
|
|
188
188
|
searchable: ['name', 'description', 'appearance_icon', 'appearance_color'],
|
|
189
189
|
},
|
|
190
190
|
},
|
|
191
|
+
{
|
|
192
|
+
entityId: 'staff:staff_time_project',
|
|
193
|
+
enabled: true,
|
|
194
|
+
priority: 7,
|
|
195
|
+
buildSource: async (ctx) => {
|
|
196
|
+
const { t } = await resolveTranslations()
|
|
197
|
+
const record = ctx.record
|
|
198
|
+
const lines: string[] = []
|
|
199
|
+
appendLine(lines, 'Name', record.name)
|
|
200
|
+
appendLine(lines, 'Code', record.code)
|
|
201
|
+
appendLine(lines, 'Description', record.description)
|
|
202
|
+
appendLine(lines, 'Type', record.project_type ?? record.projectType)
|
|
203
|
+
appendLine(lines, 'Cost Center', record.cost_center ?? record.costCenter)
|
|
204
|
+
const presenter: SearchResultPresenter = {
|
|
205
|
+
title: String(record.name ?? record.id ?? t('staff.search.badge.timeProject', 'Project')),
|
|
206
|
+
subtitle: formatSubtitle(record.code, record.project_type ?? record.projectType),
|
|
207
|
+
icon: 'clock',
|
|
208
|
+
badge: t('staff.search.badge.timeProject', 'Project'),
|
|
209
|
+
}
|
|
210
|
+
return buildIndexSource(ctx, presenter, lines)
|
|
211
|
+
},
|
|
212
|
+
formatResult: async (ctx) => {
|
|
213
|
+
const { t } = await resolveTranslations()
|
|
214
|
+
return {
|
|
215
|
+
title: String(ctx.record.name ?? ctx.record.id ?? ''),
|
|
216
|
+
subtitle: formatSubtitle(ctx.record.code, ctx.record.project_type ?? ctx.record.projectType),
|
|
217
|
+
icon: 'clock',
|
|
218
|
+
badge: t('staff.search.badge.timeProject', 'Project'),
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
resolveUrl: async (ctx) => `/backend/staff/timesheets/projects/${encodeURIComponent(String(ctx.record.id))}`,
|
|
222
|
+
fieldPolicy: {
|
|
223
|
+
searchable: ['name', 'code', 'description', 'project_type', 'cost_center'],
|
|
224
|
+
},
|
|
225
|
+
},
|
|
191
226
|
],
|
|
192
227
|
}
|
|
193
228
|
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import type { ModuleSetupConfig } from '@open-mercato/shared/modules/setup'
|
|
2
|
+
import { appendWidgetsToRoles } from '@open-mercato/core/modules/dashboards/lib/role-widgets'
|
|
2
3
|
import { seedStaffAddressTypes, seedStaffTeamExamples } from './lib/seeds'
|
|
3
4
|
|
|
5
|
+
const TIMESHEETS_DASHBOARD_WIDGET_IDS = [
|
|
6
|
+
'staff.timesheets.timeReporting',
|
|
7
|
+
'staff.timesheets.hoursByProject',
|
|
8
|
+
]
|
|
9
|
+
|
|
4
10
|
export const setup: ModuleSetupConfig = {
|
|
5
11
|
seedDefaults: async (ctx) => {
|
|
6
12
|
const scope = { tenantId: ctx.tenantId, organizationId: ctx.organizationId }
|
|
7
13
|
await seedStaffAddressTypes(ctx.em, scope)
|
|
14
|
+
await appendWidgetsToRoles(ctx.em, {
|
|
15
|
+
tenantId: ctx.tenantId,
|
|
16
|
+
organizationId: ctx.organizationId,
|
|
17
|
+
roleNames: ['superadmin', 'admin', 'employee'],
|
|
18
|
+
widgetIds: TIMESHEETS_DASHBOARD_WIDGET_IDS,
|
|
19
|
+
})
|
|
8
20
|
},
|
|
9
21
|
|
|
10
22
|
seedExamples: async (ctx) => {
|
|
@@ -20,6 +32,9 @@ export const setup: ModuleSetupConfig = {
|
|
|
20
32
|
'staff.my_availability.manage',
|
|
21
33
|
'staff.my_leave_requests.view',
|
|
22
34
|
'staff.my_leave_requests.send',
|
|
35
|
+
'staff.timesheets.view',
|
|
36
|
+
'staff.timesheets.manage_own',
|
|
37
|
+
'staff.timesheets.projects.view',
|
|
23
38
|
],
|
|
24
39
|
},
|
|
25
40
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type DateRangePreset, isValidDateRangePreset } from '@open-mercato/ui/backend/date-range'
|
|
2
|
+
|
|
3
|
+
export type HoursByProjectSettings = {
|
|
4
|
+
dateRange: DateRangePreset
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_SETTINGS: HoursByProjectSettings = {
|
|
8
|
+
dateRange: 'this_month',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function hydrateSettings(raw: unknown): HoursByProjectSettings {
|
|
12
|
+
if (!raw || typeof raw !== 'object') return { ...DEFAULT_SETTINGS }
|
|
13
|
+
const obj = raw as Record<string, unknown>
|
|
14
|
+
return {
|
|
15
|
+
dateRange: isValidDateRangePreset(obj.dateRange) ? obj.dateRange : DEFAULT_SETTINGS.dateRange,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import type { DashboardWidgetComponentProps } from '@open-mercato/shared/modules/dashboard/widgets'
|
|
5
|
+
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
6
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
7
|
+
import {
|
|
8
|
+
DateRangeSelect,
|
|
9
|
+
InlineDateRangeSelect,
|
|
10
|
+
type DateRangePreset,
|
|
11
|
+
} from '@open-mercato/ui/backend/date-range'
|
|
12
|
+
import { DEFAULT_SETTINGS, hydrateSettings, type HoursByProjectSettings } from './config'
|
|
13
|
+
|
|
14
|
+
type WidgetDataItem = { groupKey: string; groupLabel?: string; value: number | null }
|
|
15
|
+
type WidgetDataResponse = {
|
|
16
|
+
value: number | null
|
|
17
|
+
data: WidgetDataItem[]
|
|
18
|
+
metadata: { fetchedAt: string; recordCount: number }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function minutesToHours(minutes: number): string {
|
|
22
|
+
const hours = minutes / 60
|
|
23
|
+
return hours % 1 === 0 ? String(hours) : hours.toFixed(1)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function fetchData(settings: HoursByProjectSettings): Promise<WidgetDataResponse> {
|
|
27
|
+
const body = {
|
|
28
|
+
entityType: 'staff:staff_time_entries',
|
|
29
|
+
metric: { field: 'durationMinutes', aggregate: 'sum' },
|
|
30
|
+
groupBy: { field: 'timeProjectId', limit: 20, resolveLabels: true },
|
|
31
|
+
dateRange: { field: 'date', preset: settings.dateRange },
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const res = await apiCall<WidgetDataResponse>('/api/dashboards/widgets/data', {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: { 'Content-Type': 'application/json' },
|
|
37
|
+
body: JSON.stringify(body),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
if (!res.ok) {
|
|
41
|
+
const err = (res.result as Record<string, unknown>)?.error
|
|
42
|
+
throw new Error(typeof err === 'string' ? err : 'Failed to fetch data')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return res.result as WidgetDataResponse
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const HoursByProjectWidget: React.FC<DashboardWidgetComponentProps<HoursByProjectSettings>> = ({
|
|
49
|
+
mode,
|
|
50
|
+
settings = DEFAULT_SETTINGS,
|
|
51
|
+
onSettingsChange,
|
|
52
|
+
refreshToken,
|
|
53
|
+
onRefreshStateChange,
|
|
54
|
+
}) => {
|
|
55
|
+
const t = useT()
|
|
56
|
+
const hydrated = React.useMemo(() => hydrateSettings(settings), [settings])
|
|
57
|
+
const [data, setData] = React.useState<WidgetDataItem[]>([])
|
|
58
|
+
const [totalMinutes, setTotalMinutes] = React.useState(0)
|
|
59
|
+
const [loading, setLoading] = React.useState(true)
|
|
60
|
+
const [error, setError] = React.useState<string | null>(null)
|
|
61
|
+
|
|
62
|
+
const refresh = React.useCallback(async () => {
|
|
63
|
+
onRefreshStateChange?.(true)
|
|
64
|
+
setLoading(true)
|
|
65
|
+
setError(null)
|
|
66
|
+
try {
|
|
67
|
+
const result = await fetchData(hydrated)
|
|
68
|
+
const sorted = [...result.data].sort((a, b) => (b.value ?? 0) - (a.value ?? 0))
|
|
69
|
+
setData(sorted)
|
|
70
|
+
setTotalMinutes(sorted.reduce((sum, item) => sum + (item.value ?? 0), 0))
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.error('staff.timesheets.hoursByProject', err)
|
|
73
|
+
setError(t('staff.timesheets.widgets.hoursByProject.error', 'Failed to load data'))
|
|
74
|
+
} finally {
|
|
75
|
+
setLoading(false)
|
|
76
|
+
onRefreshStateChange?.(false)
|
|
77
|
+
}
|
|
78
|
+
}, [hydrated, onRefreshStateChange, t])
|
|
79
|
+
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
void refresh()
|
|
82
|
+
}, [refresh, refreshToken])
|
|
83
|
+
|
|
84
|
+
if (mode === 'settings') {
|
|
85
|
+
return (
|
|
86
|
+
<div className="space-y-4 text-sm">
|
|
87
|
+
<DateRangeSelect
|
|
88
|
+
id="hours-by-project-date-range"
|
|
89
|
+
label={t('staff.timesheets.widgets.hoursByProject.settings.dateRange', 'Date Range')}
|
|
90
|
+
value={hydrated.dateRange}
|
|
91
|
+
onChange={(dateRange: DateRangePreset) => onSettingsChange({ ...hydrated, dateRange })}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (loading) {
|
|
98
|
+
return (
|
|
99
|
+
<div className="flex h-full items-center justify-center py-8">
|
|
100
|
+
<p className="text-sm text-muted-foreground">{t('staff.timesheets.widgets.hoursByProject.loading', 'Loading...')}</p>
|
|
101
|
+
</div>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (error) {
|
|
106
|
+
return (
|
|
107
|
+
<div className="flex h-full items-center justify-center py-8">
|
|
108
|
+
<p className="text-sm text-destructive">{error}</p>
|
|
109
|
+
</div>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const maxValue = data.length > 0 ? Math.max(...data.map((d) => d.value ?? 0)) : 0
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<div className="space-y-3">
|
|
117
|
+
<div className="flex items-center justify-end">
|
|
118
|
+
<InlineDateRangeSelect
|
|
119
|
+
value={hydrated.dateRange}
|
|
120
|
+
onChange={(dateRange) => onSettingsChange({ ...hydrated, dateRange })}
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
{data.length === 0 ? (
|
|
125
|
+
<p className="py-4 text-center text-sm text-muted-foreground">
|
|
126
|
+
{t('staff.timesheets.widgets.hoursByProject.empty', 'No hours tracked in this period.')}
|
|
127
|
+
</p>
|
|
128
|
+
) : (
|
|
129
|
+
<div className="space-y-2.5">
|
|
130
|
+
{data.map((item) => {
|
|
131
|
+
const barWidth = maxValue > 0 ? ((item.value ?? 0) / maxValue) * 100 : 0
|
|
132
|
+
return (
|
|
133
|
+
<div key={item.groupKey} className="space-y-1">
|
|
134
|
+
<div className="flex items-center justify-between text-sm">
|
|
135
|
+
<span className="truncate font-medium">{item.groupLabel || item.groupKey}</span>
|
|
136
|
+
<span className="shrink-0 tabular-nums text-muted-foreground">{minutesToHours(item.value ?? 0)} h</span>
|
|
137
|
+
</div>
|
|
138
|
+
<div className="h-2 w-full rounded-full bg-muted">
|
|
139
|
+
<div
|
|
140
|
+
className="h-2 rounded-full bg-primary transition-all"
|
|
141
|
+
style={{ width: `${barWidth}%` }}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
)
|
|
146
|
+
})}
|
|
147
|
+
|
|
148
|
+
<div className="flex items-center justify-between border-t pt-2 text-sm font-semibold">
|
|
149
|
+
<span>{t('staff.timesheets.widgets.hoursByProject.total', 'Total')}</span>
|
|
150
|
+
<span className="tabular-nums">{minutesToHours(totalMinutes)} h</span>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
)}
|
|
154
|
+
</div>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export default HoursByProjectWidget
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { lazyDashboardWidget, type DashboardWidgetModule } from '@open-mercato/shared/modules/dashboard/widgets'
|
|
2
|
+
import { DEFAULT_SETTINGS, hydrateSettings, type HoursByProjectSettings } from './config'
|
|
3
|
+
|
|
4
|
+
const HoursByProjectWidget = lazyDashboardWidget(() => import('./widget.client'))
|
|
5
|
+
|
|
6
|
+
const widget: DashboardWidgetModule<HoursByProjectSettings> = {
|
|
7
|
+
metadata: {
|
|
8
|
+
id: 'staff.timesheets.hoursByProject',
|
|
9
|
+
title: 'Hours by Project',
|
|
10
|
+
description: 'Tracked hours grouped by project for a selected period',
|
|
11
|
+
features: ['dashboards.view', 'analytics.view', 'staff.timesheets.view'],
|
|
12
|
+
defaultSize: 'md',
|
|
13
|
+
defaultEnabled: false,
|
|
14
|
+
defaultSettings: DEFAULT_SETTINGS,
|
|
15
|
+
tags: ['analytics', 'staff', 'timesheets'],
|
|
16
|
+
category: 'analytics',
|
|
17
|
+
icon: 'clock',
|
|
18
|
+
supportsRefresh: true,
|
|
19
|
+
},
|
|
20
|
+
Widget: HoursByProjectWidget,
|
|
21
|
+
hydrateSettings,
|
|
22
|
+
dehydrateSettings: (s) => ({ dateRange: s.dateRange }),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default widget
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type TimeReportingSettings = {
|
|
2
|
+
lastProjectId: string | null
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_SETTINGS: TimeReportingSettings = {
|
|
6
|
+
lastProjectId: null,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function hydrateSettings(raw: unknown): TimeReportingSettings {
|
|
10
|
+
if (!raw || typeof raw !== 'object') return { ...DEFAULT_SETTINGS }
|
|
11
|
+
const obj = raw as Record<string, unknown>
|
|
12
|
+
return {
|
|
13
|
+
lastProjectId: typeof obj.lastProjectId === 'string' ? obj.lastProjectId : null,
|
|
14
|
+
}
|
|
15
|
+
}
|