Skip to content

Commit 2f57b5e

Browse files
committed
fix: Update TIP on promotions
1 parent 46bf7ae commit 2f57b5e

6 files changed

Lines changed: 39 additions & 5 deletions

File tree

integration-tests/http/__tests__/promotions/admin/promotions.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
generatePublishableKey,
66
generateStoreHeaders,
77
} from "../../../../helpers/create-admin-user"
8-
import { medusaTshirtProduct } from "../../../__fixtures__/product"
98
import { setupTaxStructure } from "../../../../modules/__tests__/fixtures/tax"
9+
import { medusaTshirtProduct } from "../../../__fixtures__/product"
1010

1111
jest.setTimeout(50000)
1212

@@ -1399,6 +1399,7 @@ medusaIntegrationTestRunner({
13991399
{
14001400
code: "TEST_TWO",
14011401
application_method: { value: 200 },
1402+
is_tax_inclusive: true,
14021403
},
14031404
adminHeaders
14041405
)
@@ -1411,6 +1412,7 @@ medusaIntegrationTestRunner({
14111412
application_method: expect.objectContaining({
14121413
value: 200,
14131414
}),
1415+
is_tax_inclusive: true,
14141416
})
14151417
)
14161418
})

packages/admin/dashboard/src/i18n/translations/en.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@
20742074
},
20752075
"taxInclusive": {
20762076
"title": "Does promotion include taxes?",
2077-
"description": "Enable this field to apply the promotion after taxes. If disabled, the promotion will be applied before taxes."
2077+
"description": "Enable this field to apply the promotion after taxes"
20782078
},
20792079
"status": {
20802080
"label": "Status",
@@ -2697,7 +2697,10 @@
26972697
"placeholder": "wrong_size",
26982698
"tooltip": "The value should be a unique identifier for the return reason."
26992699
},
2700-
"label": { "label": "Label", "placeholder": "Wrong size" },
2700+
"label": {
2701+
"label": "Label",
2702+
"placeholder": "Wrong size"
2703+
},
27012704
"description": {
27022705
"label": "Description",
27032706
"placeholder": "Customer received the wrong size"
@@ -3048,4 +3051,4 @@
30483051
"seconds_one": "Second",
30493052
"seconds_other": "Seconds"
30503053
}
3051-
}
3054+
}

packages/admin/dashboard/src/routes/promotions/promotion-edit-details/components/edit-promotion-form/edit-promotion-details-form.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { zodResolver } from "@hookform/resolvers/zod"
22
import { AdminPromotion } from "@medusajs/types"
3-
import { Button, CurrencyInput, Input, RadioGroup, Text } from "@medusajs/ui"
3+
import {
4+
Button,
5+
CurrencyInput,
6+
Input,
7+
RadioGroup,
8+
Switch,
9+
Text,
10+
} from "@medusajs/ui"
411
import { useForm, useWatch } from "react-hook-form"
512
import { Trans, useTranslation } from "react-i18next"
613
import * as zod from "zod"
@@ -11,6 +18,7 @@ import { RouteDrawer, useRouteModal } from "../../../../../components/modals"
1118
import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
1219
import { useUpdatePromotion } from "../../../../../hooks/api/promotions"
1320
import { getCurrencySymbol } from "../../../../../lib/data/currencies"
21+
import { SwitchBox } from "../../../../../components/common/switch-box"
1422

1523
type EditPromotionFormProps = {
1624
promotion: AdminPromotion
@@ -19,6 +27,7 @@ type EditPromotionFormProps = {
1927
const EditPromotionSchema = zod.object({
2028
is_automatic: zod.string().toLowerCase(),
2129
code: zod.string().min(1),
30+
is_tax_inclusive: zod.boolean(),
2231
status: zod.enum(["active", "inactive", "draft"]),
2332
value_type: zod.enum(["fixed", "percentage"]),
2433
value: zod.number(),
@@ -34,6 +43,7 @@ export const EditPromotionDetailsForm = ({
3443
const form = useForm<zod.infer<typeof EditPromotionSchema>>({
3544
defaultValues: {
3645
is_automatic: promotion.is_automatic!.toString(),
46+
is_tax_inclusive: promotion.is_tax_inclusive,
3747
code: promotion.code,
3848
status: promotion.status,
3949
value: promotion.application_method!.value,
@@ -58,6 +68,7 @@ export const EditPromotionDetailsForm = ({
5868
is_automatic: data.is_automatic === "true",
5969
code: data.code,
6070
status: data.status,
71+
is_tax_inclusive: data.is_tax_inclusive,
6172
application_method: {
6273
value: data.value,
6374
type: data.value_type as any,
@@ -161,6 +172,14 @@ export const EditPromotionDetailsForm = ({
161172
}}
162173
/>
163174

175+
{promotion.type !== "buyget" ? (
176+
<SwitchBox
177+
control={form.control}
178+
name="is_tax_inclusive"
179+
label={t("promotions.form.taxInclusive.title")}
180+
description={t("promotions.form.taxInclusive.description")}
181+
/>
182+
) : null}
164183
<div className="flex flex-col gap-y-4">
165184
<Form.Field
166185
control={form.control}

packages/core/types/src/http/promotion/admin/payloads.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ export interface AdminUpdatePromotion {
197197
* by entering the code at checkout.
198198
*/
199199
is_automatic?: boolean
200+
/**
201+
* Whether the promotion is tax inclusive.
202+
*/
203+
is_tax_inclusive?: boolean
200204
/**
201205
* The type of promotion.
202206
*/

packages/core/types/src/promotion/common/promotion.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ export interface UpdatePromotionDTO {
168168
*/
169169
type?: PromotionTypeValues
170170

171+
/**
172+
* Whether the promotion is tax inclusive.
173+
*/
174+
is_tax_inclusive?: boolean
175+
171176
/**
172177
* The status of the promotion:
173178
*

packages/medusa/src/api/admin/promotions/validators.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export const UpdatePromotion = z
187187
.object({
188188
code: z.string().optional(),
189189
is_automatic: z.boolean().optional(),
190+
is_tax_inclusive: z.boolean().optional(),
190191
type: z.nativeEnum(PromotionType).optional(),
191192
status: z.nativeEnum(PromotionStatus).optional(),
192193
campaign_id: z.string().nullish(),

0 commit comments

Comments
 (0)