Skip to content

Commit

Permalink
Merge branch 'main' into fix/method-card-spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
bolariin authored Dec 22, 2023
2 parents bdbef2c + e5c46da commit b2e188b
Show file tree
Hide file tree
Showing 33 changed files with 321 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
cla:
runs-on: ubuntu-latest
if: |
(github.event.issue.pull_request
(github.event.issue.pull_request
&& !github.event.issue.pull_request.merged_at
&& contains(github.event.comment.body, 'signed')
)
)
|| (github.event.pull_request && !github.event.pull_request.merged)
steps:
- uses: Shopify/shopify-cla-action@v1
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @shopify/discount-app-components

## 2.1.2

### Patch Changes

- [#188](https://github.com/Shopify/discount-app-components/pull/188) [`0e366a8`](https://github.com/Shopify/discount-app-components/commit/0e366a8f9ede089de37ec4f8fcf0a86577c4711f) Thanks [@mathiusj](https://github.com/mathiusj)! - move strategy to constants

## 2.1.1

### Patch Changes

- [#186](https://github.com/Shopify/discount-app-components/pull/186) [`4b47938`](https://github.com/Shopify/discount-app-components/commit/4b479380fb64cc4c730b9faff3baa22dc1227789) Thanks [@mathiusj](https://github.com/mathiusj)! - export strategy type from index

## 2.1.0

### Minor Changes

- [#178](https://github.com/Shopify/discount-app-components/pull/178) [`0d67597`](https://github.com/Shopify/discount-app-components/commit/0d67597354622bd9fd616bfc7ca93dca1c013401) Thanks [@mathiusj](https://github.com/mathiusj)! - add strategy all to DiscountApplicationStrategyCard

## 2.0.0

### Major Changes
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

`@shopify/discount-app-components` provides a set of stateless discount components to help 3p app developers create [AppBridge](https://shopify.dev/apps/tools/app-bridge)-powered discounts apps.

## Note on updates

While we strive to keep the library updated, please note that the current version available in the Shopify admin may be different from this version. We will communicate upcoming updates as they are planned.

## App development

For more information about creating apps for the Shopify App Store, see the [app development documentation](https://shopify.dev/apps).
Expand Down
4 changes: 4 additions & 0 deletions locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@
"maximum": {
"label": "Maximum",
"helpText": "Uplatní se jen sleva, která nabízí maximální snížení částky."
},
"all": {
"label": "Vše",
"helpText": "Uplatní se všechny slevy za splnění příslušných podmínek."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Maksimum",
"helpText": "Anvend kun den rabat, der giver den maksimale prisnedsættelse."
},
"all": {
"label": "Alle",
"helpText": "Anvend alle rabatter med betingelser, der er opfyldt."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Maximal",
"helpText": "Nur den Rabatt verwenden, bei dem am meisten gespart wird."
},
"all": {
"label": "Alle",
"helpText": "Alle Rabatte anwenden, deren Bedingungen erfüllt sind."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Maximum",
"helpText": "Only apply the discount that offers the maximum reduction."
},
"all": {
"label": "All",
"helpText": "Apply all discounts with conditions that are satisfied."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@
"maximum": {
"label": "Máximo",
"helpText": "Aplica solo el descuento que ofrezca la máxima reducción del precio."
},
"all": {
"label": "Todos",
"helpText": "Aplica todos los descuentos cuyas condiciones se cumplan."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Enimmäistaso",
"helpText": "Käytä vain sellaista alennusta, joka tarjoaa suurimman alennuksen."
},
"all": {
"label": "Kaikki",
"helpText": "Sovella kaikkia alennuksia ehdoilla, jotka täyttyvät."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@
"maximum": {
"label": "Maximale",
"helpText": "Appliquer uniquement la réduction maximale."
},
"all": {
"label": "Tout",
"helpText": "Appliquez toutes les réductions dont les conditions sont satisfaites."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@
"maximum": {
"label": "Massimo",
"helpText": "Applica solo lo sconto che offre la massima riduzione."
},
"all": {
"label": "Tutti",
"helpText": "Applica tutti gli sconti con le condizioni soddisfatte."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "最大",
"helpText": "最大のディスカウントを提供するディスカウントのみを適用します。"
},
"all": {
"label": "すべて",
"helpText": "条件を満たしたすべてのディスカウントを適用します。"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "최대",
"helpText": "차액이 가장 큰 할인만 적용합니다."
},
"all": {
"label": "모두",
"helpText": "조건을 만족하는 모든 할인에 적용합니다."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Maksimum",
"helpText": "Bruk bare den rabatten som gir den største reduksjonen."
},
"all": {
"label": "Alle",
"helpText": "Bruk alle rabattene med betingelsene som er oppfylt."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Maximum",
"helpText": "Pas alleen de korting toe die de maximale reductie biedt."
},
"all": {
"label": "Alle",
"helpText": "Pas alle kortingen toe waarbij aan de voorwaarden is voldaan."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@
"maximum": {
"label": "Maksimum",
"helpText": "Zastosuj tylko ten rabat, który oferuje maksymalną obniżkę."
},
"all": {
"label": "Wszystko",
"helpText": "Zastosuj wszystkie rabaty, których warunki zostały spełnione."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@
"maximum": {
"label": "Máximo",
"helpText": "Somente aplique o desconto que oferece a redução máxima."
},
"all": {
"label": "Todos",
"helpText": "Aplique todos os descontos se as condições forem atendidas."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,10 @@
"maximum": {
"label": "Máximo",
"helpText": "Aplicar apenas o desconto que oferece a máxima redução."
},
"all": {
"label": "Tudo",
"helpText": "Aplique todos os descontos com as condições cumpridas."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Maximum",
"helpText": "Tillämpa bara den rabatt som erbjuder störst avdrag."
},
"all": {
"label": "Alla",
"helpText": "Tillämpa alla rabatter vars villkor uppfylls."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "ค่าสูงสุด",
"helpText": "ใช้งานเฉพาะส่วนลดที่มีมูลค่าส่วนลดมากที่สุด"
},
"all": {
"label": "ทั้งหมด",
"helpText": "ใช้งานส่วนลดทั้งหมดที่ตรงตามเงื่อนไข"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Maksimum",
"helpText": "Yalnızca maksimum en büyük düşüş sağlayan indirimi uygulayın."
},
"all": {
"label": "Tümü",
"helpText": "Koşulları karşılanan tüm indirimleri uygulayın."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "Tối đa",
"helpText": "Chỉ áp dụng ưu đãi giảm giá có mức khấu trừ tối đa."
},
"all": {
"label": "Tất cả",
"helpText": "Áp dụng mọi ưu đãi giảm giá có các điều kiện được thỏa mãn."
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "最大降幅",
"helpText": "仅应用提供最大金额降幅的折扣。"
},
"all": {
"label": "全部",
"helpText": "应用满足条件的全部折扣。"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@
"maximum": {
"label": "最大值",
"helpText": "僅套用提供最大折價的折扣。"
},
"all": {
"label": "全部",
"helpText": "僅在滿足條件的情況下,套用所有折扣。"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@shopify/discount-app-components",
"description": "Shopify’s discounts component library",
"version": "2.0.0",
"version": "2.1.2",
"author": "Shopify <dev@shopify.com>",
"repository": "https://github.com/Shopify/discount-app-components",
"bugs": "https://github.com/Shopify/discount-app-components/issues",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import React from 'react';
import {Box, Card, ChoiceList, Text, BlockStack} from '@shopify/polaris';
import {useI18n} from '@shopify/react-i18n';

import {DiscountApplicationStrategy, Field} from '../../types';
import {Field} from '../../types';
import {DiscountClass, DiscountApplicationStrategy} from '../../constants';

export interface DiscountAppStrategyProps {
/**
* The discount application strategy.
*/
strategy: Field<DiscountApplicationStrategy>;
discountClass: DiscountClass;
}

const I18N_SCOPE = {
Expand All @@ -17,12 +19,43 @@ const I18N_SCOPE = {

export function DiscountApplicationStrategyCard({
strategy,
discountClass,
}: DiscountAppStrategyProps) {
const [i18n] = useI18n();

const handleChange = (strategies: DiscountApplicationStrategy[]) =>
strategy.onChange(strategies[0]);

const isProduct = discountClass === DiscountClass.Product;
const isOrder = discountClass === DiscountClass.Order;
const isShipping = discountClass === DiscountClass.Shipping;

const choices = [
...(isProduct || isOrder
? [
{
value: DiscountApplicationStrategy.First,
label: i18n.translate('first.label', I18N_SCOPE),
helpText: i18n.translate('first.helpText', I18N_SCOPE),
},
{
value: DiscountApplicationStrategy.Maximum,
label: i18n.translate('maximum.label', I18N_SCOPE),
helpText: i18n.translate('maximum.helpText', I18N_SCOPE),
},
]
: []),
...(isProduct || isShipping
? [
{
value: DiscountApplicationStrategy.All,
label: i18n.translate('all.label', I18N_SCOPE),
helpText: i18n.translate('all.helpText', I18N_SCOPE),
},
]
: []),
];

return (
<Box paddingBlockEnd="400">
<Card padding="400">
Expand All @@ -33,18 +66,7 @@ export function DiscountApplicationStrategyCard({
<ChoiceList
title={i18n.translate('title', I18N_SCOPE)}
titleHidden
choices={[
{
value: DiscountApplicationStrategy.First,
label: i18n.translate('first.label', I18N_SCOPE),
helpText: i18n.translate('first.helpText', I18N_SCOPE),
},
{
value: DiscountApplicationStrategy.Maximum,
label: i18n.translate('maximum.label', I18N_SCOPE),
helpText: i18n.translate('maximum.helpText', I18N_SCOPE),
},
]}
choices={choices}
selected={[strategy.value]}
onChange={handleChange}
/>
Expand Down
Loading

0 comments on commit b2e188b

Please sign in to comment.