@treely/strapi-slices 7.15.0 → 7.15.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.
@@ -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.forecastedAmountYear.toolTip': string;
13
- 'features.projectInfo.properties.forecastedAmountYear.label': string;
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.forecastedAmountYear.label': string;
13
- 'features.projectInfo.properties.forecastedAmountYear.toolTip': string;
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
  };
@@ -0,0 +1,3 @@
1
+ import FPMProject from '../../models/fpm/FPMProject';
2
+ declare const getFpmProjectById: (projectId: string) => Promise<FPMProject>;
3
+ export default getFpmProjectById;
@@ -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.forecastedAmountYear.toolTip': string;
66
- 'features.projectInfo.properties.forecastedAmountYear.label': string;
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.forecastedAmountYear.label': string;
66
- 'features.projectInfo.properties.forecastedAmountYear.toolTip': string;
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 _callee2(locale, preview) {
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 _callee2$(_context2) {
561
- while (1) switch (_context2.prev = _context2.next) {
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
- _context2.next = 5;
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 = _context2.sent;
575
+ _yield$Promise$all = _context.sent;
576
576
  fpmProjects = _yield$Promise$all[0].data;
577
577
  strapiProjects = _yield$Promise$all[1];
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
- }())));
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 _context2.stop();
595
+ return _context.stop();
634
596
  }
635
- }, _callee2);
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.forecastedAmountYear.toolTip': 'Dies ist der jährlich verkaufbare Betrag an Credits pro Jahr im Durchschnitt. Dieser Wert repräsentiert nicht die Verfügbarkeiten.',
1475
- 'features.projectInfo.properties.forecastedAmountYear.label': 'Projektvolumen',
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.forecastedAmountYear.label': 'Project Volume',
1616
- 'features.projectInfo.properties.forecastedAmountYear.toolTip': "This is the average amount of credits that are issued per year. This value doesn't represent availabilities.",
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 !== 0 || project.riskBuffer ? React__default.default.createElement(React__default.default.Fragment, null, React__default.default.createElement(boemly.Spacer, {
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 !== 0 && React__default.default.createElement(boemly.Tooltip, {
5619
+ }, project.averageSellableAmountPerYear && project.averageSellableAmountPerYear > 0 && React__default.default.createElement(boemly.Tooltip, {
5658
5620
  label: formatMessage({
5659
- id: 'features.projectInfo.properties.forecastedAmountYear.toolTip'
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.forecastedAmountYear.label'
5625
+ id: 'features.projectInfo.properties.projectVolume.label'
5664
5626
  }),
5665
5627
  text: formatMessage({
5666
5628
  id: 'unit.formatter.tonsCo2PerYear'
@@ -5780,18 +5742,97 @@ var Contact = function Contact(_ref) {
5780
5742
  }) : React__default.default.createElement(React__default.default.Fragment, null)));
5781
5743
  };
5782
5744
 
5745
+ var getFpmProjectById = /*#__PURE__*/function () {
5746
+ var _ref = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(projectId) {
5747
+ var fpmResponse;
5748
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5749
+ while (1) switch (_context.prev = _context.next) {
5750
+ case 0:
5751
+ _context.next = 2;
5752
+ return fpmClient.get("/public/projects/" + projectId);
5753
+ case 2:
5754
+ fpmResponse = _context.sent;
5755
+ return _context.abrupt("return", fpmResponse.data);
5756
+ case 4:
5757
+ case "end":
5758
+ return _context.stop();
5759
+ }
5760
+ }, _callee);
5761
+ }));
5762
+ return function getFpmProjectById(_x) {
5763
+ return _ref.apply(this, arguments);
5764
+ };
5765
+ }();
5766
+
5783
5767
  var ProjectFacts = function ProjectFacts(_ref) {
5784
5768
  var slice = _ref.slice,
5785
5769
  project = _ref.project;
5786
- if (!project) {
5770
+ var _useState = React.useState(project),
5771
+ enhancedProject = _useState[0],
5772
+ setEnhancedProject = _useState[1];
5773
+ var _useState2 = React.useState(false),
5774
+ isLoading = _useState2[0],
5775
+ setIsLoading = _useState2[1];
5776
+ React.useEffect(function () {
5777
+ var fetchCompleteProjectData = /*#__PURE__*/function () {
5778
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5779
+ var completeFpmProject, mergedProject;
5780
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5781
+ while (1) switch (_context.prev = _context.next) {
5782
+ case 0:
5783
+ if (!(project && project.id)) {
5784
+ _context.next = 17;
5785
+ break;
5786
+ }
5787
+ setIsLoading(true);
5788
+ _context.prev = 2;
5789
+ _context.next = 5;
5790
+ return getFpmProjectById(project.id);
5791
+ case 5:
5792
+ completeFpmProject = _context.sent;
5793
+ // Merge the complete FPM data with existing project data (preserving Strapi fields like slug, portfolioHost, thumbnail)
5794
+ mergedProject = _extends({}, completeFpmProject, {
5795
+ slug: project.slug,
5796
+ portfolioHost: project.portfolioHost,
5797
+ thumbnail: project.thumbnail
5798
+ });
5799
+ setEnhancedProject(mergedProject);
5800
+ _context.next = 14;
5801
+ break;
5802
+ case 10:
5803
+ _context.prev = 10;
5804
+ _context.t0 = _context["catch"](2);
5805
+ console.error('Error fetching complete project data:', _context.t0);
5806
+ // Fallback to original project data if fetch fails
5807
+ setEnhancedProject(project);
5808
+ case 14:
5809
+ _context.prev = 14;
5810
+ setIsLoading(false);
5811
+ return _context.finish(14);
5812
+ case 17:
5813
+ case "end":
5814
+ return _context.stop();
5815
+ }
5816
+ }, _callee, null, [[2, 10, 14, 17]]);
5817
+ }));
5818
+ return function fetchCompleteProjectData() {
5819
+ return _ref2.apply(this, arguments);
5820
+ };
5821
+ }();
5822
+ fetchCompleteProjectData();
5823
+ }, [project]);
5824
+ if (!enhancedProject) {
5787
5825
  return React__default.default.createElement(React__default.default.Fragment, null, "Invalid configuration, check if a project this id exists in the FPM");
5788
5826
  }
5827
+ if (isLoading) {
5828
+ return React__default.default.createElement(boemly.DefaultSectionContainer, null, React__default.default.createElement(boemly.Wrapper, null, React__default.default.createElement("div", null, "Loading project data...")));
5829
+ }
5789
5830
  return React__default.default.createElement(boemly.DefaultSectionContainer, null, React__default.default.createElement(boemly.Wrapper, null, React__default.default.createElement(boemly.Flex, {
5790
5831
  flexDir: ['column', null, null, 'row'],
5791
5832
  gap: "4",
5792
5833
  width: "full"
5793
5834
  }, React__default.default.createElement(ProjectInfo, {
5794
- project: project,
5835
+ project: enhancedProject,
5795
5836
  subtitles: slice
5796
5837
  }), React__default.default.createElement(boemly.Flex, {
5797
5838
  flexDir: "column",