@treely/strapi-slices 5.15.1 → 5.17.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/README.md +6 -0
- package/dist/components/CreditsAvailableBadge/CreditsAvailableBadge.d.ts +2 -2
- package/dist/models/PortfolioProject.d.ts +0 -3
- package/dist/models/fpm/FPMProject.d.ts +8 -0
- package/dist/models/strapi/StrapiProject.d.ts +0 -2
- package/dist/rootMessages.de.d.ts +2 -5
- package/dist/rootMessages.en.d.ts +2 -5
- package/dist/slices/ProjectFacts/messages.de.d.ts +0 -1
- package/dist/slices/ProjectFacts/messages.en.d.ts +0 -1
- package/dist/slices/ProjectGridCard/ProjectGridCard.d.ts +6 -0
- package/dist/slices/ProjectGridCard/index.d.ts +2 -0
- package/dist/slices/ProjectGridCard/messages.de.d.ts +5 -0
- package/dist/slices/ProjectGridCard/messages.en.d.ts +5 -0
- package/dist/slices/ProjectsGrid/ProjectsGrid.d.ts +3 -1
- package/dist/slices/ProjectsGrid/ProjectsGrid.stories.d.ts +2 -0
- package/dist/slices/ProjectsMap/MapMarker.d.ts +3 -3
- package/dist/strapi-slices.cjs.development.js +144 -137
- 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 +146 -139
- package/dist/strapi-slices.esm.js.map +1 -1
- package/dist/utils/getMessages.d.ts +4 -10
- package/package.json +1 -1
- package/src/components/CreditsAvailableBadge/CreditsAvailableBadge.test.tsx +8 -6
- package/src/components/CreditsAvailableBadge/CreditsAvailableBadge.tsx +31 -22
- package/src/components/CreditsAvailableBadge/messages.de.ts +1 -1
- package/src/components/portfolio/ProjectInfo/ProjectInfo.tsx +3 -7
- package/src/integrations/strapi/getPortfolioProjects.test.ts +2 -2
- package/src/integrations/strapi/getPortfolioProjects.ts +0 -6
- package/src/models/PortfolioProject.ts +0 -3
- package/src/models/fpm/FPMProject.ts +9 -0
- package/src/models/strapi/StrapiProject.ts +0 -2
- package/src/rootMessages.de.ts +2 -2
- package/src/rootMessages.en.ts +2 -2
- package/src/slices/ProjectFacts/ProjectFacts.stories.tsx +1 -2
- package/src/slices/ProjectFacts/messages.de.ts +0 -1
- package/src/slices/ProjectFacts/messages.en.ts +0 -1
- package/src/slices/ProjectGridCard/ProjectGridCard.test.tsx +60 -0
- package/src/slices/ProjectGridCard/ProjectGridCard.tsx +75 -0
- package/src/slices/ProjectGridCard/index.ts +3 -0
- package/src/slices/ProjectGridCard/messages.de.ts +6 -0
- package/src/slices/ProjectGridCard/messages.en.ts +6 -0
- package/src/slices/ProjectsGrid/ProjectsGrid.stories.tsx +35 -1
- package/src/slices/ProjectsGrid/ProjectsGrid.test.tsx +0 -3
- package/src/slices/ProjectsGrid/ProjectsGrid.tsx +5 -3
- package/src/slices/ProjectsMap/MapMarker.test.tsx +3 -2
- package/src/slices/ProjectsMap/MapMarker.tsx +9 -12
- package/src/slices/ProjectsMap/ProjectsMap.stories.tsx +0 -2
- package/src/slices/ProjectsMap/ProjectsMap.tsx +1 -1
- package/src/slices/TextWithCard/TextWithCard.stories.tsx +2 -3
- package/src/slices/TextWithCard/TextWithCard.tsx +2 -2
- package/src/test/integrationMocks/fpmProjectMock.ts +3 -1
- package/src/test/integrationMocks/portfolioProjectMock.ts +1 -3
- package/src/test/mocks/portfolioProjectMock.ts +0 -2
- package/src/test/strapiMocks/strapiProject.ts +0 -2
- package/dist/components/portfolio/PortfolioProjectCard/PortfolioProjectCard.d.ts +0 -6
- package/dist/components/portfolio/PortfolioProjectCard/index.d.ts +0 -2
- package/dist/components/portfolio/PortfolioProjectCard/messages.de.d.ts +0 -7
- package/dist/components/portfolio/PortfolioProjectCard/messages.en.d.ts +0 -7
- package/dist/models/CreditsAvailableState.d.ts +0 -7
- package/src/components/portfolio/PortfolioProjectCard/PortfolioProjectCard.test.tsx +0 -53
- package/src/components/portfolio/PortfolioProjectCard/PortfolioProjectCard.tsx +0 -69
- package/src/components/portfolio/PortfolioProjectCard/index.ts +0 -3
- package/src/components/portfolio/PortfolioProjectCard/messages.de.ts +0 -8
- package/src/components/portfolio/PortfolioProjectCard/messages.en.ts +0 -8
- package/src/models/CreditsAvailableState.ts +0 -8
|
@@ -20,8 +20,9 @@ declare const getMessages: (locale: string) => {
|
|
|
20
20
|
'sections.shopCheckout.summary.price.taxIncluded': string;
|
|
21
21
|
'sections.shopCheckout.submit': string;
|
|
22
22
|
'sections.projectsMap.link.text': string;
|
|
23
|
+
'sections.projectCardGrid.certified': string;
|
|
24
|
+
'sections.projectCardGrid.certificationInProgres': string;
|
|
23
25
|
'sections.projectFacts.projectInfo.value': string;
|
|
24
|
-
'projects.projectFacts.properties.area': string;
|
|
25
26
|
'sections.glossary.copyButtonLabel': string;
|
|
26
27
|
'sections.glossary.copySuccessMessage': string;
|
|
27
28
|
'sections.glossary.copyFailureMessage': string;
|
|
@@ -59,10 +60,6 @@ declare const getMessages: (locale: string) => {
|
|
|
59
60
|
'features.projectInfo.properties.forecastedAmountYear.toolTip': string;
|
|
60
61
|
'features.projectInfo.properties.riskBuffer': string;
|
|
61
62
|
'features.projectInfo.properties.year': string;
|
|
62
|
-
'components.portfolioProjectCard.text.yes': string;
|
|
63
|
-
'components.portfolioProjectCard.text.some': string;
|
|
64
|
-
'components.portfolioProjectCard.text.no': string;
|
|
65
|
-
'components.portfolioProjectCard.text.notYet': string;
|
|
66
63
|
'features.portfolio.documentsDownloadList.projectDocuments': string;
|
|
67
64
|
'features.portfolio.documentsDownloadList.downloadDocument': string;
|
|
68
65
|
'components.creditsAvailableBadge.text.yes': string;
|
|
@@ -91,8 +88,9 @@ declare const getMessages: (locale: string) => {
|
|
|
91
88
|
'sections.shopCheckout.summary.price.taxIncluded': string;
|
|
92
89
|
'sections.shopCheckout.submit': string;
|
|
93
90
|
'sections.projectsMap.link.text': string;
|
|
91
|
+
'sections.projectCardGrid.certified': string;
|
|
92
|
+
'sections.projectCardGrid.certificationInProgres': string;
|
|
94
93
|
'sections.projectFacts.projectInfo.value': string;
|
|
95
|
-
'projects.projectFacts.properties.area': string;
|
|
96
94
|
'sections.glossary.copyButtonLabel': string;
|
|
97
95
|
'sections.glossary.copySuccessMessage': string;
|
|
98
96
|
'sections.glossary.copyFailureMessage': string;
|
|
@@ -130,10 +128,6 @@ declare const getMessages: (locale: string) => {
|
|
|
130
128
|
'features.projectInfo.properties.forecastedAmountYear.label': string;
|
|
131
129
|
'features.projectInfo.properties.riskBuffer': string;
|
|
132
130
|
'features.projectInfo.properties.year': string;
|
|
133
|
-
'components.portfolioProjectCard.text.yes': string;
|
|
134
|
-
'components.portfolioProjectCard.text.some': string;
|
|
135
|
-
'components.portfolioProjectCard.text.no': string;
|
|
136
|
-
'components.portfolioProjectCard.text.notYet': string;
|
|
137
131
|
'features.portfolio.documentsDownloadList.projectDocuments': string;
|
|
138
132
|
'features.portfolio.documentsDownloadList.downloadDocument': string;
|
|
139
133
|
'components.creditsAvailableBadge.text.yes': string;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '../../test/testUtils';
|
|
3
|
-
import CreditsAvailableState from '../../models/CreditsAvailableState';
|
|
4
3
|
import CreditsAvailableBadge, {
|
|
5
4
|
CreditsAvailableBadgeProps,
|
|
6
5
|
} from './CreditsAvailableBadge';
|
|
7
6
|
import messagesEn from './messages.en';
|
|
7
|
+
import { CreditAvailability } from '../../models/fpm/FPMProject';
|
|
8
8
|
|
|
9
9
|
const defaultProps: CreditsAvailableBadgeProps = {
|
|
10
|
-
status:
|
|
10
|
+
status: CreditAvailability.CREDITS_AVAILABLE,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
const setup = (props: Partial<CreditsAvailableBadgeProps> = {}) => {
|
|
@@ -34,12 +34,14 @@ describe('The CreditsAvailableBadge component', () => {
|
|
|
34
34
|
screen.getByText(messagesEn['components.creditsAvailableBadge.text.yes'])
|
|
35
35
|
).toBeInTheDocument();
|
|
36
36
|
expect(
|
|
37
|
-
screen
|
|
37
|
+
screen
|
|
38
|
+
.getByText(messagesEn['components.creditsAvailableBadge.text.yes'])
|
|
39
|
+
.closest('a')
|
|
38
40
|
).toHaveAttribute('href', 'link-to');
|
|
39
41
|
});
|
|
40
42
|
|
|
41
43
|
it('renders correctly for the "some" case', () => {
|
|
42
|
-
setup({ status:
|
|
44
|
+
setup({ status: CreditAvailability.SOME_CREDITS_AVAILABLE });
|
|
43
45
|
|
|
44
46
|
expect(
|
|
45
47
|
screen.getByText(messagesEn['components.creditsAvailableBadge.text.some'])
|
|
@@ -47,7 +49,7 @@ describe('The CreditsAvailableBadge component', () => {
|
|
|
47
49
|
});
|
|
48
50
|
|
|
49
51
|
it('renders correctly for the "no" case', () => {
|
|
50
|
-
setup({ status:
|
|
52
|
+
setup({ status: CreditAvailability.NO_CREDITS_AVAILABLE });
|
|
51
53
|
|
|
52
54
|
expect(
|
|
53
55
|
screen.getByText(messagesEn['components.creditsAvailableBadge.text.no'])
|
|
@@ -55,7 +57,7 @@ describe('The CreditsAvailableBadge component', () => {
|
|
|
55
57
|
});
|
|
56
58
|
|
|
57
59
|
it('renders correctly for the "notYet" case', () => {
|
|
58
|
-
setup({ status:
|
|
60
|
+
setup({ status: CreditAvailability.SOON_CREDITS_AVAILABLE });
|
|
59
61
|
|
|
60
62
|
expect(
|
|
61
63
|
screen.getByText(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { Badge } from 'boemly';
|
|
2
|
+
import { Flex, Tag, Text } from 'boemly';
|
|
4
3
|
import NextLink from 'next/link';
|
|
5
4
|
import { IntlContext } from '../ContextProvider';
|
|
5
|
+
import { CreditAvailability } from '../../models/fpm/FPMProject';
|
|
6
6
|
|
|
7
7
|
export interface CreditsAvailableBadgeProps {
|
|
8
|
-
status:
|
|
8
|
+
status: CreditAvailability;
|
|
9
9
|
href?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -16,40 +16,49 @@ const CreditsAvailableBadge = ({
|
|
|
16
16
|
const { formatMessage } = useContext(IntlContext);
|
|
17
17
|
|
|
18
18
|
const variants: Record<
|
|
19
|
-
|
|
20
|
-
{
|
|
19
|
+
CreditAvailability,
|
|
20
|
+
{ message: string; color: string }
|
|
21
21
|
> = {
|
|
22
|
-
[
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
[CreditAvailability.CREDITS_AVAILABLE]: {
|
|
23
|
+
message: formatMessage({
|
|
24
|
+
id: 'components.creditsAvailableBadge.text.yes',
|
|
25
|
+
}),
|
|
26
|
+
color: 'var(--boemly-colors-primary-800)',
|
|
25
27
|
},
|
|
26
|
-
[
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
[CreditAvailability.NO_CREDITS_AVAILABLE]: {
|
|
29
|
+
message: formatMessage({
|
|
30
|
+
id: 'components.creditsAvailableBadge.text.no',
|
|
31
|
+
}),
|
|
32
|
+
color: 'var(--boemly-colors-red-600)',
|
|
29
33
|
},
|
|
30
|
-
[
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
[CreditAvailability.SOME_CREDITS_AVAILABLE]: {
|
|
35
|
+
message: formatMessage({
|
|
36
|
+
id: 'components.creditsAvailableBadge.text.some',
|
|
37
|
+
}),
|
|
38
|
+
color: 'var(--boemly-colors-orange-500)',
|
|
33
39
|
},
|
|
34
|
-
[
|
|
35
|
-
|
|
36
|
-
text: formatMessage({
|
|
40
|
+
[CreditAvailability.SOON_CREDITS_AVAILABLE]: {
|
|
41
|
+
message: formatMessage({
|
|
37
42
|
id: 'components.creditsAvailableBadge.text.notYet',
|
|
38
43
|
}),
|
|
44
|
+
color: 'var(--boemly-colors-blue-500)',
|
|
39
45
|
},
|
|
40
46
|
};
|
|
41
47
|
|
|
42
48
|
const variant = variants[status];
|
|
43
49
|
|
|
44
50
|
return (
|
|
45
|
-
<
|
|
51
|
+
<Flex
|
|
52
|
+
justifyContent="flex-start"
|
|
46
53
|
as={href ? NextLink : undefined}
|
|
47
54
|
href={href}
|
|
48
|
-
colorScheme={variant.color}
|
|
49
|
-
width="fit-content"
|
|
50
55
|
>
|
|
51
|
-
{variant.
|
|
52
|
-
|
|
56
|
+
<Tag backgroundColor={variant.color} mt="2" mb="1">
|
|
57
|
+
<Text color="white" size="xsLowBold">
|
|
58
|
+
{variant.message}
|
|
59
|
+
</Text>
|
|
60
|
+
</Tag>
|
|
61
|
+
</Flex>
|
|
53
62
|
);
|
|
54
63
|
};
|
|
55
64
|
|
|
@@ -2,6 +2,6 @@ const messagesDe = {
|
|
|
2
2
|
'components.creditsAvailableBadge.text.yes': 'Credits verfügbar',
|
|
3
3
|
'components.creditsAvailableBadge.text.some': 'Einige verbleibende Credits',
|
|
4
4
|
'components.creditsAvailableBadge.text.no': 'Keine verbleibenden Credits',
|
|
5
|
-
'components.creditsAvailableBadge.text.notYet': '
|
|
5
|
+
'components.creditsAvailableBadge.text.notYet': 'Credits bald verfügbar',
|
|
6
6
|
};
|
|
7
7
|
export default messagesDe;
|
|
@@ -248,13 +248,9 @@ export const ProjectInfo: React.FC<ProjectInfoProps> = ({
|
|
|
248
248
|
<></>
|
|
249
249
|
)}
|
|
250
250
|
|
|
251
|
-
|
|
252
|
-
<
|
|
253
|
-
|
|
254
|
-
</Box>
|
|
255
|
-
) : (
|
|
256
|
-
<></>
|
|
257
|
-
)}
|
|
251
|
+
<Box mt="2">
|
|
252
|
+
<CreditsAvailableBadge status={project.creditAvailability} />
|
|
253
|
+
</Box>
|
|
258
254
|
</Container>
|
|
259
255
|
);
|
|
260
256
|
};
|
|
@@ -27,7 +27,7 @@ describe('The getPortfolioProjects function', () => {
|
|
|
27
27
|
expect(projects[0]).toStrictEqual({
|
|
28
28
|
...fpmProjectMock,
|
|
29
29
|
slug: strapiProjectMock.attributes.slug,
|
|
30
|
-
|
|
30
|
+
creditAvailability: fpmProjectMock.creditAvailability,
|
|
31
31
|
});
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -50,7 +50,7 @@ describe('The getPortfolioProjects function', () => {
|
|
|
50
50
|
expect(projects[0]).toStrictEqual({
|
|
51
51
|
...fpmProjectMock,
|
|
52
52
|
slug: strapiProjectMock.attributes.slug,
|
|
53
|
-
|
|
53
|
+
creditAvailability: fpmProjectMock.creditAvailability,
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
});
|
|
@@ -64,15 +64,9 @@ const getPortfolioProjects = async (
|
|
|
64
64
|
if (strapiProject?.attributes.slug) {
|
|
65
65
|
toReturn.slug = strapiProject.attributes.slug;
|
|
66
66
|
}
|
|
67
|
-
if (strapiProject?.attributes.creditsAvailable) {
|
|
68
|
-
toReturn.creditsAvailable = strapiProject?.attributes.creditsAvailable;
|
|
69
|
-
}
|
|
70
67
|
if (strapiProject?.attributes.thumbnail) {
|
|
71
68
|
toReturn.thumbnail = strapiProject?.attributes.thumbnail;
|
|
72
69
|
}
|
|
73
|
-
if (strapiProject?.attributes.footerSubTitle) {
|
|
74
|
-
toReturn.footerSubTitle = strapiProject?.attributes.footerSubTitle;
|
|
75
|
-
}
|
|
76
70
|
if (strapiProject?.attributes.portfolio.data?.attributes.host) {
|
|
77
71
|
toReturn.portfolioHost =
|
|
78
72
|
strapiProject.attributes.portfolio.data.attributes.host;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { StrapiImage } from '..';
|
|
2
|
-
import CreditsAvailableState from './CreditsAvailableState';
|
|
3
2
|
import FPMProject from './fpm/FPMProject';
|
|
4
3
|
|
|
5
4
|
interface PortfolioProject extends FPMProject {
|
|
@@ -7,8 +6,6 @@ interface PortfolioProject extends FPMProject {
|
|
|
7
6
|
slug?: string;
|
|
8
7
|
portfolioHost?: string;
|
|
9
8
|
thumbnail?: StrapiImage | null;
|
|
10
|
-
creditsAvailable?: CreditsAvailableState;
|
|
11
|
-
footerSubTitle?: string;
|
|
12
9
|
}
|
|
13
10
|
|
|
14
11
|
export default PortfolioProject;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import Issuer from './Issuer';
|
|
2
2
|
|
|
3
|
+
export enum CreditAvailability {
|
|
4
|
+
CREDITS_AVAILABLE = 'credits_available',
|
|
5
|
+
NO_CREDITS_AVAILABLE = 'no_credits_available',
|
|
6
|
+
SOME_CREDITS_AVAILABLE = 'some_credits_available',
|
|
7
|
+
SOON_CREDITS_AVAILABLE = 'soon_credits_available',
|
|
8
|
+
}
|
|
9
|
+
|
|
3
10
|
interface FPMProject {
|
|
4
11
|
id: string;
|
|
5
12
|
title: string;
|
|
@@ -33,6 +40,8 @@ interface FPMProject {
|
|
|
33
40
|
forecastedAmountYearly?: number;
|
|
34
41
|
riskBuffer?: number;
|
|
35
42
|
defaultIssuer?: Issuer;
|
|
43
|
+
creditAvailability: CreditAvailability;
|
|
44
|
+
certificationDate?: Date;
|
|
36
45
|
|
|
37
46
|
createdAt: Date;
|
|
38
47
|
updatedAt: Date;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import CreditsAvailableState from '../CreditsAvailableState';
|
|
2
1
|
import Locale from '../Locale';
|
|
3
2
|
import IStrapi from './IStrapi';
|
|
4
3
|
import IStrapiData from './IStrapiData';
|
|
@@ -12,7 +11,6 @@ interface StrapiProject {
|
|
|
12
11
|
slug: string;
|
|
13
12
|
locale: Locale;
|
|
14
13
|
fpmProjectId?: string;
|
|
15
|
-
creditsAvailable?: CreditsAvailableState;
|
|
16
14
|
footerSubTitle?: string;
|
|
17
15
|
createdAt: string;
|
|
18
16
|
updatedAt: string;
|
package/src/rootMessages.de.ts
CHANGED
|
@@ -6,9 +6,9 @@ import customerQuoteCardMessagesDe from './components/CustomerQuoteCard/messages
|
|
|
6
6
|
import glossaryMessagesDe from './slices/Glossary/messages.de';
|
|
7
7
|
import portfolioDocumentsDownloadListMessagesDe from './components/portfolio/DocumentsDownloadList/messages.de';
|
|
8
8
|
import projectFactsMessagesDe from './slices/ProjectFacts/messages.de';
|
|
9
|
+
import projectGridCardMesssagesDe from './slices/ProjectGridCard/messages.de';
|
|
9
10
|
import projectsMapMessagesDe from './slices/ProjectsMap/messages.de';
|
|
10
11
|
import portfolioProjectInfoMessagesDe from './components/portfolio/ProjectInfo/messages.de';
|
|
11
|
-
import portfolioProjectCardMessagesDe from './components/portfolio/PortfolioProjectCard/messages.de';
|
|
12
12
|
import portfolioSmallCheckoutMessagesDe from './components/portfolio/SmallCheckout/messages.de';
|
|
13
13
|
import shopCheckoutMessagesDe from './slices/ShopCheckout/messages.de';
|
|
14
14
|
import textCarouselMessagesDe from './slices/TextCarousel/messages.de';
|
|
@@ -22,7 +22,6 @@ const rootMessagesDe = {
|
|
|
22
22
|
//
|
|
23
23
|
...creditsAvailableBadgeMessagesDe,
|
|
24
24
|
...portfolioDocumentsDownloadListMessagesDe,
|
|
25
|
-
...portfolioProjectCardMessagesDe,
|
|
26
25
|
...portfolioProjectInfoMessagesDe,
|
|
27
26
|
...portfolioSmallCheckoutMessagesDe,
|
|
28
27
|
|
|
@@ -35,6 +34,7 @@ const rootMessagesDe = {
|
|
|
35
34
|
...customerQuoteCardMessagesDe,
|
|
36
35
|
...glossaryMessagesDe,
|
|
37
36
|
...projectFactsMessagesDe,
|
|
37
|
+
...projectGridCardMesssagesDe,
|
|
38
38
|
...projectsMapMessagesDe,
|
|
39
39
|
...shopCheckoutMessagesDe,
|
|
40
40
|
...textCarouselMessagesDe,
|
package/src/rootMessages.en.ts
CHANGED
|
@@ -6,9 +6,9 @@ import customerQuoteCardMessagesEn from './components/CustomerQuoteCard/messages
|
|
|
6
6
|
import glossaryMessagesEn from './slices/Glossary/messages.en';
|
|
7
7
|
import portfolioDocumentsDownloadListMessagesEn from './components/portfolio/DocumentsDownloadList/messages.en';
|
|
8
8
|
import projectFactsMessagesEn from './slices/ProjectFacts/messages.en';
|
|
9
|
+
import projectGridCardMesssagesEn from './slices/ProjectGridCard/messages.en';
|
|
9
10
|
import projectsMapMessagesEn from './slices/ProjectsMap/messages.en';
|
|
10
11
|
import portfolioProjectInfoMessagesEn from './components/portfolio/ProjectInfo/messages.en';
|
|
11
|
-
import portfolioProjectCardMessagesEn from './components/portfolio/PortfolioProjectCard/messages.en';
|
|
12
12
|
import portfolioSmallCheckoutMessagesEn from './components/portfolio/SmallCheckout/messages.en';
|
|
13
13
|
import shopCheckoutMessagesEn from './slices/ShopCheckout/messages.en';
|
|
14
14
|
import textCarouselMessagesEn from './slices/TextCarousel/messages.en';
|
|
@@ -22,7 +22,6 @@ const rootMessagesEn = {
|
|
|
22
22
|
//
|
|
23
23
|
...creditsAvailableBadgeMessagesEn,
|
|
24
24
|
...portfolioDocumentsDownloadListMessagesEn,
|
|
25
|
-
...portfolioProjectCardMessagesEn,
|
|
26
25
|
...portfolioProjectInfoMessagesEn,
|
|
27
26
|
...portfolioSmallCheckoutMessagesEn,
|
|
28
27
|
|
|
@@ -35,6 +34,7 @@ const rootMessagesEn = {
|
|
|
35
34
|
...customerQuoteCardMessagesEn,
|
|
36
35
|
...glossaryMessagesEn,
|
|
37
36
|
...projectFactsMessagesEn,
|
|
37
|
+
...projectGridCardMesssagesEn,
|
|
38
38
|
...projectsMapMessagesEn,
|
|
39
39
|
...shopCheckoutMessagesEn,
|
|
40
40
|
...textCarouselMessagesEn,
|
|
@@ -3,7 +3,6 @@ import { StoryFn, Meta } from '@storybook/react';
|
|
|
3
3
|
|
|
4
4
|
import fpmProjectMock from '../../test/integrationMocks/fpmProjectMock';
|
|
5
5
|
import { storybookStrapiAvatarMock } from '../../test/storybookMocks/storybookStrapiMedia';
|
|
6
|
-
import CreditsAvailableState from '../../models/CreditsAvailableState';
|
|
7
6
|
import ProjectFacts from '.';
|
|
8
7
|
|
|
9
8
|
export default {
|
|
@@ -53,7 +52,7 @@ WithCheckout.args = {
|
|
|
53
52
|
|
|
54
53
|
export const FullProps = Template.bind({});
|
|
55
54
|
FullProps.args = {
|
|
56
|
-
project:
|
|
55
|
+
project: fpmProjectMock,
|
|
57
56
|
slice: {
|
|
58
57
|
projectId: fpmProjectMock.id,
|
|
59
58
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { render, screen } from '../../test/testUtils';
|
|
2
|
+
import { ProjectGridCardProps } from './ProjectGridCard';
|
|
3
|
+
import ProjectGridCard from '.';
|
|
4
|
+
import fpmProjectMock from '../../test/integrationMocks/fpmProjectMock';
|
|
5
|
+
import { strapiMediaMock } from '../../test/strapiMocks/strapiMedia';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import messagesEn from '../../components/CreditsAvailableBadge/messages.en';
|
|
8
|
+
|
|
9
|
+
const defaultProps: ProjectGridCardProps = {
|
|
10
|
+
project: {
|
|
11
|
+
...fpmProjectMock,
|
|
12
|
+
slug: 'slug',
|
|
13
|
+
thumbnail: { img: { data: strapiMediaMock }, alt: 'Alt Text', id: 1 },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const setup = (props = {}) => {
|
|
18
|
+
const combinedProps = { ...defaultProps, ...props };
|
|
19
|
+
render(<ProjectGridCard {...combinedProps} />);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('The ProjectGridCard component', () => {
|
|
23
|
+
it('displays the project card', () => {
|
|
24
|
+
setup();
|
|
25
|
+
|
|
26
|
+
expect(screen.getByText(fpmProjectMock.title)).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('displays the project thumbnail', () => {
|
|
30
|
+
setup();
|
|
31
|
+
|
|
32
|
+
expect(screen.getByRole('img')).toHaveProperty('alt', 'Alt Text');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('displays the project area', () => {
|
|
36
|
+
setup();
|
|
37
|
+
|
|
38
|
+
expect(screen.getByText('140 ha')).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('displays the project location', () => {
|
|
42
|
+
setup();
|
|
43
|
+
|
|
44
|
+
expect(screen.getByText('Austria')).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('displays the certification date if it is defined', () => {
|
|
48
|
+
setup();
|
|
49
|
+
|
|
50
|
+
expect(screen.getByText('Certified, 2020')).toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('displays the credits available badge', () => {
|
|
54
|
+
setup();
|
|
55
|
+
|
|
56
|
+
expect(
|
|
57
|
+
screen.getByText(messagesEn['components.creditsAvailableBadge.text.yes'])
|
|
58
|
+
).toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Box, Container, Flex, Heading, Tag, Text } from 'boemly';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import Image from 'next/image';
|
|
4
|
+
import PortfolioProject from '../../models/PortfolioProject';
|
|
5
|
+
import { strapiMediaUrl } from '../..';
|
|
6
|
+
import { IntlContext } from 'react-intl';
|
|
7
|
+
import { FORMAT_AS_HECTARE_CONFIG } from '../../constants/formatter';
|
|
8
|
+
import CreditsAvailableBadge from '../../components/CreditsAvailableBadge';
|
|
9
|
+
|
|
10
|
+
export interface ProjectGridCardProps {
|
|
11
|
+
project: PortfolioProject;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ProjectGridCard = ({
|
|
15
|
+
project,
|
|
16
|
+
}: ProjectGridCardProps): JSX.Element => {
|
|
17
|
+
const { formatNumber, formatMessage } = useContext(IntlContext);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Container>
|
|
21
|
+
<Flex flexDir="column" height="full">
|
|
22
|
+
{project.thumbnail && (
|
|
23
|
+
<Box borderRadius="xl" position="relative" height="36" mb="2">
|
|
24
|
+
<Image
|
|
25
|
+
src={strapiMediaUrl(project.thumbnail?.img, 'medium')}
|
|
26
|
+
alt={project.thumbnail?.alt}
|
|
27
|
+
fill
|
|
28
|
+
style={{
|
|
29
|
+
objectFit: project.thumbnail?.objectFit || 'cover',
|
|
30
|
+
borderRadius: 'var(--boemly-radii-xl)',
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
</Box>
|
|
34
|
+
)}
|
|
35
|
+
<Heading my="4" size="lg">
|
|
36
|
+
{project.title}
|
|
37
|
+
</Heading>
|
|
38
|
+
<Flex flexDir="row" gap="2">
|
|
39
|
+
<Tag>
|
|
40
|
+
<Text size="xsLowBold" color="gray.800">
|
|
41
|
+
{formatNumber(
|
|
42
|
+
(project.area || 0) / 10000,
|
|
43
|
+
FORMAT_AS_HECTARE_CONFIG
|
|
44
|
+
)}
|
|
45
|
+
</Text>
|
|
46
|
+
</Tag>
|
|
47
|
+
<Tag>
|
|
48
|
+
<Text size="xsLowBold" color="gray.800">
|
|
49
|
+
{project.location}
|
|
50
|
+
</Text>
|
|
51
|
+
</Tag>
|
|
52
|
+
{project.certificationDate ? (
|
|
53
|
+
<Tag>
|
|
54
|
+
<Text size="xsLowBold" color="gray.800">
|
|
55
|
+
{formatMessage(
|
|
56
|
+
{ id: 'sections.projectCardGrid.certified' },
|
|
57
|
+
{ year: project.certificationDate.getFullYear() }
|
|
58
|
+
)}
|
|
59
|
+
</Text>
|
|
60
|
+
</Tag>
|
|
61
|
+
) : (
|
|
62
|
+
<Tag>
|
|
63
|
+
<Text size="xsLowBold" color="gray.800">
|
|
64
|
+
{formatMessage({
|
|
65
|
+
id: 'sections.projectCardGrid.certificationInProgres',
|
|
66
|
+
})}
|
|
67
|
+
</Text>
|
|
68
|
+
</Tag>
|
|
69
|
+
)}
|
|
70
|
+
</Flex>
|
|
71
|
+
<CreditsAvailableBadge status={project.creditAvailability} />
|
|
72
|
+
</Flex>
|
|
73
|
+
</Container>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -2,8 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { StoryFn, Meta } from '@storybook/react';
|
|
3
3
|
|
|
4
4
|
import ProjectsGrid from '.';
|
|
5
|
-
import portfolioProjectMock from '../../test/integrationMocks/portfolioProjectMock';
|
|
6
5
|
import { strapiProjectMock } from '../../test/strapiMocks/strapiProject';
|
|
6
|
+
import portfolioProjectMock from '../../test/integrationMocks/portfolioProjectMock';
|
|
7
|
+
import { CreditAvailability } from '../../models/fpm/FPMProject';
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: 'slices/ProjectsGrid',
|
|
@@ -21,3 +22,36 @@ Minimal.args = {
|
|
|
21
22
|
projects: { data: [strapiProjectMock] },
|
|
22
23
|
},
|
|
23
24
|
};
|
|
25
|
+
|
|
26
|
+
export const WithoutCertificationDate = Template.bind({});
|
|
27
|
+
WithoutCertificationDate.args = {
|
|
28
|
+
projects: [{ ...portfolioProjectMock, certificationDate: undefined }],
|
|
29
|
+
slice: {
|
|
30
|
+
projects: { data: [strapiProjectMock] },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const WithCreditsAvailabilityVariants = Template.bind({});
|
|
35
|
+
WithCreditsAvailabilityVariants.args = {
|
|
36
|
+
projects: [
|
|
37
|
+
portfolioProjectMock,
|
|
38
|
+
{
|
|
39
|
+
...portfolioProjectMock,
|
|
40
|
+
title: 'Project 2',
|
|
41
|
+
creditAvailability: CreditAvailability.SOME_CREDITS_AVAILABLE,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
...portfolioProjectMock,
|
|
45
|
+
title: 'Project 3',
|
|
46
|
+
creditAvailability: CreditAvailability.SOON_CREDITS_AVAILABLE,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
...portfolioProjectMock,
|
|
50
|
+
title: 'Project 4',
|
|
51
|
+
creditAvailability: CreditAvailability.NO_CREDITS_AVAILABLE,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
slice: {
|
|
55
|
+
projects: { data: [strapiProjectMock] },
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -4,7 +4,6 @@ import ProjectsGrid from '.';
|
|
|
4
4
|
import { ProjectsGridProps } from './ProjectsGrid';
|
|
5
5
|
import fpmProjectMock from '../../test/integrationMocks/fpmProjectMock';
|
|
6
6
|
import { strapiMediaMock } from '../../test/strapiMocks/strapiMedia';
|
|
7
|
-
import CreditsAvailableState from '../../models/CreditsAvailableState';
|
|
8
7
|
import { strapiProjectMock } from '../../test/strapiMocks/strapiProject';
|
|
9
8
|
|
|
10
9
|
const defaultProps: ProjectsGridProps = {
|
|
@@ -17,8 +16,6 @@ const defaultProps: ProjectsGridProps = {
|
|
|
17
16
|
slug: 'slug',
|
|
18
17
|
isPublic: true,
|
|
19
18
|
thumbnail: { img: { data: strapiMediaMock }, alt: 'Alt Text', id: 1 },
|
|
20
|
-
footerSubTitle: 'certified-123',
|
|
21
|
-
creditsAvailable: CreditsAvailableState.YES,
|
|
22
19
|
},
|
|
23
20
|
],
|
|
24
21
|
};
|
|
@@ -2,9 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { Box, DefaultSectionContainer, SimpleGrid, Wrapper } from 'boemly';
|
|
3
3
|
import Link from 'next/link';
|
|
4
4
|
import { MEDIUM_TRANSITION_DURATION } from '../../constants/animations';
|
|
5
|
+
import ProjectGridCard from '../ProjectGridCard';
|
|
5
6
|
import PortfolioProject from '../../models/PortfolioProject';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
7
|
+
import IStrapi from '../../models/strapi/IStrapi';
|
|
8
|
+
import IStrapiData from '../../models/strapi/IStrapiData';
|
|
9
|
+
import StrapiProject from '../../models/strapi/StrapiProject';
|
|
8
10
|
|
|
9
11
|
export interface ProjectsGridProps {
|
|
10
12
|
slice: {
|
|
@@ -65,7 +67,7 @@ export const ProjectsGrid: React.FC<ProjectsGridProps> = ({
|
|
|
65
67
|
transition={`box-shadow ease ${MEDIUM_TRANSITION_DURATION}s`}
|
|
66
68
|
_hover={{ boxShadow: 'lg' }}
|
|
67
69
|
>
|
|
68
|
-
<
|
|
70
|
+
<ProjectGridCard project={project} />
|
|
69
71
|
</Box>
|
|
70
72
|
</ConditionalWrapper>
|
|
71
73
|
))}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { fireEvent, render, screen, waitFor } from '../../test/testUtils';
|
|
3
|
-
import CreditsAvailableState from '../../models/CreditsAvailableState';
|
|
4
3
|
import MapMarker, { MapMarkerProps } from './MapMarker';
|
|
5
4
|
import messagesEn from './messages.en';
|
|
5
|
+
import { CreditAvailability } from '../../models/fpm/FPMProject';
|
|
6
6
|
|
|
7
7
|
const defaultProps: MapMarkerProps = {
|
|
8
8
|
title: 'Project title',
|
|
9
9
|
portfolioHost: '',
|
|
10
10
|
isPublic: true,
|
|
11
|
+
creditAvailability: CreditAvailability.CREDITS_AVAILABLE,
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const setup = (props: Partial<MapMarkerProps> = {}) => {
|
|
@@ -88,7 +89,7 @@ describe('The MapMarker component', () => {
|
|
|
88
89
|
|
|
89
90
|
it('renders the credit availability if it is defined', () => {
|
|
90
91
|
setup({
|
|
91
|
-
|
|
92
|
+
creditAvailability: CreditAvailability.CREDITS_AVAILABLE,
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
fireEvent.mouseEnter(screen.getByTestId('mapmarker-pin'));
|