-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
167 additions
and
105 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react' | ||
import { useSelector } from 'react-redux' | ||
import { MetaData } from 'src/containers/MetaData' | ||
import { env } from 'src/core/env' | ||
import { selectCurrentFeedItem } from 'src/core/useCases/feed' | ||
import { texts } from 'src/i18n' | ||
|
||
export function ActionsMetadata() { | ||
const currentFeedItem = useSelector(selectCurrentFeedItem) | ||
|
||
if (currentFeedItem && currentFeedItem.itemType === 'Entourage') { | ||
const { author, title, description, entourageType, groupType } = currentFeedItem | ||
const { partner } = author | ||
const organizerName = partner ? partner.name : author.displayName | ||
|
||
const pronoun = partner ? texts.content.map.actions.shareTitles.their : texts.content.map.actions.shareTitles.his | ||
|
||
let shareTitle | ||
if (groupType === 'outing') { | ||
shareTitle = `${texts.content.map.actions.shareTitles.participate} ${organizerName}` | ||
} else if (groupType === 'action') { | ||
shareTitle = entourageType === 'contribution' | ||
? `${texts.content.map.actions.shareTitles.help} ${organizerName}` | ||
+ ` ${texts.content.map.actions.shareTitles.realize} ${pronoun} ${texts.content.map.actions.shareTitles.action}` | ||
: `${texts.content.map.actions.shareTitles.comeToHelp} ${organizerName}` | ||
} | ||
|
||
const url = `${env.SERVER_URL}/actions${currentFeedItem ? `/${currentFeedItem.uuid}` : ''}` | ||
|
||
return ( | ||
<MetaData | ||
description={`${title}. ${description}`} | ||
title={shareTitle} | ||
url={url} | ||
/> | ||
) | ||
} | ||
|
||
return ( | ||
<MetaData | ||
description={texts.nav.pageDescriptions.actions} | ||
title={`${texts.nav.pageTitles.actions} - ${texts.nav.pageTitles.main}`} | ||
url={`${env.SERVER_URL}/actions`} | ||
/> | ||
) | ||
} |
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 @@ | ||
export { ActionsMetadata } from './ActionsMetadata' |
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
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
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 |
---|---|---|
@@ -1,32 +1,47 @@ | ||
import { AppContext } from 'next/app' | ||
import React from 'react' | ||
import { SplashScreen } from 'src/components/SplashScreen' | ||
import { ActionsMetadata } from '../containers/ActionsMetadata' | ||
import { wrapperStore } from '../core/boostrapStore' | ||
import { feedActions, selectFeedIsFetching, selectFeedIsIdle } from '../core/useCases/feed' | ||
import { MapActions } from 'src/containers/MapContainer' | ||
import { MetaData } from 'src/containers/MetaData' | ||
import { env } from 'src/core/env' | ||
import { texts } from 'src/i18n' | ||
import { useLoadGoogleMapApi } from 'src/utils/misc' | ||
import { StatelessPage } from 'src/utils/types' | ||
|
||
interface Props {} | ||
|
||
const Actions: StatelessPage<Props> = () => { | ||
const googleMapApiIsLoaded = useLoadGoogleMapApi() | ||
|
||
return ( | ||
<> | ||
<MetaData | ||
description={texts.nav.pageDescriptions.actions} | ||
title={`${texts.nav.pageTitles.actions} - ${texts.nav.pageTitles.main}`} | ||
url={`${env.SERVER_URL}/actions`} | ||
/> | ||
{ !googleMapApiIsLoaded ? <SplashScreen /> : <MapActions /> } | ||
<ActionsMetadata /> | ||
<MapActions /> | ||
</> | ||
) | ||
} | ||
|
||
// Actions.getInitialProps = async (ctx) => { | ||
// Wait until React Queries support SSR. Coming soon | ||
// see https://github.com/tannerlinsley/react-query/issues/14 | ||
// } | ||
Actions.getInitialProps = wrapperStore.getInitialPageProps((store) => { | ||
return (ctx: AppContext['ctx']) => { | ||
const poiId = ctx.query.actionId as string | ||
|
||
if (poiId) { | ||
return new Promise((resolve) => { | ||
store.subscribe(() => { | ||
const feedIsIdle = selectFeedIsIdle(store.getState()) | ||
const feedIsFetching = selectFeedIsFetching(store.getState()) | ||
// const feedItemDetailsIsFetching = selectFeedItemDetailsIsFetching(store.getState()) | ||
|
||
const isReady = !feedIsIdle && !feedIsFetching | ||
|
||
if (isReady) { | ||
resolve() | ||
} | ||
}) | ||
|
||
store.dispatch(feedActions.init()) | ||
store.dispatch(feedActions.setCurrentFeedItemUuid(poiId)) | ||
}) | ||
} | ||
|
||
return Promise.resolve() | ||
} | ||
}) | ||
|
||
export default Actions |
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.