@treely/strapi-slices 7.13.1 → 7.15.0

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,6 +1,6 @@
1
1
  import React from 'react';
2
- import { Article, BlogPosting, Brand, BreadcrumbList, Event, FAQPage, HowTo, LocalBusiness, Offer, Organization, Person, Product, Service, WebPage, WithContext } from 'schema-dts';
3
- type SupportedSchemaType = Article | BlogPosting | Brand | BreadcrumbList | Event | FAQPage | HowTo | LocalBusiness | Offer | Organization | Person | Product | Service | WebPage;
2
+ import { Article, BlogPosting, Brand, BreadcrumbList, Event, FAQPage, HowTo, LocalBusiness, Offer, Organization, Person, Product, QAPage, Service, SoftwareApplication, WebPage, WithContext } from 'schema-dts';
3
+ type SupportedSchemaType = Article | BlogPosting | Brand | BreadcrumbList | Event | FAQPage | HowTo | LocalBusiness | Offer | Organization | Person | Product | QAPage | Product | Service | SoftwareApplication | WebPage;
4
4
  interface SEOTagsProps {
5
5
  title: string;
6
6
  description: string;
@@ -16,7 +16,6 @@ interface SEOTagsProps {
16
16
  * This can be a single schema object or an array of schema objects.
17
17
  * Each object must include an `@context` property set to "https://schema.org"
18
18
  * and an `@type` property indicating the type of schema (e.g., Article, Product).
19
- * The schema falls back to the default schema if it is invalid.
20
19
  */
21
20
  schemaMarkup?: WithContext<SupportedSchemaType> | WithContext<SupportedSchemaType>[];
22
21
  }
@@ -10,7 +10,7 @@ export interface ProjectInfoProps {
10
10
  projectTypeSubtitle?: string;
11
11
  projectDeveloperSubtitle?: string;
12
12
  verificationStandardSubtitle?: string;
13
- forecastedAmountSubtitle?: string;
13
+ averageSellableAmountPerYearSubtitle?: string;
14
14
  riskBufferSubtitle?: string;
15
15
  buyCreditsSubtitle?: string;
16
16
  };
@@ -39,6 +39,7 @@ interface FPMProject {
39
39
  updatedAt: Date;
40
40
  };
41
41
  forecastedAmountYearly?: number;
42
+ averageSellableAmountPerYear: number;
42
43
  riskBuffer?: number;
43
44
  defaultIssuer?: Issuer;
44
45
  creditAvailability: CreditAvailability;
@@ -23,7 +23,7 @@ export interface ProjectFactsProps {
23
23
  projectTypeSubtitle?: string;
24
24
  projectDeveloperSubtitle?: string;
25
25
  verificationStandardSubtitle?: string;
26
- forecastedAmountSubtitle?: string;
26
+ averageSellableAmountPerYearSubtitle?: string;
27
27
  riskBufferSubtitle?: string;
28
28
  buyCreditsSubtitle?: string;
29
29
  contactTitle?: string;
@@ -555,10 +555,10 @@ var getStrapiProjects = /*#__PURE__*/function () {
555
555
  }();
556
556
 
557
557
  var getPortfolioProjects = /*#__PURE__*/function () {
558
- var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(locale, preview) {
558
+ var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(locale, preview) {
559
559
  var cache, _yield$Promise$all, fpmProjects, strapiProjects;
560
- return _regeneratorRuntime().wrap(function _callee$(_context) {
561
- while (1) switch (_context.prev = _context.next) {
560
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
561
+ while (1) switch (_context2.prev = _context2.next) {
562
562
  case 0:
563
563
  if (locale === void 0) {
564
564
  locale = 'en';
@@ -567,34 +567,72 @@ var getPortfolioProjects = /*#__PURE__*/function () {
567
567
  preview = false;
568
568
  }
569
569
  cache = preview ? false : undefined;
570
- _context.next = 5;
570
+ _context2.next = 5;
571
571
  return Promise.all([fpmClient.get('/public/projects', {
572
572
  cache: cache
573
573
  }), getStrapiProjects(locale, STRAPI_DEFAULT_POPULATE_DEPTH, preview)]);
574
574
  case 5:
575
- _yield$Promise$all = _context.sent;
575
+ _yield$Promise$all = _context2.sent;
576
576
  fpmProjects = _yield$Promise$all[0].data;
577
577
  strapiProjects = _yield$Promise$all[1];
578
- return _context.abrupt("return", fpmProjects.map(function (fpmProject) {
579
- var _strapiProject$attrib;
580
- var strapiProject = strapiProjects.get(fpmProject.id);
581
- var toReturn = fpmProject;
582
- if (strapiProject != null && strapiProject.attributes.slug) {
583
- toReturn.slug = strapiProject.attributes.slug;
584
- }
585
- if (strapiProject != null && strapiProject.attributes.thumbnail) {
586
- toReturn.thumbnail = strapiProject == null ? void 0 : strapiProject.attributes.thumbnail;
587
- }
588
- if (strapiProject != null && (_strapiProject$attrib = strapiProject.attributes.portfolio.data) != null && _strapiProject$attrib.attributes.host) {
589
- toReturn.portfolioHost = strapiProject.attributes.portfolio.data.attributes.host;
590
- }
591
- return toReturn;
592
- }));
578
+ return _context2.abrupt("return", Promise.all(fpmProjects.map(/*#__PURE__*/function () {
579
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(fpmProject) {
580
+ var _strapiProject$attrib;
581
+ var fpmProjectWithAverageSellableAmountPerYear, _error$response, strapiProject, toReturn;
582
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
583
+ while (1) switch (_context.prev = _context.next) {
584
+ case 0:
585
+ _context.prev = 0;
586
+ _context.next = 3;
587
+ return fpmClient.get("/public/projects/" + fpmProject.id, {
588
+ cache: cache
589
+ });
590
+ case 3:
591
+ fpmProjectWithAverageSellableAmountPerYear = _context.sent;
592
+ fpmProject.averageSellableAmountPerYear = fpmProjectWithAverageSellableAmountPerYear.data.averageSellableAmountPerYear;
593
+ // Handle 404 errors for private projects
594
+ _context.next = 14;
595
+ break;
596
+ case 7:
597
+ _context.prev = 7;
598
+ _context.t0 = _context["catch"](0);
599
+ if (!(((_error$response = _context.t0.response) == null ? void 0 : _error$response.status) === 404)) {
600
+ _context.next = 13;
601
+ break;
602
+ }
603
+ fpmProject.averageSellableAmountPerYear = 0;
604
+ _context.next = 14;
605
+ break;
606
+ case 13:
607
+ throw _context.t0;
608
+ case 14:
609
+ strapiProject = strapiProjects.get(fpmProject.id);
610
+ toReturn = fpmProject;
611
+ if (strapiProject != null && strapiProject.attributes.slug) {
612
+ toReturn.slug = strapiProject.attributes.slug;
613
+ }
614
+ if (strapiProject != null && strapiProject.attributes.thumbnail) {
615
+ toReturn.thumbnail = strapiProject == null ? void 0 : strapiProject.attributes.thumbnail;
616
+ }
617
+ if (strapiProject != null && (_strapiProject$attrib = strapiProject.attributes.portfolio.data) != null && _strapiProject$attrib.attributes.host) {
618
+ toReturn.portfolioHost = strapiProject.attributes.portfolio.data.attributes.host;
619
+ }
620
+ return _context.abrupt("return", toReturn);
621
+ case 20:
622
+ case "end":
623
+ return _context.stop();
624
+ }
625
+ }, _callee, null, [[0, 7]]);
626
+ }));
627
+ return function (_x3) {
628
+ return _ref2.apply(this, arguments);
629
+ };
630
+ }())));
593
631
  case 9:
594
632
  case "end":
595
- return _context.stop();
633
+ return _context2.stop();
596
634
  }
597
- }, _callee);
635
+ }, _callee2);
598
636
  }));
