@treely/strapi-slices 7.14.0 → 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.
- package/dist/components/portfolio/ProjectInfo/ProjectInfo.d.ts +1 -1
- package/dist/models/fpm/FPMProject.d.ts +1 -0
- package/dist/slices/ProjectFacts/ProjectFacts.d.ts +1 -1
- package/dist/strapi-slices.cjs.development.js +69 -31
- package/dist/strapi-slices.cjs.development.js.map +1 -1
- package/dist/strapi-slices.cjs.production.min.js +1 -1
- package/dist/strapi-slices.cjs.production.min.js.map +1 -1
- package/dist/strapi-slices.esm.js +69 -31
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/portfolio/ProjectInfo/ProjectInfo.test.tsx +9 -4
- package/src/components/portfolio/ProjectInfo/ProjectInfo.tsx +45 -41
- package/src/components/portfolio/ProjectInfo/messages.de.ts +1 -1
- package/src/components/portfolio/ProjectInfo/messages.en.ts +1 -1
- package/src/integrations/strapi/getPortfolioProjects.test.ts +43 -22
- package/src/integrations/strapi/getPortfolioProjects.ts +39 -18
- package/src/models/fpm/FPMProject.ts +1 -0
- package/src/slices/ProjectFacts/ProjectFacts.stories.tsx +2 -1
- package/src/slices/ProjectFacts/ProjectFacts.tsx +1 -1
- package/src/slices/TextWithCard/TextWithCard.stories.tsx +1 -0
- package/src/test/integrationMocks/fpmProjectMock.ts +1 -0
|
@@ -536,10 +536,10 @@ var getStrapiProjects = /*#__PURE__*/function () {
|
|
|
536
536
|
}();
|
|
537
537
|
|
|
538
538
|
var getPortfolioProjects = /*#__PURE__*/function () {
|
|
539
|
-
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
539
|
+
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(locale, preview) {
|
|
540
540
|
var cache, _yield$Promise$all, fpmProjects, strapiProjects;
|
|
541
|
-
return _regeneratorRuntime().wrap(function
|
|
542
|
-
while (1) switch (
|
|
541
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
542
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
543
543
|
case 0:
|
|
544
544
|
if (locale === void 0) {
|
|
545
545
|
locale = 'en';
|
|
@@ -548,34 +548,72 @@ var getPortfolioProjects = /*#__PURE__*/function () {
|
|
|
548
548
|
preview = false;
|
|
549
549
|
}
|
|
550
550
|
cache = preview ? false : undefined;
|
|
551
|
-
|
|
551
|
+
_context2.next = 5;
|
|
552
552
|
return Promise.all([fpmClient.get('/public/projects', {
|
|
553
553
|
cache: cache
|
|
554
554
|
}), getStrapiProjects(locale, STRAPI_DEFAULT_POPULATE_DEPTH, preview)]);
|
|
555
555
|
case 5:
|
|
556
|
-
_yield$Promise$all =
|
|
556
|
+
_yield$Promise$all = _context2.sent;
|
|
557
557
|
fpmProjects = _yield$Promise$all[0].data;
|
|
558
558
|
strapiProjects = _yield$Promise$all[1];
|
|
559
|
-
return
|
|
560
|
-
var
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
559
|
+
return _context2.abrupt("return", Promise.all(fpmProjects.map(/*#__PURE__*/function () {
|
|
560
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(fpmProject) {
|
|
561
|
+
var _strapiProject$attrib;
|
|
562
|
+
var fpmProjectWithAverageSellableAmountPerYear, _error$response, strapiProject, toReturn;
|
|
563
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
564
|
+
while (1) switch (_context.prev = _context.next) {
|
|
565
|
+
case 0:
|
|
566
|
+
_context.prev = 0;
|
|
567
|
+
_context.next = 3;
|
|
568
|
+
return fpmClient.get("/public/projects/" + fpmProject.id, {
|
|
569
|
+
cache: cache
|
|
570
|
+
});
|
|
571
|
+
case 3:
|
|
572
|
+
fpmProjectWithAverageSellableAmountPerYear = _context.sent;
|
|
573
|
+
fpmProject.averageSellableAmountPerYear = fpmProjectWithAverageSellableAmountPerYear.data.averageSellableAmountPerYear;
|
|
574
|
+
// Handle 404 errors for private projects
|
|
575
|
+
_context.next = 14;
|
|
576
|
+
break;
|
|
577
|
+
case 7:
|
|
578
|
+
_context.prev = 7;
|
|
579
|
+
_context.t0 = _context["catch"](0);
|
|
580
|
+
if (!(((_error$response = _context.t0.response) == null ? void 0 : _error$response.status) === 404)) {
|
|
581
|
+
_context.next = 13;
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
fpmProject.averageSellableAmountPerYear = 0;
|
|
585
|
+
_context.next = 14;
|
|
586
|
+
break;
|
|
587
|
+
case 13:
|
|
588
|
+
throw _context.t0;
|
|
589
|
+
case 14:
|
|
590
|
+
strapiProject = strapiProjects.get(fpmProject.id);
|
|
591
|
+
toReturn = fpmProject;
|
|
592
|
+
if (strapiProject != null && strapiProject.attributes.slug) {
|
|
593
|
+
toReturn.slug = strapiProject.attributes.slug;
|
|
594
|
+
}
|
|
595
|
+
if (strapiProject != null && strapiProject.attributes.thumbnail) {
|
|
596
|
+
toReturn.thumbnail = strapiProject == null ? void 0 : strapiProject.attributes.thumbnail;
|
|
597
|
+
}
|
|
598
|
+
if (strapiProject != null && (_strapiProject$attrib = strapiProject.attributes.portfolio.data) != null && _strapiProject$attrib.attributes.host) {
|
|
599
|
+
toReturn.portfolioHost = strapiProject.attributes.portfolio.data.attributes.host;
|
|
600
|
+
}
|
|
601
|
+
return _context.abrupt("return", toReturn);
|
|
602
|
+
case 20:
|
|
603
|
+
case "end":
|
|
604
|
+
return _context.stop();
|
|
605
|
+
}
|
|
606
|
+
}, _callee, null, [[0, 7]]);
|
|
607
|
+
}));
|
|
608
|
+
return function (_x3) {
|
|
609
|
+
return _ref2.apply(this, arguments);
|
|
610
|
+
};
|
|
611
|
+
}())));
|
|
574
612
|
case 9:
|
|
575
613
|
case "end":
|
|
576
|
-
return
|
|
614
|
+
return _context2.stop();
|
|
577
615
|
}
|
|
578
|
-
},
|
|
616
|
+
}, _callee2);
|
|
579
617
|
}));
|
|
580
618
|
return function getPortfolioProjects(_x, _x2) {
|
|
581
619
|
return _ref.apply(this, arguments);
|
|
@@ -1414,7 +1452,7 @@ var messagesDe$7 = {
|
|
|
1414
1452
|
'features.projectInfo.properties.verificationStandard.label': 'Verifizierungsstandard',
|
|
1415
1453
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': 'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
|
|
1416
1454
|
'features.projectInfo.properties.verificationStandard.value.MfKWCH': 'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
|
|
1417
|
-
'features.projectInfo.properties.forecastedAmountYear.toolTip': 'Dies ist
|
|
1455
|
+
'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.',
|
|
1418
1456
|
'features.projectInfo.properties.forecastedAmountYear.label': 'Projektvolumen',
|
|
1419
1457
|
'features.projectInfo.properties.riskBuffer': 'Anteil Risikopuffer',
|
|
1420
1458
|
'features.projectInfo.properties.year': '{years} {years, plural, one {Jahr} other {Jahre} }'
|
|
@@ -1556,7 +1594,7 @@ var messagesEn$3 = {
|
|
|
1556
1594
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': 'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
|
|
1557
1595
|
'features.projectInfo.properties.verificationStandard.value.MfKWCH': 'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
|
|
1558
1596
|
'features.projectInfo.properties.forecastedAmountYear.label': 'Project Volume',
|
|
1559
|
-
'features.projectInfo.properties.forecastedAmountYear.toolTip': "This is the
|
|
1597
|
+
'features.projectInfo.properties.forecastedAmountYear.toolTip': "This is the average amount of credits that are issued per year. This value doesn't represent availabilities.",
|
|
1560
1598
|
'features.projectInfo.properties.riskBuffer': 'Risk Buffer Share',
|
|
1561
1599
|
'features.projectInfo.properties.year': '{years} {years, plural, one {year} other {years} }'
|
|
1562
1600
|
};
|
|
@@ -5589,15 +5627,15 @@ var ProjectInfo = function ProjectInfo(_ref) {
|
|
|
5589
5627
|
style: {
|
|
5590
5628
|
objectFit: 'contain'
|
|
5591
5629
|
}
|
|
5592
|
-
})))) : React.createElement(React.Fragment, null), project.
|
|
5630
|
+
})))) : React.createElement(React.Fragment, null), project.averageSellableAmountPerYear !== 0 || project.riskBuffer ? React.createElement(React.Fragment, null, React.createElement(Spacer, {
|
|
5593
5631
|
height: "8"
|
|
5594
5632
|
}), React.createElement(Divider, null), React.createElement(Spacer, {
|
|
5595
5633
|
height: "8"
|
|
5596
|
-
}), React.createElement(SimpleGrid, {
|
|
5634
|
+
})) : React.createElement(React.Fragment, null), React.createElement(SimpleGrid, {
|
|
5597
5635
|
columns: [1, null, null, 2],
|
|
5598
5636
|
spacingX: "10",
|
|
5599
5637
|
spacingY: "8"
|
|
5600
|
-
}, React.createElement(Tooltip, {
|
|
5638
|
+
}, project.averageSellableAmountPerYear !== 0 && React.createElement(Tooltip, {
|
|
5601
5639
|
label: formatMessage({
|
|
5602
5640
|
id: 'features.projectInfo.properties.forecastedAmountYear.toolTip'
|
|
5603
5641
|
})
|
|
@@ -5608,18 +5646,18 @@ var ProjectInfo = function ProjectInfo(_ref) {
|
|
|
5608
5646
|
text: formatMessage({
|
|
5609
5647
|
id: 'unit.formatter.tonsCo2PerYear'
|
|
5610
5648
|
}, {
|
|
5611
|
-
number: formatNumber(convertCo2AmountKgToTons(project.
|
|
5649
|
+
number: formatNumber(convertCo2AmountKgToTons(project.averageSellableAmountPerYear.toString()), {
|
|
5612
5650
|
maximumFractionDigits: 0
|
|
5613
5651
|
})
|
|
5614
5652
|
}),
|
|
5615
|
-
caption: subtitles.
|
|
5616
|
-
}))), React.createElement(Box, null, React.createElement(LabelTextPair, {
|
|
5653
|
+
caption: subtitles.averageSellableAmountPerYearSubtitle
|
|
5654
|
+
}))), project.riskBuffer && React.createElement(Box, null, React.createElement(LabelTextPair, {
|
|
5617
5655
|
label: formatMessage({
|
|
5618
5656
|
id: 'features.projectInfo.properties.riskBuffer'
|
|
5619
5657
|
}),
|
|
5620
5658
|
text: formatNumber(project.riskBuffer / 100, FORMAT_AS_PERCENT_CONFIG),
|
|
5621
5659
|
caption: subtitles.riskBufferSubtitle
|
|
5622
|
-
})))
|
|
5660
|
+
}))), React.createElement(Box, {
|
|
5623
5661
|
mt: "2"
|
|
5624
5662
|
}, React.createElement(CreditsAvailableBadge, {
|
|
5625
5663
|
status: project.creditAvailability
|