@medusajs/dashboard 2.10.4-preview-20250924090158 → 2.10.4-preview-20250924120212
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/dist/{add-campaign-promotions-62IIOR5K.mjs → add-campaign-promotions-APV4J7Z2.mjs} +4 -4
- package/dist/{api-key-management-detail-TEW653QF.mjs → api-key-management-detail-P2CXWYQG.mjs} +1 -1
- package/dist/app.js +43 -63
- package/dist/app.mjs +3 -3
- package/dist/{campaign-budget-edit-OXNTSPGE.mjs → campaign-budget-edit-UWGCET5Z.mjs} +1 -1
- package/dist/{campaign-configuration-Z5HA2DG3.mjs → campaign-configuration-WWCCFNYQ.mjs} +1 -1
- package/dist/{campaign-create-GRKYQY5D.mjs → campaign-create-CQ3XBHSY.mjs} +2 -2
- package/dist/{campaign-detail-XYLU3HF4.mjs → campaign-detail-CBO7PBOR.mjs} +4 -4
- package/dist/{campaign-edit-3TDW52BO.mjs → campaign-edit-R43GXNET.mjs} +1 -1
- package/dist/{campaign-list-IDPRC2MD.mjs → campaign-list-CDO5PRTL.mjs} +1 -1
- package/dist/{categories-metadata-JFNWZA5D.mjs → categories-metadata-HNABPXTE.mjs} +1 -1
- package/dist/{category-detail-CL3XCV7E.mjs → category-detail-JUKMFR4W.mjs} +1 -1
- package/dist/{category-products-UZEG63WY.mjs → category-products-CWLUKUVK.mjs} +1 -1
- package/dist/{chunk-NDNUJ2UK.mjs → chunk-3S523T5F.mjs} +1 -1
- package/dist/{chunk-FUQ27NT5.mjs → chunk-5FAWKUSU.mjs} +1 -1
- package/dist/{chunk-LJDVFJK7.mjs → chunk-AXXGAOQL.mjs} +1 -1
- package/dist/{chunk-NKM6CHK6.mjs → chunk-FGF5B6J4.mjs} +105 -105
- package/dist/{chunk-4CGHNQP2.mjs → chunk-G3VGLFVH.mjs} +47 -47
- package/dist/{chunk-HEBATBOH.mjs → chunk-KTBA6OOV.mjs} +1 -1
- package/dist/{chunk-6W7OL4TX.mjs → chunk-NUA3JO5E.mjs} +1 -1
- package/dist/{chunk-ZODJNBAV.mjs → chunk-R2G2B47Y.mjs} +1 -0
- package/dist/{chunk-UOEALCPZ.mjs → chunk-TEMN4ESF.mjs} +1 -1
- package/dist/{chunk-TWP4GTKM.mjs → chunk-ZWWM2OU2.mjs} +1 -1
- package/dist/{collection-add-products-QTFBLLND.mjs → collection-add-products-E22XLIP7.mjs} +1 -1
- package/dist/{collection-detail-ZEAUSZBJ.mjs → collection-detail-LOJ6WZLT.mjs} +1 -1
- package/dist/{collection-list-V27JHDAD.mjs → collection-list-KKEZLFLJ.mjs} +1 -1
- package/dist/{collection-metadata-JAEMZMU6.mjs → collection-metadata-MEA56JQC.mjs} +1 -1
- package/dist/{customer-detail-YBOM6KGC.mjs → customer-detail-Z5TU254N.mjs} +1 -1
- package/dist/{customer-group-detail-72VFORGF.mjs → customer-group-detail-VCRUQIYD.mjs} +1 -1
- package/dist/{customer-group-list-6XY7YF5E.mjs → customer-group-list-MCQ4AUJF.mjs} +1 -1
- package/dist/{customers-add-customer-group-ZUCFXW2U.mjs → customers-add-customer-group-X3VHASZ6.mjs} +1 -1
- package/dist/{edit-rules-RY7JMYLR.mjs → edit-rules-SVG7IOSY.mjs} +2 -2
- package/dist/{inventory-create-F5PSTEN2.mjs → inventory-create-DR5LNYQB.mjs} +1 -1
- package/dist/{inventory-detail-WI5T47QL.mjs → inventory-detail-D4MBCFS2.mjs} +1 -1
- package/dist/{inventory-metadata-QGPVSAUI.mjs → inventory-metadata-T22JZF4O.mjs} +1 -1
- package/dist/{inventory-stock-VQNXCIOA.mjs → inventory-stock-CPNDJYBD.mjs} +1 -1
- package/dist/{location-detail-M4CYDTSY.mjs → location-detail-SG4X4HBT.mjs} +1 -1
- package/dist/{location-fulfillment-providers-XVEQZCUD.mjs → location-fulfillment-providers-YNKCL3FV.mjs} +1 -1
- package/dist/{location-service-zone-shipping-option-create-I3HAEEFA.mjs → location-service-zone-shipping-option-create-PF7YJSC3.mjs} +1 -1
- package/dist/{login-QOENXTB7.mjs → login-23RIW4IY.mjs} +1 -1
- package/dist/{order-create-claim-MOBLO4YM.mjs → order-create-claim-LBA6UTTF.mjs} +1 -1
- package/dist/{order-create-edit-C75GUZJE.mjs → order-create-edit-7GLQP5CD.mjs} +1 -1
- package/dist/{order-create-exchange-RCUALEXO.mjs → order-create-exchange-IXPHBHKP.mjs} +1 -1
- package/dist/{order-create-fulfillment-EZTEZ4CF.mjs → order-create-fulfillment-5UJQFERR.mjs} +1 -1
- package/dist/{order-create-refund-4FAIESAN.mjs → order-create-refund-QZRNHK2D.mjs} +1 -1
- package/dist/{order-create-shipment-PTUJKVWK.mjs → order-create-shipment-TQJHHC7T.mjs} +1 -1
- package/dist/{order-detail-CNQ7HP32.mjs → order-detail-NERZLT7X.mjs} +1 -1
- package/dist/{order-edit-billing-address-46CFUZGL.mjs → order-edit-billing-address-BMUX3GJL.mjs} +1 -1
- package/dist/{order-edit-email-FOK5GQW2.mjs → order-edit-email-CS4AIJZS.mjs} +1 -1
- package/dist/{order-edit-shipping-address-WFN2SVKM.mjs → order-edit-shipping-address-GXSNNDBC.mjs} +1 -1
- package/dist/{order-metadata-COJNFRPZ.mjs → order-metadata-KWZX64YP.mjs} +1 -1
- package/dist/{order-receive-return-P4OPVOPM.mjs → order-receive-return-EXZAUMCI.mjs} +1 -1
- package/dist/{order-request-transfer-HRPCEL5L.mjs → order-request-transfer-RLU2TK44.mjs} +1 -1
- package/dist/{price-list-create-FJ2FM6GL.mjs → price-list-create-RHSKBROB.mjs} +1 -1
- package/dist/{price-list-detail-VNZ3Q426.mjs → price-list-detail-7E2SZNKI.mjs} +1 -1
- package/dist/{price-list-prices-add-FMZKGOHD.mjs → price-list-prices-add-RM5FDABU.mjs} +1 -1
- package/dist/{product-attributes-6ELSX5OH.mjs → product-attributes-K5EMRHFS.mjs} +4 -4
- package/dist/{product-create-6NWXJ7AY.mjs → product-create-5KQFXFJF.mjs} +4 -4
- package/dist/{product-create-variant-KGBSFIKQ.mjs → product-create-variant-37CVX4QI.mjs} +1 -1
- package/dist/{product-detail-G53SUBEP.mjs → product-detail-UM6PIKWQ.mjs} +4 -4
- package/dist/{product-edit-ZYUXMIZP.mjs → product-edit-QSCZEH74.mjs} +4 -4
- package/dist/{product-export-XA5POQKT.mjs → product-export-JNLDMDUS.mjs} +1 -1
- package/dist/{product-import-DYTT4YDA.mjs → product-import-CA75XMEH.mjs} +1 -1
- package/dist/{product-list-R6IDCNRV.mjs → product-list-XA5SJLXF.mjs} +1 -1
- package/dist/{product-media-AKHSFDJQ.mjs → product-media-36YW62IO.mjs} +2 -2
- package/dist/{product-metadata-44VYAXZD.mjs → product-metadata-JKWIAMVB.mjs} +1 -1
- package/dist/{product-organization-J2UYHJ6I.mjs → product-organization-YL4ZUCC4.mjs} +4 -4
- package/dist/{product-shipping-profile-FN7L2V4X.mjs → product-shipping-profile-PEIUF5AK.mjs} +4 -4
- package/dist/{product-stock-PX5NAHH6.mjs → product-stock-4XECV73O.mjs} +1 -1
- package/dist/{product-tag-create-R4YSSXD6.mjs → product-tag-create-U5DAEOBS.mjs} +1 -1
- package/dist/{product-tag-detail-XJEGQD7U.mjs → product-tag-detail-YB44E6JT.mjs} +1 -1
- package/dist/{product-tag-edit-7JXF42HY.mjs → product-tag-edit-J3OPHCDJ.mjs} +1 -1
- package/dist/{product-tag-list-GTUMQQ6V.mjs → product-tag-list-6TGDOAMD.mjs} +1 -1
- package/dist/{product-tag-metadata-5QV3HMXJ.mjs → product-tag-metadata-VAHEGSFJ.mjs} +1 -1
- package/dist/{product-type-detail-CN74BB3Y.mjs → product-type-detail-EN3WAIVO.mjs} +1 -1
- package/dist/{product-type-metadata-JPFREADV.mjs → product-type-metadata-R3YLZGY5.mjs} +1 -1
- package/dist/{product-variant-detail-BSLEUW5J.mjs → product-variant-detail-TYV4BYNG.mjs} +1 -1
- package/dist/{product-variant-edit-VOW5633S.mjs → product-variant-edit-YPQDVG5C.mjs} +1 -1
- package/dist/{product-variant-metadata-KDSV47PE.mjs → product-variant-metadata-DII5YHIK.mjs} +1 -1
- package/dist/{promotion-add-campaign-JXBRCUXL.mjs → promotion-add-campaign-YREHV6TQ.mjs} +7 -20
- package/dist/{promotion-create-YPX2R3ZB.mjs → promotion-create-TLW6T5IO.mjs} +4 -4
- package/dist/{promotion-detail-RISSMGU5.mjs → promotion-detail-BYA66IL7.mjs} +3 -3
- package/dist/{promotion-edit-details-I5DYHQUM.mjs → promotion-edit-details-A2UUSAZA.mjs} +1 -1
- package/dist/{promotion-list-UPVSOD6R.mjs → promotion-list-TOYJAQ4D.mjs} +4 -4
- package/dist/{refund-reason-create-CYHPXX2O.mjs → refund-reason-create-D5DJVOXP.mjs} +1 -1
- package/dist/{refund-reason-list-RGRFZ5DU.mjs → refund-reason-list-V7UO2NAY.mjs} +1 -1
- package/dist/{region-metadata-NXD563F4.mjs → region-metadata-23FQEWQ7.mjs} +1 -1
- package/dist/{reservation-detail-64MMXK7D.mjs → reservation-detail-USSX2THW.mjs} +1 -1
- package/dist/{reservation-metadata-4GZCEGM7.mjs → reservation-metadata-PKWRLWNT.mjs} +1 -1
- package/dist/{reset-password-AYCPBCKE.mjs → reset-password-EKZEJXQU.mjs} +1 -1
- package/dist/{sales-channel-add-products-EAWW7ADY.mjs → sales-channel-add-products-DKDV65UU.mjs} +1 -1
- package/dist/{sales-channel-detail-3F3HFTD2.mjs → sales-channel-detail-JKJLEM4C.mjs} +1 -1
- package/dist/{sales-channel-list-KNLMJ67Q.mjs → sales-channel-list-FOAVTG7H.mjs} +1 -1
- package/dist/{sales-channel-metadata-LAHTTRLQ.mjs → sales-channel-metadata-3RXYX7U2.mjs} +1 -1
- package/dist/{shipping-option-type-create-IPKK5MRS.mjs → shipping-option-type-create-ZLYFQFYI.mjs} +1 -1
- package/dist/{shipping-option-type-detail-NEQ4RA5F.mjs → shipping-option-type-detail-OMVJZSOI.mjs} +1 -1
- package/dist/{shipping-option-type-edit-CC64TWSB.mjs → shipping-option-type-edit-5XHFIDEZ.mjs} +1 -1
- package/dist/{shipping-option-type-list-3GTGTBK7.mjs → shipping-option-type-list-SGTTVHWK.mjs} +1 -1
- package/dist/{shipping-profile-metadata-EPVLPEEM.mjs → shipping-profile-metadata-3TZDQ27Z.mjs} +1 -1
- package/dist/{store-detail-PUOKMK4K.mjs → store-detail-72GMDFY7.mjs} +1 -1
- package/dist/{store-metadata-JYIVRRLW.mjs → store-metadata-TXSRTL6B.mjs} +1 -1
- package/dist/{tax-region-create-SP46RW2E.mjs → tax-region-create-U6XXHBMJ.mjs} +2 -2
- package/dist/{tax-region-detail-MQKBEBOZ.mjs → tax-region-detail-V4E63XUI.mjs} +1 -1
- package/dist/{tax-region-edit-2H5ACSFG.mjs → tax-region-edit-2DQPKIJG.mjs} +1 -1
- package/dist/{tax-region-province-detail-HNK2ZJWL.mjs → tax-region-province-detail-P6LPVSQJ.mjs} +1 -1
- package/dist/{tax-region-tax-override-create-XZJ3EIFJ.mjs → tax-region-tax-override-create-BPZKBPN6.mjs} +1 -1
- package/dist/{tax-region-tax-override-edit-QHQHFI2Y.mjs → tax-region-tax-override-edit-O7LUBRQN.mjs} +1 -1
- package/dist/{user-metadata-F6KRFYDW.mjs → user-metadata-TM3FFLIR.mjs} +1 -1
- package/dist/{workflow-execution-detail-JRJZATNU.mjs → workflow-execution-detail-3IBZZVRE.mjs} +1 -1
- package/package.json +9 -9
- package/src/hooks/api/campaigns.tsx +1 -0
- package/src/i18n/translations/en.json +1 -1
- package/src/routes/promotions/promotion-add-campaign/components/add-campaign-promotion-form/add-campaign-promotion-form.tsx +45 -52
- package/src/routes/promotions/promotion-add-campaign/promotion-add-campaign.tsx +4 -21
@@ -38,7 +38,7 @@ import "./chunk-ZCZL3STK.mjs";
|
|
38
38
|
import "./chunk-OHSRRFGN.mjs";
|
39
39
|
import "./chunk-F6PXCY3N.mjs";
|
40
40
|
import "./chunk-NCR5UWRI.mjs";
|
41
|
-
import "./chunk-
|
41
|
+
import "./chunk-R2G2B47Y.mjs";
|
42
42
|
import "./chunk-GRT22PE5.mjs";
|
43
43
|
import "./chunk-32IQRUVY.mjs";
|
44
44
|
import "./chunk-KSRI5LOF.mjs";
|
package/dist/{tax-region-province-detail-HNK2ZJWL.mjs → tax-region-province-detail-P6LPVSQJ.mjs}
RENAMED
@@ -56,7 +56,7 @@ import "./chunk-ZCZL3STK.mjs";
|
|
56
56
|
import "./chunk-OHSRRFGN.mjs";
|
57
57
|
import "./chunk-F6PXCY3N.mjs";
|
58
58
|
import "./chunk-NCR5UWRI.mjs";
|
59
|
-
import "./chunk-
|
59
|
+
import "./chunk-R2G2B47Y.mjs";
|
60
60
|
import "./chunk-GRT22PE5.mjs";
|
61
61
|
import "./chunk-32IQRUVY.mjs";
|
62
62
|
import "./chunk-KSRI5LOF.mjs";
|
@@ -104,7 +104,7 @@ import "./chunk-ZCZL3STK.mjs";
|
|
104
104
|
import "./chunk-OHSRRFGN.mjs";
|
105
105
|
import "./chunk-F6PXCY3N.mjs";
|
106
106
|
import "./chunk-NCR5UWRI.mjs";
|
107
|
-
import "./chunk-
|
107
|
+
import "./chunk-R2G2B47Y.mjs";
|
108
108
|
import "./chunk-GRT22PE5.mjs";
|
109
109
|
import "./chunk-32IQRUVY.mjs";
|
110
110
|
import "./chunk-KSRI5LOF.mjs";
|
package/dist/{tax-region-tax-override-edit-QHQHFI2Y.mjs → tax-region-tax-override-edit-O7LUBRQN.mjs}
RENAMED
@@ -105,7 +105,7 @@ import "./chunk-ZCZL3STK.mjs";
|
|
105
105
|
import "./chunk-OHSRRFGN.mjs";
|
106
106
|
import "./chunk-F6PXCY3N.mjs";
|
107
107
|
import "./chunk-NCR5UWRI.mjs";
|
108
|
-
import "./chunk-
|
108
|
+
import "./chunk-R2G2B47Y.mjs";
|
109
109
|
import {
|
110
110
|
useShippingOptions
|
111
111
|
} from "./chunk-GRT22PE5.mjs";
|
@@ -31,7 +31,7 @@ import "./chunk-ZCZL3STK.mjs";
|
|
31
31
|
import "./chunk-OHSRRFGN.mjs";
|
32
32
|
import "./chunk-F6PXCY3N.mjs";
|
33
33
|
import "./chunk-NCR5UWRI.mjs";
|
34
|
-
import "./chunk-
|
34
|
+
import "./chunk-R2G2B47Y.mjs";
|
35
35
|
import "./chunk-GRT22PE5.mjs";
|
36
36
|
import "./chunk-32IQRUVY.mjs";
|
37
37
|
import "./chunk-KSRI5LOF.mjs";
|
package/dist/{workflow-execution-detail-JRJZATNU.mjs → workflow-execution-detail-3IBZZVRE.mjs}
RENAMED
@@ -40,7 +40,7 @@ import "./chunk-ZCZL3STK.mjs";
|
|
40
40
|
import "./chunk-OHSRRFGN.mjs";
|
41
41
|
import "./chunk-F6PXCY3N.mjs";
|
42
42
|
import "./chunk-NCR5UWRI.mjs";
|
43
|
-
import "./chunk-
|
43
|
+
import "./chunk-R2G2B47Y.mjs";
|
44
44
|
import "./chunk-GRT22PE5.mjs";
|
45
45
|
import "./chunk-32IQRUVY.mjs";
|
46
46
|
import "./chunk-KSRI5LOF.mjs";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/dashboard",
|
3
|
-
"version": "2.10.4-preview-
|
3
|
+
"version": "2.10.4-preview-20250924120212",
|
4
4
|
"scripts": {
|
5
5
|
"generate:static": "node ./scripts/generate-currencies.js && prettier --write ./src/lib/currencies.ts",
|
6
6
|
"dev": "vite",
|
@@ -45,10 +45,10 @@
|
|
45
45
|
"@dnd-kit/utilities": "^3.2.2",
|
46
46
|
"@hookform/error-message": "^2.0.1",
|
47
47
|
"@hookform/resolvers": "3.4.2",
|
48
|
-
"@medusajs/admin-shared": "2.10.4-preview-
|
49
|
-
"@medusajs/icons": "2.10.4-preview-
|
50
|
-
"@medusajs/js-sdk": "2.10.4-preview-
|
51
|
-
"@medusajs/ui": "4.0.24-preview-
|
48
|
+
"@medusajs/admin-shared": "2.10.4-preview-20250924120212",
|
49
|
+
"@medusajs/icons": "2.10.4-preview-20250924120212",
|
50
|
+
"@medusajs/js-sdk": "2.10.4-preview-20250924120212",
|
51
|
+
"@medusajs/ui": "4.0.24-preview-20250924120212",
|
52
52
|
"@radix-ui/react-dialog": "1.1.4",
|
53
53
|
"@radix-ui/react-dismissable-layer": "1.1.4",
|
54
54
|
"@tanstack/react-query": "5.64.2",
|
@@ -78,10 +78,10 @@
|
|
78
78
|
"zod": "3.25.76"
|
79
79
|
},
|
80
80
|
"devDependencies": {
|
81
|
-
"@medusajs/admin-shared": "2.10.4-preview-
|
82
|
-
"@medusajs/admin-vite-plugin": "2.10.4-preview-
|
83
|
-
"@medusajs/types": "2.10.4-preview-
|
84
|
-
"@medusajs/ui-preset": "2.10.4-preview-
|
81
|
+
"@medusajs/admin-shared": "2.10.4-preview-20250924120212",
|
82
|
+
"@medusajs/admin-vite-plugin": "2.10.4-preview-20250924120212",
|
83
|
+
"@medusajs/types": "2.10.4-preview-20250924120212",
|
84
|
+
"@medusajs/ui-preset": "2.10.4-preview-20250924120212",
|
85
85
|
"@types/node": "^20.11.15",
|
86
86
|
"@types/react": "^18.2.79",
|
87
87
|
"@types/react-dom": "^18.2.25",
|
@@ -130,6 +130,7 @@ export const useAddOrRemoveCampaignPromotions = (
|
|
130
130
|
onSuccess: (data, variables, context) => {
|
131
131
|
queryClient.invalidateQueries({ queryKey: campaignsQueryKeys.details() })
|
132
132
|
queryClient.invalidateQueries({ queryKey: promotionsQueryKeys.lists() })
|
133
|
+
queryClient.invalidateQueries({ queryKey: promotionsQueryKeys.details() })
|
133
134
|
options?.onSuccess?.(data, variables, context)
|
134
135
|
},
|
135
136
|
...options,
|
@@ -2234,7 +2234,7 @@
|
|
2234
2234
|
"total_used": "Budget used",
|
2235
2235
|
"budget_limit": "Budget limit",
|
2236
2236
|
"campaign_id": {
|
2237
|
-
"hint": "
|
2237
|
+
"hint": "Disabled campaigns have budget in a different currency than the promotion."
|
2238
2238
|
}
|
2239
2239
|
},
|
2240
2240
|
"budget": {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { zodResolver } from "@hookform/resolvers/zod"
|
2
2
|
import { AdminCampaign, AdminPromotion } from "@medusajs/types"
|
3
|
-
import { Button, RadioGroup,
|
3
|
+
import { Button, RadioGroup, toast } from "@medusajs/ui"
|
4
4
|
import { useEffect } from "react"
|
5
5
|
import { useForm, useWatch } from "react-hook-form"
|
6
|
-
import {
|
6
|
+
import { useTranslation } from "react-i18next"
|
7
7
|
import * as zod from "zod"
|
8
8
|
import { Form } from "../../../../../components/common/form"
|
9
9
|
import { RouteDrawer, useRouteModal } from "../../../../../components/modals"
|
@@ -11,11 +11,14 @@ import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
|
|
11
11
|
import { useUpdatePromotion } from "../../../../../hooks/api/promotions"
|
12
12
|
import { CreateCampaignFormFields } from "../../../../campaigns/common/components/create-campaign-form-fields"
|
13
13
|
import { CampaignDetails } from "./campaign-details"
|
14
|
+
import { sdk } from "../../../../../lib/client"
|
15
|
+
import { useComboboxData } from "../../../../../hooks/use-combobox-data"
|
16
|
+
import { Combobox } from "../../../../../components/inputs/combobox"
|
17
|
+
import { useCampaign } from "../../../../../hooks/api/campaigns"
|
14
18
|
import { useDocumentDirection } from "../../../../../hooks/use-document-direction"
|
15
19
|
|
16
20
|
type EditPromotionFormProps = {
|
17
21
|
promotion: AdminPromotion
|
18
|
-
campaigns: AdminCampaign[]
|
19
22
|
}
|
20
23
|
|
21
24
|
const EditPromotionSchema = zod.object({
|
@@ -25,14 +28,16 @@ const EditPromotionSchema = zod.object({
|
|
25
28
|
|
26
29
|
export const AddCampaignPromotionFields = ({
|
27
30
|
form,
|
28
|
-
campaigns,
|
29
31
|
withNewCampaign = true,
|
32
|
+
promotionCurrencyCode,
|
30
33
|
}: {
|
31
34
|
form: any
|
32
|
-
campaigns: AdminCampaign[]
|
33
35
|
withNewCampaign?: boolean
|
36
|
+
promotionCurrencyCode?: string
|
34
37
|
}) => {
|
35
38
|
const { t } = useTranslation()
|
39
|
+
const direction = useDocumentDirection()
|
40
|
+
|
36
41
|
const watchCampaignId = useWatch({
|
37
42
|
control: form.control,
|
38
43
|
name: "campaign_id",
|
@@ -43,8 +48,31 @@ export const AddCampaignPromotionFields = ({
|
|
43
48
|
name: "campaign_choice",
|
44
49
|
})
|
45
50
|
|
46
|
-
const
|
47
|
-
|
51
|
+
const campaignsCombobox = useComboboxData({
|
52
|
+
queryFn: (params) =>
|
53
|
+
sdk.admin.campaign.list({
|
54
|
+
...params,
|
55
|
+
}),
|
56
|
+
queryKey: ["campaigns"],
|
57
|
+
getOptions: (data) =>
|
58
|
+
data.campaigns.map((campaign) => ({
|
59
|
+
label: campaign.name.toUpperCase(),
|
60
|
+
value: campaign.id,
|
61
|
+
disabled:
|
62
|
+
campaign.budget?.currency_code &&
|
63
|
+
campaign.budget?.currency_code?.toLowerCase() !==
|
64
|
+
promotionCurrencyCode?.toLowerCase(), // also cannot add promotion which doesn't have currency defined to a campaign with a currency amount budget
|
65
|
+
})),
|
66
|
+
})
|
67
|
+
|
68
|
+
const { campaign: selectedCampaign } = useCampaign(
|
69
|
+
watchCampaignId as string,
|
70
|
+
undefined,
|
71
|
+
{
|
72
|
+
enabled: !!watchCampaignId,
|
73
|
+
}
|
74
|
+
)
|
75
|
+
|
48
76
|
return (
|
49
77
|
<div className="flex flex-col gap-y-8">
|
50
78
|
<Form.Field
|
@@ -99,58 +127,24 @@ export const AddCampaignPromotionFields = ({
|
|
99
127
|
<Form.Field
|
100
128
|
control={form.control}
|
101
129
|
name="campaign_id"
|
102
|
-
render={({ field: { onChange,
|
130
|
+
render={({ field: { onChange, ...field } }) => {
|
103
131
|
return (
|
104
132
|
<Form.Item>
|
105
|
-
<Form.Label>
|
133
|
+
<Form.Label tooltip={t("campaigns.fields.campaign_id.hint")}>
|
106
134
|
{t("promotions.form.campaign.existing.title")}
|
107
135
|
</Form.Label>
|
108
136
|
|
109
137
|
<Form.Control>
|
110
|
-
<
|
138
|
+
<Combobox
|
111
139
|
dir={direction}
|
112
|
-
|
140
|
+
options={campaignsCombobox.options}
|
141
|
+
searchValue={campaignsCombobox.searchValue}
|
142
|
+
onSearchValueChange={campaignsCombobox.onSearchValueChange}
|
143
|
+
onChange={onChange}
|
113
144
|
{...field}
|
114
|
-
>
|
115
|
-
<Select.Trigger ref={ref}>
|
116
|
-
<Select.Value />
|
117
|
-
</Select.Trigger>
|
118
|
-
|
119
|
-
<Select.Content>
|
120
|
-
{!campaigns.length && (
|
121
|
-
<div className="flex h-[120px] flex-col items-center justify-center gap-2 p-2">
|
122
|
-
<span className="txt-small text-ui-fg-subtle font-medium">
|
123
|
-
{t(
|
124
|
-
"promotions.form.campaign.existing.placeholder.title"
|
125
|
-
)}
|
126
|
-
</span>
|
127
|
-
<span className="txt-small text-ui-fg-muted">
|
128
|
-
{t(
|
129
|
-
"promotions.form.campaign.existing.placeholder.desc"
|
130
|
-
)}
|
131
|
-
</span>
|
132
|
-
</div>
|
133
|
-
)}
|
134
|
-
{campaigns.map((c) => (
|
135
|
-
<Select.Item key={c.id} value={c.id}>
|
136
|
-
{c.name?.toUpperCase()}
|
137
|
-
</Select.Item>
|
138
|
-
))}
|
139
|
-
</Select.Content>
|
140
|
-
</Select>
|
145
|
+
></Combobox>
|
141
146
|
</Form.Control>
|
142
147
|
|
143
|
-
<Text
|
144
|
-
size="small"
|
145
|
-
leading="compact"
|
146
|
-
className="text-ui-fg-subtle"
|
147
|
-
>
|
148
|
-
<Trans
|
149
|
-
t={t}
|
150
|
-
i18nKey="campaigns.fields.campaign_id.hint"
|
151
|
-
components={[<br key="break" />]}
|
152
|
-
/>
|
153
|
-
</Text>
|
154
148
|
<Form.ErrorMessage />
|
155
149
|
</Form.Item>
|
156
150
|
)
|
@@ -162,14 +156,13 @@ export const AddCampaignPromotionFields = ({
|
|
162
156
|
<CreateCampaignFormFields form={form} fieldScope="campaign." />
|
163
157
|
)}
|
164
158
|
|
165
|
-
<CampaignDetails campaign={selectedCampaign} />
|
159
|
+
<CampaignDetails campaign={selectedCampaign as AdminCampaign} />
|
166
160
|
</div>
|
167
161
|
)
|
168
162
|
}
|
169
163
|
|
170
164
|
export const AddCampaignPromotionForm = ({
|
171
165
|
promotion,
|
172
|
-
campaigns,
|
173
166
|
}: EditPromotionFormProps) => {
|
174
167
|
const { t } = useTranslation()
|
175
168
|
const { handleSuccess } = useRouteModal()
|
@@ -227,8 +220,8 @@ export const AddCampaignPromotionForm = ({
|
|
227
220
|
<RouteDrawer.Body className="size-full overflow-auto">
|
228
221
|
<AddCampaignPromotionFields
|
229
222
|
form={form}
|
230
|
-
campaigns={campaigns}
|
231
223
|
withNewCampaign={false}
|
224
|
+
promotionCurrencyCode={promotion.application_method?.currency_code}
|
232
225
|
/>
|
233
226
|
</RouteDrawer.Body>
|
234
227
|
|
@@ -3,7 +3,6 @@ import { useTranslation } from "react-i18next"
|
|
3
3
|
import { useParams } from "react-router-dom"
|
4
4
|
|
5
5
|
import { RouteDrawer } from "../../../components/modals"
|
6
|
-
import { useCampaigns } from "../../../hooks/api/campaigns"
|
7
6
|
import { usePromotion } from "../../../hooks/api/promotions"
|
8
7
|
import { AddCampaignPromotionForm } from "./components/add-campaign-promotion-form"
|
9
8
|
|
@@ -12,24 +11,8 @@ export const PromotionAddCampaign = () => {
|
|
12
11
|
const { t } = useTranslation()
|
13
12
|
const { promotion, isPending, isError, error } = usePromotion(id!)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
if (promotion?.application_method?.currency_code) {
|
18
|
-
campaignQuery = {
|
19
|
-
budget: {
|
20
|
-
currency_code: promotion?.application_method?.currency_code,
|
21
|
-
},
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
const {
|
26
|
-
campaigns,
|
27
|
-
isPending: areCampaignsLoading,
|
28
|
-
isError: isCampaignError,
|
29
|
-
error: campaignError,
|
30
|
-
} = useCampaigns(campaignQuery)
|
31
|
-
if (isError || isCampaignError) {
|
32
|
-
throw error || campaignError
|
14
|
+
if (isError) {
|
15
|
+
throw error
|
33
16
|
}
|
34
17
|
|
35
18
|
return (
|
@@ -38,8 +21,8 @@ export const PromotionAddCampaign = () => {
|
|
38
21
|
<Heading>{t("promotions.campaign.edit.header")}</Heading>
|
39
22
|
</RouteDrawer.Header>
|
40
23
|
|
41
|
-
{!isPending &&
|
42
|
-
<AddCampaignPromotionForm promotion={promotion}
|
24
|
+
{!isPending && promotion && (
|
25
|
+
<AddCampaignPromotionForm promotion={promotion} />
|
43
26
|
)}
|
44
27
|
</RouteDrawer>
|
45
28
|
)
|