payment-kit 1.14.28 → 1.14.29

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/blocklet.yml CHANGED
@@ -14,7 +14,7 @@ repository:
14
14
  type: git
15
15
  url: git+https://github.com/blocklet/payment-kit.git
16
16
  specVersion: 1.2.8
17
- version: 1.14.28
17
+ version: 1.14.29
18
18
  logo: logo.png
19
19
  files:
20
20
  - dist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payment-kit",
3
- "version": "1.14.28",
3
+ "version": "1.14.29",
4
4
  "scripts": {
5
5
  "dev": "blocklet dev --open",
6
6
  "eject": "vite eject",
@@ -52,7 +52,7 @@
52
52
  "@arcblock/validator": "^1.18.128",
53
53
  "@blocklet/js-sdk": "1.16.28",
54
54
  "@blocklet/logger": "1.16.28",
55
- "@blocklet/payment-react": "1.14.28",
55
+ "@blocklet/payment-react": "1.14.29",
56
56
  "@blocklet/sdk": "1.16.28",
57
57
  "@blocklet/ui-react": "^2.10.16",
58
58
  "@blocklet/uploader": "^0.1.20",
@@ -118,7 +118,7 @@
118
118
  "devDependencies": {
119
119
  "@abtnode/types": "1.16.28",
120
120
  "@arcblock/eslint-config-ts": "^0.3.2",
121
- "@blocklet/payment-types": "1.14.28",
121
+ "@blocklet/payment-types": "1.14.29",
122
122
  "@types/cookie-parser": "^1.4.7",
123
123
  "@types/cors": "^2.8.17",
124
124
  "@types/debug": "^4.1.12",
@@ -160,5 +160,5 @@
160
160
  "parser": "typescript"
161
161
  }
162
162
  },
163
- "gitHead": "79178aa9251fb54006f6e0fe32a14619d1e8f06e"
163
+ "gitHead": "104f4189d9ef96c1e332ffa90824ebd3063c989d"
164
164
  }
