@open-mercato/core 0.6.6 → 0.6.7-develop.6553.1.2ec7246e04
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/gateway_session_initialization/index.js +23 -0
- package/dist/generated/entities/gateway_session_initialization/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +1 -0
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +12 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/api_keys/api/keys/route.js +30 -13
- package/dist/modules/api_keys/api/keys/route.js.map +2 -2
- package/dist/modules/api_keys/cli.js +2 -1
- package/dist/modules/api_keys/cli.js.map +2 -2
- package/dist/modules/attachments/api/file/[id]/route.js +9 -7
- package/dist/modules/attachments/api/file/[id]/route.js.map +2 -2
- package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js +9 -7
- package/dist/modules/attachments/api/image/[id]/[[...slug]]/route.js.map +2 -2
- package/dist/modules/attachments/api/route.js +21 -17
- package/dist/modules/attachments/api/route.js.map +2 -2
- package/dist/modules/attachments/components/AttachmentContentPreview.js +6 -35
- package/dist/modules/attachments/components/AttachmentContentPreview.js.map +2 -2
- package/dist/modules/attachments/lib/reconcileOrganization.js +110 -0
- package/dist/modules/attachments/lib/reconcileOrganization.js.map +7 -0
- package/dist/modules/attachments/lib/requestScope.js +10 -0
- package/dist/modules/attachments/lib/requestScope.js.map +7 -0
- package/dist/modules/audit_logs/backend/audit-logs/page.js +14 -24
- package/dist/modules/audit_logs/backend/audit-logs/page.js.map +2 -2
- package/dist/modules/auth/api/autologin.js +85 -0
- package/dist/modules/auth/api/autologin.js.map +7 -0
- package/dist/modules/auth/api/users/route.js +6 -2
- package/dist/modules/auth/api/users/route.js.map +2 -2
- package/dist/modules/auth/cli.js +3 -2
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/lib/autologin.js +19 -0
- package/dist/modules/auth/lib/autologin.js.map +7 -0
- package/dist/modules/configs/lib/upgrade-actions.js +22 -0
- package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
- package/dist/modules/customer_accounts/api/admin/roles/[id]/acl.js +1 -0
- package/dist/modules/customer_accounts/api/admin/roles/[id]/acl.js.map +2 -2
- package/dist/modules/customer_accounts/api/admin/roles/[id].js +17 -3
- package/dist/modules/customer_accounts/api/admin/roles/[id].js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/users/[id]/roles.js +6 -1
- package/dist/modules/customer_accounts/api/portal/users/[id]/roles.js.map +2 -2
- package/dist/modules/customer_accounts/api/portal/users-invite.js +6 -1
- package/dist/modules/customer_accounts/api/portal/users-invite.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerInvitationService.js +1 -0
- package/dist/modules/customer_accounts/services/customerInvitationService.js.map +2 -2
- package/dist/modules/customer_accounts/services/customerRbacService.js +6 -1
- package/dist/modules/customer_accounts/services/customerRbacService.js.map +2 -2
- package/dist/modules/customer_accounts/widgets/injection-table.js +0 -2
- package/dist/modules/customer_accounts/widgets/injection-table.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js +7 -1
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/ViewTabsRow.js +2 -2
- package/dist/modules/customers/backend/customers/deals/pipeline/components/ViewTabsRow.js.map +2 -2
- package/dist/modules/customers/components/detail/CompanyDetailTabs.js +37 -43
- package/dist/modules/customers/components/detail/CompanyDetailTabs.js.map +2 -2
- package/dist/modules/customers/components/detail/DealDetailTabs.js +23 -35
- package/dist/modules/customers/components/detail/DealDetailTabs.js.map +2 -2
- package/dist/modules/customers/components/detail/DetailTabsLayout.js +6 -21
- package/dist/modules/customers/components/detail/DetailTabsLayout.js.map +2 -2
- package/dist/modules/customers/components/detail/MobilePersonDetail.js +26 -32
- package/dist/modules/customers/components/detail/MobilePersonDetail.js.map +2 -2
- package/dist/modules/customers/components/detail/PersonDetailTabs.js +29 -39
- package/dist/modules/customers/components/detail/PersonDetailTabs.js.map +2 -2
- package/dist/modules/customers/components/detail/useDealsAccess.js +16 -0
- package/dist/modules/customers/components/detail/useDealsAccess.js.map +7 -0
- package/dist/modules/dashboards/api/roles/widgets/route.js +22 -3
- package/dist/modules/dashboards/api/roles/widgets/route.js.map +2 -2
- package/dist/modules/dashboards/api/users/widgets/route.js +22 -3
- package/dist/modules/dashboards/api/users/widgets/route.js.map +2 -2
- package/dist/modules/dashboards/cli.js +4 -3
- package/dist/modules/dashboards/cli.js.map +2 -2
- package/dist/modules/dashboards/lib/widgetAssignmentScope.js +9 -1
- package/dist/modules/dashboards/lib/widgetAssignmentScope.js.map +2 -2
- package/dist/modules/dictionaries/commands/entries.js +7 -14
- package/dist/modules/dictionaries/commands/entries.js.map +2 -2
- package/dist/modules/dictionaries/commands/entry-operations.js +7 -16
- package/dist/modules/dictionaries/commands/entry-operations.js.map +2 -2
- package/dist/modules/dictionaries/commands/factory.js +9 -3
- package/dist/modules/dictionaries/commands/factory.js.map +2 -2
- package/dist/modules/dictionaries/fields/dictionary.js +56 -41
- package/dist/modules/dictionaries/fields/dictionary.js.map +2 -2
- package/dist/modules/directory/utils/organizationScope.js +10 -3
- package/dist/modules/directory/utils/organizationScope.js.map +2 -2
- package/dist/modules/entities/api/records.js +5 -4
- package/dist/modules/entities/api/records.js.map +2 -2
- package/dist/modules/entities/backend/entities/system/[entityId]/page.meta.js +1 -0
- package/dist/modules/entities/backend/entities/system/[entityId]/page.meta.js.map +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/page.js +49 -49
- package/dist/modules/entities/backend/entities/user/[entityId]/page.js.map +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/page.meta.js +1 -0
- package/dist/modules/entities/backend/entities/user/[entityId]/page.meta.js.map +2 -2
- package/dist/modules/entities/cli.js +2 -1
- package/dist/modules/entities/cli.js.map +2 -2
- package/dist/modules/feature_toggles/api/check/boolean/route.js +0 -14
- package/dist/modules/feature_toggles/api/check/boolean/route.js.map +2 -2
- package/dist/modules/feature_toggles/defaults.json +8 -0
- package/dist/modules/integrations/backend/integrations/[id]/page.js +9 -80
- package/dist/modules/integrations/backend/integrations/[id]/page.js.map +2 -2
- package/dist/modules/payment_gateways/data/entities.js +45 -0
- package/dist/modules/payment_gateways/data/entities.js.map +2 -2
- package/dist/modules/payment_gateways/lib/gateway-service.js +173 -38
- package/dist/modules/payment_gateways/lib/gateway-service.js.map +3 -3
- package/dist/modules/payment_gateways/lib/session-idempotency.js +104 -0
- package/dist/modules/payment_gateways/lib/session-idempotency.js.map +7 -0
- package/dist/modules/payment_gateways/migrations/Migration20260709220938_payment_gateways.js +11 -0
- package/dist/modules/payment_gateways/migrations/Migration20260709220938_payment_gateways.js.map +7 -0
- package/dist/modules/planner/backend/planner/availability-rulesets/[id]/page.js +16 -14
- package/dist/modules/planner/backend/planner/availability-rulesets/[id]/page.js.map +2 -2
- package/dist/modules/planner/components/AvailabilityRulesEditor.js +18 -30
- package/dist/modules/planner/components/AvailabilityRulesEditor.js.map +2 -2
- package/dist/modules/query_index/api/status.js +2 -8
- package/dist/modules/query_index/api/status.js.map +2 -2
- package/dist/modules/resources/backend/resources/resources/[id]/page.js +24 -24
- package/dist/modules/resources/backend/resources/resources/[id]/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/create/page.js +6 -0
- package/dist/modules/sales/backend/sales/channels/create/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/create/page.meta.js +2 -0
- package/dist/modules/sales/backend/sales/channels/create/page.meta.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.js +6 -0
- package/dist/modules/sales/backend/sales/channels/offers/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/offers/page.meta.js +2 -0
- package/dist/modules/sales/backend/sales/channels/offers/page.meta.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/page.js +6 -0
- package/dist/modules/sales/backend/sales/channels/page.js.map +2 -2
- package/dist/modules/sales/backend/sales/channels/page.meta.js +2 -0
- package/dist/modules/sales/backend/sales/channels/page.meta.js.map +2 -2
- package/dist/modules/sales/backend/sales/documents/[id]/page.js +6 -4
- package/dist/modules/sales/backend/sales/documents/[id]/page.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +44 -0
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/commands/returns.js +2 -27
- package/dist/modules/sales/commands/returns.js.map +2 -2
- package/dist/modules/sales/components/SalesChannelsDisabledNotice.js +15 -0
- package/dist/modules/sales/components/SalesChannelsDisabledNotice.js.map +7 -0
- package/dist/modules/sales/components/documents/AddressesSection.js +6 -2
- package/dist/modules/sales/components/documents/AddressesSection.js.map +2 -2
- package/dist/modules/sales/components/documents/ItemsSection.js +1 -0
- package/dist/modules/sales/components/documents/ItemsSection.js.map +2 -2
- package/dist/modules/sales/components/documents/LineItemDialog.js +9 -0
- package/dist/modules/sales/components/documents/LineItemDialog.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentForm.js +51 -3
- package/dist/modules/sales/components/documents/SalesDocumentForm.js.map +2 -2
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js +10 -8
- package/dist/modules/sales/components/documents/SalesDocumentsTable.js.map +2 -2
- package/dist/modules/sales/components/documents/ShipmentDialog.js +59 -38
- package/dist/modules/sales/components/documents/ShipmentDialog.js.map +2 -2
- package/dist/modules/sales/components/useSalesChannelsEnabled.js +44 -0
- package/dist/modules/sales/components/useSalesChannelsEnabled.js.map +7 -0
- package/dist/modules/sales/lib/calculations.js +6 -0
- package/dist/modules/sales/lib/calculations.js.map +2 -2
- package/dist/modules/sales/lib/salesChannelsToggle.js +18 -0
- package/dist/modules/sales/lib/salesChannelsToggle.js.map +7 -0
- package/dist/modules/sales/lib/salesChannelsToggleId.js +5 -0
- package/dist/modules/sales/lib/salesChannelsToggleId.js.map +7 -0
- package/dist/modules/sales/lib/shipments/snapshots.js +27 -1
- package/dist/modules/sales/lib/shipments/snapshots.js.map +2 -2
- package/dist/modules/staff/backend/staff/team-members/[id]/page.js +22 -25
- package/dist/modules/staff/backend/staff/team-members/[id]/page.js.map +2 -2
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js +12 -14
- package/dist/modules/staff/backend/staff/teams/[id]/edit/page.js.map +2 -2
- package/dist/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.js +10 -29
- package/dist/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.js.map +2 -2
- package/dist/modules/sync_excel/lib/adapters/customers.js +19 -20
- package/dist/modules/sync_excel/lib/adapters/customers.js.map +2 -2
- package/dist/modules/sync_excel/lib/parser.js +185 -0
- package/dist/modules/sync_excel/lib/parser.js.map +2 -2
- package/dist/modules/sync_excel/lib/upload-storage.js +20 -1
- package/dist/modules/sync_excel/lib/upload-storage.js.map +2 -2
- package/generated/entities/gateway_session_initialization/index.ts +10 -0
- package/generated/entities.ids.generated.ts +1 -0
- package/generated/entity-fields-registry.ts +12 -0
- package/package.json +9 -8
- package/src/modules/api_keys/api/keys/route.ts +36 -13
- package/src/modules/api_keys/cli.ts +2 -3
- package/src/modules/attachments/api/file/[id]/route.ts +11 -7
- package/src/modules/attachments/api/image/[id]/[[...slug]]/route.ts +11 -7
- package/src/modules/attachments/api/route.ts +26 -21
- package/src/modules/attachments/components/AttachmentContentPreview.tsx +9 -44
- package/src/modules/attachments/lib/reconcileOrganization.ts +188 -0
- package/src/modules/attachments/lib/requestScope.ts +27 -0
- package/src/modules/audit_logs/backend/audit-logs/page.tsx +12 -22
- package/src/modules/auth/api/autologin.ts +100 -0
- package/src/modules/auth/api/users/route.ts +11 -2
- package/src/modules/auth/cli.ts +3 -2
- package/src/modules/auth/lib/autologin.ts +36 -0
- package/src/modules/configs/i18n/de.json +5 -1
- package/src/modules/configs/i18n/en.json +5 -1
- package/src/modules/configs/i18n/es.json +5 -1
- package/src/modules/configs/i18n/pl.json +5 -1
- package/src/modules/configs/lib/upgrade-actions.ts +24 -0
- package/src/modules/customer_accounts/AGENTS.md +8 -6
- package/src/modules/customer_accounts/api/admin/roles/[id]/acl.ts +1 -0
- package/src/modules/customer_accounts/api/admin/roles/[id].ts +17 -3
- package/src/modules/customer_accounts/api/portal/users/[id]/roles.ts +6 -1
- package/src/modules/customer_accounts/api/portal/users-invite.ts +6 -1
- package/src/modules/customer_accounts/services/customerInvitationService.ts +1 -0
- package/src/modules/customer_accounts/services/customerRbacService.ts +9 -2
- package/src/modules/customer_accounts/widgets/injection-table.ts +0 -2
- package/src/modules/customers/backend/customers/companies-v2/[id]/page.tsx +11 -1
- package/src/modules/customers/backend/customers/deals/pipeline/components/ViewTabsRow.tsx +6 -2
- package/src/modules/customers/components/detail/CompanyDetailTabs.tsx +39 -55
- package/src/modules/customers/components/detail/DealDetailTabs.tsx +24 -49
- package/src/modules/customers/components/detail/DetailTabsLayout.tsx +13 -24
- package/src/modules/customers/components/detail/MobilePersonDetail.tsx +25 -31
- package/src/modules/customers/components/detail/PersonDetailTabs.tsx +29 -50
- package/src/modules/customers/components/detail/useDealsAccess.ts +19 -0
- package/src/modules/dashboards/api/roles/widgets/route.ts +22 -3
- package/src/modules/dashboards/api/users/widgets/route.ts +22 -3
- package/src/modules/dashboards/cli.ts +4 -9
- package/src/modules/dashboards/lib/widgetAssignmentScope.ts +18 -0
- package/src/modules/dictionaries/commands/entries.ts +7 -16
- package/src/modules/dictionaries/commands/entry-operations.ts +8 -18
- package/src/modules/dictionaries/commands/factory.ts +8 -2
- package/src/modules/dictionaries/fields/dictionary.tsx +55 -32
- package/src/modules/dictionaries/i18n/de.json +2 -0
- package/src/modules/dictionaries/i18n/en.json +2 -0
- package/src/modules/dictionaries/i18n/es.json +2 -0
- package/src/modules/dictionaries/i18n/pl.json +2 -0
- package/src/modules/directory/utils/organizationScope.ts +36 -2
- package/src/modules/entities/api/records.ts +5 -7
- package/src/modules/entities/backend/entities/system/[entityId]/page.meta.ts +1 -0
- package/src/modules/entities/backend/entities/user/[entityId]/page.meta.ts +1 -0
- package/src/modules/entities/backend/entities/user/[entityId]/page.tsx +51 -49
- package/src/modules/entities/cli.ts +2 -1
- package/src/modules/entities/i18n/de.json +34 -0
- package/src/modules/entities/i18n/en.json +34 -0
- package/src/modules/entities/i18n/es.json +34 -0
- package/src/modules/entities/i18n/pl.json +34 -0
- package/src/modules/feature_toggles/api/check/boolean/route.ts +0 -15
- package/src/modules/feature_toggles/defaults.json +8 -0
- package/src/modules/integrations/backend/integrations/[id]/page.tsx +16 -59
- package/src/modules/payment_gateways/data/entities.ts +39 -0
- package/src/modules/payment_gateways/lib/gateway-service.ts +211 -40
- package/src/modules/payment_gateways/lib/session-idempotency.ts +142 -0
- package/src/modules/payment_gateways/migrations/.snapshot-open-mercato.json +236 -0
- package/src/modules/payment_gateways/migrations/Migration20260709220938_payment_gateways.ts +10 -0
- package/src/modules/planner/backend/planner/availability-rulesets/[id]/page.tsx +14 -20
- package/src/modules/planner/components/AvailabilityRulesEditor.tsx +16 -34
- package/src/modules/query_index/api/status.ts +2 -8
- package/src/modules/resources/backend/resources/resources/[id]/page.tsx +27 -37
- package/src/modules/sales/backend/sales/channels/create/page.meta.ts +3 -0
- package/src/modules/sales/backend/sales/channels/create/page.tsx +7 -0
- package/src/modules/sales/backend/sales/channels/offers/page.meta.ts +3 -0
- package/src/modules/sales/backend/sales/channels/offers/page.tsx +7 -0
- package/src/modules/sales/backend/sales/channels/page.meta.ts +4 -0
- package/src/modules/sales/backend/sales/channels/page.tsx +7 -0
- package/src/modules/sales/backend/sales/documents/[id]/page.tsx +7 -5
- package/src/modules/sales/commands/documents.ts +65 -0
- package/src/modules/sales/commands/returns.ts +2 -32
- package/src/modules/sales/components/SalesChannelsDisabledNotice.tsx +21 -0
- package/src/modules/sales/components/documents/AddressesSection.tsx +6 -2
- package/src/modules/sales/components/documents/ItemsSection.tsx +5 -0
- package/src/modules/sales/components/documents/LineItemDialog.tsx +10 -0
- package/src/modules/sales/components/documents/SalesDocumentForm.tsx +53 -3
- package/src/modules/sales/components/documents/SalesDocumentsTable.tsx +10 -8
- package/src/modules/sales/components/documents/ShipmentDialog.tsx +65 -40
- package/src/modules/sales/components/useSalesChannelsEnabled.ts +59 -0
- package/src/modules/sales/i18n/de.json +5 -0
- package/src/modules/sales/i18n/en.json +5 -0
- package/src/modules/sales/i18n/es.json +5 -0
- package/src/modules/sales/i18n/pl.json +5 -0
- package/src/modules/sales/lib/calculations.ts +15 -0
- package/src/modules/sales/lib/salesChannelsToggle.ts +26 -0
- package/src/modules/sales/lib/salesChannelsToggleId.ts +1 -0
- package/src/modules/sales/lib/shipments/snapshots.ts +30 -0
- package/src/modules/staff/backend/staff/team-members/[id]/page.tsx +25 -34
- package/src/modules/staff/backend/staff/teams/[id]/edit/page.tsx +11 -17
- package/src/modules/staff/lib/timesheets-projects-ui/SavedViewTabs.tsx +11 -28
- package/src/modules/sync_excel/lib/adapters/customers.ts +20 -22
- package/src/modules/sync_excel/lib/parser.ts +245 -0
- package/src/modules/sync_excel/lib/upload-storage.ts +23 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import * as React from 'react'
|
|
4
|
-
import { cn } from '@open-mercato/shared/lib/utils'
|
|
5
4
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
5
|
import { Button } from '@open-mercato/ui/primitives/button'
|
|
7
|
-
import {
|
|
6
|
+
import { Tabs, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'
|
|
8
7
|
import {
|
|
9
8
|
Users,
|
|
10
9
|
Handshake,
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
Plus,
|
|
15
14
|
} from 'lucide-react'
|
|
16
15
|
import type { SectionAction } from '@open-mercato/ui/backend/detail'
|
|
16
|
+
import { useDealsAccess } from './useDealsAccess'
|
|
17
17
|
|
|
18
18
|
export type CompanyTabId =
|
|
19
19
|
| 'people'
|
|
@@ -27,7 +27,7 @@ type TabDef = {
|
|
|
27
27
|
id: CompanyTabId
|
|
28
28
|
label: string
|
|
29
29
|
icon?: React.ReactNode
|
|
30
|
-
|
|
30
|
+
count?: React.ReactNode
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
type CompanyDetailTabsProps = {
|
|
@@ -58,21 +58,9 @@ export function resolveLegacyTab(tab: string | null | undefined): CompanyTabId {
|
|
|
58
58
|
return tab as CompanyTabId
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
NEW
|
|
65
|
-
</span>
|
|
66
|
-
)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function CountBadge({ count }: { count: number }) {
|
|
70
|
-
if (count <= 0) return null
|
|
71
|
-
return (
|
|
72
|
-
<span className="ml-1.5 rounded-full bg-muted px-1.5 py-0.5 text-xs font-medium leading-none text-muted-foreground">
|
|
73
|
-
{count > 999 ? '999+' : count}
|
|
74
|
-
</span>
|
|
75
|
-
)
|
|
61
|
+
function formatTabCount(count: number): string | number | undefined {
|
|
62
|
+
if (count <= 0) return undefined
|
|
63
|
+
return count > 999 ? '999+' : count
|
|
76
64
|
}
|
|
77
65
|
|
|
78
66
|
export function CompanyDetailTabs({
|
|
@@ -87,6 +75,7 @@ export function CompanyDetailTabs({
|
|
|
87
75
|
children,
|
|
88
76
|
}: CompanyDetailTabsProps) {
|
|
89
77
|
const t = useT()
|
|
78
|
+
const { canViewDeals } = useDealsAccess()
|
|
90
79
|
|
|
91
80
|
const builtInTabs: TabDef[] = React.useMemo(
|
|
92
81
|
() => [
|
|
@@ -94,34 +83,38 @@ export function CompanyDetailTabs({
|
|
|
94
83
|
id: 'people',
|
|
95
84
|
label: t('customers.companies.detail.tabs.people', 'People'),
|
|
96
85
|
icon: <Users className="size-4" />,
|
|
97
|
-
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: 'deals',
|
|
101
|
-
label: t('customers.companies.detail.tabs.deals', 'Deals'),
|
|
102
|
-
icon: <Handshake className="size-4" />,
|
|
103
|
-
badge: <CountBadge count={dealsCount} />,
|
|
86
|
+
count: formatTabCount(peopleCount),
|
|
104
87
|
},
|
|
88
|
+
...(canViewDeals
|
|
89
|
+
? [
|
|
90
|
+
{
|
|
91
|
+
id: 'deals' as CompanyTabId,
|
|
92
|
+
label: t('customers.companies.detail.tabs.deals', 'Deals'),
|
|
93
|
+
icon: <Handshake className="size-4" />,
|
|
94
|
+
count: formatTabCount(dealsCount),
|
|
95
|
+
},
|
|
96
|
+
]
|
|
97
|
+
: []),
|
|
105
98
|
{
|
|
106
99
|
id: 'activity-log',
|
|
107
100
|
label: t('customers.companies.detail.tabs.activityLog', 'Activity log'),
|
|
108
101
|
icon: <Clock className="size-4" />,
|
|
109
|
-
|
|
102
|
+
count: formatTabCount(activitiesCount),
|
|
110
103
|
},
|
|
111
104
|
{
|
|
112
105
|
id: 'changelog',
|
|
113
106
|
label: t('customers.companies.detail.tabs.changelog', 'Changelog'),
|
|
114
107
|
icon: <History className="size-4" />,
|
|
115
|
-
|
|
108
|
+
count: 'NEW',
|
|
116
109
|
},
|
|
117
110
|
{
|
|
118
111
|
id: 'files',
|
|
119
112
|
label: t('customers.companies.detail.tabs.files', 'Files'),
|
|
120
113
|
icon: <Paperclip className="size-4" />,
|
|
121
|
-
|
|
114
|
+
count: formatTabCount(filesCount),
|
|
122
115
|
},
|
|
123
116
|
],
|
|
124
|
-
[t, peopleCount, dealsCount, activitiesCount, filesCount],
|
|
117
|
+
[t, canViewDeals, peopleCount, dealsCount, activitiesCount, filesCount],
|
|
125
118
|
)
|
|
126
119
|
|
|
127
120
|
const allTabs: TabDef[] = React.useMemo(
|
|
@@ -138,33 +131,24 @@ export function CompanyDetailTabs({
|
|
|
138
131
|
return (
|
|
139
132
|
<div>
|
|
140
133
|
{/* Tab navigation */}
|
|
141
|
-
<div className="flex items-end justify-between gap-2 border-b"
|
|
142
|
-
<
|
|
143
|
-
{
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
className={cn(
|
|
155
|
-
'h-auto shrink-0 rounded-none border-b-2 px-3 py-2.5 hover:bg-transparent',
|
|
156
|
-
isActive
|
|
157
|
-
? 'border-foreground text-foreground font-semibold'
|
|
158
|
-
: 'border-transparent text-muted-foreground hover:text-foreground',
|
|
159
|
-
)}
|
|
160
|
-
>
|
|
161
|
-
{tab.icon && <span className="mr-1.5">{tab.icon}</span>}
|
|
134
|
+
<div className="flex items-end justify-between gap-2 border-b">
|
|
135
|
+
<Tabs
|
|
136
|
+
value={activeTab}
|
|
137
|
+
onValueChange={(value) => onTabChange(value as CompanyTabId)}
|
|
138
|
+
variant="underline"
|
|
139
|
+
className="min-w-0 flex-1"
|
|
140
|
+
>
|
|
141
|
+
<TabsList
|
|
142
|
+
aria-label={t('customers.companies.detail.tabs.label', 'Company detail sections')}
|
|
143
|
+
className="-mb-px w-full overflow-x-auto border-b-0 px-1"
|
|
144
|
+
>
|
|
145
|
+
{allTabs.map((tab) => (
|
|
146
|
+
<TabsTrigger key={tab.id} value={tab.id} leading={tab.icon} count={tab.count}>
|
|
162
147
|
{tab.label}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
</nav>
|
|
148
|
+
</TabsTrigger>
|
|
149
|
+
))}
|
|
150
|
+
</TabsList>
|
|
151
|
+
</Tabs>
|
|
168
152
|
{sectionAction ? (
|
|
169
153
|
<Button
|
|
170
154
|
type="button"
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { Activity, Building2, History, NotebookPen, Paperclip, Users } from 'lucide-react'
|
|
5
|
-
import { cn } from '@open-mercato/shared/lib/utils'
|
|
6
5
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
7
|
-
import {
|
|
6
|
+
import { Tabs, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'
|
|
8
7
|
|
|
9
8
|
export type DealTabId =
|
|
10
9
|
| 'activities'
|
|
@@ -19,7 +18,7 @@ type TabDef = {
|
|
|
19
18
|
id: DealTabId
|
|
20
19
|
label: string
|
|
21
20
|
icon?: React.ReactNode
|
|
22
|
-
|
|
21
|
+
count?: React.ReactNode
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
type DealDetailTabsProps = {
|
|
@@ -38,21 +37,9 @@ export function resolveLegacyTab(tab: string | null | undefined): DealTabId {
|
|
|
38
37
|
return SUPPORTED_TAB_IDS.has(tab as DealTabId) ? (tab as DealTabId) : 'activities'
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
function
|
|
42
|
-
if (count <= 0) return
|
|
43
|
-
return
|
|
44
|
-
<span className="ml-1.5 rounded-sm bg-muted px-1.5 py-px text-xs font-semibold leading-none text-muted-foreground">
|
|
45
|
-
{count > 999 ? '999+' : count}
|
|
46
|
-
</span>
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function NewBadge() {
|
|
51
|
-
return (
|
|
52
|
-
<span className="ml-1.5 rounded-sm bg-muted px-1.5 py-px text-xs font-semibold leading-none text-muted-foreground">
|
|
53
|
-
NEW
|
|
54
|
-
</span>
|
|
55
|
-
)
|
|
40
|
+
function formatTabCount(count: number): string | number | undefined {
|
|
41
|
+
if (count <= 0) return undefined
|
|
42
|
+
return count > 999 ? '999+' : count
|
|
56
43
|
}
|
|
57
44
|
|
|
58
45
|
export function DealDetailTabs({
|
|
@@ -76,13 +63,13 @@ export function DealDetailTabs({
|
|
|
76
63
|
id: 'people',
|
|
77
64
|
label: t('customers.deals.detail.tabs.people', 'People'),
|
|
78
65
|
icon: <Users className="size-4" />,
|
|
79
|
-
|
|
66
|
+
count: formatTabCount(peopleCount),
|
|
80
67
|
},
|
|
81
68
|
{
|
|
82
69
|
id: 'companies',
|
|
83
70
|
label: t('customers.deals.detail.tabs.companies', 'Companies'),
|
|
84
71
|
icon: <Building2 className="size-4" />,
|
|
85
|
-
|
|
72
|
+
count: formatTabCount(companiesCount),
|
|
86
73
|
},
|
|
87
74
|
{
|
|
88
75
|
id: 'notes',
|
|
@@ -98,7 +85,7 @@ export function DealDetailTabs({
|
|
|
98
85
|
id: 'changelog',
|
|
99
86
|
label: t('customers.deals.detail.tabs.changelog', 'Changelog'),
|
|
100
87
|
icon: <History className="size-4" />,
|
|
101
|
-
|
|
88
|
+
count: 'NEW',
|
|
102
89
|
},
|
|
103
90
|
],
|
|
104
91
|
[companiesCount, peopleCount, t],
|
|
@@ -117,34 +104,22 @@ export function DealDetailTabs({
|
|
|
117
104
|
|
|
118
105
|
return (
|
|
119
106
|
<div>
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
? 'border-foreground text-foreground font-semibold'
|
|
137
|
-
: 'border-transparent text-muted-foreground hover:text-foreground',
|
|
138
|
-
)}
|
|
139
|
-
>
|
|
140
|
-
{tab.icon ? <span className="mr-1.5">{tab.icon}</span> : null}
|
|
141
|
-
{tab.label}
|
|
142
|
-
{tab.badge}
|
|
143
|
-
</Button>
|
|
144
|
-
)
|
|
145
|
-
})}
|
|
146
|
-
</nav>
|
|
147
|
-
</div>
|
|
107
|
+
<Tabs
|
|
108
|
+
value={activeTab}
|
|
109
|
+
onValueChange={(value) => onTabChange(value as DealTabId)}
|
|
110
|
+
variant="underline"
|
|
111
|
+
>
|
|
112
|
+
<TabsList
|
|
113
|
+
aria-label={t('customers.deals.detail.tabs.label', 'Deal detail sections')}
|
|
114
|
+
className="w-full overflow-x-auto"
|
|
115
|
+
>
|
|
116
|
+
{allTabs.map((tab) => (
|
|
117
|
+
<TabsTrigger key={tab.id} value={tab.id} leading={tab.icon} count={tab.count}>
|
|
118
|
+
{tab.label}
|
|
119
|
+
</TabsTrigger>
|
|
120
|
+
))}
|
|
121
|
+
</TabsList>
|
|
122
|
+
</Tabs>
|
|
148
123
|
|
|
149
124
|
<div className="pt-5" role="tabpanel">
|
|
150
125
|
{children}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import type { SectionAction } from '@open-mercato/ui/backend/detail'
|
|
5
5
|
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { Tabs, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'
|
|
6
7
|
import { cn } from '@open-mercato/shared/lib/utils'
|
|
7
8
|
import { Plus } from 'lucide-react'
|
|
8
9
|
|
|
@@ -46,31 +47,19 @@ export function DetailTabsLayout<TId extends string = string>({
|
|
|
46
47
|
return (
|
|
47
48
|
<div className={cn('space-y-4', className)}>
|
|
48
49
|
<div className={cn('flex flex-wrap items-center justify-between gap-3', headerClassName)}>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
<Tabs
|
|
51
|
+
value={activeTab}
|
|
52
|
+
onValueChange={(value) => handleTabChange(value as TId)}
|
|
53
|
+
variant="underline"
|
|
53
54
|
>
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
key={tab.id}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
onClick={() => handleTabChange(tab.id)}
|
|
63
|
-
className={cn(
|
|
64
|
-
'h-auto rounded-none border-b-2 px-0 py-1',
|
|
65
|
-
activeTab === tab.id
|
|
66
|
-
? 'border-accent-indigo text-foreground hover:bg-transparent'
|
|
67
|
-
: 'border-transparent text-muted-foreground hover:text-foreground hover:bg-transparent'
|
|
68
|
-
)}
|
|
69
|
-
>
|
|
70
|
-
{tab.label}
|
|
71
|
-
</Button>
|
|
72
|
-
))}
|
|
73
|
-
</nav>
|
|
55
|
+
<TabsList className={cn('h-auto flex-wrap border-b-0', navClassName)} aria-label={navAriaLabel}>
|
|
56
|
+
{tabs.map((tab) => (
|
|
57
|
+
<TabsTrigger key={tab.id} value={tab.id}>
|
|
58
|
+
{tab.label}
|
|
59
|
+
</TabsTrigger>
|
|
60
|
+
))}
|
|
61
|
+
</TabsList>
|
|
62
|
+
</Tabs>
|
|
74
63
|
{sectionAction ? (
|
|
75
64
|
<Button
|
|
76
65
|
type="button"
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { useRouter, useSearchParams } from 'next/navigation'
|
|
5
5
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
|
-
import {
|
|
7
|
-
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { Tabs, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'
|
|
8
7
|
|
|
9
8
|
export type MobilePersonZone = 'details' | 'activity'
|
|
10
9
|
|
|
@@ -80,35 +79,30 @@ export function MobilePersonDetail({
|
|
|
80
79
|
|
|
81
80
|
return (
|
|
82
81
|
<div className="space-y-4">
|
|
83
|
-
<div
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
>
|
|
108
|
-
{t(entry.labelKey, entry.fallback)}
|
|
109
|
-
</Button>
|
|
110
|
-
)
|
|
111
|
-
})}
|
|
82
|
+
<div onKeyDown={handleKeyDown}>
|
|
83
|
+
<Tabs
|
|
84
|
+
value={zone}
|
|
85
|
+
onValueChange={(value) => handleZoneChange(value as MobilePersonZone)}
|
|
86
|
+
variant="underline"
|
|
87
|
+
>
|
|
88
|
+
<TabsList
|
|
89
|
+
aria-label={t(
|
|
90
|
+
'customers.people.mobile.zoneSwitcher.ariaLabel',
|
|
91
|
+
'Zone selector',
|
|
92
|
+
)}
|
|
93
|
+
className="w-full"
|
|
94
|
+
>
|
|
95
|
+
{ZONES.map((entry) => (
|
|
96
|
+
<TabsTrigger
|
|
97
|
+
key={entry.id}
|
|
98
|
+
value={entry.id}
|
|
99
|
+
className="flex-1 justify-center"
|
|
100
|
+
>
|
|
101
|
+
{t(entry.labelKey, entry.fallback)}
|
|
102
|
+
</TabsTrigger>
|
|
103
|
+
))}
|
|
104
|
+
</TabsList>
|
|
105
|
+
</Tabs>
|
|
112
106
|
</div>
|
|
113
107
|
<div
|
|
114
108
|
id={`mobile-person-zone-${zone}`}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import * as React from 'react'
|
|
4
|
-
import { cn } from '@open-mercato/shared/lib/utils'
|
|
5
4
|
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
6
5
|
import { Button } from '@open-mercato/ui/primitives/button'
|
|
6
|
+
import { Tabs, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'
|
|
7
7
|
import {
|
|
8
8
|
SquareCheckBig,
|
|
9
9
|
Mail,
|
|
@@ -32,7 +32,7 @@ type TabDef = {
|
|
|
32
32
|
id: PersonTabId
|
|
33
33
|
label: string
|
|
34
34
|
icon?: React.ReactNode
|
|
35
|
-
|
|
35
|
+
count?: React.ReactNode
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
type PersonDetailTabsProps = {
|
|
@@ -56,21 +56,9 @@ export function resolveLegacyTab(tab: string | null | undefined): PersonTabId {
|
|
|
56
56
|
return SUPPORTED_TAB_IDS.has(tab as PersonTabId) ? (tab as PersonTabId) : 'activities'
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
function
|
|
60
|
-
if (count <= 0) return
|
|
61
|
-
return
|
|
62
|
-
<span className="ml-1 rounded-full bg-muted px-1.5 py-0.5 text-xs font-medium leading-none text-muted-foreground">
|
|
63
|
-
{count > 999 ? '999+' : count}
|
|
64
|
-
</span>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function NewBadge() {
|
|
69
|
-
return (
|
|
70
|
-
<span className="ml-1.5 rounded bg-foreground px-1.5 py-0.5 text-overline font-semibold leading-none text-background">
|
|
71
|
-
NEW
|
|
72
|
-
</span>
|
|
73
|
-
)
|
|
59
|
+
function formatTabCount(count: number): string | number | undefined {
|
|
60
|
+
if (count <= 0) return undefined
|
|
61
|
+
return count > 999 ? '999+' : count
|
|
74
62
|
}
|
|
75
63
|
|
|
76
64
|
export function PersonDetailTabs({
|
|
@@ -94,7 +82,7 @@ export function PersonDetailTabs({
|
|
|
94
82
|
id: 'activities',
|
|
95
83
|
label: t('customers.people.detail.tabs.activities', 'Activities'),
|
|
96
84
|
icon: <SquareCheckBig className="size-4" />,
|
|
97
|
-
|
|
85
|
+
count: formatTabCount(activitiesCount),
|
|
98
86
|
},
|
|
99
87
|
{
|
|
100
88
|
id: 'emails',
|
|
@@ -105,37 +93,37 @@ export function PersonDetailTabs({
|
|
|
105
93
|
id: 'deals',
|
|
106
94
|
label: t('customers.people.detail.tabs.deals', 'Deals'),
|
|
107
95
|
icon: <Briefcase className="size-4" />,
|
|
108
|
-
|
|
96
|
+
count: formatTabCount(dealsCount),
|
|
109
97
|
},
|
|
110
98
|
{
|
|
111
99
|
id: 'companies',
|
|
112
100
|
label: t('customers.people.detail.tabs.companies', 'Companies'),
|
|
113
101
|
icon: <Building2 className="size-4" />,
|
|
114
|
-
|
|
102
|
+
count: formatTabCount(companiesCount),
|
|
115
103
|
},
|
|
116
104
|
{
|
|
117
105
|
id: 'addresses',
|
|
118
106
|
label: t('customers.people.detail.tabs.addresses', 'Addresses'),
|
|
119
107
|
icon: <MapPin className="size-4" />,
|
|
120
|
-
|
|
108
|
+
count: formatTabCount(addressesCount),
|
|
121
109
|
},
|
|
122
110
|
{
|
|
123
111
|
id: 'tasks',
|
|
124
112
|
label: t('customers.people.detail.tabs.tasks', 'Tasks'),
|
|
125
113
|
icon: <Check className="size-4" />,
|
|
126
|
-
|
|
114
|
+
count: formatTabCount(tasksCount),
|
|
127
115
|
},
|
|
128
116
|
{
|
|
129
117
|
id: 'changelog',
|
|
130
118
|
label: t('customers.people.detail.tabs.changelog', 'Change log'),
|
|
131
119
|
icon: <History className="size-4" />,
|
|
132
|
-
|
|
120
|
+
count: 'NEW',
|
|
133
121
|
},
|
|
134
122
|
{
|
|
135
123
|
id: 'files',
|
|
136
124
|
label: t('customers.people.detail.tabs.files', 'Files'),
|
|
137
125
|
icon: <Paperclip className="size-4" />,
|
|
138
|
-
|
|
126
|
+
count: formatTabCount(filesCount),
|
|
139
127
|
},
|
|
140
128
|
],
|
|
141
129
|
[t, activitiesCount, dealsCount, companiesCount, addressesCount, tasksCount, filesCount],
|
|
@@ -155,33 +143,24 @@ export function PersonDetailTabs({
|
|
|
155
143
|
return (
|
|
156
144
|
<div>
|
|
157
145
|
{/* Tab navigation — full width above both zones */}
|
|
158
|
-
<div className="flex items-end justify-between gap-2 border-b"
|
|
159
|
-
<
|
|
160
|
-
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
className={cn(
|
|
172
|
-
'h-auto shrink-0 rounded-none border-b-2 px-3 py-2.5 hover:bg-transparent',
|
|
173
|
-
isActive
|
|
174
|
-
? 'border-foreground text-foreground font-semibold'
|
|
175
|
-
: 'border-transparent text-muted-foreground hover:text-foreground',
|
|
176
|
-
)}
|
|
177
|
-
>
|
|
178
|
-
{tab.icon && <span className="mr-1.5">{tab.icon}</span>}
|
|
146
|
+
<div className="flex items-end justify-between gap-2 border-b">
|
|
147
|
+
<Tabs
|
|
148
|
+
value={activeTab}
|
|
149
|
+
onValueChange={(value) => onTabChange(value as PersonTabId)}
|
|
150
|
+
variant="underline"
|
|
151
|
+
className="min-w-0 flex-1"
|
|
152
|
+
>
|
|
153
|
+
<TabsList
|
|
154
|
+
aria-label={t('customers.people.detail.tabs.label', 'Person detail sections')}
|
|
155
|
+
className="-mb-px w-full overflow-x-auto border-b-0 px-1"
|
|
156
|
+
>
|
|
157
|
+
{allTabs.map((tab) => (
|
|
158
|
+
<TabsTrigger key={tab.id} value={tab.id} leading={tab.icon} count={tab.count}>
|
|
179
159
|
{tab.label}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
</nav>
|
|
160
|
+
</TabsTrigger>
|
|
161
|
+
))}
|
|
162
|
+
</TabsList>
|
|
163
|
+
</Tabs>
|
|
185
164
|
{sectionAction ? (
|
|
186
165
|
<Button
|
|
187
166
|
type="button"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { useBackendChrome } from '@open-mercato/ui/backend/BackendChromeProvider'
|
|
5
|
+
import { hasFeature } from '@open-mercato/shared/security/features'
|
|
6
|
+
|
|
7
|
+
export type DealsAccess = {
|
|
8
|
+
canViewDeals: boolean
|
|
9
|
+
isReady: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useDealsAccess(): DealsAccess {
|
|
13
|
+
const { payload, isReady } = useBackendChrome()
|
|
14
|
+
const canViewDeals = React.useMemo(
|
|
15
|
+
() => hasFeature(payload?.grantedFeatures ?? [], 'customers.deals.view'),
|
|
16
|
+
[payload?.grantedFeatures],
|
|
17
|
+
)
|
|
18
|
+
return { canViewDeals, isReady }
|
|
19
|
+
}
|
|
@@ -6,7 +6,10 @@ import { DashboardRoleWidgets } from '@open-mercato/core/modules/dashboards/data
|
|
|
6
6
|
import { Role } from '@open-mercato/core/modules/auth/data/entities'
|
|
7
7
|
import { roleWidgetSettingsSchema } from '@open-mercato/core/modules/dashboards/data/validators'
|
|
8
8
|
import { loadAllWidgets } from '@open-mercato/core/modules/dashboards/lib/widgets'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
resolveWidgetAssignmentReadScope,
|
|
11
|
+
resolveWidgetAssignmentTargetAccess,
|
|
12
|
+
} from '@open-mercato/core/modules/dashboards/lib/widgetAssignmentScope'
|
|
10
13
|
import { hasFeature } from '@open-mercato/shared/security/features'
|
|
11
14
|
import {
|
|
12
15
|
runCrudMutationGuardAfterSuccess,
|
|
@@ -70,7 +73,15 @@ export async function GET(req: Request) {
|
|
|
70
73
|
})
|
|
71
74
|
|
|
72
75
|
const role = await em.findOne(Role, { id: roleId, deletedAt: null })
|
|
73
|
-
|
|
76
|
+
const access = resolveWidgetAssignmentTargetAccess({
|
|
77
|
+
isSuperAdmin: !!acl.isSuperAdmin,
|
|
78
|
+
scopeTenantId: tenantId,
|
|
79
|
+
target: role,
|
|
80
|
+
})
|
|
81
|
+
if (access === 'forbidden') {
|
|
82
|
+
return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
|
|
83
|
+
}
|
|
84
|
+
if (access === 'not-found') {
|
|
74
85
|
return NextResponse.json({ error: 'Role not found' }, { status: 404 })
|
|
75
86
|
}
|
|
76
87
|
|
|
@@ -121,7 +132,15 @@ export async function PUT(req: Request) {
|
|
|
121
132
|
const organizationId = auth.orgId ?? null
|
|
122
133
|
|
|
123
134
|
const role = await em.findOne(Role, { id: parsed.data.roleId, deletedAt: null })
|
|
124
|
-
|
|
135
|
+
const access = resolveWidgetAssignmentTargetAccess({
|
|
136
|
+
isSuperAdmin: !!acl.isSuperAdmin,
|
|
137
|
+
scopeTenantId: tenantId,
|
|
138
|
+
target: role,
|
|
139
|
+
})
|
|
140
|
+
if (access === 'forbidden') {
|
|
141
|
+
return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
|
|
142
|
+
}
|
|
143
|
+
if (access === 'not-found') {
|
|
125
144
|
return NextResponse.json({ error: 'Role not found' }, { status: 404 })
|
|
126
145
|
}
|
|
127
146
|
|
|
@@ -7,7 +7,10 @@ import { User } from '@open-mercato/core/modules/auth/data/entities'
|
|
|
7
7
|
import { userWidgetSettingsSchema } from '@open-mercato/core/modules/dashboards/data/validators'
|
|
8
8
|
import { loadAllWidgets } from '@open-mercato/core/modules/dashboards/lib/widgets'
|
|
9
9
|
import { resolveAllowedWidgetIds } from '@open-mercato/core/modules/dashboards/lib/access'
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
resolveWidgetAssignmentReadScope,
|
|
12
|
+
resolveWidgetAssignmentTargetAccess,
|
|
13
|
+
} from '@open-mercato/core/modules/dashboards/lib/widgetAssignmentScope'
|
|
11
14
|
import { hasFeature } from '@open-mercato/shared/security/features'
|
|
12
15
|
import {
|
|
13
16
|
runCrudMutationGuardAfterSuccess,
|
|
@@ -53,7 +56,15 @@ export async function GET(req: Request) {
|
|
|
53
56
|
})
|
|
54
57
|
|
|
55
58
|
const targetUserForRead = await em.findOne(User, { id: userId, deletedAt: null })
|
|
56
|
-
|
|
59
|
+
const readAccess = resolveWidgetAssignmentTargetAccess({
|
|
60
|
+
isSuperAdmin: !!acl.isSuperAdmin,
|
|
61
|
+
scopeTenantId: tenantId,
|
|
62
|
+
target: targetUserForRead,
|
|
63
|
+
})
|
|
64
|
+
if (readAccess === 'forbidden') {
|
|
65
|
+
return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
|
|
66
|
+
}
|
|
67
|
+
if (readAccess === 'not-found') {
|
|
57
68
|
return NextResponse.json({ error: 'User not found' }, { status: 404 })
|
|
58
69
|
}
|
|
59
70
|
|
|
@@ -121,7 +132,15 @@ export async function PUT(req: Request) {
|
|
|
121
132
|
const organizationId = auth.orgId ?? null
|
|
122
133
|
|
|
123
134
|
const targetUser = await em.findOne(User, { id: parsed.data.userId, deletedAt: null })
|
|
124
|
-
|
|
135
|
+
const writeAccess = resolveWidgetAssignmentTargetAccess({
|
|
136
|
+
isSuperAdmin: !!acl.isSuperAdmin,
|
|
137
|
+
scopeTenantId: tenantId,
|
|
138
|
+
target: targetUser,
|
|
139
|
+
})
|
|
140
|
+
if (writeAccess === 'forbidden') {
|
|
141
|
+
return NextResponse.json({ error: 'Forbidden' }, { status: 403 })
|
|
142
|
+
}
|
|
143
|
+
if (writeAccess === 'not-found') {
|
|
125
144
|
return NextResponse.json({ error: 'User not found' }, { status: 404 })
|
|
126
145
|
}
|
|
127
146
|
|