@hartl-services/medusa-affiliate 0.3.0
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/.medusa/server/src/admin/index.js +3739 -0
- package/.medusa/server/src/admin/index.mjs +3738 -0
- package/.medusa/server/src/api/admin/affiliate-applications/[id]/approve/route.js +28 -0
- package/.medusa/server/src/api/admin/affiliate-applications/[id]/reject/route.js +19 -0
- package/.medusa/server/src/api/admin/affiliate-applications/route.js +23 -0
- package/.medusa/server/src/api/admin/affiliate-distribution-reports/query.js +171 -0
- package/.medusa/server/src/api/admin/affiliate-distribution-reports/route.js +13 -0
- package/.medusa/server/src/api/admin/affiliate-program-settings/route.js +27 -0
- package/.medusa/server/src/api/admin/affiliate-reports/[id]/route.js +45 -0
- package/.medusa/server/src/api/admin/affiliate-reports/route.js +27 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/consignment-reminders/route.js +31 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/consignment-transfers/route.js +41 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/coupon-codes/[coupon_id]/reconcile/route.js +34 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/coupon-codes/[coupon_id]/revoke/route.js +36 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/coupon-codes/[coupon_id]/rotate/route.js +40 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/coupon-codes/route.js +56 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/distribution/route.js +45 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/inactive/route.js +20 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/route.js +50 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/slugs/[slug_id]/route.js +19 -0
- package/.medusa/server/src/api/admin/affiliates/[id]/slugs/route.js +26 -0
- package/.medusa/server/src/api/admin/affiliates/route.js +43 -0
- package/.medusa/server/src/api/admin/consignment-report-response.js +36 -0
- package/.medusa/server/src/api/admin/consignment-reports/[id]/approve/route.js +25 -0
- package/.medusa/server/src/api/admin/consignment-reports/[id]/correct/route.js +18 -0
- package/.medusa/server/src/api/admin/consignment-reports/[id]/reject/route.js +15 -0
- package/.medusa/server/src/api/admin/consignment-reports/[id]/route.js +11 -0
- package/.medusa/server/src/api/admin/consignment-reports/route.js +27 -0
- package/.medusa/server/src/api/admin/customers/[id]/affiliate/route.js +50 -0
- package/.medusa/server/src/api/admin/orders/[id]/affiliate-attribution/route.js +30 -0
- package/.medusa/server/src/api/affiliate-coupon-http.js +152 -0
- package/.medusa/server/src/api/affiliate-referral-cookie.js +34 -0
- package/.medusa/server/src/api/affiliate-self-service-http.js +37 -0
- package/.medusa/server/src/api/middlewares.js +786 -0
- package/.medusa/server/src/api/store/affiliate-referrals/apply-coupon/route.js +47 -0
- package/.medusa/server/src/api/store/affiliate-referrals/capture/route.js +76 -0
- package/.medusa/server/src/api/store/affiliate-referrals/carts/[cart_id]/route.js +20 -0
- package/.medusa/server/src/api/store/affiliates/consignment-inventory/route.js +53 -0
- package/.medusa/server/src/api/store/affiliates/consignment-report-response.js +31 -0
- package/.medusa/server/src/api/store/affiliates/consignment-reports/[id]/submit/route.js +40 -0
- package/.medusa/server/src/api/store/affiliates/consignment-reports/route.js +43 -0
- package/.medusa/server/src/api/store/affiliates/coupon-labels/route.js +14 -0
- package/.medusa/server/src/api/store/affiliates/me/commissions/route.js +35 -0
- package/.medusa/server/src/api/store/affiliates/me/coupon-codes/[coupon_id]/revoke/route.js +36 -0
- package/.medusa/server/src/api/store/affiliates/me/coupon-codes/[coupon_id]/rotate/route.js +40 -0
- package/.medusa/server/src/api/store/affiliates/me/coupon-codes/route.js +55 -0
- package/.medusa/server/src/api/store/affiliates/me/dashboard/route.js +15 -0
- package/.medusa/server/src/api/store/affiliates/me/route.js +85 -0
- package/.medusa/server/src/api/store/affiliates/me/slugs/[slug_id]/route.js +29 -0
- package/.medusa/server/src/api/store/affiliates/me/slugs/route.js +34 -0
- package/.medusa/server/src/api/store/affiliates/own-order-discount/route.js +22 -0
- package/.medusa/server/src/api/store/affiliates/own-order-promotion/route.js +30 -0
- package/.medusa/server/src/api/store/affiliates/register/route.js +27 -0
- package/.medusa/server/src/api/store/affiliates/resolve-referral/route.js +34 -0
- package/.medusa/server/src/api/validators.js +52 -0
- package/.medusa/server/src/api/wire-response.js +10 -0
- package/.medusa/server/src/integration/email-events.js +51 -0
- package/.medusa/server/src/integrations/inventory-transfer/batch-management-transfer-adapter.js +36 -0
- package/.medusa/server/src/integrations/inventory-transfer/native-inventory-transfer-adapter.js +30 -0
- package/.medusa/server/src/integrations/inventory-transfer/resolve-inventory-transfer-adapter.js +46 -0
- package/.medusa/server/src/integrations/inventory-transfer/types.js +3 -0
- package/.medusa/server/src/jobs/affiliate-attribution-expiry.js +20 -0
- package/.medusa/server/src/jobs/affiliate-consignment-report-reminders.js +15 -0
- package/.medusa/server/src/jobs/affiliate-promotion-freshness.js +24 -0
- package/.medusa/server/src/lib/query-string.js +15 -0
- package/.medusa/server/src/modules/affiliate/domain/affiliate-attribution-policy.js +81 -0
- package/.medusa/server/src/modules/affiliate/domain/affiliate-coupon-policy.js +61 -0
- package/.medusa/server/src/modules/affiliate/domain/commission-policy.js +33 -0
- package/.medusa/server/src/modules/affiliate/domain/consignment-reminder-rules.js +74 -0
- package/.medusa/server/src/modules/affiliate/domain/email-normalization.js +20 -0
- package/.medusa/server/src/modules/affiliate/domain/own-order-coupon-code.js +37 -0
- package/.medusa/server/src/modules/affiliate/domain/plugin-options.js +40 -0
- package/.medusa/server/src/modules/affiliate/index.js +13 -0
- package/.medusa/server/src/modules/affiliate/migrations/Migration20260827085154.js +423 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-application.js +38 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-cart-referral.js +65 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-code-redemption.js +41 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-coupon.js +55 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-distribution-settings.js +22 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-order-attribution.js +49 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-program-settings.js +28 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-referral-session.js +34 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate-slug.js +27 -0
- package/.medusa/server/src/modules/affiliate/models/affiliate.js +49 -0
- package/.medusa/server/src/modules/affiliate/models/commission-entry.js +62 -0
- package/.medusa/server/src/modules/affiliate/models/consignment-report-line.js +21 -0
- package/.medusa/server/src/modules/affiliate/models/consignment-report.js +31 -0
- package/.medusa/server/src/modules/affiliate/models/consignment-transfer-line.js +16 -0
- package/.medusa/server/src/modules/affiliate/models/consignment-transfer.js +20 -0
- package/.medusa/server/src/modules/affiliate/models/customer-affiliate-assignment.js +58 -0
- package/.medusa/server/src/modules/affiliate/service.js +2321 -0
- package/.medusa/server/src/modules/affiliate/services/affiliate-application-manager.js +171 -0
- package/.medusa/server/src/modules/affiliate/services/affiliate-coupon-manager.js +441 -0
- package/.medusa/server/src/modules/affiliate/services/affiliate-discount.service.js +55 -0
- package/.medusa/server/src/modules/affiliate/services/affiliate-manager.js +242 -0
- package/.medusa/server/src/modules/affiliate/services/affiliate-partner-portal.service.js +138 -0
- package/.medusa/server/src/modules/affiliate/services/affiliate-report.service.js +436 -0
- package/.medusa/server/src/modules/affiliate/services/affiliate-slug-manager.js +163 -0
- package/.medusa/server/src/modules/affiliate/services/commission-ledger.service.js +729 -0
- package/.medusa/server/src/modules/affiliate/services/customer-affiliate-assignment-manager.js +350 -0
- package/.medusa/server/src/modules/affiliate/services/order-attribution-manager.js +1051 -0
- package/.medusa/server/src/modules/affiliate/services/referral-lifecycle-manager.js +1420 -0
- package/.medusa/server/src/modules/affiliate/services/utils.js +49 -0
- package/.medusa/server/src/modules/affiliate/types/internal.js +3 -0
- package/.medusa/server/src/paths/affiliate.js +7 -0
- package/.medusa/server/src/paths/index.js +18 -0
- package/.medusa/server/src/schemas/index.js +18 -0
- package/.medusa/server/src/schemas/store.js +24 -0
- package/.medusa/server/src/subscribers/affiliate-cart-updated.js +92 -0
- package/.medusa/server/src/subscribers/affiliate-order-canceled.js +70 -0
- package/.medusa/server/src/subscribers/affiliate-order-placed.js +63 -0
- package/.medusa/server/src/subscribers/affiliate-order-return-received.js +67 -0
- package/.medusa/server/src/subscribers/affiliate-product-eligibility-updated.js +87 -0
- package/.medusa/server/src/types/admin-api.js +3 -0
- package/.medusa/server/src/types/enums.js +53 -0
- package/.medusa/server/src/types/index.js +32 -0
- package/.medusa/server/src/types/public.js +3 -0
- package/.medusa/server/src/types/store-api.js +3 -0
- package/.medusa/server/src/utils/affiliate-cart-operation-lock.js +316 -0
- package/.medusa/server/src/utils/affiliate-promotion-mutation-authorization.js +49 -0
- package/.medusa/server/src/utils/cart-promotions.js +9 -0
- package/.medusa/server/src/utils/money.js +79 -0
- package/.medusa/server/src/utils/promotion-code-availability.js +34 -0
- package/.medusa/server/src/utils/registered-email-checkout.js +101 -0
- package/.medusa/server/src/utils/resolve-services.js +7 -0
- package/.medusa/server/src/utils/settle-cart-promotions.js +44 -0
- package/.medusa/server/src/workflows/affiliate/affiliate-coupon-cart.js +215 -0
- package/.medusa/server/src/workflows/affiliate/affiliate-coupon-command-authorization.js +20 -0
- package/.medusa/server/src/workflows/affiliate/apply-affiliate-coupon.js +174 -0
- package/.medusa/server/src/workflows/affiliate/apply-own-order-promotion.js +89 -0
- package/.medusa/server/src/workflows/affiliate/approve-consignment-report.js +186 -0
- package/.medusa/server/src/workflows/affiliate/correct-approved-consignment-report.js +263 -0
- package/.medusa/server/src/workflows/affiliate/create-affiliate-coupon.js +35 -0
- package/.medusa/server/src/workflows/affiliate/create-commission-correction-for-cancellation.js +21 -0
- package/.medusa/server/src/workflows/affiliate/create-commission-correction-for-refund.js +24 -0
- package/.medusa/server/src/workflows/affiliate/create-commission-for-order.js +17 -0
- package/.medusa/server/src/workflows/affiliate/deactivate-affiliate.js +89 -0
- package/.medusa/server/src/workflows/affiliate/enable-distribution.js +120 -0
- package/.medusa/server/src/workflows/affiliate/enrich-affiliate-report.js +75 -0
- package/.medusa/server/src/workflows/affiliate/ensure-affiliate-coupon-promotion.js +410 -0
- package/.medusa/server/src/workflows/affiliate/ensure-affiliate-own-order-promotion.js +240 -0
- package/.medusa/server/src/workflows/affiliate/ensure-default-affiliate-coupon.js +32 -0
- package/.medusa/server/src/workflows/affiliate/expire-affiliate-attribution-state.js +131 -0
- package/.medusa/server/src/workflows/affiliate/finalize-affiliate-order-attribution.js +82 -0
- package/.medusa/server/src/workflows/affiliate/payment-authorization.js +33 -0
- package/.medusa/server/src/workflows/affiliate/promotion-eligibility.js +179 -0
- package/.medusa/server/src/workflows/affiliate/reconcile-affiliate-cart-referral.js +219 -0
- package/.medusa/server/src/workflows/affiliate/reconcile-affiliate-coupon.js +388 -0
- package/.medusa/server/src/workflows/affiliate/refresh-affiliate-promotions.js +114 -0
- package/.medusa/server/src/workflows/affiliate/resolve-coupon-labels.js +40 -0
- package/.medusa/server/src/workflows/affiliate/revoke-affiliate-coupon.js +29 -0
- package/.medusa/server/src/workflows/affiliate/rotate-affiliate-coupon.js +36 -0
- package/.medusa/server/src/workflows/affiliate/run-consignment-report-reminders.js +58 -0
- package/.medusa/server/src/workflows/affiliate/submit-consignment-report.js +279 -0
- package/.medusa/server/src/workflows/affiliate/transfer-batch-aware-inventory.js +172 -0
- package/.medusa/server/src/workflows/affiliate/transfer-consignment-stock.js +106 -0
- package/.medusa/server/src/workflows/affiliate/update-affiliate-coupon-discounts.js +129 -0
- package/.medusa/server/src/workflows/affiliate/utils.js +118 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-affiliate-attribution.js +57 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-order-created-composition.js +111 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-own-order-discount.js +75 -0
- package/.medusa/server/src/workflows/hooks/enforce-unique-promotion-codes.js +33 -0
- package/.medusa/server/src/workflows/hooks/validate-affiliate-customer-code.js +239 -0
- package/.medusa/server/src/workflows/hooks/validate-complete-cart-affiliate-referral.js +137 -0
- package/LICENSE +21 -0
- package/README.md +799 -0
- package/dist/integration/email-events.d.ts +20 -0
- package/dist/integration/email-events.js +50 -0
- package/package.json +84 -0
|
@@ -0,0 +1,3738 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
|
+
import { Label, Text, Button, Input, Container, Heading, toast, Prompt, Select, Textarea, RadioGroup, Tooltip } from "@medusajs/ui";
|
|
4
|
+
import { useState, useDeferredValue, useEffect, useRef } from "react";
|
|
5
|
+
import { useQuery, useQueryClient, useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { affiliateAdminPaths } from "@hartl-services/medusa-food-supplements-contracts/paths/affiliate";
|
|
7
|
+
import Medusa from "@medusajs/js-sdk";
|
|
8
|
+
import { Link, useNavigate, useParams, useSearchParams } from "react-router-dom";
|
|
9
|
+
const texts = {
|
|
10
|
+
routes: {
|
|
11
|
+
affiliates: "Affiliates",
|
|
12
|
+
newAffiliate: "Affiliate anlegen",
|
|
13
|
+
applications: "Offene Anfragen",
|
|
14
|
+
reports: "Affiliate-Berichte"
|
|
15
|
+
},
|
|
16
|
+
common: {
|
|
17
|
+
dash: "-",
|
|
18
|
+
back: "Zurück",
|
|
19
|
+
next: "Weiter",
|
|
20
|
+
pageRange: (from, to, count) => `${from} bis ${to} von ${count}`
|
|
21
|
+
},
|
|
22
|
+
status: {
|
|
23
|
+
active: "Aktiv",
|
|
24
|
+
inactive: "Inaktiv",
|
|
25
|
+
pending: "Ausstehend",
|
|
26
|
+
rejected: "Abgelehnt",
|
|
27
|
+
approved: "Genehmigt"
|
|
28
|
+
},
|
|
29
|
+
hooks: {
|
|
30
|
+
missingAffiliateId: "Affiliate-ID fehlt.",
|
|
31
|
+
noApplicationSelected: "Keine Bewerbung ausgewählt."
|
|
32
|
+
},
|
|
33
|
+
list: {
|
|
34
|
+
heading: "Affiliates",
|
|
35
|
+
description: "Affiliates, Sätze, Slugs und Status verwalten.",
|
|
36
|
+
searchPlaceholder: "Anzeigename suchen",
|
|
37
|
+
statusAll: "Alle Status",
|
|
38
|
+
create: "Neu anlegen",
|
|
39
|
+
edit: "Bearbeiten",
|
|
40
|
+
reactivate: "Reaktivieren",
|
|
41
|
+
loading: "Affiliates werden geladen…",
|
|
42
|
+
loadError: (message) => `Affiliates konnten nicht geladen werden: ${message}`,
|
|
43
|
+
emptyFiltered: "Keine Affiliates für diese Filter gefunden.",
|
|
44
|
+
empty: "Keine Affiliates gefunden.",
|
|
45
|
+
columns: {
|
|
46
|
+
affiliate: "Affiliate",
|
|
47
|
+
status: "Status",
|
|
48
|
+
commission: "Provision",
|
|
49
|
+
ownDiscount: "Eigenrabatt",
|
|
50
|
+
primarySlug: "Primärer Slug",
|
|
51
|
+
created: "Erstellt",
|
|
52
|
+
action: "Aktion"
|
|
53
|
+
},
|
|
54
|
+
statusOptions: {
|
|
55
|
+
all: "Alle Status",
|
|
56
|
+
active: "Aktiv",
|
|
57
|
+
inactive: "Inaktiv",
|
|
58
|
+
rejected: "Abgelehnt"
|
|
59
|
+
},
|
|
60
|
+
toasts: {
|
|
61
|
+
reactivated: "Affiliate wurde reaktiviert",
|
|
62
|
+
reactivateFailed: "Affiliate konnte nicht reaktiviert werden"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
applications: {
|
|
66
|
+
heading: "Affiliate-Bewerbungen",
|
|
67
|
+
description: "Anfragen aus dem Storefront zur Aufnahme als Affiliate prüfen.",
|
|
68
|
+
loading: "Bewerbungen werden geladen…",
|
|
69
|
+
loadError: (message) => `Bewerbungen konnten nicht geladen werden: ${message}`,
|
|
70
|
+
empty: "Keine Affiliate-Bewerbungen gefunden.",
|
|
71
|
+
columns: {
|
|
72
|
+
applicant: "Bewerber",
|
|
73
|
+
customer: "Kunde",
|
|
74
|
+
slug: "Slug",
|
|
75
|
+
submitted: "Eingereicht",
|
|
76
|
+
action: "Aktion"
|
|
77
|
+
},
|
|
78
|
+
review: "Prüfen",
|
|
79
|
+
reviewHeading: (name) => `${name} prüfen`,
|
|
80
|
+
customerLine: (customerId) => `Kunde ${customerId}`,
|
|
81
|
+
approveHeading: "Genehmigen",
|
|
82
|
+
affiliateSlugLabel: "Affiliate-Slug",
|
|
83
|
+
affiliateSlugPlaceholder: "affiliate-slug",
|
|
84
|
+
commissionLabel: "Provision %",
|
|
85
|
+
ownDiscountLabel: "Eigenrabatt %",
|
|
86
|
+
approve: "Genehmigen",
|
|
87
|
+
approving: "Wird genehmigt…",
|
|
88
|
+
rejectHeading: "Ablehnen",
|
|
89
|
+
reasonLabel: "Grund",
|
|
90
|
+
reject: "Ablehnen",
|
|
91
|
+
rejecting: "Wird abgelehnt…",
|
|
92
|
+
toasts: {
|
|
93
|
+
approved: "Affiliate-Bewerbung genehmigt",
|
|
94
|
+
approveFailed: "Bewerbung konnte nicht genehmigt werden",
|
|
95
|
+
rejected: "Affiliate-Bewerbung abgelehnt",
|
|
96
|
+
rejectFailed: "Bewerbung konnte nicht abgelehnt werden"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
form: {
|
|
100
|
+
createHeading: "Affiliate anlegen",
|
|
101
|
+
createDescription: "Legen Sie einen wiederverwendbaren Affiliate-Datensatz an, der optional mit einem Kunden verknüpft ist.",
|
|
102
|
+
initialSlugLabel: "Anfangs-Slug",
|
|
103
|
+
initialSlugPlaceholder: "wird generiert, falls leer",
|
|
104
|
+
creating: "Wird erstellt…",
|
|
105
|
+
create: "Affiliate anlegen",
|
|
106
|
+
notFoundHeading: "Affiliate nicht gefunden",
|
|
107
|
+
notFoundBody: "Die Affiliate-ID fehlt in der aktuellen Route.",
|
|
108
|
+
backToList: "Zurück zu den Affiliates",
|
|
109
|
+
loadErrorHeading: "Affiliate konnte nicht geladen werden",
|
|
110
|
+
loading: "Affiliate wird geladen…",
|
|
111
|
+
createdAt: (value) => `Erstellt ${value}`,
|
|
112
|
+
setInactive: "Auf inaktiv setzen",
|
|
113
|
+
saving: "Wird gespeichert…",
|
|
114
|
+
save: "Änderungen speichern",
|
|
115
|
+
fields: {
|
|
116
|
+
displayName: "Anzeigename",
|
|
117
|
+
commission: "Provision %",
|
|
118
|
+
ownDiscount: "Eigenrabatt %",
|
|
119
|
+
referredBy: "Werbender Affiliate",
|
|
120
|
+
referrerCommission: "Werber-Provision %",
|
|
121
|
+
internalNotes: "Interne Notizen",
|
|
122
|
+
customerAssignmentMode: "Kunden-Zuordnung",
|
|
123
|
+
customerAssignmentModeHint: "Legt fest, wie Bestellungen eines geworbenen Kunden zugeordnet werden.",
|
|
124
|
+
assignmentDurationDays: "Zuordnungsfrist"
|
|
125
|
+
},
|
|
126
|
+
assignmentModes: {
|
|
127
|
+
lifetime: {
|
|
128
|
+
label: "Lifetime",
|
|
129
|
+
description: "Alle zukünftigen Bestellungen dieses Kunden bleiben zugeordnet."
|
|
130
|
+
},
|
|
131
|
+
timeLimited: {
|
|
132
|
+
label: "Zeitlich begrenzt",
|
|
133
|
+
description: "Die Frist beginnt mit der ersten erfolgreichen Bestellung und wird nicht verlängert."
|
|
134
|
+
},
|
|
135
|
+
orderOnly: {
|
|
136
|
+
label: "Nur Bestellung",
|
|
137
|
+
description: "Eine spätere Bestellung benötigt einen neuen Referral-Link oder Coupon."
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
slugs: {
|
|
141
|
+
heading: "Affiliate-Slugs",
|
|
142
|
+
description: "Slugs sind global eindeutig. Nur aktive Slugs lösen Empfehlungen auf.",
|
|
143
|
+
placeholder: "new-affiliate-slug",
|
|
144
|
+
add: "Slug hinzufügen"
|
|
145
|
+
},
|
|
146
|
+
toasts: {
|
|
147
|
+
created: "Affiliate erstellt",
|
|
148
|
+
createFailed: "Affiliate konnte nicht erstellt werden",
|
|
149
|
+
updated: "Affiliate aktualisiert",
|
|
150
|
+
updateFailed: "Affiliate konnte nicht aktualisiert werden",
|
|
151
|
+
setInactive: "Affiliate auf inaktiv gesetzt",
|
|
152
|
+
setInactiveFailed: "Affiliate konnte nicht auf inaktiv gesetzt werden",
|
|
153
|
+
slugCreated: "Affiliate-Slug erstellt",
|
|
154
|
+
slugCreateFailed: "Slug konnte nicht erstellt werden"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
statusSelect: {
|
|
158
|
+
label: "Status",
|
|
159
|
+
options: {
|
|
160
|
+
pending: "Ausstehend",
|
|
161
|
+
active: "Aktiv",
|
|
162
|
+
inactive: "Inaktiv",
|
|
163
|
+
rejected: "Abgelehnt"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
slugTable: {
|
|
167
|
+
empty: "Noch keine Slugs.",
|
|
168
|
+
columns: {
|
|
169
|
+
slug: "Slug",
|
|
170
|
+
state: "Zustand",
|
|
171
|
+
primary: "Primär",
|
|
172
|
+
actions: "Aktionen"
|
|
173
|
+
},
|
|
174
|
+
active: "Aktiv",
|
|
175
|
+
inactive: "Inaktiv",
|
|
176
|
+
yes: "Ja",
|
|
177
|
+
no: "Nein",
|
|
178
|
+
makePrimary: "Primär",
|
|
179
|
+
activate: "Aktivieren",
|
|
180
|
+
deactivate: "Deaktivieren",
|
|
181
|
+
toasts: {
|
|
182
|
+
updated: "Affiliate-Slug aktualisiert",
|
|
183
|
+
updateFailed: "Slug konnte nicht aktualisiert werden"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
coupons: {
|
|
187
|
+
heading: "Affiliate-Coupons",
|
|
188
|
+
description: "Coupon-Codes gewähren den Kundenrabatt und sind unabhängig von Referral-Slugs.",
|
|
189
|
+
createHeading: "Coupon anlegen",
|
|
190
|
+
generated: "Code automatisch generieren",
|
|
191
|
+
custom: "Eigenen Coupon-Code verwenden",
|
|
192
|
+
customCodeLabel: "Eigener Coupon-Code",
|
|
193
|
+
customCodePlaceholder: "SOMMER-2026",
|
|
194
|
+
codeHint: "3 bis 32 Zeichen: Buchstaben, Ziffern und Bindestriche.",
|
|
195
|
+
create: "Coupon anlegen",
|
|
196
|
+
creating: "Wird angelegt…",
|
|
197
|
+
loading: "Coupons werden geladen…",
|
|
198
|
+
loadError: (message) => `Coupons konnten nicht geladen werden: ${message}`,
|
|
199
|
+
empty: "Noch keine Coupons vorhanden.",
|
|
200
|
+
details: {
|
|
201
|
+
couponId: "Coupon-ID",
|
|
202
|
+
promotionId: "Promotion-ID",
|
|
203
|
+
idempotencyKey: "Idempotency-Key",
|
|
204
|
+
created: "Erstellt",
|
|
205
|
+
createdBy: "Erstellt von",
|
|
206
|
+
revoked: "Widerrufen",
|
|
207
|
+
revokedBy: "Widerrufen von",
|
|
208
|
+
setupError: "Bereitstellungsfehler"
|
|
209
|
+
},
|
|
210
|
+
statuses: {
|
|
211
|
+
active: "Aktiv",
|
|
212
|
+
affiliate_inactive: "Affiliate inaktiv",
|
|
213
|
+
provisioning: "Wird bereitgestellt",
|
|
214
|
+
provisioning_failed: "Bereitstellung fehlgeschlagen",
|
|
215
|
+
revoked: "Widerrufen"
|
|
216
|
+
},
|
|
217
|
+
actorTypes: {
|
|
218
|
+
system: "System",
|
|
219
|
+
admin: "Admin",
|
|
220
|
+
affiliate: "Affiliate"
|
|
221
|
+
},
|
|
222
|
+
actor: (type, id) => id ? `${type} · ${id}` : type,
|
|
223
|
+
rotate: "Rotieren",
|
|
224
|
+
rotateHeading: (code) => `Coupon ${code} rotieren`,
|
|
225
|
+
rotateDescription: "Die Rotation legt einen neuen Coupon an und widerruft den bisherigen dauerhaft.",
|
|
226
|
+
rotating: "Wird rotiert…",
|
|
227
|
+
cancel: "Abbrechen",
|
|
228
|
+
revoke: "Widerrufen",
|
|
229
|
+
revokeHeading: "Coupon widerrufen?",
|
|
230
|
+
revokeDescription: (code) => `${code} wird dauerhaft gesperrt und kann nicht reaktiviert werden.`,
|
|
231
|
+
reconcile: "Bereitstellung abgleichen",
|
|
232
|
+
reconciling: "Wird abgeglichen…",
|
|
233
|
+
reconcileOutcome: (outcome) => `Ergebnis: ${outcome}`,
|
|
234
|
+
reconcileOutcomes: {
|
|
235
|
+
created: "Promotion erstellt",
|
|
236
|
+
adopted: "Promotion übernommen",
|
|
237
|
+
repaired: "Promotion repariert",
|
|
238
|
+
unchanged: "Keine Änderung erforderlich",
|
|
239
|
+
revoked_cleanup: "Widerruf bereinigt"
|
|
240
|
+
},
|
|
241
|
+
rotationFinalized: "Rotation wurde abgeschlossen.",
|
|
242
|
+
toasts: {
|
|
243
|
+
created: "Coupon angelegt",
|
|
244
|
+
createFailed: "Coupon konnte nicht angelegt werden",
|
|
245
|
+
rotated: "Coupon rotiert",
|
|
246
|
+
rotateFailed: "Coupon konnte nicht rotiert werden",
|
|
247
|
+
revoked: "Coupon widerrufen",
|
|
248
|
+
revokeFailed: "Coupon konnte nicht widerrufen werden",
|
|
249
|
+
reconciled: "Coupon-Bereitstellung abgeglichen",
|
|
250
|
+
reconcileFailed: "Coupon-Bereitstellung konnte nicht abgeglichen werden"
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
assignment: {
|
|
254
|
+
heading: "Affiliate-Zuordnung",
|
|
255
|
+
checking: "Wird geprüft…",
|
|
256
|
+
isAffiliate: "Dieser Kunde ist selbst Affiliate und kann keinen werbenden Affiliate zugewiesen bekommen.",
|
|
257
|
+
none: "Keine aktive Affiliate-Zuordnung.",
|
|
258
|
+
history: "Zuordnungsverlauf",
|
|
259
|
+
historyEmpty: "Keine beendeten Affiliate-Zuordnungen.",
|
|
260
|
+
current: "Aktuelle Zuordnung",
|
|
261
|
+
validUntil: (value) => `Gültig bis ${value}`,
|
|
262
|
+
lifetime: "Lifetime",
|
|
263
|
+
ended: "Beendet",
|
|
264
|
+
active: "Aktiv",
|
|
265
|
+
mode: "Modus",
|
|
266
|
+
assignedAt: "Zugeordnet",
|
|
267
|
+
endedReason: "Beendigungsgrund",
|
|
268
|
+
endedReasons: {
|
|
269
|
+
expired: "Frist abgelaufen",
|
|
270
|
+
reassigned: "Durch andere Zuordnung ersetzt",
|
|
271
|
+
adminRemoved: "Manuell entfernt",
|
|
272
|
+
affiliateInactive: "Affiliate wurde inaktiv gesetzt",
|
|
273
|
+
customerBecameAffiliate: "Kunde wurde selbst Affiliate",
|
|
274
|
+
notProvided: "Nicht angegeben",
|
|
275
|
+
unknown: "Unbekannter Beendigungsgrund"
|
|
276
|
+
},
|
|
277
|
+
orderOnlyUnavailable: "Dieser Affiliate verwendet Nur Bestellung und kann keinem Kunden manuell zugeordnet werden.",
|
|
278
|
+
save: "Zuordnung speichern",
|
|
279
|
+
remove: "Zuordnung entfernen",
|
|
280
|
+
toasts: {
|
|
281
|
+
saved: "Affiliate-Zuordnung aktualisiert",
|
|
282
|
+
saveFailed: "Zuordnung konnte nicht aktualisiert werden",
|
|
283
|
+
removed: "Affiliate-Zuordnung entfernt",
|
|
284
|
+
removeFailed: "Zuordnung konnte nicht entfernt werden"
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
reference: {
|
|
288
|
+
remove: "Entfernen",
|
|
289
|
+
searching: "Wird gesucht…",
|
|
290
|
+
affiliate: {
|
|
291
|
+
label: "Affiliate",
|
|
292
|
+
placeholder: "Aktive Affiliates nach Anzeigename suchen",
|
|
293
|
+
empty: "Keine aktiven Affiliates gefunden."
|
|
294
|
+
},
|
|
295
|
+
customer: {
|
|
296
|
+
label: "Kunde",
|
|
297
|
+
placeholder: "Kunden nach E-Mail oder Name suchen",
|
|
298
|
+
empty: "Keine Kunden gefunden."
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
reports: {
|
|
302
|
+
heading: "Affiliate-Berichte",
|
|
303
|
+
description: "Berichte fassen unveränderliche Einträge des Provisionsjournals nach Buchungsdatum zusammen.",
|
|
304
|
+
from: "Von",
|
|
305
|
+
to: "Bis",
|
|
306
|
+
loading: "Bericht wird geladen…",
|
|
307
|
+
loadError: (message) => `Bericht konnte nicht geladen werden: ${message}`,
|
|
308
|
+
empty: "Keine Provisionseinträge für diesen Zeitraum gefunden.",
|
|
309
|
+
details: "Details",
|
|
310
|
+
columns: {
|
|
311
|
+
affiliate: "Affiliate",
|
|
312
|
+
status: "Status",
|
|
313
|
+
orderValue: "Bestellungswert",
|
|
314
|
+
commission: "davon Provision",
|
|
315
|
+
orderCount: "Anzahl Bestellungen",
|
|
316
|
+
action: "Aktion"
|
|
317
|
+
},
|
|
318
|
+
orderValueTooltip: "Netto-Warenwert, auf dessen Basis die Provision berechnet wurde (ohne Steuer/Versand).",
|
|
319
|
+
attributedOrdersTooltip: "Enthält alle Attributionen, auch Bestellungen mit 0 EUR oder ohne provisionsfähige Positionen.",
|
|
320
|
+
commissionedOrdersTooltip: "Zählt nur positive direkte Order-Provisionsbuchungen."
|
|
321
|
+
},
|
|
322
|
+
reportDetail: {
|
|
323
|
+
fallbackHeading: "Affiliate-Bericht",
|
|
324
|
+
description: "Journaleinträge für den ausgewählten Affiliate und Zeitraum.",
|
|
325
|
+
from: "Von",
|
|
326
|
+
to: "Bis",
|
|
327
|
+
journalEntries: "Journaleinträge",
|
|
328
|
+
entryCount: (count) => `${count} Journaleinträge`,
|
|
329
|
+
orderValue: "Bestellungswert",
|
|
330
|
+
orderCount: (count) => `${count} Bestellungen`,
|
|
331
|
+
attributedOrders: (count) => `${count} attribuierte Bestellungen`,
|
|
332
|
+
commissionedOrders: (count) => `${count} provisionierte Bestellungen`,
|
|
333
|
+
loading: "Bericht wird geladen…",
|
|
334
|
+
loadError: (message) => `Bericht konnte nicht geladen werden: ${message}`,
|
|
335
|
+
empty: "Keine Provisionseinträge für diesen Zeitraum gefunden.",
|
|
336
|
+
viewOrder: "Bestellung ansehen",
|
|
337
|
+
columns: {
|
|
338
|
+
occurredAt: "Buchungsdatum",
|
|
339
|
+
type: "Typ",
|
|
340
|
+
order: "Bestellung",
|
|
341
|
+
customer: "Kunde",
|
|
342
|
+
base: "Basis",
|
|
343
|
+
rate: "Satz",
|
|
344
|
+
commission: "Provision"
|
|
345
|
+
},
|
|
346
|
+
entryTypes: {
|
|
347
|
+
order_commission: "Direkte Provision",
|
|
348
|
+
affiliate_referral_bonus: "Empfehlungsbonus",
|
|
349
|
+
affiliate_own_order_referrer_bonus: "Partner werben",
|
|
350
|
+
refund_correction: "Korrektur: Rückerstattung",
|
|
351
|
+
cancellation_correction: "Korrektur: Stornierung",
|
|
352
|
+
manual_correction: "Manuelle Korrektur"
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
orderAttribution: {
|
|
356
|
+
heading: "Affiliate-Attribution",
|
|
357
|
+
loading: "Affiliate-Attribution wird geladen…",
|
|
358
|
+
loadError: (message) => `Affiliate-Attribution konnte nicht geladen werden: ${message}`,
|
|
359
|
+
empty: "Keine Affiliate-Zuordnung.",
|
|
360
|
+
affiliate: "Affiliate",
|
|
361
|
+
source: "Referral-Quelle",
|
|
362
|
+
sources: {
|
|
363
|
+
customer_assignment: "Kunden-Zuordnung",
|
|
364
|
+
referral_link: "Referral-Link",
|
|
365
|
+
coupon: "Coupon"
|
|
366
|
+
},
|
|
367
|
+
referralSlug: "Referral-Slug",
|
|
368
|
+
referralCoupon: "Referral-Coupon",
|
|
369
|
+
appliedCoupon: "Angewandter Coupon",
|
|
370
|
+
appliedCouponId: "Angewandte Coupon-ID",
|
|
371
|
+
appliedPromotionId: "Angewandte Promotion-ID",
|
|
372
|
+
noAppliedCoupon: "Kein Coupon angewandt",
|
|
373
|
+
mode: "Modus",
|
|
374
|
+
duration: "Dauer",
|
|
375
|
+
assignmentReference: "Zuordnungsreferenz",
|
|
376
|
+
commissionRate: "Provisionssatz",
|
|
377
|
+
referrerRate: "Werber-Provision",
|
|
378
|
+
referrerAffiliate: "Werbender Affiliate",
|
|
379
|
+
currency: "Währung",
|
|
380
|
+
attributedAt: "Attribuiert am",
|
|
381
|
+
noDuration: "Keine Frist",
|
|
382
|
+
noReference: "Keine Referenz",
|
|
383
|
+
noReferrerRate: "Keine Werber-Provision",
|
|
384
|
+
noReferrerAffiliate: "Keiner"
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
const affiliateKeys = {
|
|
388
|
+
all: ["affiliate"],
|
|
389
|
+
lists: () => [...affiliateKeys.all, "list"],
|
|
390
|
+
list: (params) => [...affiliateKeys.lists(), params],
|
|
391
|
+
details: () => [...affiliateKeys.all, "detail"],
|
|
392
|
+
detail: (id) => [...affiliateKeys.details(), id],
|
|
393
|
+
couponCodes: (affiliateId) => [...affiliateKeys.all, "coupon-codes", affiliateId],
|
|
394
|
+
couponCodeList: (affiliateId, params) => [...affiliateKeys.couponCodes(affiliateId), "list", params],
|
|
395
|
+
applications: () => [...affiliateKeys.all, "applications"],
|
|
396
|
+
applicationList: (params) => [...affiliateKeys.applications(), params],
|
|
397
|
+
reports: () => [...affiliateKeys.all, "reports"],
|
|
398
|
+
reportOverview: (params) => [...affiliateKeys.reports(), "overview", params],
|
|
399
|
+
reportDetail: (affiliateId, params) => [...affiliateKeys.reports(), "detail", affiliateId, params],
|
|
400
|
+
customerAssignment: (customerId) => [...affiliateKeys.all, "customer-assignment", customerId],
|
|
401
|
+
customerIsAffiliate: (customerId) => [...affiliateKeys.all, "customer-is-affiliate", customerId],
|
|
402
|
+
orderAttribution: (orderId) => [...affiliateKeys.all, "order-attribution", orderId],
|
|
403
|
+
affiliateReferenceSearch: (search) => [...affiliateKeys.all, "affiliate-reference-search", search],
|
|
404
|
+
affiliateReference: (id) => [...affiliateKeys.all, "affiliate-reference", id],
|
|
405
|
+
customerReferenceSearch: (search) => [...affiliateKeys.all, "customer-reference-search", search],
|
|
406
|
+
customerReference: (id) => [...affiliateKeys.all, "customer-reference", id]
|
|
407
|
+
};
|
|
408
|
+
const withQuery = (path, params) => {
|
|
409
|
+
const search = new URLSearchParams();
|
|
410
|
+
for (const [key, value] of Object.entries(params)) {
|
|
411
|
+
if (value !== void 0 && value !== null && value !== "") {
|
|
412
|
+
search.set(key, String(value));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
const query = search.toString();
|
|
416
|
+
return query ? `${path}?${query}` : path;
|
|
417
|
+
};
|
|
418
|
+
const sdk = new Medusa({
|
|
419
|
+
baseUrl: __BACKEND_URL__ ?? "/",
|
|
420
|
+
auth: {
|
|
421
|
+
type: __AUTH_TYPE__ ?? "session",
|
|
422
|
+
jwtTokenStorageKey: __JWT_TOKEN_STORAGE_KEY__ || void 0
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
const listAffiliateApplications = (params) => sdk.client.fetch(withQuery(affiliateAdminPaths.get.applications, params));
|
|
426
|
+
const approveAffiliateApplication = (applicationId, payload) => sdk.client.fetch(affiliateAdminPaths.post.approveApplication(applicationId), {
|
|
427
|
+
method: "POST",
|
|
428
|
+
body: payload
|
|
429
|
+
});
|
|
430
|
+
const rejectAffiliateApplication = (applicationId, payload) => sdk.client.fetch(affiliateAdminPaths.post.rejectApplication(applicationId), {
|
|
431
|
+
method: "POST",
|
|
432
|
+
body: payload
|
|
433
|
+
});
|
|
434
|
+
const listAffiliates = (params) => sdk.client.fetch(withQuery(affiliateAdminPaths.get.affiliates, params));
|
|
435
|
+
const listCustomers = async (params) => {
|
|
436
|
+
const { customers, count, limit, offset } = await sdk.admin.customer.list({
|
|
437
|
+
q: params.q,
|
|
438
|
+
limit: params.limit,
|
|
439
|
+
offset: params.offset,
|
|
440
|
+
fields: "id,email,first_name,last_name"
|
|
441
|
+
});
|
|
442
|
+
return { customers, count, limit, offset };
|
|
443
|
+
};
|
|
444
|
+
const retrieveCustomer = async (customerId) => {
|
|
445
|
+
const { customer } = await sdk.admin.customer.retrieve(customerId, {
|
|
446
|
+
fields: "id,email,first_name,last_name"
|
|
447
|
+
});
|
|
448
|
+
return { customer };
|
|
449
|
+
};
|
|
450
|
+
const createAffiliate = (payload) => sdk.client.fetch(affiliateAdminPaths.post.createAffiliate, {
|
|
451
|
+
method: "POST",
|
|
452
|
+
body: payload
|
|
453
|
+
});
|
|
454
|
+
const retrieveAffiliate = (affiliateId) => sdk.client.fetch(affiliateAdminPaths.get.affiliate(affiliateId));
|
|
455
|
+
const updateAffiliate = (affiliateId, payload) => sdk.client.fetch(affiliateAdminPaths.post.updateAffiliate(affiliateId), {
|
|
456
|
+
method: "POST",
|
|
457
|
+
body: payload
|
|
458
|
+
});
|
|
459
|
+
const setAffiliateInactive = (affiliateId) => sdk.client.fetch(affiliateAdminPaths.post.setAffiliateInactive(affiliateId), {
|
|
460
|
+
method: "POST"
|
|
461
|
+
});
|
|
462
|
+
const createAffiliateSlug = (affiliateId, payload) => sdk.client.fetch(affiliateAdminPaths.post.createAffiliateSlug(affiliateId), {
|
|
463
|
+
method: "POST",
|
|
464
|
+
body: payload
|
|
465
|
+
});
|
|
466
|
+
const updateAffiliateSlug = (affiliateId, slugId, payload) => sdk.client.fetch(affiliateAdminPaths.post.updateAffiliateSlug(affiliateId, slugId), {
|
|
467
|
+
method: "POST",
|
|
468
|
+
body: payload
|
|
469
|
+
});
|
|
470
|
+
const listAffiliateCouponCodes = (affiliateId, params) => sdk.client.fetch(
|
|
471
|
+
withQuery(affiliateAdminPaths.get.affiliateCouponCodes(affiliateId), {
|
|
472
|
+
lifecycle_status: params.lifecycle_status,
|
|
473
|
+
provisioning_status: params.provisioning_status,
|
|
474
|
+
limit: params.limit,
|
|
475
|
+
offset: params.offset
|
|
476
|
+
})
|
|
477
|
+
);
|
|
478
|
+
const createAffiliateCouponCode = (affiliateId, payload) => sdk.client.fetch(
|
|
479
|
+
affiliateAdminPaths.post.createAffiliateCouponCode(affiliateId),
|
|
480
|
+
{ method: "POST", body: payload }
|
|
481
|
+
);
|
|
482
|
+
const rotateAffiliateCouponCode = (affiliateId, couponId, payload) => sdk.client.fetch(
|
|
483
|
+
affiliateAdminPaths.post.rotateAffiliateCouponCode(affiliateId, couponId),
|
|
484
|
+
{ method: "POST", body: payload }
|
|
485
|
+
);
|
|
486
|
+
const revokeAffiliateCouponCode = (affiliateId, couponId) => sdk.client.fetch(
|
|
487
|
+
affiliateAdminPaths.post.revokeAffiliateCouponCode(affiliateId, couponId),
|
|
488
|
+
{ method: "POST" }
|
|
489
|
+
);
|
|
490
|
+
const reconcileAffiliateCouponCode = (affiliateId, couponId) => sdk.client.fetch(
|
|
491
|
+
affiliateAdminPaths.post.reconcileAffiliateCouponCode(affiliateId, couponId),
|
|
492
|
+
{ method: "POST" }
|
|
493
|
+
);
|
|
494
|
+
const getCustomerAffiliateAssignment = (customerId) => sdk.client.fetch(affiliateAdminPaths.get.customerAssignment(customerId));
|
|
495
|
+
const getOrderAffiliateAttribution = (orderId) => sdk.client.fetch(
|
|
496
|
+
affiliateAdminPaths.get.orderAttribution(orderId)
|
|
497
|
+
);
|
|
498
|
+
const setCustomerAffiliateAssignment = (customerId, payload) => sdk.client.fetch(affiliateAdminPaths.post.setCustomerAssignment(customerId), {
|
|
499
|
+
method: "POST",
|
|
500
|
+
body: payload
|
|
501
|
+
});
|
|
502
|
+
const removeCustomerAffiliateAssignment = (customerId) => sdk.client.fetch(affiliateAdminPaths.delete.customerAssignment(customerId), {
|
|
503
|
+
method: "DELETE"
|
|
504
|
+
});
|
|
505
|
+
const getAffiliateReportOverview = (params) => sdk.client.fetch(withQuery(affiliateAdminPaths.get.reports, params));
|
|
506
|
+
const getAffiliateReportDetail = (affiliateId, params) => sdk.client.fetch(withQuery(affiliateAdminPaths.get.report(affiliateId), params));
|
|
507
|
+
const requestConsignmentReminder = (affiliateId, payload) => sdk.client.fetch(
|
|
508
|
+
affiliateAdminPaths.post.requestConsignmentReminder(affiliateId),
|
|
509
|
+
{ method: "POST", body: payload }
|
|
510
|
+
);
|
|
511
|
+
const getAffiliateDistribution = (affiliateId) => sdk.client.fetch(
|
|
512
|
+
affiliateAdminPaths.get.distribution(affiliateId)
|
|
513
|
+
);
|
|
514
|
+
const enableAffiliateDistribution = (affiliateId, payload) => sdk.client.fetch(
|
|
515
|
+
affiliateAdminPaths.post.updateDistribution(affiliateId),
|
|
516
|
+
{ method: "POST", body: payload }
|
|
517
|
+
);
|
|
518
|
+
const transferConsignmentStock = (affiliateId, payload) => sdk.client.fetch(
|
|
519
|
+
affiliateAdminPaths.post.transferConsignmentStock(affiliateId),
|
|
520
|
+
{ method: "POST", body: payload }
|
|
521
|
+
);
|
|
522
|
+
const getSourceInventoryQuantity = async (inventoryItemId, locationId) => {
|
|
523
|
+
const response = await sdk.admin.inventoryItem.listLevels(inventoryItemId, {
|
|
524
|
+
location_id: locationId,
|
|
525
|
+
limit: 1
|
|
526
|
+
});
|
|
527
|
+
return response.inventory_levels[0]?.stocked_quantity ?? null;
|
|
528
|
+
};
|
|
529
|
+
const listSourceBatches = (inventoryItemId, locationId) => sdk.client.fetch(
|
|
530
|
+
withQuery("/admin/batch-management/batches", {
|
|
531
|
+
inventory_item_id: inventoryItemId,
|
|
532
|
+
location_id: locationId,
|
|
533
|
+
limit: 100,
|
|
534
|
+
offset: 0
|
|
535
|
+
})
|
|
536
|
+
);
|
|
537
|
+
const listAdminConsignmentReports = (params) => sdk.client.fetch(
|
|
538
|
+
withQuery(affiliateAdminPaths.get.consignmentReports, params)
|
|
539
|
+
);
|
|
540
|
+
const retrieveAdminConsignmentReport = (reportId) => sdk.client.fetch(
|
|
541
|
+
affiliateAdminPaths.get.consignmentReport(reportId)
|
|
542
|
+
);
|
|
543
|
+
const approveAdminConsignmentReport = (reportId, payload) => sdk.client.fetch(
|
|
544
|
+
affiliateAdminPaths.post.approveConsignmentReport(reportId),
|
|
545
|
+
{ method: "POST", body: payload }
|
|
546
|
+
);
|
|
547
|
+
const rejectAdminConsignmentReport = (reportId, payload) => sdk.client.fetch(
|
|
548
|
+
affiliateAdminPaths.post.rejectConsignmentReport(reportId),
|
|
549
|
+
{ method: "POST", body: payload }
|
|
550
|
+
);
|
|
551
|
+
const getAffiliateProgramSettings = () => sdk.client.fetch(
|
|
552
|
+
affiliateAdminPaths.get.programSettings
|
|
553
|
+
);
|
|
554
|
+
const updateAffiliateProgramSettings = (payload) => sdk.client.fetch(
|
|
555
|
+
affiliateAdminPaths.post.updateProgramSettings,
|
|
556
|
+
{ method: "POST", body: payload }
|
|
557
|
+
);
|
|
558
|
+
const getAffiliateDistributionReports = (params) => sdk.client.fetch(
|
|
559
|
+
withQuery(affiliateAdminPaths.get.distributionReports, params)
|
|
560
|
+
);
|
|
561
|
+
const SearchableReferenceField = ({
|
|
562
|
+
label,
|
|
563
|
+
value,
|
|
564
|
+
selectedLabel,
|
|
565
|
+
search,
|
|
566
|
+
placeholder,
|
|
567
|
+
emptyText,
|
|
568
|
+
isLoading,
|
|
569
|
+
options,
|
|
570
|
+
disabled = false,
|
|
571
|
+
onSearchChange,
|
|
572
|
+
onSelect,
|
|
573
|
+
onClear
|
|
574
|
+
}) => {
|
|
575
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
576
|
+
const showDropdown = isOpen && !disabled;
|
|
577
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
578
|
+
/* @__PURE__ */ jsx(Label, { children: label }),
|
|
579
|
+
value && /* @__PURE__ */ jsxs("div", { className: "border-ui-border-base bg-ui-bg-subtle flex items-start justify-between gap-3 rounded-md border px-3 py-2", children: [
|
|
580
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
581
|
+
/* @__PURE__ */ jsx(Text, { className: "truncate text-sm font-medium", children: selectedLabel || value }),
|
|
582
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-muted truncate text-xs", children: value })
|
|
583
|
+
] }),
|
|
584
|
+
/* @__PURE__ */ jsx(
|
|
585
|
+
Button,
|
|
586
|
+
{
|
|
587
|
+
type: "button",
|
|
588
|
+
size: "small",
|
|
589
|
+
variant: "secondary",
|
|
590
|
+
disabled,
|
|
591
|
+
onClick: onClear,
|
|
592
|
+
children: texts.reference.remove
|
|
593
|
+
}
|
|
594
|
+
)
|
|
595
|
+
] }),
|
|
596
|
+
/* @__PURE__ */ jsx(
|
|
597
|
+
Input,
|
|
598
|
+
{
|
|
599
|
+
value: search,
|
|
600
|
+
disabled,
|
|
601
|
+
onFocus: () => setIsOpen(true),
|
|
602
|
+
onChange: (event) => {
|
|
603
|
+
onSearchChange(event.target.value);
|
|
604
|
+
setIsOpen(true);
|
|
605
|
+
},
|
|
606
|
+
onKeyDown: (event) => {
|
|
607
|
+
if (event.key === "Escape") {
|
|
608
|
+
setIsOpen(false);
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
placeholder
|
|
612
|
+
}
|
|
613
|
+
),
|
|
614
|
+
showDropdown && /* @__PURE__ */ jsx("div", { className: "border-ui-border-base bg-ui-bg-base shadow-elevation-card-rest max-h-64 overflow-auto rounded-md border", children: isLoading ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle px-3 py-2 text-sm", children: texts.reference.searching }) : options.length ? options.map((option) => /* @__PURE__ */ jsxs(
|
|
615
|
+
"button",
|
|
616
|
+
{
|
|
617
|
+
type: "button",
|
|
618
|
+
className: "hover:bg-ui-bg-subtle grid w-full gap-0.5 px-3 py-2 text-left",
|
|
619
|
+
onClick: () => {
|
|
620
|
+
onSelect(option);
|
|
621
|
+
setIsOpen(false);
|
|
622
|
+
},
|
|
623
|
+
children: [
|
|
624
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-base truncate text-sm font-medium", children: option.label }),
|
|
625
|
+
/* @__PURE__ */ jsx("span", { className: "text-ui-fg-muted truncate text-xs", children: option.description ?? option.id })
|
|
626
|
+
]
|
|
627
|
+
},
|
|
628
|
+
option.id
|
|
629
|
+
)) : /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle px-3 py-2 text-sm", children: emptyText }) })
|
|
630
|
+
] });
|
|
631
|
+
};
|
|
632
|
+
const AffiliateReferenceField = ({
|
|
633
|
+
label = texts.reference.affiliate.label,
|
|
634
|
+
value,
|
|
635
|
+
onChange,
|
|
636
|
+
excludeAffiliateId,
|
|
637
|
+
disabled
|
|
638
|
+
}) => {
|
|
639
|
+
const [search, setSearch] = useState("");
|
|
640
|
+
const [selectedLabel, setSelectedLabel] = useState("");
|
|
641
|
+
const deferredSearch = useDeferredValue(search);
|
|
642
|
+
const affiliatesQuery = useQuery({
|
|
643
|
+
queryKey: affiliateKeys.affiliateReferenceSearch(deferredSearch),
|
|
644
|
+
queryFn: () => listAffiliates({
|
|
645
|
+
status: "active",
|
|
646
|
+
q: deferredSearch.trim(),
|
|
647
|
+
limit: 100,
|
|
648
|
+
offset: 0
|
|
649
|
+
})
|
|
650
|
+
});
|
|
651
|
+
const selectedAffiliateQuery = useQuery({
|
|
652
|
+
queryKey: affiliateKeys.affiliateReference(value),
|
|
653
|
+
enabled: !!value,
|
|
654
|
+
queryFn: () => retrieveAffiliate(value)
|
|
655
|
+
});
|
|
656
|
+
const options = (affiliatesQuery.data?.affiliates ?? []).filter((affiliate) => affiliate.id !== excludeAffiliateId).map((affiliate) => {
|
|
657
|
+
const primarySlug = affiliate.slugs?.find((slug) => slug.is_primary)?.slug;
|
|
658
|
+
return {
|
|
659
|
+
id: affiliate.id,
|
|
660
|
+
label: affiliate.display_name,
|
|
661
|
+
description: primarySlug ? `${affiliate.id} · ${primarySlug}` : affiliate.id
|
|
662
|
+
};
|
|
663
|
+
});
|
|
664
|
+
const selectedAffiliate = selectedAffiliateQuery.data?.affiliate;
|
|
665
|
+
const displayLabel = selectedLabel || selectedAffiliate?.display_name || value;
|
|
666
|
+
return /* @__PURE__ */ jsx(
|
|
667
|
+
SearchableReferenceField,
|
|
668
|
+
{
|
|
669
|
+
label,
|
|
670
|
+
value,
|
|
671
|
+
selectedLabel: displayLabel,
|
|
672
|
+
search,
|
|
673
|
+
placeholder: texts.reference.affiliate.placeholder,
|
|
674
|
+
emptyText: texts.reference.affiliate.empty,
|
|
675
|
+
isLoading: affiliatesQuery.isLoading || affiliatesQuery.isFetching,
|
|
676
|
+
options,
|
|
677
|
+
disabled,
|
|
678
|
+
onSearchChange: setSearch,
|
|
679
|
+
onSelect: (option) => {
|
|
680
|
+
onChange(option.id);
|
|
681
|
+
setSelectedLabel(option.label);
|
|
682
|
+
setSearch("");
|
|
683
|
+
},
|
|
684
|
+
onClear: () => {
|
|
685
|
+
onChange("");
|
|
686
|
+
setSelectedLabel("");
|
|
687
|
+
setSearch("");
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
};
|
|
692
|
+
const getErrorMessage = (error) => {
|
|
693
|
+
if (error instanceof Error && error.message) {
|
|
694
|
+
return error.message;
|
|
695
|
+
}
|
|
696
|
+
if (typeof error !== "object" || error === null) {
|
|
697
|
+
return "Unbekannter Fehler";
|
|
698
|
+
}
|
|
699
|
+
const candidate = error;
|
|
700
|
+
for (const value of [
|
|
701
|
+
candidate.response?.data?.message,
|
|
702
|
+
candidate.response?.data?.error,
|
|
703
|
+
candidate.body?.message,
|
|
704
|
+
candidate.body?.error,
|
|
705
|
+
candidate.message,
|
|
706
|
+
candidate.statusText
|
|
707
|
+
]) {
|
|
708
|
+
if (typeof value === "string" && value.trim()) {
|
|
709
|
+
return value;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return "Unbekannter Fehler";
|
|
713
|
+
};
|
|
714
|
+
const ADMIN_LOCALE = "de-DE";
|
|
715
|
+
const formatDate = (value) => {
|
|
716
|
+
if (!value) {
|
|
717
|
+
return texts.common.dash;
|
|
718
|
+
}
|
|
719
|
+
return new Intl.DateTimeFormat(ADMIN_LOCALE, {
|
|
720
|
+
year: "numeric",
|
|
721
|
+
month: "2-digit",
|
|
722
|
+
day: "2-digit"
|
|
723
|
+
}).format(new Date(value));
|
|
724
|
+
};
|
|
725
|
+
const formatDateTime = (value) => {
|
|
726
|
+
if (!value) {
|
|
727
|
+
return texts.common.dash;
|
|
728
|
+
}
|
|
729
|
+
return new Intl.DateTimeFormat(ADMIN_LOCALE, {
|
|
730
|
+
year: "numeric",
|
|
731
|
+
month: "2-digit",
|
|
732
|
+
day: "2-digit",
|
|
733
|
+
hour: "2-digit",
|
|
734
|
+
minute: "2-digit"
|
|
735
|
+
}).format(new Date(value));
|
|
736
|
+
};
|
|
737
|
+
const formatAmount = (amount, currencyCode) => new Intl.NumberFormat(ADMIN_LOCALE, {
|
|
738
|
+
style: "currency",
|
|
739
|
+
currency: currencyCode.toUpperCase()
|
|
740
|
+
}).format(amount);
|
|
741
|
+
const statusLabels = {
|
|
742
|
+
active: texts.status.active,
|
|
743
|
+
inactive: texts.status.inactive,
|
|
744
|
+
pending: texts.status.pending,
|
|
745
|
+
rejected: texts.status.rejected,
|
|
746
|
+
approved: texts.status.approved
|
|
747
|
+
};
|
|
748
|
+
const formatStatus = (status) => {
|
|
749
|
+
if (!status) {
|
|
750
|
+
return texts.common.dash;
|
|
751
|
+
}
|
|
752
|
+
return statusLabels[status] ?? status;
|
|
753
|
+
};
|
|
754
|
+
const commissionEntryTypeLabels = texts.reportDetail.entryTypes;
|
|
755
|
+
const formatCommissionEntryType = (type) => {
|
|
756
|
+
if (!type) {
|
|
757
|
+
return texts.common.dash;
|
|
758
|
+
}
|
|
759
|
+
return commissionEntryTypeLabels[type] ?? type;
|
|
760
|
+
};
|
|
761
|
+
const getTodayInputDate = () => {
|
|
762
|
+
const now = /* @__PURE__ */ new Date();
|
|
763
|
+
const timezoneOffsetMs = now.getTimezoneOffset() * 60 * 1e3;
|
|
764
|
+
return new Date(now.getTime() - timezoneOffsetMs).toISOString().slice(0, 10);
|
|
765
|
+
};
|
|
766
|
+
const getMonthStartInputDate = () => {
|
|
767
|
+
const now = /* @__PURE__ */ new Date();
|
|
768
|
+
const start = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
769
|
+
const timezoneOffsetMs = start.getTimezoneOffset() * 60 * 1e3;
|
|
770
|
+
return new Date(start.getTime() - timezoneOffsetMs).toISOString().slice(0, 10);
|
|
771
|
+
};
|
|
772
|
+
const useCustomerAffiliateAssignment = (customerId) => useQuery({
|
|
773
|
+
queryKey: affiliateKeys.customerAssignment(customerId),
|
|
774
|
+
queryFn: () => getCustomerAffiliateAssignment(customerId)
|
|
775
|
+
});
|
|
776
|
+
const useCustomerIsAffiliate = (customerId) => useQuery({
|
|
777
|
+
queryKey: affiliateKeys.customerIsAffiliate(customerId),
|
|
778
|
+
queryFn: async () => {
|
|
779
|
+
const { affiliates } = await listAffiliates({
|
|
780
|
+
customer_id: customerId,
|
|
781
|
+
limit: 1,
|
|
782
|
+
offset: 0
|
|
783
|
+
});
|
|
784
|
+
return affiliates.some((affiliate) => affiliate.status !== "rejected");
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
const useSetCustomerAffiliateAssignment = (customerId) => {
|
|
788
|
+
const queryClient = useQueryClient();
|
|
789
|
+
return useMutation({
|
|
790
|
+
mutationFn: (affiliateId) => setCustomerAffiliateAssignment(customerId, {
|
|
791
|
+
affiliate_id: affiliateId,
|
|
792
|
+
source: "admin"
|
|
793
|
+
}),
|
|
794
|
+
onSuccess: async () => {
|
|
795
|
+
await queryClient.invalidateQueries({
|
|
796
|
+
queryKey: affiliateKeys.customerAssignment(customerId)
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
};
|
|
801
|
+
const useRemoveCustomerAffiliateAssignment = (customerId) => {
|
|
802
|
+
const queryClient = useQueryClient();
|
|
803
|
+
return useMutation({
|
|
804
|
+
mutationFn: () => removeCustomerAffiliateAssignment(customerId),
|
|
805
|
+
onSuccess: async () => {
|
|
806
|
+
await queryClient.invalidateQueries({
|
|
807
|
+
queryKey: affiliateKeys.customerAssignment(customerId)
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
};
|
|
812
|
+
const useAffiliates = (params = {}) => useQuery({
|
|
813
|
+
queryKey: affiliateKeys.list(params),
|
|
814
|
+
queryFn: () => listAffiliates({
|
|
815
|
+
limit: 50,
|
|
816
|
+
offset: 0,
|
|
817
|
+
...params
|
|
818
|
+
})
|
|
819
|
+
});
|
|
820
|
+
const useAffiliate = (affiliateId) => useQuery({
|
|
821
|
+
queryKey: affiliateKeys.detail(affiliateId),
|
|
822
|
+
enabled: !!affiliateId,
|
|
823
|
+
queryFn: () => retrieveAffiliate(affiliateId ?? "")
|
|
824
|
+
});
|
|
825
|
+
const useAffiliateCouponCodes = (affiliateId, params = {}) => useQuery({
|
|
826
|
+
queryKey: affiliateKeys.couponCodeList(affiliateId, params),
|
|
827
|
+
enabled: !!affiliateId,
|
|
828
|
+
queryFn: () => listAffiliateCouponCodes(affiliateId ?? "", params)
|
|
829
|
+
});
|
|
830
|
+
const requireAffiliateId = (affiliateId) => {
|
|
831
|
+
if (!affiliateId) {
|
|
832
|
+
throw new Error(texts.hooks.missingAffiliateId);
|
|
833
|
+
}
|
|
834
|
+
return affiliateId;
|
|
835
|
+
};
|
|
836
|
+
const useCreateAffiliateCouponCode = (affiliateId) => {
|
|
837
|
+
const queryClient = useQueryClient();
|
|
838
|
+
return useMutation({
|
|
839
|
+
mutationFn: (payload) => createAffiliateCouponCode(requireAffiliateId(affiliateId), payload),
|
|
840
|
+
onSuccess: async () => {
|
|
841
|
+
await queryClient.invalidateQueries({
|
|
842
|
+
queryKey: affiliateKeys.couponCodes(affiliateId)
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
};
|
|
847
|
+
const useRotateAffiliateCouponCode = (affiliateId) => {
|
|
848
|
+
const queryClient = useQueryClient();
|
|
849
|
+
return useMutation({
|
|
850
|
+
mutationFn: (input) => rotateAffiliateCouponCode(
|
|
851
|
+
requireAffiliateId(affiliateId),
|
|
852
|
+
input.couponId,
|
|
853
|
+
input.payload
|
|
854
|
+
),
|
|
855
|
+
onSuccess: async () => {
|
|
856
|
+
await queryClient.invalidateQueries({
|
|
857
|
+
queryKey: affiliateKeys.couponCodes(affiliateId)
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
const useRevokeAffiliateCouponCode = (affiliateId) => {
|
|
863
|
+
const queryClient = useQueryClient();
|
|
864
|
+
return useMutation({
|
|
865
|
+
mutationFn: (couponId) => revokeAffiliateCouponCode(requireAffiliateId(affiliateId), couponId),
|
|
866
|
+
onSuccess: async () => {
|
|
867
|
+
await queryClient.invalidateQueries({
|
|
868
|
+
queryKey: affiliateKeys.couponCodes(affiliateId)
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
};
|
|
873
|
+
const useReconcileAffiliateCouponCode = (affiliateId) => {
|
|
874
|
+
const queryClient = useQueryClient();
|
|
875
|
+
return useMutation({
|
|
876
|
+
mutationFn: (couponId) => reconcileAffiliateCouponCode(requireAffiliateId(affiliateId), couponId),
|
|
877
|
+
onSuccess: async () => {
|
|
878
|
+
await queryClient.invalidateQueries({
|
|
879
|
+
queryKey: affiliateKeys.couponCodes(affiliateId)
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
};
|
|
884
|
+
const useCreateAffiliate = () => {
|
|
885
|
+
const queryClient = useQueryClient();
|
|
886
|
+
return useMutation({
|
|
887
|
+
mutationFn: (payload) => createAffiliate(payload),
|
|
888
|
+
onSuccess: async (data) => {
|
|
889
|
+
queryClient.setQueryData(
|
|
890
|
+
affiliateKeys.detail(data.affiliate.id),
|
|
891
|
+
data
|
|
892
|
+
);
|
|
893
|
+
await queryClient.invalidateQueries({ queryKey: affiliateKeys.lists() });
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
};
|
|
897
|
+
const useUpdateAffiliate = (affiliateId) => {
|
|
898
|
+
const queryClient = useQueryClient();
|
|
899
|
+
return useMutation({
|
|
900
|
+
mutationFn: (payload) => {
|
|
901
|
+
if (!affiliateId) {
|
|
902
|
+
throw new Error(texts.hooks.missingAffiliateId);
|
|
903
|
+
}
|
|
904
|
+
return updateAffiliate(affiliateId, payload);
|
|
905
|
+
},
|
|
906
|
+
onSuccess: async (data) => {
|
|
907
|
+
queryClient.setQueryData(affiliateKeys.detail(affiliateId), data);
|
|
908
|
+
await queryClient.invalidateQueries({ queryKey: affiliateKeys.lists() });
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
};
|
|
912
|
+
const useSetAffiliateInactive = (affiliateId) => {
|
|
913
|
+
const queryClient = useQueryClient();
|
|
914
|
+
return useMutation({
|
|
915
|
+
mutationFn: () => {
|
|
916
|
+
if (!affiliateId) {
|
|
917
|
+
throw new Error(texts.hooks.missingAffiliateId);
|
|
918
|
+
}
|
|
919
|
+
return setAffiliateInactive(affiliateId);
|
|
920
|
+
},
|
|
921
|
+
onSuccess: async (data) => {
|
|
922
|
+
queryClient.setQueryData(affiliateKeys.detail(affiliateId), data);
|
|
923
|
+
await queryClient.invalidateQueries({ queryKey: affiliateKeys.lists() });
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
};
|
|
927
|
+
const useCreateAffiliateSlug = (affiliateId) => {
|
|
928
|
+
const queryClient = useQueryClient();
|
|
929
|
+
return useMutation({
|
|
930
|
+
mutationFn: (payload) => {
|
|
931
|
+
if (!affiliateId) {
|
|
932
|
+
throw new Error(texts.hooks.missingAffiliateId);
|
|
933
|
+
}
|
|
934
|
+
return createAffiliateSlug(affiliateId, {
|
|
935
|
+
slug: payload.slug,
|
|
936
|
+
active: true,
|
|
937
|
+
is_primary: payload.is_primary
|
|
938
|
+
});
|
|
939
|
+
},
|
|
940
|
+
onSuccess: async () => {
|
|
941
|
+
await queryClient.invalidateQueries({
|
|
942
|
+
queryKey: affiliateKeys.detail(affiliateId)
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
};
|
|
947
|
+
const useUpdateAffiliateSlug = (affiliateId) => {
|
|
948
|
+
const queryClient = useQueryClient();
|
|
949
|
+
return useMutation({
|
|
950
|
+
mutationFn: (payload) => {
|
|
951
|
+
if (!affiliateId) {
|
|
952
|
+
throw new Error(texts.hooks.missingAffiliateId);
|
|
953
|
+
}
|
|
954
|
+
return updateAffiliateSlug(affiliateId, payload.slugId, {
|
|
955
|
+
active: payload.active,
|
|
956
|
+
is_primary: payload.is_primary
|
|
957
|
+
});
|
|
958
|
+
},
|
|
959
|
+
onSuccess: async () => {
|
|
960
|
+
await queryClient.invalidateQueries({
|
|
961
|
+
queryKey: affiliateKeys.detail(affiliateId)
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
};
|
|
966
|
+
const formatAssignmentEndedReason = (reason) => {
|
|
967
|
+
switch (reason) {
|
|
968
|
+
case "expired":
|
|
969
|
+
return texts.assignment.endedReasons.expired;
|
|
970
|
+
case "reassigned":
|
|
971
|
+
return texts.assignment.endedReasons.reassigned;
|
|
972
|
+
case "admin_removed":
|
|
973
|
+
return texts.assignment.endedReasons.adminRemoved;
|
|
974
|
+
case "affiliate_inactive":
|
|
975
|
+
return texts.assignment.endedReasons.affiliateInactive;
|
|
976
|
+
case "customer_became_affiliate":
|
|
977
|
+
return texts.assignment.endedReasons.customerBecameAffiliate;
|
|
978
|
+
case null:
|
|
979
|
+
case void 0:
|
|
980
|
+
return texts.assignment.endedReasons.notProvided;
|
|
981
|
+
default:
|
|
982
|
+
return texts.assignment.endedReasons.unknown;
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
const getCustomerAffiliateAssignmentControlState = ({
|
|
986
|
+
hasActiveAssignment,
|
|
987
|
+
hasSelectedAffiliate,
|
|
988
|
+
selfAffiliateCheckPending,
|
|
989
|
+
customerIsAffiliate,
|
|
990
|
+
selectedModePending,
|
|
991
|
+
selectedAffiliateIsOrderOnly,
|
|
992
|
+
setMutationPending,
|
|
993
|
+
removeMutationPending
|
|
994
|
+
}) => ({
|
|
995
|
+
showAssignmentForm: !customerIsAffiliate,
|
|
996
|
+
affiliateFieldDisabled: selfAffiliateCheckPending || customerIsAffiliate,
|
|
997
|
+
saveDisabled: selfAffiliateCheckPending || customerIsAffiliate || selectedModePending || selectedAffiliateIsOrderOnly || !hasSelectedAffiliate || setMutationPending,
|
|
998
|
+
removeDisabled: !hasActiveAssignment || removeMutationPending
|
|
999
|
+
});
|
|
1000
|
+
const formatAssignmentMode = (mode) => mode === "lifetime" ? "Lifetime" : "Zeitlich begrenzt";
|
|
1001
|
+
const CustomerAffiliateAssignmentPanel = ({ customerId }) => {
|
|
1002
|
+
const [affiliateId, setAffiliateId] = useState("");
|
|
1003
|
+
const [confirmationOpen, setConfirmationOpen] = useState(false);
|
|
1004
|
+
const assignmentQuery = useCustomerAffiliateAssignment(customerId);
|
|
1005
|
+
const customerIsAffiliateQuery = useCustomerIsAffiliate(customerId);
|
|
1006
|
+
const assignment = assignmentQuery.data?.assignment ?? null;
|
|
1007
|
+
const history = (assignmentQuery.data?.history ?? []).filter((item) => item.id !== assignment?.id).sort(
|
|
1008
|
+
(left, right) => new Date(right.assigned_at).getTime() - new Date(left.assigned_at).getTime()
|
|
1009
|
+
);
|
|
1010
|
+
const selectedAffiliateQuery = useAffiliate(affiliateId || void 0);
|
|
1011
|
+
const selectedAffiliate = selectedAffiliateQuery.data?.affiliate;
|
|
1012
|
+
useEffect(() => {
|
|
1013
|
+
if (assignment?.affiliate_id) {
|
|
1014
|
+
setAffiliateId(assignment.affiliate_id);
|
|
1015
|
+
}
|
|
1016
|
+
}, [assignment?.affiliate_id]);
|
|
1017
|
+
const setMutation = useSetCustomerAffiliateAssignment(customerId);
|
|
1018
|
+
const removeMutation = useRemoveCustomerAffiliateAssignment(customerId);
|
|
1019
|
+
const selfAffiliateCheckPending = customerIsAffiliateQuery.isLoading;
|
|
1020
|
+
const customerIsAffiliate = customerIsAffiliateQuery.data ?? false;
|
|
1021
|
+
const selectedModePending = !!affiliateId && selectedAffiliateQuery.isLoading;
|
|
1022
|
+
const selectedAffiliateIsOrderOnly = selectedAffiliate?.customer_assignment_mode === "order_only";
|
|
1023
|
+
const controlState = getCustomerAffiliateAssignmentControlState({
|
|
1024
|
+
hasActiveAssignment: !!assignment,
|
|
1025
|
+
hasSelectedAffiliate: !!affiliateId,
|
|
1026
|
+
selfAffiliateCheckPending,
|
|
1027
|
+
customerIsAffiliate,
|
|
1028
|
+
selectedModePending,
|
|
1029
|
+
selectedAffiliateIsOrderOnly,
|
|
1030
|
+
setMutationPending: setMutation.isPending,
|
|
1031
|
+
removeMutationPending: removeMutation.isPending
|
|
1032
|
+
});
|
|
1033
|
+
const saveAssignment = () => !controlState.saveDisabled && setMutation.mutate(affiliateId, {
|
|
1034
|
+
onSuccess: () => {
|
|
1035
|
+
setConfirmationOpen(false);
|
|
1036
|
+
toast.success(texts.assignment.toasts.saved);
|
|
1037
|
+
},
|
|
1038
|
+
onError: (error) => toast.error(texts.assignment.toasts.saveFailed, {
|
|
1039
|
+
description: getErrorMessage(error)
|
|
1040
|
+
})
|
|
1041
|
+
});
|
|
1042
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
1043
|
+
/* @__PURE__ */ jsxs("div", { className: "px-6 py-4", children: [
|
|
1044
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: texts.assignment.heading }),
|
|
1045
|
+
selfAffiliateCheckPending ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.assignment.checking }) : customerIsAffiliate ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.assignment.isAffiliate }) : assignment ? /* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle", children: [
|
|
1046
|
+
assignment.affiliate?.display_name ?? assignment.affiliate_id,
|
|
1047
|
+
" · ",
|
|
1048
|
+
assignment.source,
|
|
1049
|
+
" ·",
|
|
1050
|
+
" ",
|
|
1051
|
+
formatDateTime(assignment.assigned_at)
|
|
1052
|
+
] }) : /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.assignment.none })
|
|
1053
|
+
] }),
|
|
1054
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 px-6 py-4", children: [
|
|
1055
|
+
controlState.showAssignmentForm ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1056
|
+
/* @__PURE__ */ jsx(
|
|
1057
|
+
AffiliateReferenceField,
|
|
1058
|
+
{
|
|
1059
|
+
value: affiliateId,
|
|
1060
|
+
onChange: setAffiliateId,
|
|
1061
|
+
disabled: controlState.affiliateFieldDisabled
|
|
1062
|
+
}
|
|
1063
|
+
),
|
|
1064
|
+
selectedAffiliateIsOrderOnly ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: texts.assignment.orderOnlyUnavailable }) : null
|
|
1065
|
+
] }) : null,
|
|
1066
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
1067
|
+
controlState.showAssignmentForm ? /* @__PURE__ */ jsx(
|
|
1068
|
+
Button,
|
|
1069
|
+
{
|
|
1070
|
+
size: "small",
|
|
1071
|
+
disabled: controlState.saveDisabled,
|
|
1072
|
+
onClick: () => {
|
|
1073
|
+
if (assignment && assignment.affiliate_id !== affiliateId) {
|
|
1074
|
+
setConfirmationOpen(true);
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
saveAssignment();
|
|
1078
|
+
},
|
|
1079
|
+
children: texts.assignment.save
|
|
1080
|
+
}
|
|
1081
|
+
) : null,
|
|
1082
|
+
/* @__PURE__ */ jsx(
|
|
1083
|
+
Button,
|
|
1084
|
+
{
|
|
1085
|
+
size: "small",
|
|
1086
|
+
variant: "secondary",
|
|
1087
|
+
disabled: controlState.removeDisabled,
|
|
1088
|
+
onClick: () => removeMutation.mutate(void 0, {
|
|
1089
|
+
onSuccess: () => {
|
|
1090
|
+
toast.success(texts.assignment.toasts.removed);
|
|
1091
|
+
setAffiliateId("");
|
|
1092
|
+
},
|
|
1093
|
+
onError: (error) => toast.error(texts.assignment.toasts.removeFailed, {
|
|
1094
|
+
description: getErrorMessage(error)
|
|
1095
|
+
})
|
|
1096
|
+
}),
|
|
1097
|
+
children: texts.assignment.remove
|
|
1098
|
+
}
|
|
1099
|
+
)
|
|
1100
|
+
] })
|
|
1101
|
+
] }),
|
|
1102
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 px-6 py-4", children: [
|
|
1103
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: texts.assignment.current }),
|
|
1104
|
+
assignment ? /* @__PURE__ */ jsx(AssignmentHistoryItem, { assignment }) : /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: texts.assignment.none })
|
|
1105
|
+
] }),
|
|
1106
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 px-6 py-4", children: [
|
|
1107
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: texts.assignment.history }),
|
|
1108
|
+
assignmentQuery.isLoading ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: texts.assignment.checking }) : assignmentQuery.isError ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error text-sm", children: getErrorMessage(assignmentQuery.error) }) : history.length ? /* @__PURE__ */ jsx("div", { className: "grid gap-2", children: history.map((item) => /* @__PURE__ */ jsx(AssignmentHistoryItem, { assignment: item }, item.id)) }) : /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: texts.assignment.historyEmpty })
|
|
1109
|
+
] }),
|
|
1110
|
+
/* @__PURE__ */ jsx(Prompt, { open: confirmationOpen, onOpenChange: setConfirmationOpen, children: /* @__PURE__ */ jsxs(Prompt.Content, { children: [
|
|
1111
|
+
/* @__PURE__ */ jsxs(Prompt.Header, { children: [
|
|
1112
|
+
/* @__PURE__ */ jsx(Prompt.Title, { children: "Affiliate-Zuordnung ändern?" }),
|
|
1113
|
+
/* @__PURE__ */ jsx(Prompt.Description, { children: "Die aktuelle Zuordnung wird beendet und historisch erhalten. Zukünftige Bestellungen werden dem neu gewählten Affiliate zugeordnet." })
|
|
1114
|
+
] }),
|
|
1115
|
+
/* @__PURE__ */ jsxs(Prompt.Footer, { children: [
|
|
1116
|
+
/* @__PURE__ */ jsx(Prompt.Cancel, { children: "Abbrechen" }),
|
|
1117
|
+
/* @__PURE__ */ jsx(Prompt.Action, { onClick: saveAssignment, children: "Zuordnung ändern" })
|
|
1118
|
+
] })
|
|
1119
|
+
] }) })
|
|
1120
|
+
] });
|
|
1121
|
+
};
|
|
1122
|
+
const AssignmentHistoryItem = ({
|
|
1123
|
+
assignment
|
|
1124
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "border-ui-border-base grid gap-1 rounded-md border p-3 text-sm", children: [
|
|
1125
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: assignment.affiliate?.display_name ?? assignment.affiliate_id }),
|
|
1126
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle", children: [
|
|
1127
|
+
texts.assignment.mode,
|
|
1128
|
+
": ",
|
|
1129
|
+
formatAssignmentMode(assignment.customer_assignment_mode),
|
|
1130
|
+
assignment.assignment_duration_days ? `, ${assignment.assignment_duration_days} Tage` : `, ${texts.assignment.lifetime}`
|
|
1131
|
+
] }),
|
|
1132
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle", children: [
|
|
1133
|
+
texts.assignment.assignedAt,
|
|
1134
|
+
": ",
|
|
1135
|
+
formatDateTime(assignment.assigned_at),
|
|
1136
|
+
assignment.valid_until ? `, ${texts.assignment.validUntil(formatDateTime(assignment.valid_until))}` : `, ${texts.assignment.lifetime}`
|
|
1137
|
+
] }),
|
|
1138
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle", children: [
|
|
1139
|
+
assignment.active ? texts.assignment.active : texts.assignment.ended,
|
|
1140
|
+
!assignment.active ? `, ${texts.assignment.endedReason}: ${formatAssignmentEndedReason(assignment.ended_reason)}` : ""
|
|
1141
|
+
] })
|
|
1142
|
+
] });
|
|
1143
|
+
const CustomerAffiliateWidget = ({ data }) => /* @__PURE__ */ jsx(CustomerAffiliateAssignmentPanel, { customerId: data.id });
|
|
1144
|
+
defineWidgetConfig({
|
|
1145
|
+
zone: "customer.details.side.after"
|
|
1146
|
+
});
|
|
1147
|
+
const useOrderAffiliateAttribution = (orderId) => useQuery({
|
|
1148
|
+
queryKey: affiliateKeys.orderAttribution(orderId),
|
|
1149
|
+
queryFn: () => getOrderAffiliateAttribution(orderId)
|
|
1150
|
+
});
|
|
1151
|
+
const formatMode = (mode) => {
|
|
1152
|
+
switch (mode) {
|
|
1153
|
+
case "lifetime":
|
|
1154
|
+
return "Lifetime";
|
|
1155
|
+
case "time_limited":
|
|
1156
|
+
return "Zeitlich begrenzt";
|
|
1157
|
+
case "order_only":
|
|
1158
|
+
return "Nur Bestellung";
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
const formatSource = (source) => texts.orderAttribution.sources[source];
|
|
1162
|
+
const OrderAffiliateAttributionPanel = ({ orderId }) => {
|
|
1163
|
+
const attributionQuery = useOrderAffiliateAttribution(orderId);
|
|
1164
|
+
const attribution = attributionQuery.data?.attribution;
|
|
1165
|
+
let content;
|
|
1166
|
+
if (attributionQuery.isLoading) {
|
|
1167
|
+
content = /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.orderAttribution.loading });
|
|
1168
|
+
} else if (attributionQuery.isError) {
|
|
1169
|
+
content = /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: texts.orderAttribution.loadError(getErrorMessage(attributionQuery.error)) });
|
|
1170
|
+
} else if (!attribution) {
|
|
1171
|
+
content = /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.orderAttribution.empty });
|
|
1172
|
+
} else {
|
|
1173
|
+
const fields = [
|
|
1174
|
+
[texts.orderAttribution.affiliate, attribution.affiliate.display_name],
|
|
1175
|
+
[texts.orderAttribution.source, formatSource(attribution.source)],
|
|
1176
|
+
[
|
|
1177
|
+
texts.orderAttribution.referralSlug,
|
|
1178
|
+
attribution.source === "referral_link" ? attribution.slug_or_code_snapshot ?? texts.common.dash : texts.common.dash
|
|
1179
|
+
],
|
|
1180
|
+
[
|
|
1181
|
+
texts.orderAttribution.referralCoupon,
|
|
1182
|
+
attribution.source === "coupon" ? attribution.slug_or_code_snapshot ?? texts.common.dash : texts.common.dash
|
|
1183
|
+
],
|
|
1184
|
+
[
|
|
1185
|
+
texts.orderAttribution.appliedCoupon,
|
|
1186
|
+
attribution.applied_coupon?.code ?? texts.orderAttribution.noAppliedCoupon
|
|
1187
|
+
],
|
|
1188
|
+
[
|
|
1189
|
+
texts.orderAttribution.appliedCouponId,
|
|
1190
|
+
attribution.applied_coupon?.affiliate_coupon_id ?? texts.common.dash
|
|
1191
|
+
],
|
|
1192
|
+
[
|
|
1193
|
+
texts.orderAttribution.appliedPromotionId,
|
|
1194
|
+
attribution.applied_coupon?.promotion_id ?? texts.common.dash
|
|
1195
|
+
],
|
|
1196
|
+
[texts.orderAttribution.mode, formatMode(attribution.customer_assignment_mode)],
|
|
1197
|
+
[
|
|
1198
|
+
texts.orderAttribution.duration,
|
|
1199
|
+
attribution.assignment_duration_days ? `${attribution.assignment_duration_days} Tage` : texts.orderAttribution.noDuration
|
|
1200
|
+
],
|
|
1201
|
+
[
|
|
1202
|
+
texts.orderAttribution.assignmentReference,
|
|
1203
|
+
attribution.customer_affiliate_assignment_id ?? texts.orderAttribution.noReference
|
|
1204
|
+
],
|
|
1205
|
+
[texts.orderAttribution.commissionRate, `${attribution.commission_rate}%`],
|
|
1206
|
+
[
|
|
1207
|
+
texts.orderAttribution.referrerAffiliate,
|
|
1208
|
+
attribution.referrer_affiliate_id ?? texts.orderAttribution.noReferrerAffiliate
|
|
1209
|
+
],
|
|
1210
|
+
[
|
|
1211
|
+
texts.orderAttribution.referrerRate,
|
|
1212
|
+
attribution.referrer_commission_rate == null ? texts.orderAttribution.noReferrerRate : `${attribution.referrer_commission_rate}%`
|
|
1213
|
+
],
|
|
1214
|
+
[texts.orderAttribution.currency, attribution.currency_code.toUpperCase()],
|
|
1215
|
+
[texts.orderAttribution.attributedAt, formatDateTime(attribution.attributed_at)]
|
|
1216
|
+
];
|
|
1217
|
+
content = /* @__PURE__ */ jsx("dl", { className: "grid gap-x-4 gap-y-3 text-sm md:grid-cols-2", children: fields.map(([label, value]) => /* @__PURE__ */ jsxs("div", { className: "grid gap-0.5", children: [
|
|
1218
|
+
/* @__PURE__ */ jsx("dt", { className: "text-ui-fg-subtle", children: label }),
|
|
1219
|
+
/* @__PURE__ */ jsx("dd", { className: "break-all font-medium", children: value })
|
|
1220
|
+
] }, label)) });
|
|
1221
|
+
}
|
|
1222
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid gap-4", children: [
|
|
1223
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: texts.orderAttribution.heading }),
|
|
1224
|
+
content
|
|
1225
|
+
] });
|
|
1226
|
+
};
|
|
1227
|
+
const OrderAffiliateAttributionWidget = ({
|
|
1228
|
+
data
|
|
1229
|
+
}) => /* @__PURE__ */ jsx(OrderAffiliateAttributionPanel, { orderId: data.id });
|
|
1230
|
+
defineWidgetConfig({
|
|
1231
|
+
zone: "order.details.side.after"
|
|
1232
|
+
});
|
|
1233
|
+
const AFFILIATES_PAGE_SIZE = 20;
|
|
1234
|
+
const AffiliateRow = ({ affiliate }) => {
|
|
1235
|
+
const primarySlug = affiliate.slugs?.find((slug) => slug.id === affiliate.primary_slug_id) ?? affiliate.slugs?.find((slug) => slug.is_primary);
|
|
1236
|
+
const reactivateMutation = useUpdateAffiliate(affiliate.id);
|
|
1237
|
+
const canReactivate = affiliate.status === "inactive" || affiliate.status === "rejected";
|
|
1238
|
+
const reactivate = () => {
|
|
1239
|
+
reactivateMutation.mutate(
|
|
1240
|
+
{ status: "active" },
|
|
1241
|
+
{
|
|
1242
|
+
onSuccess: () => toast.success(texts.list.toasts.reactivated),
|
|
1243
|
+
onError: (error) => toast.error(texts.list.toasts.reactivateFailed, {
|
|
1244
|
+
description: getErrorMessage(error)
|
|
1245
|
+
})
|
|
1246
|
+
}
|
|
1247
|
+
);
|
|
1248
|
+
};
|
|
1249
|
+
return /* @__PURE__ */ jsxs("tr", { className: "border-ui-border-base border-b", children: [
|
|
1250
|
+
/* @__PURE__ */ jsxs("td", { className: "px-6 py-3", children: [
|
|
1251
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium", children: affiliate.display_name }),
|
|
1252
|
+
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle font-mono text-xs", children: affiliate.customer_id ?? affiliate.id })
|
|
1253
|
+
] }),
|
|
1254
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 capitalize", children: formatStatus(affiliate.status) }),
|
|
1255
|
+
/* @__PURE__ */ jsxs("td", { className: "px-6 py-3 text-right tabular-nums", children: [
|
|
1256
|
+
affiliate.commission_rate,
|
|
1257
|
+
"%"
|
|
1258
|
+
] }),
|
|
1259
|
+
/* @__PURE__ */ jsxs("td", { className: "px-6 py-3 text-right tabular-nums", children: [
|
|
1260
|
+
affiliate.own_order_discount_rate,
|
|
1261
|
+
"%"
|
|
1262
|
+
] }),
|
|
1263
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3", children: primarySlug?.slug ?? texts.common.dash }),
|
|
1264
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3", children: formatDate(affiliate.created_at) }),
|
|
1265
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 text-right", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
1266
|
+
canReactivate ? /* @__PURE__ */ jsx(
|
|
1267
|
+
Button,
|
|
1268
|
+
{
|
|
1269
|
+
size: "small",
|
|
1270
|
+
variant: "secondary",
|
|
1271
|
+
disabled: reactivateMutation.isPending,
|
|
1272
|
+
onClick: reactivate,
|
|
1273
|
+
children: texts.list.reactivate
|
|
1274
|
+
}
|
|
1275
|
+
) : null,
|
|
1276
|
+
/* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: `/affiliates/${affiliate.id}`, children: texts.list.edit }) })
|
|
1277
|
+
] }) })
|
|
1278
|
+
] });
|
|
1279
|
+
};
|
|
1280
|
+
const AffiliatesTable = ({ affiliates }) => /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left text-sm", children: [
|
|
1281
|
+
/* @__PURE__ */ jsx("thead", { className: "border-ui-border-base border-b", children: /* @__PURE__ */ jsxs("tr", { className: "text-ui-fg-subtle", children: [
|
|
1282
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.list.columns.affiliate }),
|
|
1283
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.list.columns.status }),
|
|
1284
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.list.columns.commission }),
|
|
1285
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.list.columns.ownDiscount }),
|
|
1286
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.list.columns.primarySlug }),
|
|
1287
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.list.columns.created }),
|
|
1288
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.list.columns.action })
|
|
1289
|
+
] }) }),
|
|
1290
|
+
/* @__PURE__ */ jsx("tbody", { children: affiliates.map((affiliate) => /* @__PURE__ */ jsx(AffiliateRow, { affiliate }, affiliate.id)) })
|
|
1291
|
+
] }) });
|
|
1292
|
+
const AffiliateListPage = () => {
|
|
1293
|
+
const [status, setStatus] = useState("active");
|
|
1294
|
+
const [q, setQ] = useState("");
|
|
1295
|
+
const [offset, setOffset] = useState(0);
|
|
1296
|
+
const deferredQ = useDeferredValue(q);
|
|
1297
|
+
useEffect(() => {
|
|
1298
|
+
setOffset(0);
|
|
1299
|
+
}, [status, deferredQ]);
|
|
1300
|
+
const affiliatesQuery = useAffiliates({
|
|
1301
|
+
status: status === "all" ? void 0 : status,
|
|
1302
|
+
q: deferredQ || void 0,
|
|
1303
|
+
limit: AFFILIATES_PAGE_SIZE,
|
|
1304
|
+
offset
|
|
1305
|
+
});
|
|
1306
|
+
const affiliates = affiliatesQuery.data?.affiliates ?? [];
|
|
1307
|
+
const count = affiliatesQuery.data?.count ?? 0;
|
|
1308
|
+
const hasFilters = Boolean(deferredQ) || status !== "all";
|
|
1309
|
+
const renderBody = () => {
|
|
1310
|
+
if (affiliatesQuery.isLoading) {
|
|
1311
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.list.loading }) });
|
|
1312
|
+
}
|
|
1313
|
+
if (affiliatesQuery.isError) {
|
|
1314
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.list.loadError(getErrorMessage(affiliatesQuery.error)) }) });
|
|
1315
|
+
}
|
|
1316
|
+
if (!affiliates.length) {
|
|
1317
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: hasFilters ? texts.list.emptyFiltered : texts.list.empty }) });
|
|
1318
|
+
}
|
|
1319
|
+
return /* @__PURE__ */ jsx(AffiliatesTable, { affiliates });
|
|
1320
|
+
};
|
|
1321
|
+
const showPagination = !affiliatesQuery.isLoading && !affiliatesQuery.isError && count > 0;
|
|
1322
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
1323
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 px-6 py-4 lg:flex-row lg:items-center lg:justify-between", children: [
|
|
1324
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1325
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: texts.list.heading }),
|
|
1326
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.list.description })
|
|
1327
|
+
] }),
|
|
1328
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 sm:flex-row", children: [
|
|
1329
|
+
/* @__PURE__ */ jsx(Input, { value: q, onChange: (event) => setQ(event.target.value), placeholder: texts.list.searchPlaceholder }),
|
|
1330
|
+
/* @__PURE__ */ jsxs(Select, { value: status, onValueChange: setStatus, children: [
|
|
1331
|
+
/* @__PURE__ */ jsx(Select.Trigger, { className: "w-[160px]", children: /* @__PURE__ */ jsx(Select.Value, { placeholder: texts.list.statusAll }) }),
|
|
1332
|
+
/* @__PURE__ */ jsxs(Select.Content, { children: [
|
|
1333
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "all", children: texts.list.statusOptions.all }),
|
|
1334
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "active", children: texts.list.statusOptions.active }),
|
|
1335
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "inactive", children: texts.list.statusOptions.inactive }),
|
|
1336
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "rejected", children: texts.list.statusOptions.rejected })
|
|
1337
|
+
] })
|
|
1338
|
+
] }),
|
|
1339
|
+
/* @__PURE__ */ jsx(Button, { asChild: true, children: /* @__PURE__ */ jsx(Link, { to: "/affiliates/new", children: texts.list.create }) })
|
|
1340
|
+
] })
|
|
1341
|
+
] }),
|
|
1342
|
+
renderBody(),
|
|
1343
|
+
showPagination ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
1344
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: texts.common.pageRange(offset + 1, offset + affiliates.length, count) }),
|
|
1345
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1346
|
+
/* @__PURE__ */ jsx(
|
|
1347
|
+
Button,
|
|
1348
|
+
{
|
|
1349
|
+
size: "small",
|
|
1350
|
+
variant: "secondary",
|
|
1351
|
+
disabled: offset === 0,
|
|
1352
|
+
onClick: () => setOffset((current) => Math.max(0, current - AFFILIATES_PAGE_SIZE)),
|
|
1353
|
+
children: texts.common.back
|
|
1354
|
+
}
|
|
1355
|
+
),
|
|
1356
|
+
/* @__PURE__ */ jsx(
|
|
1357
|
+
Button,
|
|
1358
|
+
{
|
|
1359
|
+
size: "small",
|
|
1360
|
+
variant: "secondary",
|
|
1361
|
+
disabled: offset + affiliates.length >= count,
|
|
1362
|
+
onClick: () => setOffset((current) => current + AFFILIATES_PAGE_SIZE),
|
|
1363
|
+
children: texts.common.next
|
|
1364
|
+
}
|
|
1365
|
+
)
|
|
1366
|
+
] })
|
|
1367
|
+
] }) : null
|
|
1368
|
+
] });
|
|
1369
|
+
};
|
|
1370
|
+
const AffiliatesRoute = () => /* @__PURE__ */ jsx(AffiliateListPage, {});
|
|
1371
|
+
const config$6 = defineRouteConfig({
|
|
1372
|
+
label: texts.routes.affiliates,
|
|
1373
|
+
rank: 81
|
|
1374
|
+
});
|
|
1375
|
+
const useAffiliateApplications = (params) => useQuery({
|
|
1376
|
+
queryKey: affiliateKeys.applicationList(params),
|
|
1377
|
+
queryFn: () => listAffiliateApplications({
|
|
1378
|
+
status: params.status || void 0,
|
|
1379
|
+
limit: params.limit,
|
|
1380
|
+
offset: params.offset
|
|
1381
|
+
})
|
|
1382
|
+
});
|
|
1383
|
+
const useApproveAffiliateApplication = (applicationId) => {
|
|
1384
|
+
const queryClient = useQueryClient();
|
|
1385
|
+
return useMutation({
|
|
1386
|
+
mutationFn: (payload) => {
|
|
1387
|
+
if (!applicationId) {
|
|
1388
|
+
throw new Error(texts.hooks.noApplicationSelected);
|
|
1389
|
+
}
|
|
1390
|
+
return approveAffiliateApplication(applicationId, payload);
|
|
1391
|
+
},
|
|
1392
|
+
onSuccess: async () => {
|
|
1393
|
+
await queryClient.invalidateQueries({
|
|
1394
|
+
queryKey: affiliateKeys.applications()
|
|
1395
|
+
});
|
|
1396
|
+
await queryClient.invalidateQueries({ queryKey: affiliateKeys.lists() });
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
};
|
|
1400
|
+
const useRejectAffiliateApplication = (applicationId) => {
|
|
1401
|
+
const queryClient = useQueryClient();
|
|
1402
|
+
return useMutation({
|
|
1403
|
+
mutationFn: (payload) => {
|
|
1404
|
+
if (!applicationId) {
|
|
1405
|
+
throw new Error(texts.hooks.noApplicationSelected);
|
|
1406
|
+
}
|
|
1407
|
+
return rejectAffiliateApplication(applicationId, payload);
|
|
1408
|
+
},
|
|
1409
|
+
onSuccess: async () => {
|
|
1410
|
+
await queryClient.invalidateQueries({
|
|
1411
|
+
queryKey: affiliateKeys.applications()
|
|
1412
|
+
});
|
|
1413
|
+
await queryClient.invalidateQueries({ queryKey: affiliateKeys.lists() });
|
|
1414
|
+
}
|
|
1415
|
+
});
|
|
1416
|
+
};
|
|
1417
|
+
const PercentRateInput = ({
|
|
1418
|
+
label,
|
|
1419
|
+
value,
|
|
1420
|
+
onChange
|
|
1421
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1422
|
+
/* @__PURE__ */ jsx(Label, { children: label }),
|
|
1423
|
+
/* @__PURE__ */ jsx(
|
|
1424
|
+
Input,
|
|
1425
|
+
{
|
|
1426
|
+
min: 0,
|
|
1427
|
+
max: 100,
|
|
1428
|
+
step: "0.01",
|
|
1429
|
+
type: "number",
|
|
1430
|
+
value,
|
|
1431
|
+
onChange: (event) => onChange(Number(event.target.value))
|
|
1432
|
+
}
|
|
1433
|
+
)
|
|
1434
|
+
] });
|
|
1435
|
+
const DEFAULT_COMMISSION_RATE = 10;
|
|
1436
|
+
const DEFAULT_OWN_ORDER_DISCOUNT_RATE = 0;
|
|
1437
|
+
const APPLICATIONS_PAGE_SIZE = 20;
|
|
1438
|
+
const ApplicationsTable = ({
|
|
1439
|
+
applications,
|
|
1440
|
+
onSelect
|
|
1441
|
+
}) => /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left text-sm", children: [
|
|
1442
|
+
/* @__PURE__ */ jsx("thead", { className: "border-ui-border-base border-b", children: /* @__PURE__ */ jsxs("tr", { className: "text-ui-fg-subtle", children: [
|
|
1443
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.applications.columns.applicant }),
|
|
1444
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.applications.columns.customer }),
|
|
1445
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.applications.columns.slug }),
|
|
1446
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.applications.columns.submitted }),
|
|
1447
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.applications.columns.action })
|
|
1448
|
+
] }) }),
|
|
1449
|
+
/* @__PURE__ */ jsx("tbody", { children: applications.map((application) => /* @__PURE__ */ jsxs("tr", { className: "border-ui-border-base border-b", children: [
|
|
1450
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 font-medium", children: application.display_name }),
|
|
1451
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 font-mono text-xs", children: application.customer_id }),
|
|
1452
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3", children: application.requested_slug ?? texts.common.dash }),
|
|
1453
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3", children: formatDateTime(application.created_at) }),
|
|
1454
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 text-right", children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", onClick: () => onSelect(application), children: texts.applications.review }) })
|
|
1455
|
+
] }, application.id)) })
|
|
1456
|
+
] }) });
|
|
1457
|
+
const AffiliateApplicationsPage = () => {
|
|
1458
|
+
const [offset, setOffset] = useState(0);
|
|
1459
|
+
const [selected, setSelected] = useState(null);
|
|
1460
|
+
const [commissionRate, setCommissionRate] = useState(DEFAULT_COMMISSION_RATE);
|
|
1461
|
+
const [ownOrderDiscountRate, setOwnOrderDiscountRate] = useState(DEFAULT_OWN_ORDER_DISCOUNT_RATE);
|
|
1462
|
+
const [slug, setSlug] = useState("");
|
|
1463
|
+
const [rejectionReason, setRejectionReason] = useState("");
|
|
1464
|
+
const applicationsQuery = useAffiliateApplications({
|
|
1465
|
+
status: "pending",
|
|
1466
|
+
limit: APPLICATIONS_PAGE_SIZE,
|
|
1467
|
+
offset
|
|
1468
|
+
});
|
|
1469
|
+
const approveMutation = useApproveAffiliateApplication(selected?.id);
|
|
1470
|
+
const rejectMutation = useRejectAffiliateApplication(selected?.id);
|
|
1471
|
+
const reviewPending = approveMutation.isPending || rejectMutation.isPending;
|
|
1472
|
+
const applications = applicationsQuery.data?.applications ?? [];
|
|
1473
|
+
const count = applicationsQuery.data?.count ?? 0;
|
|
1474
|
+
const showPagination = !applicationsQuery.isLoading && !applicationsQuery.isError && count > 0;
|
|
1475
|
+
const selectApplication = (application) => {
|
|
1476
|
+
setSelected(application);
|
|
1477
|
+
setSlug(application.requested_slug ?? "");
|
|
1478
|
+
setRejectionReason(application.rejection_reason ?? "");
|
|
1479
|
+
setCommissionRate(DEFAULT_COMMISSION_RATE);
|
|
1480
|
+
setOwnOrderDiscountRate(DEFAULT_OWN_ORDER_DISCOUNT_RATE);
|
|
1481
|
+
};
|
|
1482
|
+
const approve = (event) => {
|
|
1483
|
+
event.preventDefault();
|
|
1484
|
+
approveMutation.mutate(
|
|
1485
|
+
{
|
|
1486
|
+
commission_rate: commissionRate,
|
|
1487
|
+
own_order_discount_rate: ownOrderDiscountRate,
|
|
1488
|
+
slug: slug || selected?.requested_slug || null
|
|
1489
|
+
},
|
|
1490
|
+
{
|
|
1491
|
+
onSuccess: () => {
|
|
1492
|
+
toast.success(texts.applications.toasts.approved);
|
|
1493
|
+
setSelected(null);
|
|
1494
|
+
},
|
|
1495
|
+
onError: (error) => toast.error(texts.applications.toasts.approveFailed, {
|
|
1496
|
+
description: getErrorMessage(error)
|
|
1497
|
+
})
|
|
1498
|
+
}
|
|
1499
|
+
);
|
|
1500
|
+
};
|
|
1501
|
+
const reject = (event) => {
|
|
1502
|
+
event.preventDefault();
|
|
1503
|
+
rejectMutation.mutate(
|
|
1504
|
+
{ rejection_reason: rejectionReason || null },
|
|
1505
|
+
{
|
|
1506
|
+
onSuccess: () => {
|
|
1507
|
+
toast.success(texts.applications.toasts.rejected);
|
|
1508
|
+
setSelected(null);
|
|
1509
|
+
setRejectionReason("");
|
|
1510
|
+
},
|
|
1511
|
+
onError: (error) => toast.error(texts.applications.toasts.rejectFailed, {
|
|
1512
|
+
description: getErrorMessage(error)
|
|
1513
|
+
})
|
|
1514
|
+
}
|
|
1515
|
+
);
|
|
1516
|
+
};
|
|
1517
|
+
const renderBody = () => {
|
|
1518
|
+
if (applicationsQuery.isLoading) {
|
|
1519
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.applications.loading }) });
|
|
1520
|
+
}
|
|
1521
|
+
if (applicationsQuery.isError) {
|
|
1522
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.applications.loadError(getErrorMessage(applicationsQuery.error)) }) });
|
|
1523
|
+
}
|
|
1524
|
+
if (!applications.length) {
|
|
1525
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.applications.empty }) });
|
|
1526
|
+
}
|
|
1527
|
+
return /* @__PURE__ */ jsx(ApplicationsTable, { applications, onSelect: selectApplication });
|
|
1528
|
+
};
|
|
1529
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid gap-6", children: [
|
|
1530
|
+
/* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
1531
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-4 px-6 py-4", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
1532
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: texts.applications.heading }),
|
|
1533
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.applications.description })
|
|
1534
|
+
] }) }),
|
|
1535
|
+
renderBody(),
|
|
1536
|
+
showPagination ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
1537
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: texts.common.pageRange(offset + 1, offset + applications.length, count) }),
|
|
1538
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1539
|
+
/* @__PURE__ */ jsx(
|
|
1540
|
+
Button,
|
|
1541
|
+
{
|
|
1542
|
+
size: "small",
|
|
1543
|
+
variant: "secondary",
|
|
1544
|
+
disabled: offset === 0,
|
|
1545
|
+
onClick: () => setOffset((current) => Math.max(0, current - APPLICATIONS_PAGE_SIZE)),
|
|
1546
|
+
children: texts.common.back
|
|
1547
|
+
}
|
|
1548
|
+
),
|
|
1549
|
+
/* @__PURE__ */ jsx(
|
|
1550
|
+
Button,
|
|
1551
|
+
{
|
|
1552
|
+
size: "small",
|
|
1553
|
+
variant: "secondary",
|
|
1554
|
+
disabled: offset + applications.length >= count,
|
|
1555
|
+
onClick: () => setOffset((current) => current + APPLICATIONS_PAGE_SIZE),
|
|
1556
|
+
children: texts.common.next
|
|
1557
|
+
}
|
|
1558
|
+
)
|
|
1559
|
+
] })
|
|
1560
|
+
] }) : null
|
|
1561
|
+
] }),
|
|
1562
|
+
selected ? /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
1563
|
+
/* @__PURE__ */ jsxs("div", { className: "px-6 py-4", children: [
|
|
1564
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: texts.applications.reviewHeading(selected.display_name) }),
|
|
1565
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle", children: [
|
|
1566
|
+
texts.applications.customerLine(selected.customer_id),
|
|
1567
|
+
selected.message ? ` · ${selected.message}` : ""
|
|
1568
|
+
] })
|
|
1569
|
+
] }),
|
|
1570
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-5 px-6 py-5 lg:grid-cols-2", children: [
|
|
1571
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: approve, className: "grid gap-4", children: [
|
|
1572
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: texts.applications.approveHeading }),
|
|
1573
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1574
|
+
/* @__PURE__ */ jsx(Label, { children: texts.applications.affiliateSlugLabel }),
|
|
1575
|
+
/* @__PURE__ */ jsx(
|
|
1576
|
+
Input,
|
|
1577
|
+
{
|
|
1578
|
+
value: slug,
|
|
1579
|
+
onChange: (event) => setSlug(event.target.value),
|
|
1580
|
+
placeholder: texts.applications.affiliateSlugPlaceholder
|
|
1581
|
+
}
|
|
1582
|
+
)
|
|
1583
|
+
] }),
|
|
1584
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
1585
|
+
/* @__PURE__ */ jsx(
|
|
1586
|
+
PercentRateInput,
|
|
1587
|
+
{
|
|
1588
|
+
label: texts.applications.commissionLabel,
|
|
1589
|
+
value: commissionRate,
|
|
1590
|
+
onChange: setCommissionRate
|
|
1591
|
+
}
|
|
1592
|
+
),
|
|
1593
|
+
/* @__PURE__ */ jsx(
|
|
1594
|
+
PercentRateInput,
|
|
1595
|
+
{
|
|
1596
|
+
label: texts.applications.ownDiscountLabel,
|
|
1597
|
+
value: ownOrderDiscountRate,
|
|
1598
|
+
onChange: setOwnOrderDiscountRate
|
|
1599
|
+
}
|
|
1600
|
+
)
|
|
1601
|
+
] }),
|
|
1602
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: reviewPending, children: approveMutation.isPending ? texts.applications.approving : texts.applications.approve }) })
|
|
1603
|
+
] }),
|
|
1604
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: reject, className: "grid gap-4", children: [
|
|
1605
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: texts.applications.rejectHeading }),
|
|
1606
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1607
|
+
/* @__PURE__ */ jsx(Label, { children: texts.applications.reasonLabel }),
|
|
1608
|
+
/* @__PURE__ */ jsx(Textarea, { value: rejectionReason, onChange: (event) => setRejectionReason(event.target.value) })
|
|
1609
|
+
] }),
|
|
1610
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { type: "submit", variant: "danger", disabled: reviewPending, children: rejectMutation.isPending ? texts.applications.rejecting : texts.applications.reject }) })
|
|
1611
|
+
] })
|
|
1612
|
+
] })
|
|
1613
|
+
] }) : null
|
|
1614
|
+
] });
|
|
1615
|
+
};
|
|
1616
|
+
const AffiliateApplicationsRoute = () => /* @__PURE__ */ jsx(AffiliateApplicationsPage, {});
|
|
1617
|
+
const config$5 = defineRouteConfig({
|
|
1618
|
+
label: texts.routes.applications,
|
|
1619
|
+
rank: 80
|
|
1620
|
+
});
|
|
1621
|
+
const getCustomerLabel = (customer) => {
|
|
1622
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
1623
|
+
return name ? `${name} (${customer.email})` : customer.email;
|
|
1624
|
+
};
|
|
1625
|
+
const CustomerReferenceField = ({
|
|
1626
|
+
label = texts.reference.customer.label,
|
|
1627
|
+
value,
|
|
1628
|
+
onChange
|
|
1629
|
+
}) => {
|
|
1630
|
+
const [search, setSearch] = useState("");
|
|
1631
|
+
const [selectedLabel, setSelectedLabel] = useState("");
|
|
1632
|
+
const deferredSearch = useDeferredValue(search);
|
|
1633
|
+
const customersQuery = useQuery({
|
|
1634
|
+
queryKey: affiliateKeys.customerReferenceSearch(deferredSearch),
|
|
1635
|
+
queryFn: () => listCustomers({
|
|
1636
|
+
q: deferredSearch.trim(),
|
|
1637
|
+
limit: 10,
|
|
1638
|
+
offset: 0
|
|
1639
|
+
})
|
|
1640
|
+
});
|
|
1641
|
+
const selectedCustomerQuery = useQuery({
|
|
1642
|
+
queryKey: affiliateKeys.customerReference(value),
|
|
1643
|
+
enabled: !!value,
|
|
1644
|
+
queryFn: () => retrieveCustomer(value)
|
|
1645
|
+
});
|
|
1646
|
+
const options = (customersQuery.data?.customers ?? []).map(
|
|
1647
|
+
(customer) => ({
|
|
1648
|
+
id: customer.id,
|
|
1649
|
+
label: getCustomerLabel(customer),
|
|
1650
|
+
description: customer.id
|
|
1651
|
+
})
|
|
1652
|
+
);
|
|
1653
|
+
const selectedCustomer = selectedCustomerQuery.data?.customer;
|
|
1654
|
+
const displayLabel = selectedLabel || (selectedCustomer ? getCustomerLabel(selectedCustomer) : value);
|
|
1655
|
+
return /* @__PURE__ */ jsx(
|
|
1656
|
+
SearchableReferenceField,
|
|
1657
|
+
{
|
|
1658
|
+
label,
|
|
1659
|
+
value,
|
|
1660
|
+
selectedLabel: displayLabel,
|
|
1661
|
+
search,
|
|
1662
|
+
placeholder: texts.reference.customer.placeholder,
|
|
1663
|
+
emptyText: texts.reference.customer.empty,
|
|
1664
|
+
isLoading: customersQuery.isLoading || customersQuery.isFetching,
|
|
1665
|
+
options,
|
|
1666
|
+
onSearchChange: setSearch,
|
|
1667
|
+
onSelect: (option) => {
|
|
1668
|
+
onChange(option.id);
|
|
1669
|
+
setSelectedLabel(option.label);
|
|
1670
|
+
setSearch("");
|
|
1671
|
+
},
|
|
1672
|
+
onClear: () => {
|
|
1673
|
+
onChange("");
|
|
1674
|
+
setSelectedLabel("");
|
|
1675
|
+
setSearch("");
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
);
|
|
1679
|
+
};
|
|
1680
|
+
const STATUS_OPTIONS = [
|
|
1681
|
+
{ value: "pending", label: texts.statusSelect.options.pending },
|
|
1682
|
+
{ value: "active", label: texts.statusSelect.options.active },
|
|
1683
|
+
{ value: "inactive", label: texts.statusSelect.options.inactive },
|
|
1684
|
+
{ value: "rejected", label: texts.statusSelect.options.rejected }
|
|
1685
|
+
];
|
|
1686
|
+
const AffiliateStatusSelect = ({
|
|
1687
|
+
value,
|
|
1688
|
+
onChange,
|
|
1689
|
+
label = texts.statusSelect.label
|
|
1690
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1691
|
+
/* @__PURE__ */ jsx(Label, { children: label }),
|
|
1692
|
+
/* @__PURE__ */ jsxs(Select, { value, onValueChange: onChange, children: [
|
|
1693
|
+
/* @__PURE__ */ jsx(Select.Trigger, { children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
1694
|
+
/* @__PURE__ */ jsx(Select.Content, { children: STATUS_OPTIONS.map((option) => /* @__PURE__ */ jsx(Select.Item, { value: option.value, children: option.label }, option.value)) })
|
|
1695
|
+
] })
|
|
1696
|
+
] });
|
|
1697
|
+
const assignmentDurationSelectId = "affiliate-assignment-duration";
|
|
1698
|
+
const assignmentDurationSelectLabelId = `${assignmentDurationSelectId}-label`;
|
|
1699
|
+
const AssignmentDurationSelect = ({
|
|
1700
|
+
presetDurationDays,
|
|
1701
|
+
persistedDurationDays,
|
|
1702
|
+
onPresetDurationChange
|
|
1703
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "grid max-w-[180px] gap-2", children: [
|
|
1704
|
+
/* @__PURE__ */ jsx(
|
|
1705
|
+
Label,
|
|
1706
|
+
{
|
|
1707
|
+
id: assignmentDurationSelectLabelId,
|
|
1708
|
+
htmlFor: assignmentDurationSelectId,
|
|
1709
|
+
children: texts.form.fields.assignmentDurationDays
|
|
1710
|
+
}
|
|
1711
|
+
),
|
|
1712
|
+
/* @__PURE__ */ jsxs(
|
|
1713
|
+
Select,
|
|
1714
|
+
{
|
|
1715
|
+
value: persistedDurationDays == null ? String(presetDurationDays) : "persisted",
|
|
1716
|
+
onValueChange: (value) => {
|
|
1717
|
+
switch (value) {
|
|
1718
|
+
case "30":
|
|
1719
|
+
onPresetDurationChange(30);
|
|
1720
|
+
break;
|
|
1721
|
+
case "90":
|
|
1722
|
+
onPresetDurationChange(90);
|
|
1723
|
+
break;
|
|
1724
|
+
case "180":
|
|
1725
|
+
onPresetDurationChange(180);
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
},
|
|
1729
|
+
children: [
|
|
1730
|
+
/* @__PURE__ */ jsx(
|
|
1731
|
+
Select.Trigger,
|
|
1732
|
+
{
|
|
1733
|
+
id: assignmentDurationSelectId,
|
|
1734
|
+
"aria-labelledby": assignmentDurationSelectLabelId,
|
|
1735
|
+
children: /* @__PURE__ */ jsx(Select.Value, {})
|
|
1736
|
+
}
|
|
1737
|
+
),
|
|
1738
|
+
/* @__PURE__ */ jsxs(Select.Content, { children: [
|
|
1739
|
+
persistedDurationDays != null ? /* @__PURE__ */ jsxs(Select.Item, { value: "persisted", children: [
|
|
1740
|
+
"Aktuell: ",
|
|
1741
|
+
persistedDurationDays,
|
|
1742
|
+
" Tage"
|
|
1743
|
+
] }) : null,
|
|
1744
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "30", children: "30 Tage" }),
|
|
1745
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "90", children: "90 Tage" }),
|
|
1746
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "180", children: "180 Tage" })
|
|
1747
|
+
] })
|
|
1748
|
+
]
|
|
1749
|
+
}
|
|
1750
|
+
)
|
|
1751
|
+
] });
|
|
1752
|
+
function ConsignmentTransferForm({
|
|
1753
|
+
affiliateId
|
|
1754
|
+
}) {
|
|
1755
|
+
const queryClient = useQueryClient();
|
|
1756
|
+
const [sourceLocationId, setSourceLocationId] = useState("");
|
|
1757
|
+
const [inventoryItemId, setInventoryItemId] = useState("");
|
|
1758
|
+
const [quantity, setQuantity] = useState(1);
|
|
1759
|
+
const [batchMode, setBatchMode] = useState(false);
|
|
1760
|
+
const [batchId, setBatchId] = useState("");
|
|
1761
|
+
const stock = useQuery({
|
|
1762
|
+
queryKey: [
|
|
1763
|
+
"affiliate",
|
|
1764
|
+
"source-stock",
|
|
1765
|
+
sourceLocationId,
|
|
1766
|
+
inventoryItemId
|
|
1767
|
+
],
|
|
1768
|
+
queryFn: () => getSourceInventoryQuantity(inventoryItemId, sourceLocationId),
|
|
1769
|
+
enabled: Boolean(sourceLocationId && inventoryItemId)
|
|
1770
|
+
});
|
|
1771
|
+
const batches = useQuery({
|
|
1772
|
+
queryKey: [
|
|
1773
|
+
"affiliate",
|
|
1774
|
+
"source-batches",
|
|
1775
|
+
sourceLocationId,
|
|
1776
|
+
inventoryItemId
|
|
1777
|
+
],
|
|
1778
|
+
queryFn: () => listSourceBatches(inventoryItemId, sourceLocationId),
|
|
1779
|
+
enabled: Boolean(batchMode && sourceLocationId && inventoryItemId)
|
|
1780
|
+
});
|
|
1781
|
+
const transfer = useMutation({
|
|
1782
|
+
mutationFn: (idempotencyKey) => transferConsignmentStock(affiliateId, {
|
|
1783
|
+
source_location_id: sourceLocationId,
|
|
1784
|
+
idempotency_key: idempotencyKey,
|
|
1785
|
+
lines: [
|
|
1786
|
+
{
|
|
1787
|
+
inventory_item_id: inventoryItemId,
|
|
1788
|
+
quantity,
|
|
1789
|
+
...batchMode ? { batch_id: batchId } : {}
|
|
1790
|
+
}
|
|
1791
|
+
]
|
|
1792
|
+
}),
|
|
1793
|
+
onSuccess: async () => {
|
|
1794
|
+
toast.success("Kommissionsbestand wurde übertragen.");
|
|
1795
|
+
setInventoryItemId("");
|
|
1796
|
+
setBatchId("");
|
|
1797
|
+
await queryClient.invalidateQueries({
|
|
1798
|
+
queryKey: ["affiliate", "distribution", affiliateId]
|
|
1799
|
+
});
|
|
1800
|
+
},
|
|
1801
|
+
onError: (error) => toast.error("Übertragung fehlgeschlagen.", {
|
|
1802
|
+
description: getErrorMessage(error)
|
|
1803
|
+
})
|
|
1804
|
+
});
|
|
1805
|
+
const submit = (event) => {
|
|
1806
|
+
event.preventDefault();
|
|
1807
|
+
transfer.mutate(crypto.randomUUID());
|
|
1808
|
+
};
|
|
1809
|
+
const invalid = !sourceLocationId || !inventoryItemId || quantity < 1 || batchMode && !batchId;
|
|
1810
|
+
return /* @__PURE__ */ jsxs("form", { onSubmit: submit, className: "grid gap-4", children: [
|
|
1811
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
1812
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1813
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "consignment-source-location", children: "Quelllager" }),
|
|
1814
|
+
/* @__PURE__ */ jsx(
|
|
1815
|
+
Input,
|
|
1816
|
+
{
|
|
1817
|
+
id: "consignment-source-location",
|
|
1818
|
+
required: true,
|
|
1819
|
+
value: sourceLocationId,
|
|
1820
|
+
onChange: (event) => setSourceLocationId(event.target.value),
|
|
1821
|
+
placeholder: "sloc_…"
|
|
1822
|
+
}
|
|
1823
|
+
)
|
|
1824
|
+
] }),
|
|
1825
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1826
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "consignment-inventory-item", children: "Artikel" }),
|
|
1827
|
+
/* @__PURE__ */ jsx(
|
|
1828
|
+
Input,
|
|
1829
|
+
{
|
|
1830
|
+
id: "consignment-inventory-item",
|
|
1831
|
+
required: true,
|
|
1832
|
+
value: inventoryItemId,
|
|
1833
|
+
onChange: (event) => setInventoryItemId(event.target.value),
|
|
1834
|
+
placeholder: "iitem_…"
|
|
1835
|
+
}
|
|
1836
|
+
)
|
|
1837
|
+
] })
|
|
1838
|
+
] }),
|
|
1839
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
1840
|
+
"Aktueller Quellbestand:",
|
|
1841
|
+
" ",
|
|
1842
|
+
stock.isLoading ? "wird geladen …" : stock.data == null ? "–" : stock.data
|
|
1843
|
+
] }),
|
|
1844
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-3", children: [
|
|
1845
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1846
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "consignment-transfer-quantity", children: "Menge" }),
|
|
1847
|
+
/* @__PURE__ */ jsx(
|
|
1848
|
+
Input,
|
|
1849
|
+
{
|
|
1850
|
+
id: "consignment-transfer-quantity",
|
|
1851
|
+
type: "number",
|
|
1852
|
+
min: 1,
|
|
1853
|
+
step: 1,
|
|
1854
|
+
value: quantity,
|
|
1855
|
+
onChange: (event) => setQuantity(Number(event.target.value))
|
|
1856
|
+
}
|
|
1857
|
+
)
|
|
1858
|
+
] }),
|
|
1859
|
+
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 pt-7 text-sm", children: [
|
|
1860
|
+
/* @__PURE__ */ jsx(
|
|
1861
|
+
"input",
|
|
1862
|
+
{
|
|
1863
|
+
type: "checkbox",
|
|
1864
|
+
checked: batchMode,
|
|
1865
|
+
onChange: (event) => setBatchMode(event.target.checked)
|
|
1866
|
+
}
|
|
1867
|
+
),
|
|
1868
|
+
"Chargenmodus"
|
|
1869
|
+
] })
|
|
1870
|
+
] }),
|
|
1871
|
+
batchMode ? /* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1872
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "consignment-batch", children: "Charge / MHD" }),
|
|
1873
|
+
/* @__PURE__ */ jsxs(
|
|
1874
|
+
"select",
|
|
1875
|
+
{
|
|
1876
|
+
id: "consignment-batch",
|
|
1877
|
+
required: true,
|
|
1878
|
+
className: "bg-ui-bg-field border-ui-border-base rounded-md border px-3 py-2 text-sm",
|
|
1879
|
+
value: batchId,
|
|
1880
|
+
onChange: (event) => setBatchId(event.target.value),
|
|
1881
|
+
children: [
|
|
1882
|
+
/* @__PURE__ */ jsx("option", { value: "", children: batches.isLoading ? "Chargen werden geladen …" : "Charge auswählen" }),
|
|
1883
|
+
batches.data?.batches.map((batch) => /* @__PURE__ */ jsxs("option", { value: batch.id, children: [
|
|
1884
|
+
batch.name,
|
|
1885
|
+
" · MHD",
|
|
1886
|
+
" ",
|
|
1887
|
+
new Date(batch.expiry_date).toLocaleDateString("de-DE"),
|
|
1888
|
+
" ·",
|
|
1889
|
+
" ",
|
|
1890
|
+
batch.quantity,
|
|
1891
|
+
" Stück"
|
|
1892
|
+
] }, batch.id))
|
|
1893
|
+
]
|
|
1894
|
+
}
|
|
1895
|
+
),
|
|
1896
|
+
batches.isError ? /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-error", children: "Chargen konnten nicht geladen werden. Ist Batch Management installiert?" }) : null
|
|
1897
|
+
] }) : null,
|
|
1898
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: invalid || transfer.isPending, children: transfer.isPending ? "Wird übertragen …" : "Ware übertragen" }) })
|
|
1899
|
+
] });
|
|
1900
|
+
}
|
|
1901
|
+
function AffiliateDistributionPanel({
|
|
1902
|
+
affiliateId
|
|
1903
|
+
}) {
|
|
1904
|
+
const queryClient = useQueryClient();
|
|
1905
|
+
const [regionId, setRegionId] = useState("");
|
|
1906
|
+
const [shippingOptionId, setShippingOptionId] = useState("");
|
|
1907
|
+
const queryKey = ["affiliate", "distribution", affiliateId];
|
|
1908
|
+
const distribution = useQuery({
|
|
1909
|
+
queryKey,
|
|
1910
|
+
queryFn: () => getAffiliateDistribution(affiliateId)
|
|
1911
|
+
});
|
|
1912
|
+
const settings = distribution.data?.distribution;
|
|
1913
|
+
const enable = useMutation({
|
|
1914
|
+
mutationFn: (enabled) => enableAffiliateDistribution(affiliateId, {
|
|
1915
|
+
enabled,
|
|
1916
|
+
...enabled ? {
|
|
1917
|
+
region_id: regionId || settings?.region_id,
|
|
1918
|
+
shipping_option_id: shippingOptionId || settings?.shipping_option_id
|
|
1919
|
+
} : {}
|
|
1920
|
+
}),
|
|
1921
|
+
onSuccess: async (_data, enabled) => {
|
|
1922
|
+
toast.success(
|
|
1923
|
+
enabled ? "Kommissionsvertrieb ist aktiviert." : "Kommissionsvertrieb ist deaktiviert."
|
|
1924
|
+
);
|
|
1925
|
+
await queryClient.invalidateQueries({ queryKey });
|
|
1926
|
+
},
|
|
1927
|
+
onError: (error, enabled) => toast.error(
|
|
1928
|
+
enabled ? "Kommissionsvertrieb konnte nicht aktiviert werden." : "Kommissionsvertrieb konnte nicht deaktiviert werden.",
|
|
1929
|
+
{
|
|
1930
|
+
description: getErrorMessage(error)
|
|
1931
|
+
}
|
|
1932
|
+
)
|
|
1933
|
+
});
|
|
1934
|
+
const submit = (event) => {
|
|
1935
|
+
event.preventDefault();
|
|
1936
|
+
enable.mutate(true);
|
|
1937
|
+
};
|
|
1938
|
+
return /* @__PURE__ */ jsxs(Container, { id: "affiliate-distribution", className: "grid gap-5", children: [
|
|
1939
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1940
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Kommissionsvertrieb" }),
|
|
1941
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Internes Partnerlager aktivieren und manuelle Sendungen buchen." })
|
|
1942
|
+
] }),
|
|
1943
|
+
distribution.isLoading ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Konfiguration wird geladen …" }) : distribution.isError ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: getErrorMessage(distribution.error) }) : settings ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1944
|
+
/* @__PURE__ */ jsxs("dl", { className: "grid gap-2 text-sm md:grid-cols-2", children: [
|
|
1945
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1946
|
+
/* @__PURE__ */ jsx("dt", { className: "text-ui-fg-subtle", children: "Partnerlager" }),
|
|
1947
|
+
/* @__PURE__ */ jsx("dd", { children: settings.stock_location_id })
|
|
1948
|
+
] }),
|
|
1949
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1950
|
+
/* @__PURE__ */ jsx("dt", { className: "text-ui-fg-subtle", children: "Interner Sales Channel" }),
|
|
1951
|
+
/* @__PURE__ */ jsx("dd", { children: settings.internal_sales_channel_id })
|
|
1952
|
+
] }),
|
|
1953
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1954
|
+
/* @__PURE__ */ jsx("dt", { className: "text-ui-fg-subtle", children: "Region" }),
|
|
1955
|
+
/* @__PURE__ */ jsx("dd", { children: settings.region_id })
|
|
1956
|
+
] }),
|
|
1957
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1958
|
+
/* @__PURE__ */ jsx("dt", { className: "text-ui-fg-subtle", children: "Versandoption" }),
|
|
1959
|
+
/* @__PURE__ */ jsx("dd", { children: settings.shipping_option_id })
|
|
1960
|
+
] })
|
|
1961
|
+
] }),
|
|
1962
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
1963
|
+
Button,
|
|
1964
|
+
{
|
|
1965
|
+
type: "button",
|
|
1966
|
+
variant: settings.enabled ? "danger" : "primary",
|
|
1967
|
+
disabled: enable.isPending,
|
|
1968
|
+
onClick: () => enable.mutate(!settings.enabled),
|
|
1969
|
+
children: settings.enabled ? "Kommissionsvertrieb deaktivieren" : "Kommissionsvertrieb reaktivieren"
|
|
1970
|
+
}
|
|
1971
|
+
) }),
|
|
1972
|
+
settings.enabled ? /* @__PURE__ */ jsx(ConsignmentTransferForm, { affiliateId }) : null
|
|
1973
|
+
] }) : /* @__PURE__ */ jsxs("form", { onSubmit: submit, className: "grid gap-4", children: [
|
|
1974
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
1975
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1976
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "distribution-region", children: "Region" }),
|
|
1977
|
+
/* @__PURE__ */ jsx(
|
|
1978
|
+
Input,
|
|
1979
|
+
{
|
|
1980
|
+
id: "distribution-region",
|
|
1981
|
+
required: true,
|
|
1982
|
+
value: regionId,
|
|
1983
|
+
onChange: (event) => setRegionId(event.target.value),
|
|
1984
|
+
placeholder: "reg_…"
|
|
1985
|
+
}
|
|
1986
|
+
)
|
|
1987
|
+
] }),
|
|
1988
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
1989
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "distribution-shipping-option", children: "Interne Versandoption" }),
|
|
1990
|
+
/* @__PURE__ */ jsx(
|
|
1991
|
+
Input,
|
|
1992
|
+
{
|
|
1993
|
+
id: "distribution-shipping-option",
|
|
1994
|
+
required: true,
|
|
1995
|
+
value: shippingOptionId,
|
|
1996
|
+
onChange: (event) => setShippingOptionId(event.target.value),
|
|
1997
|
+
placeholder: "so_…"
|
|
1998
|
+
}
|
|
1999
|
+
)
|
|
2000
|
+
] })
|
|
2001
|
+
] }),
|
|
2002
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
2003
|
+
Button,
|
|
2004
|
+
{
|
|
2005
|
+
type: "submit",
|
|
2006
|
+
disabled: !regionId || !shippingOptionId || enable.isPending,
|
|
2007
|
+
children: enable.isPending ? "Wird aktiviert …" : "Kommissionsvertrieb aktivieren"
|
|
2008
|
+
}
|
|
2009
|
+
) })
|
|
2010
|
+
] })
|
|
2011
|
+
] });
|
|
2012
|
+
}
|
|
2013
|
+
function initialMonth() {
|
|
2014
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 7);
|
|
2015
|
+
}
|
|
2016
|
+
function ConsignmentReminderPanel({
|
|
2017
|
+
affiliateId
|
|
2018
|
+
}) {
|
|
2019
|
+
const [month, setMonth] = useState(initialMonth);
|
|
2020
|
+
const periodStart = `${month}-01`;
|
|
2021
|
+
const request = useMutation({
|
|
2022
|
+
mutationFn: () => requestConsignmentReminder(affiliateId, {
|
|
2023
|
+
period_start: periodStart
|
|
2024
|
+
}),
|
|
2025
|
+
onSuccess: () => {
|
|
2026
|
+
toast.success("Reminder wurde angefordert.");
|
|
2027
|
+
},
|
|
2028
|
+
onError: (error) => {
|
|
2029
|
+
const message = getErrorMessage(error);
|
|
2030
|
+
toast.error("Reminder konnte nicht angefordert werden.", {
|
|
2031
|
+
description: message
|
|
2032
|
+
});
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2035
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid gap-4", children: [
|
|
2036
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2037
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Meldungs-Reminder" }),
|
|
2038
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Einen Reminder für einen frei gewählten Meldezeitraum anfordern." })
|
|
2039
|
+
] }),
|
|
2040
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-end gap-3", children: [
|
|
2041
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
2042
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "affiliate-reminder-month", children: "Zeitraum" }),
|
|
2043
|
+
/* @__PURE__ */ jsx(
|
|
2044
|
+
Input,
|
|
2045
|
+
{
|
|
2046
|
+
id: "affiliate-reminder-month",
|
|
2047
|
+
type: "month",
|
|
2048
|
+
value: month,
|
|
2049
|
+
onChange: (event) => setMonth(event.target.value)
|
|
2050
|
+
}
|
|
2051
|
+
)
|
|
2052
|
+
] }),
|
|
2053
|
+
/* @__PURE__ */ jsx(
|
|
2054
|
+
Button,
|
|
2055
|
+
{
|
|
2056
|
+
type: "button",
|
|
2057
|
+
onClick: () => request.mutate(),
|
|
2058
|
+
disabled: request.isPending || !/^\d{4}-\d{2}$/.test(month),
|
|
2059
|
+
children: request.isPending ? "Wird angefordert …" : "Reminder anfordern"
|
|
2060
|
+
}
|
|
2061
|
+
)
|
|
2062
|
+
] })
|
|
2063
|
+
] });
|
|
2064
|
+
}
|
|
2065
|
+
const resolveCouponCommandIdempotency = (current, intent, createKey = () => crypto.randomUUID()) => current?.intent === intent ? current : { intent, key: createKey() };
|
|
2066
|
+
const COUPON_PAGE_SIZE = 10;
|
|
2067
|
+
const CouponCodeChoice = ({
|
|
2068
|
+
prefix,
|
|
2069
|
+
label,
|
|
2070
|
+
mode,
|
|
2071
|
+
code,
|
|
2072
|
+
onModeChange,
|
|
2073
|
+
onCodeChange
|
|
2074
|
+
}) => /* @__PURE__ */ jsxs("div", { className: "grid gap-3", children: [
|
|
2075
|
+
/* @__PURE__ */ jsxs(
|
|
2076
|
+
RadioGroup,
|
|
2077
|
+
{
|
|
2078
|
+
"aria-label": label,
|
|
2079
|
+
value: mode,
|
|
2080
|
+
onValueChange: (value) => onModeChange(value),
|
|
2081
|
+
className: "flex flex-col gap-3 sm:flex-row sm:gap-6",
|
|
2082
|
+
children: [
|
|
2083
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2084
|
+
/* @__PURE__ */ jsx(RadioGroup.Item, { id: `${prefix}-generated`, value: "generated" }),
|
|
2085
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${prefix}-generated`, children: texts.coupons.generated })
|
|
2086
|
+
] }),
|
|
2087
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
2088
|
+
/* @__PURE__ */ jsx(RadioGroup.Item, { id: `${prefix}-custom`, value: "custom" }),
|
|
2089
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${prefix}-custom`, children: texts.coupons.custom })
|
|
2090
|
+
] })
|
|
2091
|
+
]
|
|
2092
|
+
}
|
|
2093
|
+
),
|
|
2094
|
+
mode === "custom" ? /* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
2095
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${prefix}-code`, children: texts.coupons.customCodeLabel }),
|
|
2096
|
+
/* @__PURE__ */ jsx(
|
|
2097
|
+
Input,
|
|
2098
|
+
{
|
|
2099
|
+
id: `${prefix}-code`,
|
|
2100
|
+
required: true,
|
|
2101
|
+
minLength: 3,
|
|
2102
|
+
maxLength: 32,
|
|
2103
|
+
pattern: "[A-Za-z0-9][A-Za-z0-9-]{2,31}",
|
|
2104
|
+
value: code,
|
|
2105
|
+
onChange: (event) => onCodeChange(event.target.value.toUpperCase()),
|
|
2106
|
+
placeholder: texts.coupons.customCodePlaceholder
|
|
2107
|
+
}
|
|
2108
|
+
),
|
|
2109
|
+
/* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-subtle", children: texts.coupons.codeHint })
|
|
2110
|
+
] }) : null
|
|
2111
|
+
] });
|
|
2112
|
+
const actorLabel = (type, id) => {
|
|
2113
|
+
if (!type) {
|
|
2114
|
+
return texts.common.dash;
|
|
2115
|
+
}
|
|
2116
|
+
return texts.coupons.actor(texts.coupons.actorTypes[type], id);
|
|
2117
|
+
};
|
|
2118
|
+
const CouponDetails = ({ coupon }) => {
|
|
2119
|
+
const fields = [
|
|
2120
|
+
[texts.coupons.details.couponId, coupon.id],
|
|
2121
|
+
[
|
|
2122
|
+
texts.coupons.details.promotionId,
|
|
2123
|
+
coupon.promotion_id ?? texts.common.dash
|
|
2124
|
+
],
|
|
2125
|
+
[
|
|
2126
|
+
texts.coupons.details.idempotencyKey,
|
|
2127
|
+
coupon.creation_idempotency_key ?? texts.common.dash
|
|
2128
|
+
],
|
|
2129
|
+
[texts.coupons.details.created, formatDateTime(coupon.created_at)],
|
|
2130
|
+
[
|
|
2131
|
+
texts.coupons.details.createdBy,
|
|
2132
|
+
actorLabel(coupon.created_by_type, coupon.created_by_id)
|
|
2133
|
+
],
|
|
2134
|
+
[texts.coupons.details.revoked, formatDateTime(coupon.revoked_at)],
|
|
2135
|
+
[
|
|
2136
|
+
texts.coupons.details.revokedBy,
|
|
2137
|
+
actorLabel(coupon.revoked_by_type, coupon.revoked_by_id)
|
|
2138
|
+
]
|
|
2139
|
+
];
|
|
2140
|
+
return /* @__PURE__ */ jsxs("dl", { className: "grid gap-x-5 gap-y-3 text-sm sm:grid-cols-2 lg:grid-cols-3", children: [
|
|
2141
|
+
fields.map(([label, value]) => /* @__PURE__ */ jsxs("div", { className: "grid min-w-0 gap-0.5", children: [
|
|
2142
|
+
/* @__PURE__ */ jsx("dt", { className: "text-ui-fg-subtle", children: label }),
|
|
2143
|
+
/* @__PURE__ */ jsx("dd", { className: "break-all font-medium", children: value })
|
|
2144
|
+
] }, label)),
|
|
2145
|
+
coupon.promotion_setup_error ? /* @__PURE__ */ jsxs("div", { className: "grid min-w-0 gap-0.5 sm:col-span-2 lg:col-span-3", children: [
|
|
2146
|
+
/* @__PURE__ */ jsx("dt", { className: "text-ui-fg-subtle", children: texts.coupons.details.setupError }),
|
|
2147
|
+
/* @__PURE__ */ jsx("dd", { className: "text-ui-fg-error break-words font-medium", children: coupon.promotion_setup_error })
|
|
2148
|
+
] }) : null
|
|
2149
|
+
] });
|
|
2150
|
+
};
|
|
2151
|
+
const AffiliateCouponPanel = ({ affiliateId }) => {
|
|
2152
|
+
const [offset, setOffset] = useState(0);
|
|
2153
|
+
const [createMode, setCreateMode] = useState("generated");
|
|
2154
|
+
const [createCode, setCreateCode] = useState("");
|
|
2155
|
+
const [rotateCouponId, setRotateCouponId] = useState(null);
|
|
2156
|
+
const [rotateMode, setRotateMode] = useState("generated");
|
|
2157
|
+
const [rotateCode, setRotateCode] = useState("");
|
|
2158
|
+
const [revokeCoupon, setRevokeCoupon] = useState(
|
|
2159
|
+
null
|
|
2160
|
+
);
|
|
2161
|
+
const createIdempotency = useRef(null);
|
|
2162
|
+
const rotateIdempotency = useRef(null);
|
|
2163
|
+
const couponsQuery = useAffiliateCouponCodes(affiliateId, {
|
|
2164
|
+
limit: COUPON_PAGE_SIZE,
|
|
2165
|
+
offset
|
|
2166
|
+
});
|
|
2167
|
+
const createMutation = useCreateAffiliateCouponCode(affiliateId);
|
|
2168
|
+
const rotateMutation = useRotateAffiliateCouponCode(affiliateId);
|
|
2169
|
+
const revokeMutation = useRevokeAffiliateCouponCode(affiliateId);
|
|
2170
|
+
const reconcileMutation = useReconcileAffiliateCouponCode(affiliateId);
|
|
2171
|
+
const coupons = couponsQuery.data?.coupon_codes ?? [];
|
|
2172
|
+
const count = couponsQuery.data?.count ?? 0;
|
|
2173
|
+
const changeCreateMode = (mode) => {
|
|
2174
|
+
createIdempotency.current = null;
|
|
2175
|
+
setCreateMode(mode);
|
|
2176
|
+
};
|
|
2177
|
+
const changeCreateCode = (code) => {
|
|
2178
|
+
createIdempotency.current = null;
|
|
2179
|
+
setCreateCode(code);
|
|
2180
|
+
};
|
|
2181
|
+
const changeRotateMode = (mode) => {
|
|
2182
|
+
rotateIdempotency.current = null;
|
|
2183
|
+
setRotateMode(mode);
|
|
2184
|
+
};
|
|
2185
|
+
const changeRotateCode = (code) => {
|
|
2186
|
+
rotateIdempotency.current = null;
|
|
2187
|
+
setRotateCode(code);
|
|
2188
|
+
};
|
|
2189
|
+
const submitCreate = (event) => {
|
|
2190
|
+
event.preventDefault();
|
|
2191
|
+
const intent = createMode === "custom" ? `custom:${createCode.trim()}` : "generated";
|
|
2192
|
+
createIdempotency.current = resolveCouponCommandIdempotency(
|
|
2193
|
+
createIdempotency.current,
|
|
2194
|
+
intent
|
|
2195
|
+
);
|
|
2196
|
+
createMutation.mutate(
|
|
2197
|
+
{
|
|
2198
|
+
...createMode === "custom" ? { code: createCode.trim() } : {},
|
|
2199
|
+
idempotency_key: createIdempotency.current.key
|
|
2200
|
+
},
|
|
2201
|
+
{
|
|
2202
|
+
onSuccess: () => {
|
|
2203
|
+
createIdempotency.current = null;
|
|
2204
|
+
setCreateCode("");
|
|
2205
|
+
toast.success(texts.coupons.toasts.created);
|
|
2206
|
+
},
|
|
2207
|
+
onError: (error) => toast.error(texts.coupons.toasts.createFailed, {
|
|
2208
|
+
description: getErrorMessage(error)
|
|
2209
|
+
})
|
|
2210
|
+
}
|
|
2211
|
+
);
|
|
2212
|
+
};
|
|
2213
|
+
const openRotation = (couponId) => {
|
|
2214
|
+
rotateIdempotency.current = null;
|
|
2215
|
+
setRotateCouponId(couponId);
|
|
2216
|
+
setRotateMode("generated");
|
|
2217
|
+
setRotateCode("");
|
|
2218
|
+
};
|
|
2219
|
+
const closeRotation = () => {
|
|
2220
|
+
rotateIdempotency.current = null;
|
|
2221
|
+
setRotateCouponId(null);
|
|
2222
|
+
setRotateCode("");
|
|
2223
|
+
};
|
|
2224
|
+
const submitRotation = (event) => {
|
|
2225
|
+
event.preventDefault();
|
|
2226
|
+
if (!rotateCouponId) {
|
|
2227
|
+
return;
|
|
2228
|
+
}
|
|
2229
|
+
const intent = `${rotateCouponId}:${rotateMode === "custom" ? `custom:${rotateCode.trim()}` : "generated"}`;
|
|
2230
|
+
rotateIdempotency.current = resolveCouponCommandIdempotency(
|
|
2231
|
+
rotateIdempotency.current,
|
|
2232
|
+
intent
|
|
2233
|
+
);
|
|
2234
|
+
rotateMutation.mutate(
|
|
2235
|
+
{
|
|
2236
|
+
couponId: rotateCouponId,
|
|
2237
|
+
payload: {
|
|
2238
|
+
...rotateMode === "custom" ? { code: rotateCode.trim() } : {},
|
|
2239
|
+
idempotency_key: rotateIdempotency.current.key
|
|
2240
|
+
}
|
|
2241
|
+
},
|
|
2242
|
+
{
|
|
2243
|
+
onSuccess: () => {
|
|
2244
|
+
closeRotation();
|
|
2245
|
+
toast.success(texts.coupons.toasts.rotated);
|
|
2246
|
+
},
|
|
2247
|
+
onError: (error) => toast.error(texts.coupons.toasts.rotateFailed, {
|
|
2248
|
+
description: getErrorMessage(error)
|
|
2249
|
+
})
|
|
2250
|
+
}
|
|
2251
|
+
);
|
|
2252
|
+
};
|
|
2253
|
+
const revoke = () => {
|
|
2254
|
+
if (!revokeCoupon) {
|
|
2255
|
+
return;
|
|
2256
|
+
}
|
|
2257
|
+
revokeMutation.mutate(revokeCoupon.id, {
|
|
2258
|
+
onSuccess: () => {
|
|
2259
|
+
setRevokeCoupon(null);
|
|
2260
|
+
toast.success(texts.coupons.toasts.revoked);
|
|
2261
|
+
},
|
|
2262
|
+
onError: (error) => toast.error(texts.coupons.toasts.revokeFailed, {
|
|
2263
|
+
description: getErrorMessage(error)
|
|
2264
|
+
})
|
|
2265
|
+
});
|
|
2266
|
+
};
|
|
2267
|
+
const reconcile = (couponId) => {
|
|
2268
|
+
reconcileMutation.mutate(couponId, {
|
|
2269
|
+
onSuccess: (response) => toast.success(texts.coupons.toasts.reconciled, {
|
|
2270
|
+
description: [
|
|
2271
|
+
texts.coupons.reconcileOutcome(
|
|
2272
|
+
texts.coupons.reconcileOutcomes[response.outcome]
|
|
2273
|
+
),
|
|
2274
|
+
response.rotation_finalized ? texts.coupons.rotationFinalized : null
|
|
2275
|
+
].filter(Boolean).join(" ")
|
|
2276
|
+
}),
|
|
2277
|
+
onError: (error) => toast.error(texts.coupons.toasts.reconcileFailed, {
|
|
2278
|
+
description: getErrorMessage(error)
|
|
2279
|
+
})
|
|
2280
|
+
});
|
|
2281
|
+
};
|
|
2282
|
+
const renderCoupons = () => {
|
|
2283
|
+
if (couponsQuery.isLoading) {
|
|
2284
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.coupons.loading }) });
|
|
2285
|
+
}
|
|
2286
|
+
if (couponsQuery.isError) {
|
|
2287
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: texts.coupons.loadError(getErrorMessage(couponsQuery.error)) }) });
|
|
2288
|
+
}
|
|
2289
|
+
if (!coupons.length) {
|
|
2290
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.coupons.empty }) });
|
|
2291
|
+
}
|
|
2292
|
+
return coupons.map((coupon) => /* @__PURE__ */ jsxs("article", { className: "grid gap-4 px-6 py-5", children: [
|
|
2293
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [
|
|
2294
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
2295
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", className: "break-all font-mono", children: coupon.code }),
|
|
2296
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: texts.coupons.statuses[coupon.status] })
|
|
2297
|
+
] }),
|
|
2298
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
2299
|
+
/* @__PURE__ */ jsx(
|
|
2300
|
+
Button,
|
|
2301
|
+
{
|
|
2302
|
+
type: "button",
|
|
2303
|
+
size: "small",
|
|
2304
|
+
variant: "secondary",
|
|
2305
|
+
disabled: rotateMutation.isPending || rotateCouponId === coupon.id || coupon.lifecycle_status === "revoked",
|
|
2306
|
+
onClick: () => openRotation(coupon.id),
|
|
2307
|
+
children: texts.coupons.rotate
|
|
2308
|
+
}
|
|
2309
|
+
),
|
|
2310
|
+
/* @__PURE__ */ jsx(
|
|
2311
|
+
Button,
|
|
2312
|
+
{
|
|
2313
|
+
type: "button",
|
|
2314
|
+
size: "small",
|
|
2315
|
+
variant: "secondary",
|
|
2316
|
+
disabled: reconcileMutation.isPending,
|
|
2317
|
+
onClick: () => reconcile(coupon.id),
|
|
2318
|
+
children: reconcileMutation.isPending ? texts.coupons.reconciling : texts.coupons.reconcile
|
|
2319
|
+
}
|
|
2320
|
+
),
|
|
2321
|
+
/* @__PURE__ */ jsx(
|
|
2322
|
+
Button,
|
|
2323
|
+
{
|
|
2324
|
+
type: "button",
|
|
2325
|
+
size: "small",
|
|
2326
|
+
variant: "danger",
|
|
2327
|
+
disabled: revokeMutation.isPending || coupon.lifecycle_status === "revoked",
|
|
2328
|
+
onClick: () => setRevokeCoupon(coupon),
|
|
2329
|
+
children: texts.coupons.revoke
|
|
2330
|
+
}
|
|
2331
|
+
)
|
|
2332
|
+
] })
|
|
2333
|
+
] }),
|
|
2334
|
+
/* @__PURE__ */ jsx(CouponDetails, { coupon }),
|
|
2335
|
+
rotateCouponId === coupon.id ? /* @__PURE__ */ jsxs(
|
|
2336
|
+
"form",
|
|
2337
|
+
{
|
|
2338
|
+
onSubmit: submitRotation,
|
|
2339
|
+
className: "border-ui-border-base grid gap-4 rounded-lg border p-4",
|
|
2340
|
+
children: [
|
|
2341
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2342
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: texts.coupons.rotateHeading(coupon.code) }),
|
|
2343
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: texts.coupons.rotateDescription })
|
|
2344
|
+
] }),
|
|
2345
|
+
/* @__PURE__ */ jsx(
|
|
2346
|
+
CouponCodeChoice,
|
|
2347
|
+
{
|
|
2348
|
+
prefix: `rotate-${coupon.id}`,
|
|
2349
|
+
label: texts.coupons.rotateHeading(coupon.code),
|
|
2350
|
+
mode: rotateMode,
|
|
2351
|
+
code: rotateCode,
|
|
2352
|
+
onModeChange: changeRotateMode,
|
|
2353
|
+
onCodeChange: changeRotateCode
|
|
2354
|
+
}
|
|
2355
|
+
),
|
|
2356
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
2357
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", onClick: closeRotation, children: texts.coupons.cancel }),
|
|
2358
|
+
/* @__PURE__ */ jsx(
|
|
2359
|
+
Button,
|
|
2360
|
+
{
|
|
2361
|
+
type: "submit",
|
|
2362
|
+
disabled: rotateMutation.isPending || rotateMode === "custom" && rotateCode.trim().length < 3,
|
|
2363
|
+
children: rotateMutation.isPending ? texts.coupons.rotating : texts.coupons.rotate
|
|
2364
|
+
}
|
|
2365
|
+
)
|
|
2366
|
+
] })
|
|
2367
|
+
]
|
|
2368
|
+
}
|
|
2369
|
+
) : null
|
|
2370
|
+
] }, coupon.id));
|
|
2371
|
+
};
|
|
2372
|
+
const showPagination = !couponsQuery.isLoading && !couponsQuery.isError && count > 0;
|
|
2373
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
2374
|
+
/* @__PURE__ */ jsxs("div", { className: "px-6 py-4", children: [
|
|
2375
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: texts.coupons.heading }),
|
|
2376
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.coupons.description })
|
|
2377
|
+
] }),
|
|
2378
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: submitCreate, className: "grid gap-4 px-6 py-5", children: [
|
|
2379
|
+
/* @__PURE__ */ jsx(Heading, { level: "h3", children: texts.coupons.createHeading }),
|
|
2380
|
+
/* @__PURE__ */ jsx(
|
|
2381
|
+
CouponCodeChoice,
|
|
2382
|
+
{
|
|
2383
|
+
prefix: "create-coupon",
|
|
2384
|
+
label: texts.coupons.createHeading,
|
|
2385
|
+
mode: createMode,
|
|
2386
|
+
code: createCode,
|
|
2387
|
+
onModeChange: changeCreateMode,
|
|
2388
|
+
onCodeChange: changeCreateCode
|
|
2389
|
+
}
|
|
2390
|
+
),
|
|
2391
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
|
|
2392
|
+
Button,
|
|
2393
|
+
{
|
|
2394
|
+
type: "submit",
|
|
2395
|
+
disabled: createMutation.isPending || createMode === "custom" && createCode.trim().length < 3,
|
|
2396
|
+
children: createMutation.isPending ? texts.coupons.creating : texts.coupons.create
|
|
2397
|
+
}
|
|
2398
|
+
) })
|
|
2399
|
+
] }),
|
|
2400
|
+
renderCoupons(),
|
|
2401
|
+
showPagination ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
2402
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: texts.common.pageRange(offset + 1, offset + coupons.length, count) }),
|
|
2403
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2404
|
+
/* @__PURE__ */ jsx(
|
|
2405
|
+
Button,
|
|
2406
|
+
{
|
|
2407
|
+
type: "button",
|
|
2408
|
+
size: "small",
|
|
2409
|
+
variant: "secondary",
|
|
2410
|
+
disabled: offset === 0,
|
|
2411
|
+
onClick: () => setOffset((current) => Math.max(0, current - COUPON_PAGE_SIZE)),
|
|
2412
|
+
children: texts.common.back
|
|
2413
|
+
}
|
|
2414
|
+
),
|
|
2415
|
+
/* @__PURE__ */ jsx(
|
|
2416
|
+
Button,
|
|
2417
|
+
{
|
|
2418
|
+
type: "button",
|
|
2419
|
+
size: "small",
|
|
2420
|
+
variant: "secondary",
|
|
2421
|
+
disabled: offset + coupons.length >= count,
|
|
2422
|
+
onClick: () => setOffset((current) => current + COUPON_PAGE_SIZE),
|
|
2423
|
+
children: texts.common.next
|
|
2424
|
+
}
|
|
2425
|
+
)
|
|
2426
|
+
] })
|
|
2427
|
+
] }) : null,
|
|
2428
|
+
/* @__PURE__ */ jsx(
|
|
2429
|
+
Prompt,
|
|
2430
|
+
{
|
|
2431
|
+
open: !!revokeCoupon,
|
|
2432
|
+
onOpenChange: (open) => {
|
|
2433
|
+
if (!open) {
|
|
2434
|
+
setRevokeCoupon(null);
|
|
2435
|
+
}
|
|
2436
|
+
},
|
|
2437
|
+
children: /* @__PURE__ */ jsxs(Prompt.Content, { children: [
|
|
2438
|
+
/* @__PURE__ */ jsxs(Prompt.Header, { children: [
|
|
2439
|
+
/* @__PURE__ */ jsx(Prompt.Title, { children: texts.coupons.revokeHeading }),
|
|
2440
|
+
/* @__PURE__ */ jsx(Prompt.Description, { children: revokeCoupon ? texts.coupons.revokeDescription(revokeCoupon.code) : "" })
|
|
2441
|
+
] }),
|
|
2442
|
+
/* @__PURE__ */ jsxs(Prompt.Footer, { children: [
|
|
2443
|
+
/* @__PURE__ */ jsx(Prompt.Cancel, { children: texts.coupons.cancel }),
|
|
2444
|
+
/* @__PURE__ */ jsx(Prompt.Action, { onClick: revoke, children: texts.coupons.revoke })
|
|
2445
|
+
] })
|
|
2446
|
+
] })
|
|
2447
|
+
}
|
|
2448
|
+
)
|
|
2449
|
+
] });
|
|
2450
|
+
};
|
|
2451
|
+
const SlugTable = ({
|
|
2452
|
+
affiliateId,
|
|
2453
|
+
slugs
|
|
2454
|
+
}) => {
|
|
2455
|
+
const mutation = useUpdateAffiliateSlug(affiliateId);
|
|
2456
|
+
const update = (payload) => mutation.mutate(payload, {
|
|
2457
|
+
onSuccess: () => toast.success(texts.slugTable.toasts.updated),
|
|
2458
|
+
onError: (error) => toast.error(texts.slugTable.toasts.updateFailed, {
|
|
2459
|
+
description: getErrorMessage(error)
|
|
2460
|
+
})
|
|
2461
|
+
});
|
|
2462
|
+
if (!slugs.length) {
|
|
2463
|
+
return /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.slugTable.empty });
|
|
2464
|
+
}
|
|
2465
|
+
return /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left text-sm", children: [
|
|
2466
|
+
/* @__PURE__ */ jsx("thead", { className: "border-ui-border-base border-b", children: /* @__PURE__ */ jsxs("tr", { className: "text-ui-fg-subtle", children: [
|
|
2467
|
+
/* @__PURE__ */ jsx("th", { className: "py-3 pr-3 font-medium", children: texts.slugTable.columns.slug }),
|
|
2468
|
+
/* @__PURE__ */ jsx("th", { className: "py-3 pr-3 font-medium", children: texts.slugTable.columns.state }),
|
|
2469
|
+
/* @__PURE__ */ jsx("th", { className: "py-3 pr-3 font-medium", children: texts.slugTable.columns.primary }),
|
|
2470
|
+
/* @__PURE__ */ jsx("th", { className: "py-3 text-right font-medium", children: texts.slugTable.columns.actions })
|
|
2471
|
+
] }) }),
|
|
2472
|
+
/* @__PURE__ */ jsx("tbody", { children: slugs.map((slug) => /* @__PURE__ */ jsxs("tr", { className: "border-ui-border-base border-b", children: [
|
|
2473
|
+
/* @__PURE__ */ jsx("td", { className: "py-3 pr-3 font-medium", children: slug.slug }),
|
|
2474
|
+
/* @__PURE__ */ jsx("td", { className: "py-3 pr-3", children: slug.active ? texts.slugTable.active : texts.slugTable.inactive }),
|
|
2475
|
+
/* @__PURE__ */ jsx("td", { className: "py-3 pr-3", children: slug.is_primary ? texts.slugTable.yes : texts.slugTable.no }),
|
|
2476
|
+
/* @__PURE__ */ jsx("td", { className: "py-3 text-right", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
2477
|
+
/* @__PURE__ */ jsx(
|
|
2478
|
+
Button,
|
|
2479
|
+
{
|
|
2480
|
+
size: "small",
|
|
2481
|
+
variant: "secondary",
|
|
2482
|
+
disabled: mutation.isPending || slug.is_primary,
|
|
2483
|
+
onClick: () => update({ slugId: slug.id, is_primary: true }),
|
|
2484
|
+
children: texts.slugTable.makePrimary
|
|
2485
|
+
}
|
|
2486
|
+
),
|
|
2487
|
+
/* @__PURE__ */ jsx(
|
|
2488
|
+
Button,
|
|
2489
|
+
{
|
|
2490
|
+
size: "small",
|
|
2491
|
+
variant: "secondary",
|
|
2492
|
+
disabled: mutation.isPending || slug.is_primary,
|
|
2493
|
+
onClick: () => update({ slugId: slug.id, active: !slug.active }),
|
|
2494
|
+
children: slug.active ? texts.slugTable.deactivate : texts.slugTable.activate
|
|
2495
|
+
}
|
|
2496
|
+
)
|
|
2497
|
+
] }) })
|
|
2498
|
+
] }, slug.id)) })
|
|
2499
|
+
] }) });
|
|
2500
|
+
};
|
|
2501
|
+
const resolveAssignmentDurationDays = ({
|
|
2502
|
+
presetDurationDays,
|
|
2503
|
+
persistedDurationDays
|
|
2504
|
+
}) => persistedDurationDays ?? presetDurationDays;
|
|
2505
|
+
const emptyFormState = {
|
|
2506
|
+
displayName: "",
|
|
2507
|
+
customerId: "",
|
|
2508
|
+
status: "active",
|
|
2509
|
+
commissionRate: 10,
|
|
2510
|
+
ownOrderDiscountRate: 0,
|
|
2511
|
+
customerDiscountOverride: "",
|
|
2512
|
+
referredByAffiliateId: "",
|
|
2513
|
+
referrerCommissionRate: 0,
|
|
2514
|
+
internalNotes: "",
|
|
2515
|
+
customerAssignmentMode: "lifetime",
|
|
2516
|
+
assignmentDurationDays: 30,
|
|
2517
|
+
persistedAssignmentDurationDays: null
|
|
2518
|
+
};
|
|
2519
|
+
const assignmentModeOptions = [
|
|
2520
|
+
["lifetime", texts.form.assignmentModes.lifetime],
|
|
2521
|
+
["time_limited", texts.form.assignmentModes.timeLimited],
|
|
2522
|
+
["order_only", texts.form.assignmentModes.orderOnly]
|
|
2523
|
+
];
|
|
2524
|
+
const AffiliateFormPage = (props) => {
|
|
2525
|
+
if (props.mode === "create") {
|
|
2526
|
+
return /* @__PURE__ */ jsx(CreateAffiliateForm, {});
|
|
2527
|
+
}
|
|
2528
|
+
return /* @__PURE__ */ jsx(EditAffiliateForm, { affiliateId: props.affiliateId });
|
|
2529
|
+
};
|
|
2530
|
+
const CreateAffiliateForm = () => {
|
|
2531
|
+
const navigate = useNavigate();
|
|
2532
|
+
const [form, setForm] = useState(emptyFormState);
|
|
2533
|
+
const [slug, setSlug] = useState("");
|
|
2534
|
+
const createMutation = useCreateAffiliate();
|
|
2535
|
+
const submit = (event) => {
|
|
2536
|
+
event.preventDefault();
|
|
2537
|
+
createMutation.mutate(
|
|
2538
|
+
{
|
|
2539
|
+
display_name: form.displayName,
|
|
2540
|
+
customer_id: form.customerId || null,
|
|
2541
|
+
status: form.status,
|
|
2542
|
+
commission_rate: form.commissionRate,
|
|
2543
|
+
own_order_discount_rate: form.ownOrderDiscountRate,
|
|
2544
|
+
customer_discount_rate_override: form.customerDiscountOverride === "" ? null : Number(form.customerDiscountOverride),
|
|
2545
|
+
slug: slug || null,
|
|
2546
|
+
referred_by_affiliate_id: form.referredByAffiliateId || null,
|
|
2547
|
+
referrer_commission_rate: form.referredByAffiliateId ? form.referrerCommissionRate : null,
|
|
2548
|
+
internal_notes: form.internalNotes || null,
|
|
2549
|
+
customer_assignment_mode: form.customerAssignmentMode,
|
|
2550
|
+
assignment_duration_days: form.customerAssignmentMode === "time_limited" ? resolveAssignmentDurationDays({
|
|
2551
|
+
presetDurationDays: form.assignmentDurationDays,
|
|
2552
|
+
persistedDurationDays: form.persistedAssignmentDurationDays
|
|
2553
|
+
}) : null
|
|
2554
|
+
},
|
|
2555
|
+
{
|
|
2556
|
+
onSuccess: () => {
|
|
2557
|
+
toast.success(texts.form.toasts.created);
|
|
2558
|
+
navigate("/affiliates");
|
|
2559
|
+
},
|
|
2560
|
+
onError: (error) => {
|
|
2561
|
+
toast.error(texts.form.toasts.createFailed, {
|
|
2562
|
+
description: getErrorMessage(error)
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
);
|
|
2567
|
+
};
|
|
2568
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
2569
|
+
/* @__PURE__ */ jsxs("div", { className: "px-6 py-4", children: [
|
|
2570
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: texts.form.createHeading }),
|
|
2571
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.form.createDescription })
|
|
2572
|
+
] }),
|
|
2573
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: submit, className: "grid gap-5 px-6 py-5", children: [
|
|
2574
|
+
/* @__PURE__ */ jsx(AffiliateFormFields, { form, onChange: setForm, excludeAffiliateId: void 0, children: /* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
2575
|
+
/* @__PURE__ */ jsx(Label, { children: texts.form.initialSlugLabel }),
|
|
2576
|
+
/* @__PURE__ */ jsx(
|
|
2577
|
+
Input,
|
|
2578
|
+
{
|
|
2579
|
+
value: slug,
|
|
2580
|
+
onChange: (event) => setSlug(event.target.value),
|
|
2581
|
+
placeholder: texts.form.initialSlugPlaceholder
|
|
2582
|
+
}
|
|
2583
|
+
)
|
|
2584
|
+
] }) }),
|
|
2585
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: createMutation.isPending, children: createMutation.isPending ? texts.form.creating : texts.form.create }) })
|
|
2586
|
+
] })
|
|
2587
|
+
] });
|
|
2588
|
+
};
|
|
2589
|
+
const EditAffiliateForm = ({ affiliateId }) => {
|
|
2590
|
+
const affiliateQuery = useAffiliate(affiliateId);
|
|
2591
|
+
const affiliate = affiliateQuery.data?.affiliate;
|
|
2592
|
+
const [form, setForm] = useState(emptyFormState);
|
|
2593
|
+
const [newSlug, setNewSlug] = useState("");
|
|
2594
|
+
const initializedForId = useRef(void 0);
|
|
2595
|
+
useEffect(() => {
|
|
2596
|
+
if (!affiliate || initializedForId.current === affiliate.id) {
|
|
2597
|
+
return;
|
|
2598
|
+
}
|
|
2599
|
+
initializedForId.current = affiliate.id;
|
|
2600
|
+
setForm({
|
|
2601
|
+
displayName: affiliate.display_name,
|
|
2602
|
+
customerId: affiliate.customer_id ?? "",
|
|
2603
|
+
status: affiliate.status,
|
|
2604
|
+
commissionRate: affiliate.commission_rate,
|
|
2605
|
+
ownOrderDiscountRate: affiliate.own_order_discount_rate,
|
|
2606
|
+
customerDiscountOverride: affiliate.customer_discount_rate_override == null ? "" : String(affiliate.customer_discount_rate_override),
|
|
2607
|
+
referredByAffiliateId: affiliate.referred_by_affiliate_id ?? "",
|
|
2608
|
+
referrerCommissionRate: affiliate.referrer_commission_rate ?? 0,
|
|
2609
|
+
internalNotes: affiliate.internal_notes ?? "",
|
|
2610
|
+
customerAssignmentMode: affiliate.customer_assignment_mode,
|
|
2611
|
+
// The API accepts any positive duration, while the operator UI presents
|
|
2612
|
+
// three approved presets. Preserve an unchanged arbitrary value so an
|
|
2613
|
+
// unrelated edit never shortens the configured assignment period.
|
|
2614
|
+
assignmentDurationDays: affiliate.assignment_duration_days === 30 || affiliate.assignment_duration_days === 90 || affiliate.assignment_duration_days === 180 ? affiliate.assignment_duration_days : 30,
|
|
2615
|
+
persistedAssignmentDurationDays: affiliate.assignment_duration_days === 30 || affiliate.assignment_duration_days === 90 || affiliate.assignment_duration_days === 180 ? null : affiliate.assignment_duration_days
|
|
2616
|
+
});
|
|
2617
|
+
}, [affiliate]);
|
|
2618
|
+
const updateMutation = useUpdateAffiliate(affiliateId);
|
|
2619
|
+
const inactiveMutation = useSetAffiliateInactive(affiliateId);
|
|
2620
|
+
const createSlugMutation = useCreateAffiliateSlug(affiliateId);
|
|
2621
|
+
const submit = (event) => {
|
|
2622
|
+
event.preventDefault();
|
|
2623
|
+
updateMutation.mutate(
|
|
2624
|
+
{
|
|
2625
|
+
display_name: form.displayName,
|
|
2626
|
+
customer_id: form.customerId || null,
|
|
2627
|
+
status: form.status,
|
|
2628
|
+
commission_rate: form.commissionRate,
|
|
2629
|
+
own_order_discount_rate: form.ownOrderDiscountRate,
|
|
2630
|
+
customer_discount_rate_override: form.customerDiscountOverride === "" ? null : Number(form.customerDiscountOverride),
|
|
2631
|
+
referred_by_affiliate_id: form.referredByAffiliateId || null,
|
|
2632
|
+
referrer_commission_rate: form.referredByAffiliateId ? form.referrerCommissionRate : null,
|
|
2633
|
+
internal_notes: form.internalNotes || null,
|
|
2634
|
+
customer_assignment_mode: form.customerAssignmentMode,
|
|
2635
|
+
assignment_duration_days: form.customerAssignmentMode === "time_limited" ? resolveAssignmentDurationDays({
|
|
2636
|
+
presetDurationDays: form.assignmentDurationDays,
|
|
2637
|
+
persistedDurationDays: form.persistedAssignmentDurationDays
|
|
2638
|
+
}) : null
|
|
2639
|
+
},
|
|
2640
|
+
{
|
|
2641
|
+
onSuccess: () => toast.success(texts.form.toasts.updated),
|
|
2642
|
+
onError: (error) => toast.error(texts.form.toasts.updateFailed, {
|
|
2643
|
+
description: getErrorMessage(error)
|
|
2644
|
+
})
|
|
2645
|
+
}
|
|
2646
|
+
);
|
|
2647
|
+
};
|
|
2648
|
+
const submitSlug = (event) => {
|
|
2649
|
+
event.preventDefault();
|
|
2650
|
+
createSlugMutation.mutate(
|
|
2651
|
+
{ slug: newSlug, is_primary: !affiliate?.slugs?.length },
|
|
2652
|
+
{
|
|
2653
|
+
onSuccess: () => {
|
|
2654
|
+
toast.success(texts.form.toasts.slugCreated);
|
|
2655
|
+
setNewSlug("");
|
|
2656
|
+
},
|
|
2657
|
+
onError: (error) => toast.error(texts.form.toasts.slugCreateFailed, {
|
|
2658
|
+
description: getErrorMessage(error)
|
|
2659
|
+
})
|
|
2660
|
+
}
|
|
2661
|
+
);
|
|
2662
|
+
};
|
|
2663
|
+
if (!affiliateId) {
|
|
2664
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid gap-3", children: [
|
|
2665
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: texts.form.notFoundHeading }),
|
|
2666
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.form.notFoundBody }),
|
|
2667
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: "/affiliates", children: texts.form.backToList }) }) })
|
|
2668
|
+
] });
|
|
2669
|
+
}
|
|
2670
|
+
if (affiliateQuery.isError) {
|
|
2671
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid gap-3", children: [
|
|
2672
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: texts.form.loadErrorHeading }),
|
|
2673
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: getErrorMessage(affiliateQuery.error) }),
|
|
2674
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: "/affiliates", children: texts.form.backToList }) }) })
|
|
2675
|
+
] });
|
|
2676
|
+
}
|
|
2677
|
+
if (affiliateQuery.isLoading || !affiliate) {
|
|
2678
|
+
return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.form.loading }) });
|
|
2679
|
+
}
|
|
2680
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid gap-6", children: [
|
|
2681
|
+
/* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
2682
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4 px-6 py-4", children: [
|
|
2683
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2684
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: affiliate.display_name }),
|
|
2685
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.form.createdAt(formatDateTime(affiliate.created_at)) })
|
|
2686
|
+
] }),
|
|
2687
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
2688
|
+
/* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx("a", { href: "#affiliate-distribution", children: "Zum Kommissionsvertrieb" }) }),
|
|
2689
|
+
/* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: "/affiliates", children: texts.form.backToList }) }),
|
|
2690
|
+
/* @__PURE__ */ jsx(
|
|
2691
|
+
Button,
|
|
2692
|
+
{
|
|
2693
|
+
variant: "danger",
|
|
2694
|
+
disabled: inactiveMutation.isPending || affiliate.status === "inactive",
|
|
2695
|
+
onClick: () => inactiveMutation.mutate(void 0, {
|
|
2696
|
+
onSuccess: () => toast.success(texts.form.toasts.setInactive),
|
|
2697
|
+
onError: (error) => toast.error(texts.form.toasts.setInactiveFailed, {
|
|
2698
|
+
description: getErrorMessage(error)
|
|
2699
|
+
})
|
|
2700
|
+
}),
|
|
2701
|
+
children: texts.form.setInactive
|
|
2702
|
+
}
|
|
2703
|
+
)
|
|
2704
|
+
] })
|
|
2705
|
+
] }),
|
|
2706
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: submit, className: "grid gap-5 px-6 py-5", children: [
|
|
2707
|
+
/* @__PURE__ */ jsx(AffiliateFormFields, { form, onChange: setForm, excludeAffiliateId: affiliateId }),
|
|
2708
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: updateMutation.isPending, children: updateMutation.isPending ? texts.form.saving : texts.form.save }) })
|
|
2709
|
+
] })
|
|
2710
|
+
] }),
|
|
2711
|
+
/* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
2712
|
+
/* @__PURE__ */ jsxs("div", { className: "px-6 py-4", children: [
|
|
2713
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: texts.form.slugs.heading }),
|
|
2714
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.form.slugs.description })
|
|
2715
|
+
] }),
|
|
2716
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-5 px-6 py-5", children: [
|
|
2717
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: submitSlug, className: "grid gap-3 md:grid-cols-[minmax(0,1fr)_auto]", children: [
|
|
2718
|
+
/* @__PURE__ */ jsx(
|
|
2719
|
+
Input,
|
|
2720
|
+
{
|
|
2721
|
+
value: newSlug,
|
|
2722
|
+
onChange: (event) => setNewSlug(event.target.value),
|
|
2723
|
+
placeholder: texts.form.slugs.placeholder
|
|
2724
|
+
}
|
|
2725
|
+
),
|
|
2726
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", disabled: createSlugMutation.isPending || !newSlug.trim(), children: texts.form.slugs.add })
|
|
2727
|
+
] }),
|
|
2728
|
+
/* @__PURE__ */ jsx(SlugTable, { affiliateId: affiliate.id, slugs: affiliate.slugs ?? [] })
|
|
2729
|
+
] })
|
|
2730
|
+
] }),
|
|
2731
|
+
/* @__PURE__ */ jsx(AffiliateCouponPanel, { affiliateId: affiliate.id }),
|
|
2732
|
+
/* @__PURE__ */ jsx(AffiliateDistributionPanel, { affiliateId: affiliate.id }),
|
|
2733
|
+
/* @__PURE__ */ jsx(ConsignmentReminderPanel, { affiliateId: affiliate.id })
|
|
2734
|
+
] });
|
|
2735
|
+
};
|
|
2736
|
+
const AffiliateFormFields = ({
|
|
2737
|
+
form,
|
|
2738
|
+
onChange,
|
|
2739
|
+
excludeAffiliateId,
|
|
2740
|
+
children
|
|
2741
|
+
}) => {
|
|
2742
|
+
const set = (key, value) => onChange((current) => ({ ...current, [key]: value }));
|
|
2743
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2744
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
2745
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
2746
|
+
/* @__PURE__ */ jsx(Label, { children: texts.form.fields.displayName }),
|
|
2747
|
+
/* @__PURE__ */ jsx(Input, { required: true, value: form.displayName, onChange: (event) => set("displayName", event.target.value) })
|
|
2748
|
+
] }),
|
|
2749
|
+
/* @__PURE__ */ jsx(CustomerReferenceField, { value: form.customerId, onChange: (value) => set("customerId", value) })
|
|
2750
|
+
] }),
|
|
2751
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-3", children: [
|
|
2752
|
+
/* @__PURE__ */ jsx(AffiliateStatusSelect, { value: form.status, onChange: (value) => set("status", value) }),
|
|
2753
|
+
/* @__PURE__ */ jsx(
|
|
2754
|
+
PercentRateInput,
|
|
2755
|
+
{
|
|
2756
|
+
label: texts.form.fields.commission,
|
|
2757
|
+
value: form.commissionRate,
|
|
2758
|
+
onChange: (value) => set("commissionRate", value)
|
|
2759
|
+
}
|
|
2760
|
+
),
|
|
2761
|
+
/* @__PURE__ */ jsx(
|
|
2762
|
+
PercentRateInput,
|
|
2763
|
+
{
|
|
2764
|
+
label: texts.form.fields.ownDiscount,
|
|
2765
|
+
value: form.ownOrderDiscountRate,
|
|
2766
|
+
onChange: (value) => set("ownOrderDiscountRate", value)
|
|
2767
|
+
}
|
|
2768
|
+
)
|
|
2769
|
+
] }),
|
|
2770
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
2771
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "affiliate-customer-discount", children: "Kundenrabatt-Abweichung % (leer = global)" }),
|
|
2772
|
+
/* @__PURE__ */ jsx(
|
|
2773
|
+
Input,
|
|
2774
|
+
{
|
|
2775
|
+
id: "affiliate-customer-discount",
|
|
2776
|
+
type: "number",
|
|
2777
|
+
min: 0,
|
|
2778
|
+
max: 100,
|
|
2779
|
+
step: "0.01",
|
|
2780
|
+
value: form.customerDiscountOverride,
|
|
2781
|
+
onChange: (event) => set("customerDiscountOverride", event.target.value)
|
|
2782
|
+
}
|
|
2783
|
+
)
|
|
2784
|
+
] }),
|
|
2785
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3", children: [
|
|
2786
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2787
|
+
/* @__PURE__ */ jsx(Label, { children: texts.form.fields.customerAssignmentMode }),
|
|
2788
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-xs", children: texts.form.fields.customerAssignmentModeHint })
|
|
2789
|
+
] }),
|
|
2790
|
+
/* @__PURE__ */ jsx(
|
|
2791
|
+
RadioGroup,
|
|
2792
|
+
{
|
|
2793
|
+
"aria-label": texts.form.fields.customerAssignmentMode,
|
|
2794
|
+
value: form.customerAssignmentMode,
|
|
2795
|
+
onValueChange: (value) => set(
|
|
2796
|
+
"customerAssignmentMode",
|
|
2797
|
+
value
|
|
2798
|
+
),
|
|
2799
|
+
className: "grid gap-3",
|
|
2800
|
+
children: assignmentModeOptions.map(([value, option]) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
2801
|
+
/* @__PURE__ */ jsx(RadioGroup.Item, { id: `assignment-mode-${value}`, value }),
|
|
2802
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-0.5", children: [
|
|
2803
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `assignment-mode-${value}`, children: option.label }),
|
|
2804
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-xs", children: option.description })
|
|
2805
|
+
] })
|
|
2806
|
+
] }, value))
|
|
2807
|
+
}
|
|
2808
|
+
),
|
|
2809
|
+
form.customerAssignmentMode === "time_limited" ? /* @__PURE__ */ jsx(
|
|
2810
|
+
AssignmentDurationSelect,
|
|
2811
|
+
{
|
|
2812
|
+
presetDurationDays: form.assignmentDurationDays,
|
|
2813
|
+
persistedDurationDays: form.persistedAssignmentDurationDays,
|
|
2814
|
+
onPresetDurationChange: (assignmentDurationDays) => onChange((current) => ({
|
|
2815
|
+
...current,
|
|
2816
|
+
assignmentDurationDays,
|
|
2817
|
+
persistedAssignmentDurationDays: null
|
|
2818
|
+
}))
|
|
2819
|
+
}
|
|
2820
|
+
) : null
|
|
2821
|
+
] }),
|
|
2822
|
+
children,
|
|
2823
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
2824
|
+
/* @__PURE__ */ jsx(
|
|
2825
|
+
AffiliateReferenceField,
|
|
2826
|
+
{
|
|
2827
|
+
label: texts.form.fields.referredBy,
|
|
2828
|
+
value: form.referredByAffiliateId,
|
|
2829
|
+
onChange: (value) => set("referredByAffiliateId", value),
|
|
2830
|
+
excludeAffiliateId
|
|
2831
|
+
}
|
|
2832
|
+
),
|
|
2833
|
+
/* @__PURE__ */ jsx(
|
|
2834
|
+
PercentRateInput,
|
|
2835
|
+
{
|
|
2836
|
+
label: texts.form.fields.referrerCommission,
|
|
2837
|
+
value: form.referrerCommissionRate,
|
|
2838
|
+
onChange: (value) => set("referrerCommissionRate", value)
|
|
2839
|
+
}
|
|
2840
|
+
)
|
|
2841
|
+
] }),
|
|
2842
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
2843
|
+
/* @__PURE__ */ jsx(Label, { children: texts.form.fields.internalNotes }),
|
|
2844
|
+
/* @__PURE__ */ jsx(Textarea, { value: form.internalNotes, onChange: (event) => set("internalNotes", event.target.value) })
|
|
2845
|
+
] })
|
|
2846
|
+
] });
|
|
2847
|
+
};
|
|
2848
|
+
const AffiliateEditRoute = () => {
|
|
2849
|
+
const { id } = useParams();
|
|
2850
|
+
return /* @__PURE__ */ jsx(AffiliateFormPage, { mode: "edit", affiliateId: id });
|
|
2851
|
+
};
|
|
2852
|
+
const yearStart = () => `${(/* @__PURE__ */ new Date()).getFullYear()}-01-01`;
|
|
2853
|
+
const formatCurrencyTotals = (totals) => totals.length ? /* @__PURE__ */ jsx("div", { className: "grid gap-1", children: totals.map((total) => /* @__PURE__ */ jsx("span", { children: total.currency_code ? formatAmount(total.amount, total.currency_code) : `${total.amount} (Währung unbekannt)` }, total.currency_code ?? "unknown-currency")) }) : "–";
|
|
2854
|
+
function AffiliateDistributionReportPage() {
|
|
2855
|
+
const [draftFrom, setDraftFrom] = useState(yearStart);
|
|
2856
|
+
const [draftTo, setDraftTo] = useState(getTodayInputDate);
|
|
2857
|
+
const [range, setRange] = useState({ from: draftFrom, to: draftTo });
|
|
2858
|
+
const report = useQuery({
|
|
2859
|
+
queryKey: ["affiliate", "distribution-report", range],
|
|
2860
|
+
queryFn: () => getAffiliateDistributionReports(range)
|
|
2861
|
+
});
|
|
2862
|
+
const submit = (event) => {
|
|
2863
|
+
event.preventDefault();
|
|
2864
|
+
setRange({ from: draftFrom, to: draftTo });
|
|
2865
|
+
};
|
|
2866
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid gap-5", children: [
|
|
2867
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2868
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Affiliate-Vertriebsreport" }),
|
|
2869
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Stationäre Kommissionsverkäufe und vermittelte Webshopumsätze getrennt auswerten." })
|
|
2870
|
+
] }),
|
|
2871
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: submit, className: "flex flex-wrap items-end gap-3", children: [
|
|
2872
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
2873
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "distribution-report-from", children: "Von" }),
|
|
2874
|
+
/* @__PURE__ */ jsx(
|
|
2875
|
+
Input,
|
|
2876
|
+
{
|
|
2877
|
+
id: "distribution-report-from",
|
|
2878
|
+
type: "date",
|
|
2879
|
+
value: draftFrom,
|
|
2880
|
+
onChange: (event) => setDraftFrom(event.target.value)
|
|
2881
|
+
}
|
|
2882
|
+
)
|
|
2883
|
+
] }),
|
|
2884
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
2885
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "distribution-report-to", children: "Bis" }),
|
|
2886
|
+
/* @__PURE__ */ jsx(
|
|
2887
|
+
Input,
|
|
2888
|
+
{
|
|
2889
|
+
id: "distribution-report-to",
|
|
2890
|
+
type: "date",
|
|
2891
|
+
value: draftTo,
|
|
2892
|
+
onChange: (event) => setDraftTo(event.target.value)
|
|
2893
|
+
}
|
|
2894
|
+
)
|
|
2895
|
+
] }),
|
|
2896
|
+
/* @__PURE__ */ jsx(Button, { type: "submit", children: "Aktualisieren" })
|
|
2897
|
+
] }),
|
|
2898
|
+
report.isLoading ? /* @__PURE__ */ jsx(Text, { children: "Report wird geladen …" }) : report.isError ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: getErrorMessage(report.error) }) : !report.data?.affiliate_distribution_reports.length ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Keine Affiliates gefunden." }) : /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left text-sm", children: [
|
|
2899
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b", children: [
|
|
2900
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Affiliate" }),
|
|
2901
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Stationär" }),
|
|
2902
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Webshop" }),
|
|
2903
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Web-Provision" }),
|
|
2904
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Bestand" }),
|
|
2905
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Letzte Meldung" }),
|
|
2906
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Letzter Verkauf" }),
|
|
2907
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Inaktiv" }),
|
|
2908
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Offen / überfällig" })
|
|
2909
|
+
] }) }),
|
|
2910
|
+
/* @__PURE__ */ jsx("tbody", { children: report.data.affiliate_distribution_reports.map((row) => {
|
|
2911
|
+
return /* @__PURE__ */ jsxs(
|
|
2912
|
+
"tr",
|
|
2913
|
+
{
|
|
2914
|
+
className: row.inactive_months >= 4 ? "bg-ui-bg-error border-b" : "border-b",
|
|
2915
|
+
children: [
|
|
2916
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: row.display_name }),
|
|
2917
|
+
/* @__PURE__ */ jsxs("td", { className: "p-2", children: [
|
|
2918
|
+
formatCurrencyTotals(
|
|
2919
|
+
row.currency_totals.map((total) => ({
|
|
2920
|
+
currency_code: total.currency_code,
|
|
2921
|
+
amount: total.consignment_sales_amount
|
|
2922
|
+
}))
|
|
2923
|
+
),
|
|
2924
|
+
/* @__PURE__ */ jsxs(Text, { size: "xsmall", className: "text-ui-fg-subtle", children: [
|
|
2925
|
+
row.consignment_sales_quantity,
|
|
2926
|
+
" Stück"
|
|
2927
|
+
] })
|
|
2928
|
+
] }),
|
|
2929
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: formatCurrencyTotals(
|
|
2930
|
+
row.currency_totals.map((total) => ({
|
|
2931
|
+
currency_code: total.currency_code,
|
|
2932
|
+
amount: total.affiliate_web_sales_amount
|
|
2933
|
+
}))
|
|
2934
|
+
) }),
|
|
2935
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: formatCurrencyTotals(
|
|
2936
|
+
row.currency_totals.map((total) => ({
|
|
2937
|
+
currency_code: total.currency_code,
|
|
2938
|
+
amount: total.affiliate_web_commission_amount
|
|
2939
|
+
}))
|
|
2940
|
+
) }),
|
|
2941
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: row.current_stock_quantity }),
|
|
2942
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: formatDateTime(row.last_reported_at) }),
|
|
2943
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: formatDateTime(row.last_sale_at) }),
|
|
2944
|
+
/* @__PURE__ */ jsxs("td", { className: "p-2", children: [
|
|
2945
|
+
row.inactive_months,
|
|
2946
|
+
" Monate"
|
|
2947
|
+
] }),
|
|
2948
|
+
/* @__PURE__ */ jsxs("td", { className: "p-2", children: [
|
|
2949
|
+
row.open_reports,
|
|
2950
|
+
" / ",
|
|
2951
|
+
row.overdue_reports
|
|
2952
|
+
] })
|
|
2953
|
+
]
|
|
2954
|
+
},
|
|
2955
|
+
row.affiliate_id
|
|
2956
|
+
);
|
|
2957
|
+
}) })
|
|
2958
|
+
] }) })
|
|
2959
|
+
] });
|
|
2960
|
+
}
|
|
2961
|
+
const AffiliateDistributionReportRoute = () => /* @__PURE__ */ jsx(AffiliateDistributionReportPage, {});
|
|
2962
|
+
const config$4 = defineRouteConfig({
|
|
2963
|
+
label: "Vertriebsreport",
|
|
2964
|
+
rank: 85
|
|
2965
|
+
});
|
|
2966
|
+
function ConsignmentReportsPage() {
|
|
2967
|
+
const reports = useQuery({
|
|
2968
|
+
queryKey: ["affiliate", "consignment-reports"],
|
|
2969
|
+
queryFn: () => listAdminConsignmentReports({ limit: 100, offset: 0 })
|
|
2970
|
+
});
|
|
2971
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid gap-5", children: [
|
|
2972
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
2973
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Kommissions-Monatsmeldungen" }),
|
|
2974
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Eingereichte Inventuren prüfen und abrechnen." })
|
|
2975
|
+
] }),
|
|
2976
|
+
reports.isLoading ? /* @__PURE__ */ jsx(Text, { children: "Monatsmeldungen werden geladen …" }) : reports.isError ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: getErrorMessage(reports.error) }) : !reports.data?.reports.length ? /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: "Keine Monatsmeldungen vorhanden." }) : /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left text-sm", children: [
|
|
2977
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b", children: [
|
|
2978
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Affiliate" }),
|
|
2979
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Zeitraum" }),
|
|
2980
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Status" }),
|
|
2981
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Abweichungen" }),
|
|
2982
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Draft / Order" }),
|
|
2983
|
+
/* @__PURE__ */ jsx("th", { className: "p-2" })
|
|
2984
|
+
] }) }),
|
|
2985
|
+
/* @__PURE__ */ jsx("tbody", { children: reports.data.reports.map((report) => /* @__PURE__ */ jsxs("tr", { className: "border-b", children: [
|
|
2986
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: report.affiliate_id }),
|
|
2987
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: formatDate(report.period_start) }),
|
|
2988
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: report.status }),
|
|
2989
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: report.lines.filter(
|
|
2990
|
+
(line) => line.requires_admin_clarification || line.expected_quantity !== line.counted_quantity
|
|
2991
|
+
).length }),
|
|
2992
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: report.order_id ?? report.draft_order_id ?? "–" }),
|
|
2993
|
+
/* @__PURE__ */ jsx("td", { className: "p-2 text-right", children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(
|
|
2994
|
+
Link,
|
|
2995
|
+
{
|
|
2996
|
+
to: `/affiliates/consignment-reports/${report.id}`,
|
|
2997
|
+
children: "Prüfen"
|
|
2998
|
+
}
|
|
2999
|
+
) }) })
|
|
3000
|
+
] }, report.id)) })
|
|
3001
|
+
] }) })
|
|
3002
|
+
] });
|
|
3003
|
+
}
|
|
3004
|
+
const ConsignmentReportsRoute = () => /* @__PURE__ */ jsx(ConsignmentReportsPage, {});
|
|
3005
|
+
const config$3 = defineRouteConfig({
|
|
3006
|
+
label: "Kommissionsmeldungen",
|
|
3007
|
+
rank: 83
|
|
3008
|
+
});
|
|
3009
|
+
const NewAffiliateRoute = () => /* @__PURE__ */ jsx(AffiliateFormPage, { mode: "create" });
|
|
3010
|
+
const config$2 = defineRouteConfig({
|
|
3011
|
+
label: texts.routes.newAffiliate
|
|
3012
|
+
});
|
|
3013
|
+
const useAffiliateReportOverview = (params) => useQuery({
|
|
3014
|
+
queryKey: affiliateKeys.reportOverview(params),
|
|
3015
|
+
queryFn: () => getAffiliateReportOverview(params)
|
|
3016
|
+
});
|
|
3017
|
+
const useAffiliateReportDetail = (affiliateId, params) => useQuery({
|
|
3018
|
+
queryKey: affiliateKeys.reportDetail(affiliateId, params),
|
|
3019
|
+
enabled: !!affiliateId,
|
|
3020
|
+
queryFn: () => getAffiliateReportDetail(affiliateId ?? "", params)
|
|
3021
|
+
});
|
|
3022
|
+
const AffiliateReportsPage = () => {
|
|
3023
|
+
const [from, setFrom] = useState(getMonthStartInputDate);
|
|
3024
|
+
const [to, setTo] = useState(getTodayInputDate);
|
|
3025
|
+
const reportQuery = useAffiliateReportOverview({ from, to });
|
|
3026
|
+
const affiliates = reportQuery.data?.report.affiliates ?? [];
|
|
3027
|
+
const renderBody = () => {
|
|
3028
|
+
if (reportQuery.isLoading) {
|
|
3029
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.reports.loading }) });
|
|
3030
|
+
}
|
|
3031
|
+
if (reportQuery.isError) {
|
|
3032
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.reports.loadError(getErrorMessage(reportQuery.error)) }) });
|
|
3033
|
+
}
|
|
3034
|
+
if (!affiliates.length) {
|
|
3035
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.reports.empty }) });
|
|
3036
|
+
}
|
|
3037
|
+
return /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left text-sm", children: [
|
|
3038
|
+
/* @__PURE__ */ jsx("thead", { className: "border-ui-border-base border-b", children: /* @__PURE__ */ jsxs("tr", { className: "text-ui-fg-subtle", children: [
|
|
3039
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.reports.columns.affiliate }),
|
|
3040
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.reports.columns.status }),
|
|
3041
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: /* @__PURE__ */ jsx(Tooltip, { content: texts.reports.orderValueTooltip, children: /* @__PURE__ */ jsx("button", { type: "button", className: "decoration-ui-fg-subtle underline decoration-dotted underline-offset-2", children: texts.reports.columns.orderValue }) }) }),
|
|
3042
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.reports.columns.commission }),
|
|
3043
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.reports.columns.orderCount }),
|
|
3044
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.reports.columns.action })
|
|
3045
|
+
] }) }),
|
|
3046
|
+
/* @__PURE__ */ jsx("tbody", { children: affiliates.map((affiliate) => /* @__PURE__ */ jsxs("tr", { className: "border-ui-border-base border-b", children: [
|
|
3047
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 font-medium", children: affiliate.display_name }),
|
|
3048
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 capitalize", children: formatStatus(affiliate.status) }),
|
|
3049
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 text-right tabular-nums", children: formatAmount(affiliate.order_value_amount, affiliate.currency_code) }),
|
|
3050
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 text-right font-medium tabular-nums", children: formatAmount(affiliate.commission_amount, affiliate.currency_code) }),
|
|
3051
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 text-right tabular-nums", children: affiliate.order_count }),
|
|
3052
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 text-right", children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: `/affiliates/reports/${affiliate.affiliate_id}?from=${from}&to=${to}`, children: texts.reports.details }) }) })
|
|
3053
|
+
] }, `${affiliate.affiliate_id}-${affiliate.currency_code}`)) })
|
|
3054
|
+
] }) });
|
|
3055
|
+
};
|
|
3056
|
+
return /* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
3057
|
+
/* @__PURE__ */ jsxs("div", { className: "px-6 py-4", children: [
|
|
3058
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: texts.reports.heading }),
|
|
3059
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.reports.description })
|
|
3060
|
+
] }),
|
|
3061
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 px-6 py-4 md:grid-cols-[180px_180px_auto]", children: [
|
|
3062
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3063
|
+
/* @__PURE__ */ jsx(Label, { children: texts.reports.from }),
|
|
3064
|
+
/* @__PURE__ */ jsx(Input, { type: "date", value: from, onChange: (event) => setFrom(event.target.value) })
|
|
3065
|
+
] }),
|
|
3066
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3067
|
+
/* @__PURE__ */ jsx(Label, { children: texts.reports.to }),
|
|
3068
|
+
/* @__PURE__ */ jsx(Input, { type: "date", value: to, onChange: (event) => setTo(event.target.value) })
|
|
3069
|
+
] })
|
|
3070
|
+
] }),
|
|
3071
|
+
renderBody()
|
|
3072
|
+
] });
|
|
3073
|
+
};
|
|
3074
|
+
const AffiliateReportsRoute = () => /* @__PURE__ */ jsx(AffiliateReportsPage, {});
|
|
3075
|
+
const config$1 = defineRouteConfig({
|
|
3076
|
+
label: texts.routes.reports,
|
|
3077
|
+
rank: 82
|
|
3078
|
+
});
|
|
3079
|
+
function AffiliateProgramSettingsPage() {
|
|
3080
|
+
const queryClient = useQueryClient();
|
|
3081
|
+
const settings = useQuery({
|
|
3082
|
+
queryKey: ["affiliate", "program-settings"],
|
|
3083
|
+
queryFn: getAffiliateProgramSettings
|
|
3084
|
+
});
|
|
3085
|
+
const [commissionBase, setCommissionBase] = useState("after_discounts");
|
|
3086
|
+
const [referrerBase, setReferrerBase] = useState("order_base");
|
|
3087
|
+
const [stacking, setStacking] = useState(
|
|
3088
|
+
"allow_stacking"
|
|
3089
|
+
);
|
|
3090
|
+
const [discount, setDiscount] = useState(5);
|
|
3091
|
+
const [referralOverwritePolicy, setReferralOverwritePolicy] = useState("first_touch");
|
|
3092
|
+
const [referralWindowDays, setReferralWindowDays] = useState(30);
|
|
3093
|
+
useEffect(() => {
|
|
3094
|
+
const value = settings.data?.settings;
|
|
3095
|
+
if (!value) return;
|
|
3096
|
+
setCommissionBase(value.commission_base);
|
|
3097
|
+
setReferrerBase(value.referrer_base);
|
|
3098
|
+
setStacking(value.promotion_stacking);
|
|
3099
|
+
setDiscount(value.default_customer_discount_rate);
|
|
3100
|
+
setReferralOverwritePolicy(value.referral_overwrite_policy);
|
|
3101
|
+
setReferralWindowDays(value.referral_window_days);
|
|
3102
|
+
}, [settings.data]);
|
|
3103
|
+
const update = useMutation({
|
|
3104
|
+
mutationFn: () => {
|
|
3105
|
+
const current = settings.data?.settings;
|
|
3106
|
+
if (!current) throw new Error("Programmeinstellungen fehlen.");
|
|
3107
|
+
return updateAffiliateProgramSettings({
|
|
3108
|
+
expected_version: current.policy_version,
|
|
3109
|
+
commission_base: commissionBase,
|
|
3110
|
+
referrer_base: referrerBase,
|
|
3111
|
+
promotion_stacking: stacking,
|
|
3112
|
+
default_customer_discount_rate: discount,
|
|
3113
|
+
referral_overwrite_policy: referralOverwritePolicy,
|
|
3114
|
+
referral_window_days: referralWindowDays
|
|
3115
|
+
});
|
|
3116
|
+
},
|
|
3117
|
+
onSuccess: async (data) => {
|
|
3118
|
+
queryClient.setQueryData(["affiliate", "program-settings"], data);
|
|
3119
|
+
toast.success("Programmeinstellungen wurden gespeichert.");
|
|
3120
|
+
},
|
|
3121
|
+
onError: (error) => toast.error("Programmeinstellungen konnten nicht gespeichert werden.", {
|
|
3122
|
+
description: getErrorMessage(error)
|
|
3123
|
+
})
|
|
3124
|
+
});
|
|
3125
|
+
const submit = (event) => {
|
|
3126
|
+
event.preventDefault();
|
|
3127
|
+
update.mutate();
|
|
3128
|
+
};
|
|
3129
|
+
if (settings.isLoading) {
|
|
3130
|
+
return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Text, { children: "Einstellungen werden geladen …" }) });
|
|
3131
|
+
}
|
|
3132
|
+
if (settings.isError || !settings.data) {
|
|
3133
|
+
return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: getErrorMessage(settings.error) }) });
|
|
3134
|
+
}
|
|
3135
|
+
const previewOrderBase = commissionBase === "before_discounts" ? 100 : 90;
|
|
3136
|
+
const previewDirect = previewOrderBase * 0.1;
|
|
3137
|
+
const previewReferrerBase = referrerBase === "order_base" ? previewOrderBase : previewOrderBase - previewDirect;
|
|
3138
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid gap-5", children: [
|
|
3139
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3140
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Affiliate-Programmeinstellungen" }),
|
|
3141
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle", children: [
|
|
3142
|
+
"Globale Berechnungs- und Rabattstrategie · Version",
|
|
3143
|
+
" ",
|
|
3144
|
+
settings.data.settings.policy_version
|
|
3145
|
+
] })
|
|
3146
|
+
] }),
|
|
3147
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: submit, className: "grid gap-5", children: [
|
|
3148
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
3149
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3150
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "commission-base", children: "Provisionsbasis" }),
|
|
3151
|
+
/* @__PURE__ */ jsxs(
|
|
3152
|
+
"select",
|
|
3153
|
+
{
|
|
3154
|
+
id: "commission-base",
|
|
3155
|
+
className: "bg-ui-bg-field border-ui-border-base rounded-md border px-3 py-2 text-sm",
|
|
3156
|
+
value: commissionBase,
|
|
3157
|
+
onChange: (event) => setCommissionBase(
|
|
3158
|
+
event.target.value
|
|
3159
|
+
),
|
|
3160
|
+
children: [
|
|
3161
|
+
/* @__PURE__ */ jsx("option", { value: "before_discounts", children: "Vor Rabatten" }),
|
|
3162
|
+
/* @__PURE__ */ jsx("option", { value: "after_discounts", children: "Nach Rabatten" })
|
|
3163
|
+
]
|
|
3164
|
+
}
|
|
3165
|
+
)
|
|
3166
|
+
] }),
|
|
3167
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3168
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "referral-overwrite-policy", children: "Referral-Regel" }),
|
|
3169
|
+
/* @__PURE__ */ jsxs(
|
|
3170
|
+
Select,
|
|
3171
|
+
{
|
|
3172
|
+
value: referralOverwritePolicy,
|
|
3173
|
+
onValueChange: (value) => setReferralOverwritePolicy(value),
|
|
3174
|
+
children: [
|
|
3175
|
+
/* @__PURE__ */ jsx(Select.Trigger, { id: "referral-overwrite-policy", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
3176
|
+
/* @__PURE__ */ jsxs(Select.Content, { children: [
|
|
3177
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "first_touch", children: "First Touch" }),
|
|
3178
|
+
/* @__PURE__ */ jsx(Select.Item, { value: "last_touch", children: "Last Touch" })
|
|
3179
|
+
] })
|
|
3180
|
+
]
|
|
3181
|
+
}
|
|
3182
|
+
),
|
|
3183
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-xs", children: referralOverwritePolicy === "first_touch" ? "First Touch: Beispiel A-Link, danach B-Coupon; A bleibt." : "Last Touch: Beispiel A-Link, danach B-Coupon; B ersetzt A." })
|
|
3184
|
+
] }),
|
|
3185
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3186
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "referral-window-days", children: "Referral-Frist in Tagen" }),
|
|
3187
|
+
/* @__PURE__ */ jsx(
|
|
3188
|
+
Input,
|
|
3189
|
+
{
|
|
3190
|
+
id: "referral-window-days",
|
|
3191
|
+
type: "number",
|
|
3192
|
+
min: 1,
|
|
3193
|
+
step: 1,
|
|
3194
|
+
required: true,
|
|
3195
|
+
value: referralWindowDays,
|
|
3196
|
+
onChange: (event) => setReferralWindowDays(Number(event.target.value))
|
|
3197
|
+
}
|
|
3198
|
+
),
|
|
3199
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-xs", children: "Referral-Signale können innerhalb dieser positiven Frist ersetzt werden." })
|
|
3200
|
+
] }),
|
|
3201
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3202
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "referrer-base", children: "Vermittlerbasis" }),
|
|
3203
|
+
/* @__PURE__ */ jsxs(
|
|
3204
|
+
"select",
|
|
3205
|
+
{
|
|
3206
|
+
id: "referrer-base",
|
|
3207
|
+
className: "bg-ui-bg-field border-ui-border-base rounded-md border px-3 py-2 text-sm",
|
|
3208
|
+
value: referrerBase,
|
|
3209
|
+
onChange: (event) => setReferrerBase(event.target.value),
|
|
3210
|
+
children: [
|
|
3211
|
+
/* @__PURE__ */ jsx("option", { value: "order_base", children: "Order-Basis" }),
|
|
3212
|
+
/* @__PURE__ */ jsx("option", { value: "after_direct_commission", children: "Nach direkter Provision" })
|
|
3213
|
+
]
|
|
3214
|
+
}
|
|
3215
|
+
)
|
|
3216
|
+
] }),
|
|
3217
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3218
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "promotion-stacking", children: "Promotion-Kombination" }),
|
|
3219
|
+
/* @__PURE__ */ jsxs(
|
|
3220
|
+
"select",
|
|
3221
|
+
{
|
|
3222
|
+
id: "promotion-stacking",
|
|
3223
|
+
className: "bg-ui-bg-field border-ui-border-base rounded-md border px-3 py-2 text-sm",
|
|
3224
|
+
value: stacking,
|
|
3225
|
+
onChange: (event) => setStacking(event.target.value),
|
|
3226
|
+
children: [
|
|
3227
|
+
/* @__PURE__ */ jsx("option", { value: "allow_stacking", children: "Kombination erlauben" }),
|
|
3228
|
+
/* @__PURE__ */ jsx("option", { value: "exclusive", children: "Exklusiv" })
|
|
3229
|
+
]
|
|
3230
|
+
}
|
|
3231
|
+
)
|
|
3232
|
+
] }),
|
|
3233
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3234
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "default-customer-discount", children: "Standard-Kundenrabatt %" }),
|
|
3235
|
+
/* @__PURE__ */ jsx(
|
|
3236
|
+
Input,
|
|
3237
|
+
{
|
|
3238
|
+
id: "default-customer-discount",
|
|
3239
|
+
type: "number",
|
|
3240
|
+
min: 0,
|
|
3241
|
+
max: 100,
|
|
3242
|
+
step: "0.01",
|
|
3243
|
+
value: discount,
|
|
3244
|
+
onChange: (event) => setDiscount(Number(event.target.value))
|
|
3245
|
+
}
|
|
3246
|
+
)
|
|
3247
|
+
] })
|
|
3248
|
+
] }),
|
|
3249
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle", children: [
|
|
3250
|
+
"Vorschau bei 100 € Warenwert, 10 € Rabatt und 10 % Provision: Affiliate-Basis ",
|
|
3251
|
+
previewOrderBase.toFixed(2),
|
|
3252
|
+
" €, direkte Provision",
|
|
3253
|
+
" ",
|
|
3254
|
+
previewDirect.toFixed(2),
|
|
3255
|
+
" €, Vermittlerbasis",
|
|
3256
|
+
" ",
|
|
3257
|
+
previewReferrerBase.toFixed(2),
|
|
3258
|
+
" €."
|
|
3259
|
+
] }),
|
|
3260
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: update.isPending, children: update.isPending ? "Wird gespeichert …" : "Speichern" }) })
|
|
3261
|
+
] })
|
|
3262
|
+
] });
|
|
3263
|
+
}
|
|
3264
|
+
const AffiliateProgramSettingsRoute = () => /* @__PURE__ */ jsx(AffiliateProgramSettingsPage, {});
|
|
3265
|
+
const config = defineRouteConfig({
|
|
3266
|
+
label: "Affiliate-Einstellungen",
|
|
3267
|
+
rank: 84
|
|
3268
|
+
});
|
|
3269
|
+
function ConsignmentReportReviewPage({
|
|
3270
|
+
reportId
|
|
3271
|
+
}) {
|
|
3272
|
+
const queryClient = useQueryClient();
|
|
3273
|
+
const [lines, setLines] = useState({});
|
|
3274
|
+
const [adminNotes, setAdminNotes] = useState("");
|
|
3275
|
+
const queryKey = ["affiliate", "consignment-report", reportId];
|
|
3276
|
+
const report = useQuery({
|
|
3277
|
+
queryKey,
|
|
3278
|
+
enabled: Boolean(reportId),
|
|
3279
|
+
queryFn: () => retrieveAdminConsignmentReport(reportId ?? "")
|
|
3280
|
+
});
|
|
3281
|
+
useEffect(() => {
|
|
3282
|
+
const current2 = report.data?.report;
|
|
3283
|
+
if (!current2) return;
|
|
3284
|
+
setLines(
|
|
3285
|
+
Object.fromEntries(
|
|
3286
|
+
current2.lines.map((line) => [
|
|
3287
|
+
line.id,
|
|
3288
|
+
{
|
|
3289
|
+
quantity: line.confirmed_sale_quantity,
|
|
3290
|
+
reason: line.non_sale_reason ?? ""
|
|
3291
|
+
}
|
|
3292
|
+
])
|
|
3293
|
+
)
|
|
3294
|
+
);
|
|
3295
|
+
}, [report.data]);
|
|
3296
|
+
const approve = useMutation({
|
|
3297
|
+
mutationFn: (current2) => approveAdminConsignmentReport(current2.id, {
|
|
3298
|
+
expected_version: current2.version,
|
|
3299
|
+
confirmed_lines: current2.lines.map((line) => ({
|
|
3300
|
+
report_line_id: line.id,
|
|
3301
|
+
confirmed_sale_quantity: lines[line.id]?.quantity ?? line.confirmed_sale_quantity,
|
|
3302
|
+
non_sale_reason: lines[line.id]?.reason || null
|
|
3303
|
+
}))
|
|
3304
|
+
}),
|
|
3305
|
+
onSuccess: async () => {
|
|
3306
|
+
toast.success("Monatsmeldung wurde freigegeben.");
|
|
3307
|
+
await queryClient.invalidateQueries({ queryKey });
|
|
3308
|
+
await queryClient.invalidateQueries({
|
|
3309
|
+
queryKey: ["affiliate", "consignment-reports"]
|
|
3310
|
+
});
|
|
3311
|
+
},
|
|
3312
|
+
onError: (error) => toast.error("Freigabe fehlgeschlagen.", {
|
|
3313
|
+
description: getErrorMessage(error)
|
|
3314
|
+
})
|
|
3315
|
+
});
|
|
3316
|
+
const reject = useMutation({
|
|
3317
|
+
mutationFn: (current2) => rejectAdminConsignmentReport(current2.id, { admin_notes: adminNotes }),
|
|
3318
|
+
onSuccess: async () => {
|
|
3319
|
+
toast.success("Monatsmeldung wurde abgelehnt.");
|
|
3320
|
+
await queryClient.invalidateQueries({ queryKey });
|
|
3321
|
+
},
|
|
3322
|
+
onError: (error) => toast.error("Ablehnung fehlgeschlagen.", {
|
|
3323
|
+
description: getErrorMessage(error)
|
|
3324
|
+
})
|
|
3325
|
+
});
|
|
3326
|
+
if (!reportId) {
|
|
3327
|
+
return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Text, { children: "Report-ID fehlt." }) });
|
|
3328
|
+
}
|
|
3329
|
+
if (report.isLoading) {
|
|
3330
|
+
return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Text, { children: "Monatsmeldung wird geladen …" }) });
|
|
3331
|
+
}
|
|
3332
|
+
if (report.isError || !report.data) {
|
|
3333
|
+
return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-error", children: getErrorMessage(report.error) }) });
|
|
3334
|
+
}
|
|
3335
|
+
const current = report.data.report;
|
|
3336
|
+
return /* @__PURE__ */ jsxs(Container, { className: "grid gap-5", children: [
|
|
3337
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-4", children: [
|
|
3338
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
3339
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: "Monatsmeldung prüfen" }),
|
|
3340
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle", children: [
|
|
3341
|
+
formatDate(current.period_start),
|
|
3342
|
+
" · ",
|
|
3343
|
+
current.status,
|
|
3344
|
+
" · Version",
|
|
3345
|
+
" ",
|
|
3346
|
+
current.version
|
|
3347
|
+
] })
|
|
3348
|
+
] }),
|
|
3349
|
+
/* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, children: /* @__PURE__ */ jsx(Link, { to: "/affiliates/consignment-reports", children: "Zur Liste" }) })
|
|
3350
|
+
] }),
|
|
3351
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left text-sm", children: [
|
|
3352
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b", children: [
|
|
3353
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Artikel / Charge" }),
|
|
3354
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Erwartet" }),
|
|
3355
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Gezählt" }),
|
|
3356
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Vorschlag" }),
|
|
3357
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Abrechenbar" }),
|
|
3358
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Nicht-Verkaufsmenge" }),
|
|
3359
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Nicht-Verkauf" }),
|
|
3360
|
+
/* @__PURE__ */ jsx("th", { className: "p-2", children: "Betrag" })
|
|
3361
|
+
] }) }),
|
|
3362
|
+
/* @__PURE__ */ jsx("tbody", { children: current.lines.map((line) => /* @__PURE__ */ jsxs("tr", { className: "border-b", children: [
|
|
3363
|
+
/* @__PURE__ */ jsxs("td", { className: "p-2", children: [
|
|
3364
|
+
line.inventory_item_id,
|
|
3365
|
+
/* @__PURE__ */ jsx(Text, { size: "xsmall", className: "text-ui-fg-subtle", children: line.batch_id ?? "ohne Charge" })
|
|
3366
|
+
] }),
|
|
3367
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: line.expected_quantity }),
|
|
3368
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: line.counted_quantity }),
|
|
3369
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: line.proposed_sale_quantity }),
|
|
3370
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: /* @__PURE__ */ jsx(
|
|
3371
|
+
Input,
|
|
3372
|
+
{
|
|
3373
|
+
type: "number",
|
|
3374
|
+
min: 0,
|
|
3375
|
+
step: 1,
|
|
3376
|
+
value: lines[line.id]?.quantity ?? 0,
|
|
3377
|
+
onChange: (event) => setLines((value) => ({
|
|
3378
|
+
...value,
|
|
3379
|
+
[line.id]: {
|
|
3380
|
+
...value[line.id] ?? { reason: "" },
|
|
3381
|
+
quantity: Number(event.target.value)
|
|
3382
|
+
}
|
|
3383
|
+
}))
|
|
3384
|
+
}
|
|
3385
|
+
) }),
|
|
3386
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: Math.max(
|
|
3387
|
+
0,
|
|
3388
|
+
line.proposed_sale_quantity - (lines[line.id]?.quantity ?? 0)
|
|
3389
|
+
) }),
|
|
3390
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: /* @__PURE__ */ jsxs(
|
|
3391
|
+
"select",
|
|
3392
|
+
{
|
|
3393
|
+
className: "bg-ui-bg-field border-ui-border-base rounded-md border px-2 py-2",
|
|
3394
|
+
value: lines[line.id]?.reason ?? "",
|
|
3395
|
+
onChange: (event) => setLines((value) => ({
|
|
3396
|
+
...value,
|
|
3397
|
+
[line.id]: {
|
|
3398
|
+
...value[line.id] ?? { quantity: 0 },
|
|
3399
|
+
reason: event.target.value
|
|
3400
|
+
}
|
|
3401
|
+
})),
|
|
3402
|
+
children: [
|
|
3403
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Verkauf" }),
|
|
3404
|
+
/* @__PURE__ */ jsx("option", { value: "damaged", children: "Beschädigt" }),
|
|
3405
|
+
/* @__PURE__ */ jsx("option", { value: "expired", children: "Abgelaufen" }),
|
|
3406
|
+
/* @__PURE__ */ jsx("option", { value: "returned", children: "Retourniert" }),
|
|
3407
|
+
/* @__PURE__ */ jsx("option", { value: "correction", children: "Korrektur" })
|
|
3408
|
+
]
|
|
3409
|
+
}
|
|
3410
|
+
) }),
|
|
3411
|
+
/* @__PURE__ */ jsx("td", { className: "p-2", children: line.currency_code ? formatAmount(
|
|
3412
|
+
(lines[line.id]?.quantity ?? 0) * (line.discounted_line_total != null && line.proposed_sale_quantity > 0 ? line.discounted_line_total / line.proposed_sale_quantity : line.unit_price_snapshot ?? 0),
|
|
3413
|
+
line.currency_code
|
|
3414
|
+
) : "–" })
|
|
3415
|
+
] }, line.id)) })
|
|
3416
|
+
] }) }),
|
|
3417
|
+
current.status === "submitted" ? /* @__PURE__ */ jsxs("div", { className: "grid gap-4", children: [
|
|
3418
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
3419
|
+
Button,
|
|
3420
|
+
{
|
|
3421
|
+
onClick: () => approve.mutate(current),
|
|
3422
|
+
disabled: approve.isPending,
|
|
3423
|
+
children: approve.isPending ? "Wird freigegeben …" : "Freigeben"
|
|
3424
|
+
}
|
|
3425
|
+
) }),
|
|
3426
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3427
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "consignment-reject-notes", children: "Begründung für Ablehnung" }),
|
|
3428
|
+
/* @__PURE__ */ jsx(
|
|
3429
|
+
Textarea,
|
|
3430
|
+
{
|
|
3431
|
+
id: "consignment-reject-notes",
|
|
3432
|
+
value: adminNotes,
|
|
3433
|
+
onChange: (event) => setAdminNotes(event.target.value)
|
|
3434
|
+
}
|
|
3435
|
+
),
|
|
3436
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
3437
|
+
Button,
|
|
3438
|
+
{
|
|
3439
|
+
variant: "danger",
|
|
3440
|
+
onClick: () => reject.mutate(current),
|
|
3441
|
+
disabled: !adminNotes.trim() || reject.isPending,
|
|
3442
|
+
children: reject.isPending ? "Wird abgelehnt …" : "Ablehnen"
|
|
3443
|
+
}
|
|
3444
|
+
) })
|
|
3445
|
+
] })
|
|
3446
|
+
] }) : null
|
|
3447
|
+
] });
|
|
3448
|
+
}
|
|
3449
|
+
const ConsignmentReportReviewRoute = () => {
|
|
3450
|
+
const { id } = useParams();
|
|
3451
|
+
return /* @__PURE__ */ jsx(ConsignmentReportReviewPage, { reportId: id });
|
|
3452
|
+
};
|
|
3453
|
+
const REPORT_ENTRIES_PAGE_SIZE = 100;
|
|
3454
|
+
const AffiliateReportDetailPage = ({
|
|
3455
|
+
affiliateId
|
|
3456
|
+
}) => {
|
|
3457
|
+
const [searchParams] = useSearchParams();
|
|
3458
|
+
const [from, setFrom] = useState(
|
|
3459
|
+
() => searchParams.get("from") ?? getMonthStartInputDate()
|
|
3460
|
+
);
|
|
3461
|
+
const [to, setTo] = useState(
|
|
3462
|
+
() => searchParams.get("to") ?? getTodayInputDate()
|
|
3463
|
+
);
|
|
3464
|
+
const [offset, setOffset] = useState(0);
|
|
3465
|
+
const reportQuery = useAffiliateReportDetail(affiliateId, {
|
|
3466
|
+
from,
|
|
3467
|
+
to,
|
|
3468
|
+
limit: REPORT_ENTRIES_PAGE_SIZE,
|
|
3469
|
+
offset
|
|
3470
|
+
});
|
|
3471
|
+
const report = reportQuery.data?.report;
|
|
3472
|
+
const entries = report?.entries ?? [];
|
|
3473
|
+
const entriesCount = report?.entries_count ?? 0;
|
|
3474
|
+
const handleFromChange = (value) => {
|
|
3475
|
+
setFrom(value);
|
|
3476
|
+
setOffset(0);
|
|
3477
|
+
};
|
|
3478
|
+
const handleToChange = (value) => {
|
|
3479
|
+
setTo(value);
|
|
3480
|
+
setOffset(0);
|
|
3481
|
+
};
|
|
3482
|
+
const showPagination = !reportQuery.isLoading && !reportQuery.isError && entriesCount > 0;
|
|
3483
|
+
const renderEntries = () => {
|
|
3484
|
+
if (reportQuery.isLoading) {
|
|
3485
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.reportDetail.loading }) });
|
|
3486
|
+
}
|
|
3487
|
+
if (reportQuery.isError) {
|
|
3488
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.reportDetail.loadError(getErrorMessage(reportQuery.error)) }) });
|
|
3489
|
+
}
|
|
3490
|
+
if (!entries.length) {
|
|
3491
|
+
return /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.reportDetail.empty }) });
|
|
3492
|
+
}
|
|
3493
|
+
return /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-left text-sm", children: [
|
|
3494
|
+
/* @__PURE__ */ jsx("thead", { className: "border-ui-border-base border-b", children: /* @__PURE__ */ jsxs("tr", { className: "text-ui-fg-subtle", children: [
|
|
3495
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.reportDetail.columns.occurredAt }),
|
|
3496
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.reportDetail.columns.type }),
|
|
3497
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.reportDetail.columns.order }),
|
|
3498
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 font-medium", children: texts.reportDetail.columns.customer }),
|
|
3499
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.reportDetail.columns.base }),
|
|
3500
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.reportDetail.columns.rate }),
|
|
3501
|
+
/* @__PURE__ */ jsx("th", { className: "px-6 py-3 text-right font-medium", children: texts.reportDetail.columns.commission })
|
|
3502
|
+
] }) }),
|
|
3503
|
+
/* @__PURE__ */ jsx("tbody", { children: entries.map((entry) => /* @__PURE__ */ jsxs("tr", { className: "border-ui-border-base border-b", children: [
|
|
3504
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3", children: formatDateTime(entry.occurred_at) }),
|
|
3505
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3", children: formatCommissionEntryType(entry.type) }),
|
|
3506
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3", children: entry.order_id ? /* @__PURE__ */ jsx(
|
|
3507
|
+
Link,
|
|
3508
|
+
{
|
|
3509
|
+
to: `/orders/${entry.order_id}`,
|
|
3510
|
+
className: "text-ui-fg-interactive hover:underline",
|
|
3511
|
+
children: entry.order_display_id ? `#${entry.order_display_id}` : texts.reportDetail.viewOrder
|
|
3512
|
+
}
|
|
3513
|
+
) : texts.common.dash }),
|
|
3514
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3", children: entry.customer_id ? /* @__PURE__ */ jsx(
|
|
3515
|
+
Link,
|
|
3516
|
+
{
|
|
3517
|
+
to: `/customers/${entry.customer_id}`,
|
|
3518
|
+
className: "text-ui-fg-interactive hover:underline",
|
|
3519
|
+
children: entry.customer_name ?? texts.common.dash
|
|
3520
|
+
}
|
|
3521
|
+
) : texts.common.dash }),
|
|
3522
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 text-right tabular-nums", children: formatAmount(entry.base_amount_net, entry.currency_code) }),
|
|
3523
|
+
/* @__PURE__ */ jsxs("td", { className: "px-6 py-3 text-right tabular-nums", children: [
|
|
3524
|
+
entry.commission_rate,
|
|
3525
|
+
"%"
|
|
3526
|
+
] }),
|
|
3527
|
+
/* @__PURE__ */ jsx("td", { className: "px-6 py-3 text-right font-medium tabular-nums", children: formatAmount(entry.commission_amount, entry.currency_code) })
|
|
3528
|
+
] }, entry.id)) })
|
|
3529
|
+
] }) });
|
|
3530
|
+
};
|
|
3531
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid gap-6", children: [
|
|
3532
|
+
/* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
3533
|
+
/* @__PURE__ */ jsxs("div", { className: "px-6 py-4", children: [
|
|
3534
|
+
/* @__PURE__ */ jsx(Heading, { level: "h1", children: report?.affiliate.display_name ?? texts.reportDetail.fallbackHeading }),
|
|
3535
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", children: texts.reportDetail.description })
|
|
3536
|
+
] }),
|
|
3537
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 px-6 py-4 md:grid-cols-[180px_180px]", children: [
|
|
3538
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3539
|
+
/* @__PURE__ */ jsx(Label, { children: texts.reportDetail.from }),
|
|
3540
|
+
/* @__PURE__ */ jsx(Input, { type: "date", value: from, onChange: (event) => handleFromChange(event.target.value) })
|
|
3541
|
+
] }),
|
|
3542
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-2", children: [
|
|
3543
|
+
/* @__PURE__ */ jsx(Label, { children: texts.reportDetail.to }),
|
|
3544
|
+
/* @__PURE__ */ jsx(Input, { type: "date", value: to, onChange: (event) => handleToChange(event.target.value) })
|
|
3545
|
+
] })
|
|
3546
|
+
] }),
|
|
3547
|
+
report?.totals.length ? /* @__PURE__ */ jsx("div", { className: "grid gap-3 px-6 py-4 md:grid-cols-3", children: report.totals.map((total) => /* @__PURE__ */ jsxs("div", { className: "border-ui-border-base rounded-md border p-3", children: [
|
|
3548
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle uppercase", children: total.currency_code }),
|
|
3549
|
+
/* @__PURE__ */ jsx(Text, { className: "font-medium", children: formatAmount(total.total_commission_amount, total.currency_code) }),
|
|
3550
|
+
/* @__PURE__ */ jsxs(Text, { className: "text-ui-fg-subtle text-xs", children: [
|
|
3551
|
+
texts.reportDetail.orderValue,
|
|
3552
|
+
": ",
|
|
3553
|
+
formatAmount(total.order_value_amount, total.currency_code)
|
|
3554
|
+
] }),
|
|
3555
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-xs", children: texts.reportDetail.orderCount(total.order_count) }),
|
|
3556
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-xs", children: texts.reportDetail.entryCount(total.entry_count) }),
|
|
3557
|
+
/* @__PURE__ */ jsx(Tooltip, { content: texts.reports.attributedOrdersTooltip, children: /* @__PURE__ */ jsx("button", { type: "button", className: "text-ui-fg-subtle text-left text-xs underline decoration-dotted underline-offset-2", children: texts.reportDetail.attributedOrders(total.attributed_order_count) }) }),
|
|
3558
|
+
/* @__PURE__ */ jsx(Tooltip, { content: texts.reports.commissionedOrdersTooltip, children: /* @__PURE__ */ jsx("button", { type: "button", className: "text-ui-fg-subtle text-left text-xs underline decoration-dotted underline-offset-2", children: texts.reportDetail.commissionedOrders(total.commissioned_order_count) }) })
|
|
3559
|
+
] }, total.currency_code)) }) : null
|
|
3560
|
+
] }),
|
|
3561
|
+
/* @__PURE__ */ jsxs(Container, { className: "divide-y p-0", children: [
|
|
3562
|
+
/* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: /* @__PURE__ */ jsx(Heading, { level: "h2", children: texts.reportDetail.journalEntries }) }),
|
|
3563
|
+
renderEntries(),
|
|
3564
|
+
showPagination ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
|
|
3565
|
+
/* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle text-sm", children: texts.common.pageRange(offset + 1, offset + entries.length, entriesCount) }),
|
|
3566
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
3567
|
+
/* @__PURE__ */ jsx(
|
|
3568
|
+
Button,
|
|
3569
|
+
{
|
|
3570
|
+
size: "small",
|
|
3571
|
+
variant: "secondary",
|
|
3572
|
+
disabled: offset === 0,
|
|
3573
|
+
onClick: () => setOffset((current) => Math.max(0, current - REPORT_ENTRIES_PAGE_SIZE)),
|
|
3574
|
+
children: texts.common.back
|
|
3575
|
+
}
|
|
3576
|
+
),
|
|
3577
|
+
/* @__PURE__ */ jsx(
|
|
3578
|
+
Button,
|
|
3579
|
+
{
|
|
3580
|
+
size: "small",
|
|
3581
|
+
variant: "secondary",
|
|
3582
|
+
disabled: offset + entries.length >= entriesCount,
|
|
3583
|
+
onClick: () => setOffset((current) => current + REPORT_ENTRIES_PAGE_SIZE),
|
|
3584
|
+
children: texts.common.next
|
|
3585
|
+
}
|
|
3586
|
+
)
|
|
3587
|
+
] })
|
|
3588
|
+
] }) : null
|
|
3589
|
+
] })
|
|
3590
|
+
] });
|
|
3591
|
+
};
|
|
3592
|
+
const AffiliateReportDetailRoute = () => {
|
|
3593
|
+
const { id } = useParams();
|
|
3594
|
+
return /* @__PURE__ */ jsx(AffiliateReportDetailPage, { affiliateId: id });
|
|
3595
|
+
};
|
|
3596
|
+
const widgetModule = { widgets: [
|
|
3597
|
+
{
|
|
3598
|
+
Component: CustomerAffiliateWidget,
|
|
3599
|
+
zone: ["customer.details.side.after"],
|
|
3600
|
+
widgetId: "Widget-3af7"
|
|
3601
|
+
},
|
|
3602
|
+
{
|
|
3603
|
+
Component: OrderAffiliateAttributionWidget,
|
|
3604
|
+
zone: ["order.details.side.after"],
|
|
3605
|
+
widgetId: "Widget-52d0"
|
|
3606
|
+
}
|
|
3607
|
+
] };
|
|
3608
|
+
const routeModule = {
|
|
3609
|
+
routes: [
|
|
3610
|
+
{
|
|
3611
|
+
Component: AffiliatesRoute,
|
|
3612
|
+
path: "/affiliates",
|
|
3613
|
+
handle: { label: config$6.label, translationNs: config$6.translationNs }
|
|
3614
|
+
},
|
|
3615
|
+
{
|
|
3616
|
+
Component: AffiliateApplicationsRoute,
|
|
3617
|
+
path: "/affiliates/applications",
|
|
3618
|
+
handle: { label: config$5.label, translationNs: config$5.translationNs }
|
|
3619
|
+
},
|
|
3620
|
+
{
|
|
3621
|
+
Component: AffiliateEditRoute,
|
|
3622
|
+
path: "/affiliates/:id"
|
|
3623
|
+
},
|
|
3624
|
+
{
|
|
3625
|
+
Component: AffiliateDistributionReportRoute,
|
|
3626
|
+
path: "/affiliates/distribution-reports",
|
|
3627
|
+
handle: { label: config$4.label, translationNs: config$4.translationNs }
|
|
3628
|
+
},
|
|
3629
|
+
{
|
|
3630
|
+
Component: ConsignmentReportsRoute,
|
|
3631
|
+
path: "/affiliates/consignment-reports",
|
|
3632
|
+
handle: { label: config$3.label, translationNs: config$3.translationNs }
|
|
3633
|
+
},
|
|
3634
|
+
{
|
|
3635
|
+
Component: NewAffiliateRoute,
|
|
3636
|
+
path: "/affiliates/new",
|
|
3637
|
+
handle: { label: config$2.label, translationNs: config$2.translationNs }
|
|
3638
|
+
},
|
|
3639
|
+
{
|
|
3640
|
+
Component: AffiliateReportsRoute,
|
|
3641
|
+
path: "/affiliates/reports",
|
|
3642
|
+
handle: { label: config$1.label, translationNs: config$1.translationNs }
|
|
3643
|
+
},
|
|
3644
|
+
{
|
|
3645
|
+
Component: AffiliateProgramSettingsRoute,
|
|
3646
|
+
path: "/affiliates/settings",
|
|
3647
|
+
handle: { label: config.label, translationNs: config.translationNs }
|
|
3648
|
+
},
|
|
3649
|
+
{
|
|
3650
|
+
Component: ConsignmentReportReviewRoute,
|
|
3651
|
+
path: "/affiliates/consignment-reports/:id"
|
|
3652
|
+
},
|
|
3653
|
+
{
|
|
3654
|
+
Component: AffiliateReportDetailRoute,
|
|
3655
|
+
path: "/affiliates/reports/:id"
|
|
3656
|
+
}
|
|
3657
|
+
]
|
|
3658
|
+
};
|
|
3659
|
+
const menuItemModule = {
|
|
3660
|
+
menuItems: [
|
|
3661
|
+
{
|
|
3662
|
+
label: config$6.label,
|
|
3663
|
+
icon: void 0,
|
|
3664
|
+
path: "/affiliates",
|
|
3665
|
+
nested: void 0,
|
|
3666
|
+
rank: 81,
|
|
3667
|
+
translationNs: void 0
|
|
3668
|
+
},
|
|
3669
|
+
{
|
|
3670
|
+
label: config$5.label,
|
|
3671
|
+
icon: void 0,
|
|
3672
|
+
path: "/affiliates/applications",
|
|
3673
|
+
nested: void 0,
|
|
3674
|
+
rank: 80,
|
|
3675
|
+
translationNs: void 0
|
|
3676
|
+
},
|
|
3677
|
+
{
|
|
3678
|
+
label: config$3.label,
|
|
3679
|
+
icon: void 0,
|
|
3680
|
+
path: "/affiliates/consignment-reports",
|
|
3681
|
+
nested: void 0,
|
|
3682
|
+
rank: 83,
|
|
3683
|
+
translationNs: void 0
|
|
3684
|
+
},
|
|
3685
|
+
{
|
|
3686
|
+
label: config$4.label,
|
|
3687
|
+
icon: void 0,
|
|
3688
|
+
path: "/affiliates/distribution-reports",
|
|
3689
|
+
nested: void 0,
|
|
3690
|
+
rank: 85,
|
|
3691
|
+
translationNs: void 0
|
|
3692
|
+
},
|
|
3693
|
+
{
|
|
3694
|
+
label: config$2.label,
|
|
3695
|
+
icon: void 0,
|
|
3696
|
+
path: "/affiliates/new",
|
|
3697
|
+
nested: void 0,
|
|
3698
|
+
rank: void 0,
|
|
3699
|
+
translationNs: void 0
|
|
3700
|
+
},
|
|
3701
|
+
{
|
|
3702
|
+
label: config$1.label,
|
|
3703
|
+
icon: void 0,
|
|
3704
|
+
path: "/affiliates/reports",
|
|
3705
|
+
nested: void 0,
|
|
3706
|
+
rank: 82,
|
|
3707
|
+
translationNs: void 0
|
|
3708
|
+
},
|
|
3709
|
+
{
|
|
3710
|
+
label: config.label,
|
|
3711
|
+
icon: void 0,
|
|
3712
|
+
path: "/affiliates/settings",
|
|
3713
|
+
nested: void 0,
|
|
3714
|
+
rank: 84,
|
|
3715
|
+
translationNs: void 0
|
|
3716
|
+
}
|
|
3717
|
+
]
|
|
3718
|
+
};
|
|
3719
|
+
const formModule = { customFields: {} };
|
|
3720
|
+
const displayModule = {
|
|
3721
|
+
displays: {}
|
|
3722
|
+
};
|
|
3723
|
+
const i18nModule = { resources: {} };
|
|
3724
|
+
const cellRendererModule = {};
|
|
3725
|
+
const layoutModule = { layouts: [] };
|
|
3726
|
+
const plugin = {
|
|
3727
|
+
widgetModule,
|
|
3728
|
+
routeModule,
|
|
3729
|
+
menuItemModule,
|
|
3730
|
+
formModule,
|
|
3731
|
+
displayModule,
|
|
3732
|
+
i18nModule,
|
|
3733
|
+
cellRendererModule,
|
|
3734
|
+
layoutModule
|
|
3735
|
+
};
|
|
3736
|
+
export {
|
|
3737
|
+
plugin as default
|
|
3738
|
+
};
|