-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/projects-redesign
- Loading branch information
Showing
142 changed files
with
7,900 additions
and
1,516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,4 @@ build-storybook.log | |
src/stories | ||
.vscode/settings.json | ||
.vscode/launch.json | ||
.env copy.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import SalesforceCampaign from '../../../../src/tenants/salesforce/OceanforceCampaign'; | ||
import GetHomeMeta from '../../../../src/utils/getMetaTags/GetHomeMeta'; | ||
import { | ||
LeaderBoard, | ||
TenantScore, | ||
} from '../../../../src/features/common/types/campaign'; | ||
import { AbstractIntlMessages } from 'next-intl'; | ||
import { Tenant } from '@planet-sdk/common'; | ||
import { | ||
GetStaticProps, | ||
GetStaticPropsContext, | ||
GetStaticPropsResult, | ||
} from 'next'; | ||
import { getTenantConfig } from '../../../../src/utils/multiTenancy/helpers'; | ||
import { defaultTenant } from '../../../../tenant.config'; | ||
import getMessagesForPage from '../../../../src/utils/language/getMessagesForPage'; | ||
import { useTenant } from '../../../../src/features/common/Layout/TenantContext'; | ||
import router from 'next/router'; | ||
|
||
interface Props { | ||
pageProps: PageProps; | ||
} | ||
|
||
export default function MangroveChallenge({ | ||
pageProps: { tenantConfig }, | ||
}: Props) { | ||
const [leaderBoard, setLeaderBoard] = useState<LeaderBoard>({ | ||
mostDonated: [], | ||
mostRecent: [], | ||
}); | ||
const [tenantScore, setTenantScore] = useState<TenantScore>({ total: 0 }); | ||
const [isLoaded, setIsLoaded] = useState(false); | ||
const { setTenantConfig } = useTenant(); | ||
|
||
useEffect(() => { | ||
if (router.isReady) { | ||
setTenantConfig(tenantConfig); | ||
} | ||
}, [router.isReady]); | ||
|
||
useEffect(() => { | ||
async function loadData() { | ||
try { | ||
const leaderboardRes = await fetch( | ||
`${process.env.WEBHOOK_URL}/oceanforce-2023-leaderboard` | ||
); | ||
if (leaderboardRes.ok && leaderboardRes.status === 200) { | ||
const leaderBoardArr = await leaderboardRes.json(); | ||
setLeaderBoard(leaderBoardArr[0]); | ||
} | ||
} catch (err) { | ||
console.error('Leaderboard could not be loaded:', err); | ||
} | ||
|
||
try { | ||
const tenantscoreRes = await fetch( | ||
`${process.env.WEBHOOK_URL}/oceanforce-2023` | ||
); | ||
if (tenantscoreRes.ok && tenantscoreRes.status === 200) { | ||
const tenantScoreArr = await tenantscoreRes.json(); | ||
setTenantScore(tenantScoreArr[0]); | ||
setIsLoaded(true); | ||
} | ||
} catch (err) { | ||
console.error('Treecount could not be loaded:', err); | ||
} | ||
|
||
setIsLoaded(true); | ||
} | ||
|
||
loadData(); | ||
}, []); | ||
|
||
function getCampaignPage() { | ||
let CampaignPage; | ||
switch (tenantConfig.config.slug) { | ||
case 'salesforce': | ||
CampaignPage = SalesforceCampaign; | ||
return ( | ||
<CampaignPage | ||
leaderboard={leaderBoard} | ||
tenantScore={tenantScore} | ||
isLoaded={isLoaded} | ||
/> | ||
); | ||
default: | ||
CampaignPage = null; | ||
return CampaignPage; | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<GetHomeMeta /> | ||
{tenantConfig && isLoaded ? getCampaignPage() : <></>} | ||
</> | ||
); | ||
} | ||
|
||
export const getStaticPaths = async () => { | ||
return { | ||
paths: [{ params: { slug: 'salesforce', locale: 'en' } }], | ||
fallback: 'blocking', | ||
}; | ||
}; | ||
|
||
interface PageProps { | ||
messages: AbstractIntlMessages; | ||
tenantConfig: Tenant; | ||
} | ||
|
||
export const getStaticProps: GetStaticProps<PageProps> = async ( | ||
context: GetStaticPropsContext | ||
): Promise<GetStaticPropsResult<PageProps>> => { | ||
const tenantConfig = | ||
(await getTenantConfig(context.params?.slug as string)) ?? defaultTenant; | ||
|
||
const messages = await getMessagesForPage({ | ||
locale: context.params?.locale as string, | ||
filenames: ['common', 'donate', 'country', 'manageProjects', 'leaderboard'], | ||
}); | ||
|
||
return { | ||
props: { | ||
messages, | ||
tenantConfig, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React, { useEffect } from 'react'; | ||
import Mangroves from '../../../../src/tenants/salesforce/Mangroves'; | ||
import GetHomeMeta from '../../../../src/utils/getMetaTags/GetHomeMeta'; | ||
import { AbstractIntlMessages } from 'next-intl'; | ||
import { Tenant } from '@planet-sdk/common'; | ||
import { | ||
GetStaticProps, | ||
GetStaticPropsContext, | ||
GetStaticPropsResult, | ||
} from 'next'; | ||
import { getTenantConfig } from '../../../../src/utils/multiTenancy/helpers'; | ||
import { defaultTenant } from '../../../../tenant.config'; | ||
import getMessagesForPage from '../../../../src/utils/language/getMessagesForPage'; | ||
import { useTenant } from '../../../../src/features/common/Layout/TenantContext'; | ||
import router from 'next/router'; | ||
|
||
interface Props { | ||
pageProps: PageProps; | ||
} | ||
|
||
export default function MangrovesLandingPage({ | ||
pageProps: { tenantConfig }, | ||
}: Props) { | ||
const tenantScore = { total: 16000000 }; | ||
|
||
const { setTenantConfig } = useTenant(); | ||
|
||
useEffect(() => { | ||
if (router.isReady) { | ||
setTenantConfig(tenantConfig); | ||
} | ||
}, [router.isReady]); | ||
|
||
function getCampaignPage() { | ||
let CampaignPage; | ||
switch (tenantConfig.config.slug) { | ||
case 'salesforce': | ||
return <Mangroves tenantScore={tenantScore} isLoaded={true} />; | ||
default: | ||
CampaignPage = null; | ||
return CampaignPage; | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<GetHomeMeta /> | ||
{tenantConfig ? getCampaignPage() : <></>} | ||
</> | ||
); | ||
} | ||
|
||
export const getStaticPaths = async () => { | ||
return { | ||
paths: [{ params: { slug: 'salesforce', locale: 'en' } }], | ||
fallback: 'blocking', | ||
}; | ||
}; | ||
|
||
interface PageProps { | ||
messages: AbstractIntlMessages; | ||
tenantConfig: Tenant; | ||
} | ||
|
||
export const getStaticProps: GetStaticProps<PageProps> = async ( | ||
context: GetStaticPropsContext | ||
): Promise<GetStaticPropsResult<PageProps>> => { | ||
const tenantConfig = | ||
(await getTenantConfig(context.params?.slug as string)) ?? defaultTenant; | ||
|
||
const messages = await getMessagesForPage({ | ||
locale: context.params?.locale as string, | ||
filenames: ['common', 'donate', 'country', 'manageProjects', 'leaderboard'], | ||
}); | ||
|
||
return { | ||
props: { | ||
messages, | ||
tenantConfig, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.