599
637
  return function getPortfolioProjects(_x, _x2) {
600
638
  return _ref.apply(this, arguments);
@@ -1000,6 +1038,10 @@ var getSchemaIdentifier = function getSchemaIdentifier(schema) {
1000
1038
  return "offer-" + ((_offer$price = offer.price) != null ? _offer$price : 'unknown-price');
1001
1039
  case 'WebPage':
1002
1040
  return getSchemaProperty(schema, 'name') || 'untitled-page';
1041
+ case 'QAPage':
1042
+ return getSchemaProperty(schema, 'name') || 'untitled-qa';
1043
+ case 'SoftwareApplication':
1044
+ return getSchemaProperty(schema, 'name') || 'untitled-software';
1003
1045
  default:
1004
1046
  return 'unknown-schema';
1005
1047
  }
@@ -1012,29 +1054,6 @@ var validateSchema = function validateSchema(schema) {
1012
1054
  }
1013
1055
  return schema['@context'] === 'https://schema.org' && '@type' in schema;
1014
1056
  };
1015
- var DEFAULT_SCHEMA = {
1016
- '@context': 'https://schema.org',
1017
- '@type': 'Organization',
1018
- name: 'Tree.ly',
1019
- url: 'https://tree.ly',
1020
- logo: 'https://cdn.tree.ly/logo.png',
1021
- address: {
1022
- '@type': 'PostalAddress',
1023
- streetAddress: 'Littengasse 2b/c',
1024
- addressLocality: 'Dornbirn',
1025
- postalCode: '6850',
1026
- addressRegion: 'Vorarlberg',
1027
- addressCountry: 'AT'
1028
- },
1029
- contactPoint: {
1030
- '@type': 'ContactPoint',
1031
- telephone: '+43-5572-432015',
1032
- contactType: 'Customer Service',
1033
- areaServed: 'AT',
1034
- availableLanguage: ['English', 'German']
1035
- },
1036
- sameAs: ['https://www.linkedin.com/company/tree-ly', 'https://www.facebook.com/treely', 'https://www.instagram.com/treely']
1037
- };
1038
1057
  var SEOTags = function SEOTags(_ref) {
1039
1058
  var _shareImage$url, _shareImage$alt;
1040
1059
  var title = _ref.title,
@@ -1049,18 +1068,17 @@ var SEOTags = function SEOTags(_ref) {
1049
1068
  schemaMarkup = _ref.schemaMarkup;
1050
1069
  var shareImageUrl = (_shareImage$url = shareImage == null ? void 0 : shareImage.url) != null ? _shareImage$url : DEFAULT_SHARE_IMAGE;
1051
1070
  var shareImageAlt = (_shareImage$alt = shareImage == null ? void 0 : shareImage.alt) != null ? _shareImage$alt : DEFAULT_SHARE_ALT;
1052
- var schemas = schemaMarkup || DEFAULT_SCHEMA;
1053
- var isValidSchema = validateSchema(schemas);
1071
+ var schemas = schemaMarkup;
1072
+ var isValidSchema = schemaMarkup ? validateSchema(schemaMarkup) : false;
1054
1073
  if (schemaMarkup && !isValidSchema) {
1055
- console.warn('Invalid schema markup provided to SEOTags component. Falling back to default schema.', schemaMarkup);
1056
- schemas = DEFAULT_SCHEMA;
1057
- isValidSchema = true;
1074
+ console.warn('Invalid schema markup provided to SEOTags component. Schema markup will not be rendered.', schemaMarkup);
1075
+ schemas = undefined;
1076
+ isValidSchema = false;
1058
1077
  }
1059
- var schemaArray = Array.isArray(schemas) ? schemas : [schemas];
1078
+ var schemaArray = schemas ? Array.isArray(schemas) ? schemas : [schemas] : [];
1060
1079
  var getSchemaKey = function getSchemaKey(schema, index) {
1061
1080
  var type = schema['@type'];
1062
1081
  var identifier = getSchemaIdentifier(schema);
1063
- // Add index to ensure uniqueness, especially for fallback identifiers
1064
1082
  return type + "-" + identifier + "-" + index;
1065
1083
  };
1066
1084
  return React__default.default.createElement(Head__default.default, null, React__default.default.createElement("title", null, title + " - " + metaTitleSuffix), React__default.default.createElement("meta", {
@@ -1453,7 +1471,7 @@ var messagesDe$7 = {
1453
1471
  'features.projectInfo.properties.verificationStandard.label': 'Verifizierungsstandard',
1454
1472
  'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': 'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
1455
1473
  'features.projectInfo.properties.verificationStandard.value.MfKWCH': 'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
1456
- 'features.projectInfo.properties.forecastedAmountYear.toolTip': 'Dies ist das jährliche Projekt-Senkenvolumen gemäß dem TÜV-geprüften PDD, dieser Wert stellt nicht die aktuellen Verfügbarkeiten dar.',
1474
+ 'features.projectInfo.properties.forecastedAmountYear.toolTip': 'Dies ist der jährlich verkaufbare Betrag an Credits pro Jahr im Durchschnitt. Dieser Wert repräsentiert nicht die Verfügbarkeiten.',
1457
1475
  'features.projectInfo.properties.forecastedAmountYear.label': 'Projektvolumen',
1458
1476
  'features.projectInfo.properties.riskBuffer': 'Anteil Risikopuffer',
1459
1477
  'features.projectInfo.properties.year': '{years} {years, plural, one {Jahr} other {Jahre} }'
@@ -1595,7 +1613,7 @@ var messagesEn$3 = {
1595
1613
  'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': 'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
1596
1614
  'features.projectInfo.properties.verificationStandard.value.MfKWCH': 'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
1597
1615
  'features.projectInfo.properties.forecastedAmountYear.label': 'Project Volume',
1598
- 'features.projectInfo.properties.forecastedAmountYear.toolTip': "This is the yearly project sink volume according to the TÜV-verified PDD, this value doesn't represent current availabilities.",
1616
+ 'features.projectInfo.properties.forecastedAmountYear.toolTip': "This is the average amount of credits that are issued per year. This value doesn't represent availabilities.",
1599
1617
  'features.projectInfo.properties.riskBuffer': 'Risk Buffer Share',
1600
1618
  'features.projectInfo.properties.year': '{years} {years, plural, one {year} other {years} }'
1601
1619
  };
@@ -5628,15 +5646,15 @@ var ProjectInfo = function ProjectInfo(_ref) {
5628
5646
  style: {
5629
5647
  objectFit: 'contain'
5630
5648
  }
5631
- })))) : React__default.default.createElement(React__default.default.Fragment, null), project.forecastedAmountYearly && project.riskBuffer ? React__default.default.createElement(React__default.default.Fragment, null, React__default.default.createElement(boemly.Spacer, {
5649
+ })))) : React__default.default.createElement(React__default.default.Fragment, null), project.averageSellableAmountPerYear !== 0 || project.riskBuffer ? React__default.default.createElement(React__default.default.Fragment, null, React__default.default.createElement(boemly.Spacer, {
5632
5650
  height: "8"
5633
5651
  }), React__default.default.createElement(boemly.Divider, null), React__default.default.createElement(boemly.Spacer, {
5634
5652
  height: "8"
5635
- }), React__default.default.createElement(boemly.SimpleGrid, {
5653
+ })) : React__default.default.createElement(React__default.default.Fragment, null), React__default.default.createElement(boemly.SimpleGrid, {
5636
5654
  columns: [1, null, null, 2],
5637
5655
  spacingX: "10",
5638
5656
  spacingY: "8"
5639
- }, React__default.default.createElement(boemly.Tooltip, {
5657
+ }, project.averageSellableAmountPerYear !== 0 && React__default.default.createElement(boemly.Tooltip, {
5640
5658
  label: formatMessage({
5641
5659
  id: 'features.projectInfo.properties.forecastedAmountYear.toolTip'
5642
5660
  })
@@ -5647,18 +5665,18 @@ var ProjectInfo = function ProjectInfo(_ref) {
5647
5665
  text: formatMessage({
5648
5666
  id: 'unit.formatter.tonsCo2PerYear'
5649
5667
  }, {
5650
- number: formatNumber(convertCo2AmountKgToTons(project.forecastedAmountYearly.toString()), {
5668
+ number: formatNumber(convertCo2AmountKgToTons(project.averageSellableAmountPerYear.toString()), {
5651
5669
  maximumFractionDigits: 0
5652
5670
  })
5653
5671
  }),
5654
- caption: subtitles.forecastedAmountSubtitle
5655
- }))), React__default.default.createElement(boemly.Box, null, React__default.default.createElement(boemly.LabelTextPair, {
5672
+ caption: subtitles.averageSellableAmountPerYearSubtitle
5673
+ }))), project.riskBuffer && React__default.default.createElement(boemly.Box, null, React__default.default.createElement(boemly.LabelTextPair, {
5656
5674
  label: formatMessage({
5657
5675
  id: 'features.projectInfo.properties.riskBuffer'
5658
5676
  }),
5659
5677
  text: formatNumber(project.riskBuffer / 100, FORMAT_AS_PERCENT_CONFIG),
5660
5678
  caption: subtitles.riskBufferSubtitle
5661
- })))) : React__default.default.createElement(React__default.default.Fragment, null), React__default.default.createElement(boemly.Box, {
5679
+ }))), React__default.default.createElement(boemly.Box, {
5662
5680
  mt: "2"
5663
5681
  }, React__default.default.createElement(CreditsAvailableBadge, {
5664
5682
  status: project.creditAvailability