@treely/strapi-slices 7.15.0 → 7.15.2
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/messages.de.d.ts +2 -2
- package/dist/components/portfolio/ProjectInfo/messages.en.d.ts +2 -2
- package/dist/integrations/strapi/getFpmProjectById.d.ts +3 -0
- package/dist/rootMessages.de.d.ts +2 -2
- package/dist/rootMessages.en.d.ts +2 -2
- package/dist/strapi-slices.cjs.development.js +116 -73
- 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 +116 -73
- package/dist/strapi-slices.esm.js.map +1 -1
- package/dist/utils/getMessages.d.ts +4 -4
- package/package.json +1 -1
- package/src/components/portfolio/ProjectInfo/ProjectInfo.test.tsx +1 -1
- package/src/components/portfolio/ProjectInfo/ProjectInfo.tsx +17 -8
- package/src/components/portfolio/ProjectInfo/messages.de.ts +3 -4
- package/src/components/portfolio/ProjectInfo/messages.en.ts +2 -3
- package/src/integrations/strapi/getFpmProjectById.test.ts +24 -0
- package/src/integrations/strapi/getFpmProjectById.ts +12 -0
- package/src/integrations/strapi/getPortfolioProjects.test.ts +22 -43
- package/src/integrations/strapi/getPortfolioProjects.ts +18 -39
- package/src/slices/ProjectFacts/ProjectFacts.test.tsx +54 -6
- package/src/slices/ProjectFacts/ProjectFacts.tsx +48 -3
- package/src/utils/shuffleElements.test.ts +30 -12
|
@@ -9,8 +9,8 @@ declare const messagesDe: {
|
|
|
9
9
|
'features.projectInfo.properties.verificationStandard.label': string;
|
|
10
10
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': string;
|
|
11
11
|
'features.projectInfo.properties.verificationStandard.value.MfKWCH': string;
|
|
12
|
-
'features.projectInfo.properties.
|
|
13
|
-
'features.projectInfo.properties.
|
|
12
|
+
'features.projectInfo.properties.projectVolume.toolTip': string;
|
|
13
|
+
'features.projectInfo.properties.projectVolume.label': string;
|
|
14
14
|
'features.projectInfo.properties.riskBuffer': string;
|
|
15
15
|
'features.projectInfo.properties.year': string;
|
|
16
16
|
};
|
|
@@ -9,8 +9,8 @@ declare const messagesEn: {
|
|
|
9
9
|
'features.projectInfo.properties.verificationStandard.label': string;
|
|
10
10
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': string;
|
|
11
11
|
'features.projectInfo.properties.verificationStandard.value.MfKWCH': string;
|
|
12
|
-
'features.projectInfo.properties.
|
|
13
|
-
'features.projectInfo.properties.
|
|
12
|
+
'features.projectInfo.properties.projectVolume.label': string;
|
|
13
|
+
'features.projectInfo.properties.projectVolume.toolTip': string;
|
|
14
14
|
'features.projectInfo.properties.riskBuffer': string;
|
|
15
15
|
'features.projectInfo.properties.year': string;
|
|
16
16
|
};
|
|
@@ -62,8 +62,8 @@ declare const rootMessagesDe: {
|
|
|
62
62
|
'features.projectInfo.properties.verificationStandard.label': string;
|
|
63
63
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': string;
|
|
64
64
|
'features.projectInfo.properties.verificationStandard.value.MfKWCH': string;
|
|
65
|
-
'features.projectInfo.properties.
|
|
66
|
-
'features.projectInfo.properties.
|
|
65
|
+
'features.projectInfo.properties.projectVolume.toolTip': string;
|
|
66
|
+
'features.projectInfo.properties.projectVolume.label': string;
|
|
67
67
|
'features.projectInfo.properties.riskBuffer': string;
|
|
68
68
|
'features.projectInfo.properties.year': string;
|
|
69
69
|
'features.portfolio.documentsDownloadList.projectDocuments': string;
|
|
@@ -62,8 +62,8 @@ declare const rootMessagesEn: {
|
|
|
62
62
|
'features.projectInfo.properties.verificationStandard.label': string;
|
|
63
63
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': string;
|
|
64
64
|
'features.projectInfo.properties.verificationStandard.value.MfKWCH': string;
|
|
65
|
-
'features.projectInfo.properties.
|
|
66
|
-
'features.projectInfo.properties.
|
|
65
|
+
'features.projectInfo.properties.projectVolume.label': string;
|
|
66
|
+
'features.projectInfo.properties.projectVolume.toolTip': string;
|
|
67
67
|
'features.projectInfo.properties.riskBuffer': string;
|
|
68
68
|
'features.projectInfo.properties.year': string;
|
|
69
69
|
'features.portfolio.documentsDownloadList.projectDocuments': 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
|
|
558
|
+
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(locale, preview) {
|
|
559
559
|
var cache, _yield$Promise$all, fpmProjects, strapiProjects;
|
|
560
|
-
return _regeneratorRuntime().wrap(function
|
|
561
|
-
while (1) switch (
|
|
560
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
561
|
+
while (1) switch (_context.prev = _context.next) {
|
|
562
562
|
case 0:
|
|
563
563
|
if (locale === void 0) {
|
|
564
564
|
locale = 'en';
|
|
@@ -567,72 +567,34 @@ var getPortfolioProjects = /*#__PURE__*/function () {
|
|
|
567
567
|
preview = false;
|
|
568
568
|
}
|
|
569
569
|
cache = preview ? false : undefined;
|
|
570
|
-
|
|
570
|
+
_context.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 =
|
|
575
|
+
_yield$Promise$all = _context.sent;
|
|
576
576
|
fpmProjects = _yield$Promise$all[0].data;
|
|
577
577
|
strapiProjects = _yield$Promise$all[1];
|
|
578
|
-
return
|
|
579
|
-
var
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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
|
-
}())));
|
|
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
|
+
}));
|
|
631
593
|
case 9:
|
|
632
594
|
case "end":
|
|
633
|
-
return
|
|
595
|
+
return _context.stop();
|
|
634
596
|
}
|
|
635
|
-
},
|
|
597
|
+
}, _callee);
|
|
636
598
|
}));
|
|
637
599
|
return function getPortfolioProjects(_x, _x2) {
|
|
638
600
|
return _ref.apply(this, arguments);
|
|
@@ -1471,8 +1433,8 @@ var messagesDe$7 = {
|
|
|
1471
1433
|
'features.projectInfo.properties.verificationStandard.label': 'Verifizierungsstandard',
|
|
1472
1434
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': 'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
|
|
1473
1435
|
'features.projectInfo.properties.verificationStandard.value.MfKWCH': 'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
|
|
1474
|
-
'features.projectInfo.properties.
|
|
1475
|
-
'features.projectInfo.properties.
|
|
1436
|
+
'features.projectInfo.properties.projectVolume.toolTip': 'Dies ist die durchschnittliche Anzahl der Credits, die pro Jahr ausgestellt werden. Dieser Wert entspricht nicht den Verfügbarkeiten.',
|
|
1437
|
+
'features.projectInfo.properties.projectVolume.label': 'Projektvolumen',
|
|
1476
1438
|
'features.projectInfo.properties.riskBuffer': 'Anteil Risikopuffer',
|
|
1477
1439
|
'features.projectInfo.properties.year': '{years} {years, plural, one {Jahr} other {Jahre} }'
|
|
1478
1440
|
};
|
|
@@ -1612,8 +1574,8 @@ var messagesEn$3 = {
|
|
|
1612
1574
|
'features.projectInfo.properties.verificationStandard.label': 'Verification Standard',
|
|
1613
1575
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14': 'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
|
|
1614
1576
|
'features.projectInfo.properties.verificationStandard.value.MfKWCH': 'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
|
|
1615
|
-
'features.projectInfo.properties.
|
|
1616
|
-
'features.projectInfo.properties.
|
|
1577
|
+
'features.projectInfo.properties.projectVolume.label': 'Project Volume',
|
|
1578
|
+
'features.projectInfo.properties.projectVolume.toolTip': "This is the average amount of credits that are issued per year. This value doesn't represent availabilities.",
|
|
1617
1579
|
'features.projectInfo.properties.riskBuffer': 'Risk Buffer Share',
|
|
1618
1580
|
'features.projectInfo.properties.year': '{years} {years, plural, one {year} other {years} }'
|
|
1619
1581
|
};
|
|
@@ -5646,7 +5608,7 @@ var ProjectInfo = function ProjectInfo(_ref) {
|
|
|
5646
5608
|
style: {
|
|
5647
5609
|
objectFit: 'contain'
|
|
5648
5610
|
}
|
|
5649
|
-
})))) : React__default.default.createElement(React__default.default.Fragment, null), project.averageSellableAmountPerYear
|
|
5611
|
+
})))) : React__default.default.createElement(React__default.default.Fragment, null), project.averageSellableAmountPerYear && project.averageSellableAmountPerYear > 0 || project.riskBuffer ? React__default.default.createElement(React__default.default.Fragment, null, React__default.default.createElement(boemly.Spacer, {
|
|
5650
5612
|
height: "8"
|
|
5651
5613
|
}), React__default.default.createElement(boemly.Divider, null), React__default.default.createElement(boemly.Spacer, {
|
|
5652
5614
|
height: "8"
|
|
@@ -5654,13 +5616,13 @@ var ProjectInfo = function ProjectInfo(_ref) {
|
|
|
5654
5616
|
columns: [1, null, null, 2],
|
|
5655
5617
|
spacingX: "10",
|
|
5656
5618
|
spacingY: "8"
|
|
5657
|
-
}, project.averageSellableAmountPerYear
|
|
5619
|
+
}, project.averageSellableAmountPerYear > 0 ? React__default.default.createElement(boemly.Tooltip, {
|
|
5658
5620
|
label: formatMessage({
|
|
5659
|
-
id: 'features.projectInfo.properties.
|
|
5621
|
+
id: 'features.projectInfo.properties.projectVolume.toolTip'
|
|
5660
5622
|
})
|
|
5661
5623
|
}, React__default.default.createElement(boemly.Box, null, React__default.default.createElement(boemly.LabelTextPair, {
|
|
5662
5624
|
label: formatMessage({
|
|
5663
|
-
id: 'features.projectInfo.properties.
|
|
5625
|
+
id: 'features.projectInfo.properties.projectVolume.label'
|
|
5664
5626
|
}),
|
|
5665
5627
|
text: formatMessage({
|
|
5666
5628
|
id: 'unit.formatter.tonsCo2PerYear'
|
|
@@ -5670,17 +5632,19 @@ var ProjectInfo = function ProjectInfo(_ref) {
|
|
|
5670
5632
|
})
|
|
5671
5633
|
}),
|
|
5672
5634
|
caption: subtitles.averageSellableAmountPerYearSubtitle
|
|
5673
|
-
})))
|
|
5635
|
+
}))) : React__default.default.createElement(boemly.Box, null, React__default.default.createElement(CreditsAvailableBadge, {
|
|
5636
|
+
status: project.creditAvailability
|
|
5637
|
+
})), project.riskBuffer && React__default.default.createElement(boemly.Box, null, React__default.default.createElement(boemly.LabelTextPair, {
|
|
5674
5638
|
label: formatMessage({
|
|
5675
5639
|
id: 'features.projectInfo.properties.riskBuffer'
|
|
5676
5640
|
}),
|
|
5677
5641
|
text: formatNumber(project.riskBuffer / 100, FORMAT_AS_PERCENT_CONFIG),
|
|
5678
5642
|
caption: subtitles.riskBufferSubtitle
|
|
5679
|
-
}))), React__default.default.createElement(boemly.Box, {
|
|
5643
|
+
}))), project.averageSellableAmountPerYear > 0 ? React__default.default.createElement(boemly.Box, {
|
|
5680
5644
|
mt: "2"
|
|
5681
5645
|
}, React__default.default.createElement(CreditsAvailableBadge, {
|
|
5682
5646
|
status: project.creditAvailability
|
|
5683
|
-
})));
|
|
5647
|
+
})) : React__default.default.createElement(React__default.default.Fragment, null));
|
|
5684
5648
|
};
|
|
5685
5649
|
|
|
5686
5650
|
var DocumentsDownloadList = function DocumentsDownloadList(_ref) {
|
|
@@ -5780,18 +5744,97 @@ var Contact = function Contact(_ref) {
|
|
|
5780
5744
|
}) : React__default.default.createElement(React__default.default.Fragment, null)));
|
|
5781
5745
|
};
|
|
5782
5746
|
|
|
5747
|
+
var getFpmProjectById = /*#__PURE__*/function () {
|
|
5748
|
+
var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(projectId) {
|
|
5749
|
+
var fpmResponse;
|
|
5750
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
5751
|
+
while (1) switch (_context.prev = _context.next) {
|
|
5752
|
+
case 0:
|
|
5753
|
+
_context.next = 2;
|
|
5754
|
+
return fpmClient.get("/public/projects/" + projectId);
|
|
5755
|
+
case 2:
|
|
5756
|
+
fpmResponse = _context.sent;
|
|
5757
|
+
return _context.abrupt("return", fpmResponse.data);
|
|
5758
|
+
case 4:
|
|
5759
|
+
case "end":
|
|
5760
|
+
return _context.stop();
|
|
5761
|
+
}
|
|
5762
|
+
}, _callee);
|
|
5763
|
+
}));
|
|
5764
|
+
return function getFpmProjectById(_x) {
|
|
5765
|
+
return _ref.apply(this, arguments);
|
|
5766
|
+
};
|
|
5767
|
+
}();
|
|
5768
|
+
|
|
5783
5769
|
var ProjectFacts = function ProjectFacts(_ref) {
|
|
5784
5770
|
var slice = _ref.slice,
|
|
5785
5771
|
project = _ref.project;
|
|
5786
|
-
|
|
5772
|
+
var _useState = React.useState(project),
|
|
5773
|
+
enhancedProject = _useState[0],
|
|
5774
|
+
setEnhancedProject = _useState[1];
|
|
5775
|
+
var _useState2 = React.useState(false),
|
|
5776
|
+
isLoading = _useState2[0],
|
|
5777
|
+
setIsLoading = _useState2[1];
|
|
5778
|
+
React.useEffect(function () {
|
|
5779
|
+
var fetchCompleteProjectData = /*#__PURE__*/function () {
|
|
5780
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
5781
|
+
var completeFpmProject, mergedProject;
|
|
5782
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
5783
|
+
while (1) switch (_context.prev = _context.next) {
|
|
5784
|
+
case 0:
|
|
5785
|
+
if (!(project && project.id)) {
|
|
5786
|
+
_context.next = 17;
|
|
5787
|
+
break;
|
|
5788
|
+
}
|
|
5789
|
+
setIsLoading(true);
|
|
5790
|
+
_context.prev = 2;
|
|
5791
|
+
_context.next = 5;
|
|
5792
|
+
return getFpmProjectById(project.id);
|
|
5793
|
+
case 5:
|
|
5794
|
+
completeFpmProject = _context.sent;
|
|
5795
|
+
// Merge the complete FPM data with existing project data (preserving Strapi fields like slug, portfolioHost, thumbnail)
|
|
5796
|
+
mergedProject = _extends({}, completeFpmProject, {
|
|
5797
|
+
slug: project.slug,
|
|
5798
|
+
portfolioHost: project.portfolioHost,
|
|
5799
|
+
thumbnail: project.thumbnail
|
|
5800
|
+
});
|
|
5801
|
+
setEnhancedProject(mergedProject);
|
|
5802
|
+
_context.next = 14;
|
|
5803
|
+
break;
|
|
5804
|
+
case 10:
|
|
5805
|
+
_context.prev = 10;
|
|
5806
|
+
_context.t0 = _context["catch"](2);
|
|
5807
|
+
console.error('Error fetching complete project data:', _context.t0);
|
|
5808
|
+
// Fallback to original project data if fetch fails
|
|
5809
|
+
setEnhancedProject(project);
|
|
5810
|
+
case 14:
|
|
5811
|
+
_context.prev = 14;
|
|
5812
|
+
setIsLoading(false);
|
|
5813
|
+
return _context.finish(14);
|
|
5814
|
+
case 17:
|
|
5815
|
+
case "end":
|
|
5816
|
+
return _context.stop();
|
|
5817
|
+
}
|
|
5818
|
+
}, _callee, null, [[2, 10, 14, 17]]);
|
|
5819
|
+
}));
|
|
5820
|
+
return function fetchCompleteProjectData() {
|
|
5821
|
+
return _ref2.apply(this, arguments);
|
|
5822
|
+
};
|
|
5823
|
+
}();
|
|
5824
|
+
fetchCompleteProjectData();
|
|
5825
|
+
}, [project]);
|
|
5826
|
+
if (!enhancedProject) {
|
|
5787
5827
|
return React__default.default.createElement(React__default.default.Fragment, null, "Invalid configuration, check if a project this id exists in the FPM");
|
|
5788
5828
|
}
|
|
5829
|
+
if (isLoading) {
|
|
5830
|
+
return React__default.default.createElement(boemly.DefaultSectionContainer, null, React__default.default.createElement(boemly.Wrapper, null, React__default.default.createElement("div", null, "Loading project data...")));
|
|
5831
|
+
}
|
|
5789
5832
|
return React__default.default.createElement(boemly.DefaultSectionContainer, null, React__default.default.createElement(boemly.Wrapper, null, React__default.default.createElement(boemly.Flex, {
|
|
5790
5833
|
flexDir: ['column', null, null, 'row'],
|
|
5791
5834
|
gap: "4",
|
|
5792
5835
|
width: "full"
|
|
5793
5836
|
}, React__default.default.createElement(ProjectInfo, {
|
|
5794
|
-
project:
|
|
5837
|
+
project: enhancedProject,
|
|
5795
5838
|
subtitles: slice
|
|
5796
5839
|
}), React__default.default.createElement(boemly.Flex, {
|
|
5797
5840
|
flexDir: "column",
|