@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,327 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useRef, useCallback } from 'react'
|
|
4
|
+
import { Play, Square } from 'lucide-react'
|
|
5
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { IconButton } from '@open-mercato/ui/primitives/icon-button'
|
|
7
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
8
|
+
import { apiCall, apiCallOrThrow } from '@open-mercato/ui/backend/utils/apiCall'
|
|
9
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
10
|
+
import { ProjectColorDot } from './ProjectColorDot'
|
|
11
|
+
|
|
12
|
+
type ProjectOption = {
|
|
13
|
+
id: string
|
|
14
|
+
name: string
|
|
15
|
+
code: string | null
|
|
16
|
+
color?: string | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type TimerBarProps = {
|
|
20
|
+
projects: ProjectOption[]
|
|
21
|
+
staffMemberId: string | null
|
|
22
|
+
onTimerStopped: () => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function formatElapsed(seconds: number): string {
|
|
26
|
+
const h = Math.floor(seconds / 3600)
|
|
27
|
+
const m = Math.floor((seconds % 3600) / 60)
|
|
28
|
+
const s = seconds % 60
|
|
29
|
+
return `${h}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getToday(): string {
|
|
33
|
+
const now = new Date()
|
|
34
|
+
const year = now.getFullYear()
|
|
35
|
+
const month = String(now.getMonth() + 1).padStart(2, '0')
|
|
36
|
+
const day = String(now.getDate()).padStart(2, '0')
|
|
37
|
+
return `${year}-${month}-${day}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function TimerBar({ projects, staffMemberId, onTimerStopped }: TimerBarProps) {
|
|
41
|
+
const t = useT()
|
|
42
|
+
|
|
43
|
+
const [activeEntryId, setActiveEntryId] = useState<string | null>(null)
|
|
44
|
+
const [activeProjectId, setActiveProjectId] = useState<string | null>(null)
|
|
45
|
+
const [elapsedSeconds, setElapsedSeconds] = useState(0)
|
|
46
|
+
const [description, setDescription] = useState('')
|
|
47
|
+
const [selectedProjectId, setSelectedProjectId] = useState<string | null>(null)
|
|
48
|
+
const [isStarting, setIsStarting] = useState(false)
|
|
49
|
+
const [isStopping, setIsStopping] = useState(false)
|
|
50
|
+
const [showProjectDropdown, setShowProjectDropdown] = useState(false)
|
|
51
|
+
const [projectFilter, setProjectFilter] = useState('')
|
|
52
|
+
|
|
53
|
+
const dropdownRef = useRef<HTMLDivElement>(null)
|
|
54
|
+
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null)
|
|
55
|
+
|
|
56
|
+
const isRunning = activeEntryId !== null
|
|
57
|
+
|
|
58
|
+
const activeProject = projects.find((p) => p.id === activeProjectId)
|
|
59
|
+
const selectedProject = projects.find((p) => p.id === selectedProjectId)
|
|
60
|
+
|
|
61
|
+
const filteredProjects = projects.filter((p) =>
|
|
62
|
+
p.name.toLowerCase().includes(projectFilter.toLowerCase()),
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
const startElapsedCounter = useCallback((startedAt: string) => {
|
|
66
|
+
const startTime = new Date(startedAt).getTime()
|
|
67
|
+
const now = Date.now()
|
|
68
|
+
const initialElapsed = Math.max(0, Math.floor((now - startTime) / 1000))
|
|
69
|
+
setElapsedSeconds(initialElapsed)
|
|
70
|
+
|
|
71
|
+
if (intervalRef.current) clearInterval(intervalRef.current)
|
|
72
|
+
intervalRef.current = setInterval(() => {
|
|
73
|
+
setElapsedSeconds((prev) => prev + 1)
|
|
74
|
+
}, 1000)
|
|
75
|
+
}, [])
|
|
76
|
+
|
|
77
|
+
const stopElapsedCounter = useCallback(() => {
|
|
78
|
+
if (intervalRef.current) {
|
|
79
|
+
clearInterval(intervalRef.current)
|
|
80
|
+
intervalRef.current = null
|
|
81
|
+
}
|
|
82
|
+
setElapsedSeconds(0)
|
|
83
|
+
}, [])
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!staffMemberId) return
|
|
87
|
+
|
|
88
|
+
const today = getToday()
|
|
89
|
+
const checkActiveTimer = async () => {
|
|
90
|
+
const response = await apiCall(
|
|
91
|
+
`/api/staff/timesheets/time-entries?staffMemberId=${staffMemberId}&from=${today}&to=${today}&pageSize=50`,
|
|
92
|
+
)
|
|
93
|
+
if (!response.ok) return
|
|
94
|
+
|
|
95
|
+
const data = response.result as Record<string, unknown> | null
|
|
96
|
+
const items = (data?.items ?? data?.data ?? []) as Array<Record<string, unknown>>
|
|
97
|
+
|
|
98
|
+
const activeEntry = items.find(
|
|
99
|
+
(entry: Record<string, unknown>) =>
|
|
100
|
+
entry.started_at && !entry.ended_at,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
if (activeEntry) {
|
|
104
|
+
setActiveEntryId(String(activeEntry.id ?? ''))
|
|
105
|
+
setActiveProjectId(String(activeEntry.time_project_id ?? ''))
|
|
106
|
+
setDescription(String(activeEntry.notes ?? ''))
|
|
107
|
+
startElapsedCounter(String(activeEntry.started_at ?? ''))
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
checkActiveTimer()
|
|
112
|
+
}, [staffMemberId, startElapsedCounter])
|
|
113
|
+
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
return () => {
|
|
116
|
+
if (intervalRef.current) clearInterval(intervalRef.current)
|
|
117
|
+
}
|
|
118
|
+
}, [])
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
function handleClickOutside(event: MouseEvent) {
|
|
122
|
+
if (
|
|
123
|
+
dropdownRef.current &&
|
|
124
|
+
!dropdownRef.current.contains(event.target as Node)
|
|
125
|
+
) {
|
|
126
|
+
setShowProjectDropdown(false)
|
|
127
|
+
setProjectFilter('')
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (showProjectDropdown) {
|
|
132
|
+
document.addEventListener('mousedown', handleClickOutside)
|
|
133
|
+
}
|
|
134
|
+
return () => document.removeEventListener('mousedown', handleClickOutside)
|
|
135
|
+
}, [showProjectDropdown])
|
|
136
|
+
|
|
137
|
+
const handleStart = async () => {
|
|
138
|
+
if (!selectedProjectId || !staffMemberId) return
|
|
139
|
+
|
|
140
|
+
setIsStarting(true)
|
|
141
|
+
try {
|
|
142
|
+
const today = getToday()
|
|
143
|
+
const createResponse = await apiCallOrThrow(
|
|
144
|
+
'/api/staff/timesheets/time-entries',
|
|
145
|
+
{
|
|
146
|
+
method: 'POST',
|
|
147
|
+
headers: { 'Content-Type': 'application/json' },
|
|
148
|
+
body: JSON.stringify({
|
|
149
|
+
staffMemberId,
|
|
150
|
+
timeProjectId: selectedProjectId,
|
|
151
|
+
date: today,
|
|
152
|
+
durationMinutes: 0,
|
|
153
|
+
source: 'timer',
|
|
154
|
+
notes: description || null,
|
|
155
|
+
}),
|
|
156
|
+
},
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
const created = createResponse.result as Record<string, unknown> | null
|
|
160
|
+
const entryId = created?.id as string | undefined
|
|
161
|
+
|
|
162
|
+
await apiCallOrThrow(
|
|
163
|
+
`/api/staff/timesheets/time-entries/${entryId}/timer-start`,
|
|
164
|
+
{ method: 'POST' },
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
setActiveEntryId(entryId ?? null)
|
|
168
|
+
setActiveProjectId(selectedProjectId)
|
|
169
|
+
startElapsedCounter(new Date().toISOString())
|
|
170
|
+
} catch {
|
|
171
|
+
flash(
|
|
172
|
+
t('staff.timesheets.my.timer.startError', 'Failed to start timer'),
|
|
173
|
+
'error',
|
|
174
|
+
)
|
|
175
|
+
} finally {
|
|
176
|
+
setIsStarting(false)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const handleStop = async () => {
|
|
181
|
+
if (!activeEntryId) return
|
|
182
|
+
|
|
183
|
+
setIsStopping(true)
|
|
184
|
+
try {
|
|
185
|
+
await apiCallOrThrow(
|
|
186
|
+
`/api/staff/timesheets/time-entries/${activeEntryId}/timer-stop`,
|
|
187
|
+
{ method: 'POST' },
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
setActiveEntryId(null)
|
|
191
|
+
setActiveProjectId(null)
|
|
192
|
+
setDescription('')
|
|
193
|
+
stopElapsedCounter()
|
|
194
|
+
onTimerStopped()
|
|
195
|
+
} catch {
|
|
196
|
+
flash(
|
|
197
|
+
t('staff.timesheets.my.timer.stopError', 'Failed to stop timer'),
|
|
198
|
+
'error',
|
|
199
|
+
)
|
|
200
|
+
} finally {
|
|
201
|
+
setIsStopping(false)
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<div className="flex items-center gap-3 rounded-lg border bg-card p-3 mb-4">
|
|
207
|
+
<input
|
|
208
|
+
type="text"
|
|
209
|
+
value={description}
|
|
210
|
+
onChange={(e) => setDescription(e.target.value)}
|
|
211
|
+
readOnly={isRunning}
|
|
212
|
+
placeholder={t(
|
|
213
|
+
'staff.timesheets.my.timer.placeholder',
|
|
214
|
+
'What are you working on?',
|
|
215
|
+
)}
|
|
216
|
+
className="flex-1 bg-transparent border-0 outline-none text-sm placeholder:text-muted-foreground"
|
|
217
|
+
/>
|
|
218
|
+
|
|
219
|
+
<div className="relative" ref={dropdownRef}>
|
|
220
|
+
{isRunning ? (
|
|
221
|
+
activeProject ? (
|
|
222
|
+
<span className="inline-flex items-center gap-1.5 text-xs font-medium px-2 py-1 rounded border bg-muted">
|
|
223
|
+
<ProjectColorDot colorKey={activeProject.color} projectName={activeProject.name} size="xs" />
|
|
224
|
+
{activeProject.name}
|
|
225
|
+
</span>
|
|
226
|
+
) : null
|
|
227
|
+
) : (
|
|
228
|
+
<>
|
|
229
|
+
<Button
|
|
230
|
+
type="button"
|
|
231
|
+
variant="outline"
|
|
232
|
+
size="sm"
|
|
233
|
+
onClick={() => {
|
|
234
|
+
setShowProjectDropdown(!showProjectDropdown)
|
|
235
|
+
setProjectFilter('')
|
|
236
|
+
}}
|
|
237
|
+
className="text-xs font-medium"
|
|
238
|
+
>
|
|
239
|
+
{selectedProject
|
|
240
|
+
? (<><ProjectColorDot colorKey={selectedProject.color} projectName={selectedProject.name} size="xs" /><span className="ml-1">{selectedProject.name}</span></>)
|
|
241
|
+
: t('staff.timesheets.my.timer.selectProject', 'Project')}
|
|
242
|
+
</Button>
|
|
243
|
+
|
|
244
|
+
{showProjectDropdown && (
|
|
245
|
+
<div className="absolute right-0 top-full mt-1 z-50 min-w-[200px] rounded-md border bg-popover p-1 shadow-md">
|
|
246
|
+
<input
|
|
247
|
+
type="text"
|
|
248
|
+
value={projectFilter}
|
|
249
|
+
onChange={(e) => setProjectFilter(e.target.value)}
|
|
250
|
+
placeholder={t(
|
|
251
|
+
'staff.timesheets.my.timer.searchProject',
|
|
252
|
+
'Search projects...',
|
|
253
|
+
)}
|
|
254
|
+
className="w-full bg-transparent border-b px-2 py-1.5 text-xs outline-none placeholder:text-muted-foreground mb-1"
|
|
255
|
+
autoFocus
|
|
256
|
+
/>
|
|
257
|
+
<div className="max-h-[200px] overflow-y-auto">
|
|
258
|
+
{filteredProjects.length === 0 ? (
|
|
259
|
+
<div className="px-2 py-1.5 text-xs text-muted-foreground">
|
|
260
|
+
{t(
|
|
261
|
+
'staff.timesheets.my.timer.noProjects',
|
|
262
|
+
'No projects found',
|
|
263
|
+
)}
|
|
264
|
+
</div>
|
|
265
|
+
) : (
|
|
266
|
+
filteredProjects.map((project) => (
|
|
267
|
+
<Button
|
|
268
|
+
key={project.id}
|
|
269
|
+
type="button"
|
|
270
|
+
variant="ghost"
|
|
271
|
+
size="sm"
|
|
272
|
+
className="w-full justify-start text-xs h-auto py-1.5"
|
|
273
|
+
onClick={() => {
|
|
274
|
+
setSelectedProjectId(project.id)
|
|
275
|
+
setShowProjectDropdown(false)
|
|
276
|
+
setProjectFilter('')
|
|
277
|
+
}}
|
|
278
|
+
>
|
|
279
|
+
<ProjectColorDot colorKey={project.color} projectName={project.name} size="xs" />
|
|
280
|
+
<span className="ml-1">{project.name}</span>
|
|
281
|
+
{project.code ? (
|
|
282
|
+
<span className="ml-1 text-muted-foreground">
|
|
283
|
+
({project.code})
|
|
284
|
+
</span>
|
|
285
|
+
) : null}
|
|
286
|
+
</Button>
|
|
287
|
+
))
|
|
288
|
+
)}
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
)}
|
|
292
|
+
</>
|
|
293
|
+
)}
|
|
294
|
+
</div>
|
|
295
|
+
|
|
296
|
+
<span className="font-mono text-sm tabular-nums min-w-[64px] text-right">
|
|
297
|
+
{formatElapsed(elapsedSeconds)}
|
|
298
|
+
</span>
|
|
299
|
+
|
|
300
|
+
{isRunning ? (
|
|
301
|
+
<IconButton
|
|
302
|
+
type="button"
|
|
303
|
+
variant="outline"
|
|
304
|
+
size="default"
|
|
305
|
+
onClick={handleStop}
|
|
306
|
+
disabled={isStopping}
|
|
307
|
+
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
|
308
|
+
aria-label={t('staff.timesheets.my.timer.stop', 'Stop timer')}
|
|
309
|
+
>
|
|
310
|
+
<Square className="size-4" />
|
|
311
|
+
</IconButton>
|
|
312
|
+
) : (
|
|
313
|
+
<IconButton
|
|
314
|
+
type="button"
|
|
315
|
+
variant="outline"
|
|
316
|
+
size="default"
|
|
317
|
+
onClick={handleStart}
|
|
318
|
+
disabled={isStarting || !selectedProjectId}
|
|
319
|
+
className="bg-primary text-primary-foreground hover:bg-primary/90"
|
|
320
|
+
aria-label={t('staff.timesheets.my.timer.start', 'Start timer')}
|
|
321
|
+
>
|
|
322
|
+
<Play className="size-4" />
|
|
323
|
+
</IconButton>
|
|
324
|
+
)}
|
|
325
|
+
</div>
|
|
326
|
+
)
|
|
327
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
4
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
5
|
+
|
|
6
|
+
type ViewMode = 'weekly' | 'monthly'
|
|
7
|
+
type ViewType = 'timesheet' | 'list'
|
|
8
|
+
|
|
9
|
+
interface ViewSwitcherProps {
|
|
10
|
+
viewMode: ViewMode
|
|
11
|
+
onViewModeChange: (mode: ViewMode) => void
|
|
12
|
+
viewType: ViewType
|
|
13
|
+
onViewTypeChange: (type: ViewType) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function ViewSwitcher({ viewMode, onViewModeChange, viewType, onViewTypeChange }: ViewSwitcherProps) {
|
|
17
|
+
const t = useT()
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className="flex items-center gap-4">
|
|
21
|
+
<div className="flex items-center gap-1 rounded-md border p-1">
|
|
22
|
+
<Button
|
|
23
|
+
type="button"
|
|
24
|
+
size="sm"
|
|
25
|
+
variant={viewMode === 'weekly' ? 'default' : 'outline'}
|
|
26
|
+
onClick={() => onViewModeChange('weekly')}
|
|
27
|
+
>
|
|
28
|
+
{t('staff.timesheets.my.viewMode.weekly', 'Weekly')}
|
|
29
|
+
</Button>
|
|
30
|
+
<Button
|
|
31
|
+
type="button"
|
|
32
|
+
size="sm"
|
|
33
|
+
variant={viewMode === 'monthly' ? 'default' : 'outline'}
|
|
34
|
+
onClick={() => onViewModeChange('monthly')}
|
|
35
|
+
>
|
|
36
|
+
{t('staff.timesheets.my.viewMode.monthly', 'Monthly')}
|
|
37
|
+
</Button>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div className="flex items-center gap-1 rounded-md border p-1">
|
|
41
|
+
<Button
|
|
42
|
+
type="button"
|
|
43
|
+
size="sm"
|
|
44
|
+
variant={viewType === 'timesheet' ? 'default' : 'outline'}
|
|
45
|
+
onClick={() => onViewTypeChange('timesheet')}
|
|
46
|
+
>
|
|
47
|
+
{t('staff.timesheets.my.viewType.timesheet', 'Timesheet')}
|
|
48
|
+
</Button>
|
|
49
|
+
<Button
|
|
50
|
+
type="button"
|
|
51
|
+
size="sm"
|
|
52
|
+
variant={viewType === 'list' ? 'default' : 'outline'}
|
|
53
|
+
onClick={() => onViewTypeChange('list')}
|
|
54
|
+
>
|
|
55
|
+
{t('staff.timesheets.my.viewType.list', 'List view')}
|
|
56
|
+
</Button>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const PROJECT_COLORS = [
|
|
2
|
+
{ key: 'blue', hex: '#3B82F6' },
|
|
3
|
+
{ key: 'green', hex: '#22C55E' },
|
|
4
|
+
{ key: 'purple', hex: '#A855F7' },
|
|
5
|
+
{ key: 'red', hex: '#EF4444' },
|
|
6
|
+
{ key: 'orange', hex: '#F97316' },
|
|
7
|
+
{ key: 'yellow', hex: '#EAB308' },
|
|
8
|
+
{ key: 'pink', hex: '#EC4899' },
|
|
9
|
+
{ key: 'teal', hex: '#14B8A6' },
|
|
10
|
+
{ key: 'indigo', hex: '#6366F1' },
|
|
11
|
+
{ key: 'cyan', hex: '#06B6D4' },
|
|
12
|
+
{ key: 'emerald', hex: '#10B981' },
|
|
13
|
+
{ key: 'slate', hex: '#64748B' },
|
|
14
|
+
] as const
|
|
15
|
+
|
|
16
|
+
export type ProjectColorKey = typeof PROJECT_COLORS[number]['key']
|
|
17
|
+
|
|
18
|
+
export const PROJECT_COLOR_KEYS: ProjectColorKey[] = PROJECT_COLORS.map((c) => c.key)
|
|
19
|
+
|
|
20
|
+
const COLOR_BY_KEY = new Map<string, string>(PROJECT_COLORS.map((c) => [c.key, c.hex]))
|
|
21
|
+
|
|
22
|
+
export function isProjectColorKey(value: unknown): value is ProjectColorKey {
|
|
23
|
+
return typeof value === 'string' && COLOR_BY_KEY.has(value)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Stable, non-cryptographic string hash (djb2). Positive integer output.
|
|
28
|
+
* Used to derive a deterministic fallback color from a project's name.
|
|
29
|
+
*/
|
|
30
|
+
function hashString(input: string): number {
|
|
31
|
+
let hash = 5381
|
|
32
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
33
|
+
hash = ((hash << 5) + hash + input.charCodeAt(i)) | 0
|
|
34
|
+
}
|
|
35
|
+
return Math.abs(hash)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns a stable color for a project based on its name when no explicit
|
|
40
|
+
* color is set. Same name → same color across reloads and devices.
|
|
41
|
+
*/
|
|
42
|
+
export function autoColorFromName(name: string | null | undefined): { key: ProjectColorKey; hex: string } {
|
|
43
|
+
const safe = (name ?? '').trim().toLowerCase()
|
|
44
|
+
const index = safe.length === 0 ? 0 : hashString(safe) % PROJECT_COLORS.length
|
|
45
|
+
return PROJECT_COLORS[index]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the hex for a project, preferring the explicit color key when
|
|
50
|
+
* valid and falling back to the deterministic name-based palette otherwise.
|
|
51
|
+
*/
|
|
52
|
+
export function resolveProjectColorHex(
|
|
53
|
+
explicitKey: string | null | undefined,
|
|
54
|
+
name: string | null | undefined,
|
|
55
|
+
): string {
|
|
56
|
+
if (isProjectColorKey(explicitKey)) return COLOR_BY_KEY.get(explicitKey)!
|
|
57
|
+
return autoColorFromName(name).hex
|
|
58
|
+
}
|