@treely/strapi-slices 5.7.0 → 5.8.1

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.
@@ -1,3 +1,3 @@
1
1
  import { PortfolioProject } from '../..';
2
- declare const getPortfolioProjects: (locale?: string) => Promise<PortfolioProject[]>;
2
+ declare const getPortfolioProjects: (locale?: string, preview?: boolean) => Promise<PortfolioProject[]>;
3
3
  export default getPortfolioProjects;
@@ -0,0 +1,5 @@
1
+ interface SmallCheckoutForm {
2
+ contributionValueCurrency: string;
3
+ contributionValueKgs: string;
4
+ }
5
+ export default SmallCheckoutForm;
@@ -426,20 +426,30 @@ var strapiClient = /*#__PURE__*/axiosCacheInterceptor.setupCache( /*#__PURE__*/a
426
426
  }));
427
427
 
428
428
  var getPortfolioProjects = /*#__PURE__*/function () {
429
- var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(locale) {
430
- var _yield$Promise$all, fpmProjects, strapiProjects;
429
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(locale, preview) {
430
+ var params, _yield$Promise$all, fpmProjects, strapiProjects;
431
431
  return _regeneratorRuntime().wrap(function _callee$(_context) {
432
432
  while (1) switch (_context.prev = _context.next) {
433
433
  case 0:
434
- _context.next = 2;
434
+ if (locale === void 0) {
435
+ locale = 'en';
436
+ }
437
+ if (preview === void 0) {
438
+ preview = false;
439
+ }
440
+ params = {
441
+ populate: 'deep,6',
442
+ locale: locale,
443
+ 'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE
444
+ };
445
+ if (preview) {
446
+ params.publicationState = 'preview';
447
+ }
448
+ _context.next = 6;
435
449
  return Promise.all([fpmClient.get('/public/projects'), strapiClient.get('/projects', {
436
- params: {
437
- populate: 'deep,6',
438
- locale: locale,
439
- 'pagination[pageSize]': STRAPI_DEFAULT_PAGE_SIZE
440
- }
450
+ params: params
441
451
  })]);
442
- case 2:
452
+ case 6:
443
453
  _yield$Promise$all = _context.sent;
444
454
  fpmProjects = _yield$Promise$all[0].data;
445
455
  strapiProjects = _yield$Promise$all[1].data;
@@ -466,13 +476,13 @@ var getPortfolioProjects = /*#__PURE__*/function () {
466
476
  }
467
477
  return toReturn;
468
478
  }));
469
- case 6:
479
+ case 10:
470
480
  case "end":
471
481
  return _context.stop();
472
482
  }
473
483
  }, _callee);
474
484
  }));
475
- return function getPortfolioProjects(_x) {
485
+ return function getPortfolioProjects(_x, _x2) {
476
486
  return _ref.apply(this, arguments);
477
487
  };
478
488
  }();
@@ -4332,15 +4342,16 @@ var SmallCheckout = function SmallCheckout(_ref) {
4332
4342
  push = _useRouter.push;
4333
4343
  var validateForm = React.useCallback(function (values) {
4334
4344
  var errors = {};
4335
- if (!values.contributionValueCurrency) {
4345
+ var value = parseInt(values.contributionValueCurrency);
4346
+ if (!values.contributionValueCurrency || isNaN(value)) {
4336
4347
  errors.contributionValueCurrency = formatMessage({
4337
4348
  id: 'portfolio.smallCheckout.contributionValueCurrency.validation.empty'
4338
4349
  });
4339
- } else if (values.contributionValueCurrency < MINIMUM_CONTRIBUTION_VALUE_IN_MONEY) {
4350
+ } else if (value < MINIMUM_CONTRIBUTION_VALUE_IN_MONEY) {
4340
4351
  errors.contributionValueCurrency = formatMessage({
4341
4352
  id: "portfolio.smallCheckout.contributionValueCurrency.validation.tooLow." + currency
4342
4353
  });
4343
- } else if (values.contributionValueCurrency > MAXIMUM_CONTRIBUTION_VALUE_IN_MONEY) {
4354
+ } else if (value > MAXIMUM_CONTRIBUTION_VALUE_IN_MONEY) {
4344
4355
  errors.contributionValueCurrency = formatMessage({
4345
4356
  id: 'portfolio.smallCheckout.contributionValueCurrency.validation.tooHigh'
4346
4357
  });
@@ -4357,7 +4368,7 @@ var SmallCheckout = function SmallCheckout(_ref) {
4357
4368
  checkoutURL = new URL(FPM_API_URI + "/v1/webhooks/shop/checkout");
4358
4369
  currentURL = new URL(window.location.href);
4359
4370
  checkoutURL.searchParams.append('batchId', batchId);
4360
- checkoutURL.searchParams.append('quantity', Math.floor(contributionValueCurrency / pricePerKg).toString());
4371
+ checkoutURL.searchParams.append('quantity', Math.floor(parseInt(contributionValueCurrency) / pricePerKg).toString());
4361
4372
  checkoutURL.searchParams.append('cancelPath', currentURL.pathname);
4362
4373
  push(checkoutURL.toString());
4363
4374
  case 7:
@@ -4398,8 +4409,8 @@ var SmallCheckout = function SmallCheckout(_ref) {
4398
4409
  }))
4399
4410
  }))), React__default.default.createElement(formik.Formik, {
4400
4411
  initialValues: {
4401
- contributionValueCurrency: initialContributionValue,
4402
- contributionValueKgs: initialContributionValue / pricePerKg / 1000
4412
+ contributionValueCurrency: initialContributionValue.toString(),
4413
+ contributionValueKgs: (initialContributionValue / pricePerKg / 1000).toString()
4403
4414
  },
4404
4415
  validate: validateForm,
4405
4416
  onSubmit: onSubmit
@@ -4423,11 +4434,12 @@ var SmallCheckout = function SmallCheckout(_ref) {
4423
4434
  size: "md",
4424
4435
  inputProps: {
4425
4436
  type: 'number',
4426
- value: field.value,
4437
+ value: field.value || '',
4427
4438
  onChange: function onChange(e) {
4439
+ var value = e.target.valueAsNumber;
4428
4440
  setValues({
4429
- contributionValueCurrency: e.target.valueAsNumber,
4430
- contributionValueKgs: e.target.valueAsNumber / pricePerKg / 1000
4441
+ contributionValueCurrency: value.toString(),
4442
+ contributionValueKgs: (value / pricePerKg / 1000).toString()
4431
4443
  });
4432
4444
  }
4433
4445
  },
@@ -4453,12 +4465,12 @@ var SmallCheckout = function SmallCheckout(_ref) {
4453
4465
  size: "md",
4454
4466
  inputProps: {
4455
4467
  type: 'number',
4456
- value: field.value,
4468
+ value: field.value || '',
4457
4469
  onChange: function onChange(e) {
4458
- var value = e.target.valueAsNumber || 0;
4470
+ var value = e.target.valueAsNumber;
4459
4471
  setValues({
4460
- contributionValueCurrency: value * pricePerKg * 1000,
4461
- contributionValueKgs: value
4472
+ contributionValueCurrency: (value * pricePerKg * 1000).toString(),
4473
+ contributionValueKgs: value.toString()
4462
4474
  });
4463
4475
  }
4464
4476
  },