@@ -129,7 +129,7 @@ export default function InvoiceList({
129
129
  {
130
130
  label: t('common.amount'),
131
131
  name: 'total',
132
- width: 60,
132
+ width: 80,
133
133
  align: 'right',
134
134
  options: {
135
135
  customBodyRenderLite: (_: string, index: number) => {
@@ -206,7 +206,7 @@ export function PaymentIntentActionsInner({ data, variant, onChange }: Props) {
206
206
  reset();
207
207
  const curAmount = formatBNStr(res?.amount, data.paymentCurrency.decimal);
208
208
  if (Number(curAmount) <= 0) {
209
- Toast.info(t('admin.paymentIntent.refund.empty'));
209
+ Toast.info(t('admin.paymentIntent.refundForm.empty'));
210
210
  return;
211
211
  }
212
212
  setValue('refund.amount', curAmount);
@@ -11,7 +11,11 @@ import ProductSelect from '../payment-link/product-select';
11
11
  import CreateProduct from '../product/create';
12
12
  import ProductItem from './product-item';
13
13
 
14
- export default function PricingTableProductSettings() {
14
+ export default function PricingTableProductSettings({
15
+ triggerError = () => {},
16
+ }: {
17
+ triggerError: (keys: { [key: string]: boolean }) => void;
18
+ }) {
15
19
  const { t } = useLocaleContext();
16
20
  const [params, setParams] = useSearchParams();
17
21
  const { products, refresh } = useProductsContext();
@@ -98,6 +102,13 @@ export default function PricingTableProductSettings() {
98
102
 
99
103
  const grouped = groupPricingTableItems(items.fields);
100
104
 
105
+ useEffect(() => {
106
+ const hasDifferentCurrency = items.fields.some(
107
+ (_, index) => !isPriceCurrencyAligned(items.fields as any[], products, index)
108
+ );
109
+ triggerError({ items: hasDifferentCurrency });
110
+ }, [items.fields, products]);
111
+
101
112
  return (
102
113
  <Stack spacing={2} alignItems="flex-start">
103
114
  <Typography variant="h6" sx={{ mb: 2, fontWeight: 600 }}>
@@ -81,7 +81,7 @@ export default function PriceActions({ data, onChange, variant, setAsDefault }:
81
81
  try {
82
82
  setState({ loading: true });
83
83
  await api.put(`/api/products/${data.product_id}`, { default_price_id: data.id }).then((res) => res.data);
84
- Toast.success(t('common.removed'));
84
+ Toast.success(t('common.saveAsDefaultPriceSuccess'));
85
85
  onChange(state.action);
86
86
  } catch (err) {
87
87
  console.error(err);
@@ -135,7 +135,7 @@ export default function PriceActions({ data, onChange, variant, setAsDefault }:
135
135
  { label: t('admin.pricingTable.add'), handler: onCreatePricingTable, color: 'primary', disabled: !data.recurring },
136
136
  ];
137
137
 
138
- if (setAsDefault) {
138
+ if (!setAsDefault) {
139
139
  actions.splice(4, 0, {
140
140
  label: t('admin.price.setAsDefault'),
141
141
  handler: onSetAsDefault,
@@ -10,8 +10,9 @@ import { FormProvider, useForm } from 'react-hook-form';
10
10
  import { useSearchParams } from 'react-router-dom';
11
11
  import { dispatch } from 'use-bus';
12
12
 
13
+ import { useSetState } from 'ahooks';
13
14
  import DrawerForm from '../../../../components/drawer-form';
14
- import PricingTableCustomerSettings from '../../../../components/pricing-table/customer-settings';
15
+ // import PricingTableCustomerSettings from '../../../../components/pricing-table/customer-settings';
15
16
  import PricingTablePaymentSettings from '../../../../components/pricing-table/payment-settings';
16
17
  import PricingTablePreview from '../../../../components/pricing-table/preview';
17
18
  import PricingTableProductSettings from '../../../../components/pricing-table/product-settings';
@@ -25,6 +26,7 @@ export default function CreatePricingTable() {
25
26
  const [step, setStep] = useState(0); // ['products', 'payment', 'portal']
26
27
  const [stashed, setStashed] = useState(0);
27
28
  const fullScreenRef = useRef(null);
29
+ const [errors, triggerError] = useSetState({});
28
30
 
29
31
  const methods = useForm<TPricingTable & any>({
30
32
  shouldUnregister: false,
@@ -64,6 +66,7 @@ export default function CreatePricingTable() {
64
66
  .then(() => {
65
67
  Toast.success(t('admin.pricingTable.saved'));
66
68
  methods.reset();
69
+ setStep(0);
67
70
  dispatch('drawer.submitted');
68
71
  dispatch('pricingTable.created');
69
72
  })
@@ -80,7 +83,10 @@ export default function CreatePricingTable() {
80
83
  };
81
84
 
82
85
  const onContinue = () => {
83
- if (step < 2) {
86
+ if (Object.values(errors).some((v) => v)) {
87
+ return;
88
+ }
89
+ if (step < 1) {
84
90
  setStep(step + 1);
85
91
  } else {
86
92
  methods.handleSubmit(async (formData: any) => {
@@ -107,9 +113,9 @@ export default function CreatePricingTable() {
107
113
  <Box flex={2} sx={{ borderRight: '1px solid #eee' }} position="relative">
108
114
  <Stack height="100%" spacing={2}>
109
115
  <Box overflow="auto" sx={{ pr: 2 }}>
110
- {step === 0 && <PricingTableProductSettings />}
116
+ {step === 0 && <PricingTableProductSettings triggerError={triggerError} />}
111
117
  {step === 1 && <PricingTablePaymentSettings />}
112
- {step === 2 && <PricingTableCustomerSettings />}
118
+ {/* {step === 2 && <PricingTableCustomerSettings />} */}
113
119
  </Box>
114
120
  <Stack
115
121
  padding={2}
@@ -124,7 +130,7 @@ export default function CreatePricingTable() {
124
130
  {t('common.previous')}
125
131
  </Button>
126
132
  <Button variant="contained" color="primary" onClick={onContinue}>
127
- {step === 2 ? t('common.save') : t('common.continue')}
133
+ {step === 1 ? t('common.save') : t('common.continue')}
128
134
  </Button>
129
135
  </Stack>
130
136
  </Stack>