Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ssr-navigator #674

Merged
merged 7 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/components/Map/DetailsMap/PointsSignage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type PointsSignageProps = {
type Locations = {
description: string;
name: string;
imageUrl: string | undefined;
imageUrl: string | null;
pictogramUri: string;
position: RawCoordinate2D;
type: string;
Expand Down Expand Up @@ -52,7 +52,7 @@ export const PointsSignage: React.FC<PointsSignageProps> = ({ signage }) => {
>
<StyledTooltip>
<div className="flex flex-col">
{location.imageUrl !== undefined && <CoverImage src={location.imageUrl} alt="" />}
{location.imageUrl !== null && <CoverImage src={location.imageUrl} alt="" />}
<div className="p-4">
<div className="text-P2 mb-1 text-greyDarkColored">{location.type}</div>
<Name className="text-Mobile-C1 text-primary1 font-bold desktop:text-H4">
Expand Down
35 changes: 21 additions & 14 deletions frontend/src/components/pages/details/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ export const DetailsUIWithoutContext: React.FC<Props> = ({ detailsId, parentId,
id="details_cover"
className={!isFullscreen ? 'desktop:h-coverDetailsDesktop' : 'h-full'}
>
{details.imgs.length > 1 && navigator && navigator?.onLine ? (
{details.imgs.length > 1 &&
typeof navigator !== 'undefined' &&
navigator?.onLine ? (
<DetailsCoverCarousel
attachments={details.imgs}
onClickImage={toggleFullscreen}
Expand Down Expand Up @@ -235,6 +237,8 @@ export const DetailsUIWithoutContext: React.FC<Props> = ({ detailsId, parentId,
</div>
)}
{getGlobalConfig().enableMeteoWidget &&
typeof navigator !== 'undefined' &&
navigator.onLine &&
details.cities_raw &&
details.cities_raw[0] && (
<DetailsSection>
Expand Down Expand Up @@ -433,19 +437,22 @@ export const DetailsUIWithoutContext: React.FC<Props> = ({ detailsId, parentId,
</div>
)}

{details.reservation && details.reservation_id && (
<DetailsSection
className={marginDetailsChild}
htmlId="details_reservation"
titleId="details.reservation"
>
<DetailsReservationWidget
language={language}
reservation={details.reservation}
id={details.reservation_id}
/>
</DetailsSection>
)}
{details.reservation &&
details.reservation_id &&
typeof navigator !== 'undefined' &&
navigator.onLine && (
<DetailsSection
className={marginDetailsChild}
htmlId="details_reservation"
titleId="details.reservation"
>
<DetailsReservationWidget
language={language}
reservation={details.reservation}
id={details.reservation_id}
/>
</DetailsSection>
)}
</div>
<Footer />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,21 @@ export const DetailsCard: React.FC<DetailsCardProps> = ({
{isFullscreen &&
attachments &&
attachments.length > 0 &&
navigator &&
typeof navigator !== 'undefined' &&
navigator?.onLine && <DetailsCoverCarousel attachments={attachments} />}
{!isFullscreen && (
<DetailsCardCarousel
thumbnailUris={
navigator && navigator?.onLine ? thumbnailUris : thumbnailUris.slice(0, 1)
typeof navigator !== 'undefined' && navigator?.onLine
? thumbnailUris
: thumbnailUris.slice(0, 1)
}
height={heightState}
onClickImage={navigator && navigator?.onLine ? toggleFullscreen : undefined}
onClickImage={
typeof navigator !== 'undefined' && navigator?.onLine
? toggleFullscreen
: undefined
}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const DetailsCoverCarousel: React.FC<DetailsCoverCarouselProps> = ({
attachments,
onClickImage,
}) => {
const files = navigator && navigator?.onLine ? attachments : attachments.slice(0, 1);
const files =
typeof navigator !== 'undefined' && navigator?.onLine ? attachments : attachments.slice(0, 1);

return (
<LargeCarousel className="relative h-coverDetailsMobile desktop:h-coverDetailsDesktop">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export const ResultCardCarousel: React.FC<ResultCardCarouselProps> = ({
onClickImage,
asColumn,
}) => {
const files = navigator && navigator?.onLine ? thumbnailUris : thumbnailUris.slice(0, 1);
const files =
typeof navigator !== 'undefined' && navigator?.onLine
? thumbnailUris
: thumbnailUris.slice(0, 1);

return (
<Wrapper
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/pages/site/OutdoorCourseUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const OutdoorCourseUIWithoutContext: React.FC<Props> = ({ outdoorCourseUr
className={!isFullscreen ? 'desktop:h-coverDetailsDesktop' : 'h-full'}
>
{outdoorCourseContent.attachments.length > 1 &&
navigator &&
typeof navigator !== 'undefined' &&
navigator?.onLine ? (
<DetailsCoverCarousel
attachments={outdoorCourseContent.attachments}
Expand Down Expand Up @@ -291,6 +291,8 @@ export const OutdoorCourseUIWithoutContext: React.FC<Props> = ({ outdoorCourseUr
)}

{getGlobalConfig().enableMeteoWidget &&
typeof navigator !== 'undefined' &&
navigator.onLine &&
outdoorCourseContent.cities_raw &&
outdoorCourseContent.cities_raw[0] && (
<DetailsSection>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/pages/site/OutdoorSiteUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const OutdoorSiteUIWithoutContext: React.FC<Props> = ({ outdoorSiteUrl, language
className={!isFullscreen ? 'desktop:h-coverDetailsDesktop' : 'h-full'}
>
{outdoorSiteContent.attachments.length > 1 &&
navigator &&
typeof navigator !== 'undefined' &&
navigator?.onLine ? (
<DetailsCoverCarousel
attachments={outdoorSiteContent.attachments}
Expand Down Expand Up @@ -311,6 +311,8 @@ const OutdoorSiteUIWithoutContext: React.FC<Props> = ({ outdoorSiteUrl, language
)}

{getGlobalConfig().enableMeteoWidget &&
typeof navigator !== 'undefined' &&
navigator.onLine &&
outdoorSiteContent.cities_raw &&
outdoorSiteContent.cities_raw[0] && (
<DetailsSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export const TouristicContentUI: React.FC<TouristicContentUIProps> = ({
<Modal>
{({ toggleFullscreen }) => (
<div id="touristicContent_cover">
{touristicContent.attachments.length > 1 && navigator && navigator?.onLine ? (
{touristicContent.attachments.length > 1 &&
typeof navigator !== 'undefined' &&
navigator?.onLine ? (
<DetailsCoverCarousel
attachments={touristicContent.attachments}
onClickImage={toggleFullscreen}
Expand Down Expand Up @@ -189,6 +191,8 @@ export const TouristicContentUI: React.FC<TouristicContentUIProps> = ({
</DetailsSection>
)}
{getGlobalConfig().enableMeteoWidget &&
typeof navigator !== 'undefined' &&
navigator.onLine &&
touristicContent.cities_raw &&
touristicContent.cities_raw[0] && (
<DetailsSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const TouristicEventUIWithoutContext: React.FC<Props> = ({
className={!isFullscreen ? 'desktop:h-coverDetailsDesktop' : 'h-full'}
>
{touristicEventContent.attachments.length > 1 &&
navigator &&
typeof navigator !== 'undefined' &&
navigator?.onLine ? (
<DetailsCoverCarousel
attachments={touristicEventContent.attachments}
Expand Down Expand Up @@ -262,6 +262,8 @@ export const TouristicEventUIWithoutContext: React.FC<Props> = ({
)}

{getGlobalConfig().enableMeteoWidget &&
typeof navigator !== 'undefined' &&
navigator.onLine &&
touristicEventContent.cities_raw &&
touristicEventContent.cities_raw[0] && (
<DetailsSection>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/signage/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const adaptSignage = (
signageTypeDictionary: SignageTypeDictionary,
): Signage => ({
id: rawSignage.id,
imageUrl: rawSignage.attachments?.find(({ type }) => type === 'image')?.thumbnail,
imageUrl: rawSignage.attachments?.find(({ type }) => type === 'image')?.thumbnail ?? null,
description: rawSignage.description,
geometry: rawSignage.geometry,
name: rawSignage.name,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/signage/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface Signage {
description: string;
geometry: RawPointGeometry3D;
type: SignageType;
imageUrl: string | undefined;
imageUrl: string | null;
}

export interface SignageDictionary {
Expand Down