Skip to content

Commit

Permalink
added contact us in header when contacts in that language are avaliable
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseWynants committed Jan 30, 2025
1 parent 65d27d0 commit c1c4e82
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 28 deletions.
2 changes: 1 addition & 1 deletion modules/Layout/Contacts/Contacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Contacts({ contacts }: Props) {
}

return (
<div className={styles.contacts}>
<div id='contacts' className={styles.contacts}>

Check failure on line 38 in modules/Layout/Contacts/Contacts.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Contacts/Contacts.tsx#L38

Replace `'contacts'` with `"contacts"` (prettier/prettier)
<div className={styles.container}>
<h2 className={styles.title}>
<FormattedMessage {...translations.contacts.title} />
Expand Down
28 changes: 27 additions & 1 deletion modules/Layout/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
useCompanyInformation,
useGetLinkLocaleSlug,
useNewsroom,
useNewsroomContext,
useSearchSettings,
useCurrentLocale,

Check failure on line 9 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L9

Member 'useCurrentLocale' of the import declaration should be sorted alphabetically (sort-imports)
} from '@prezly/theme-kit-nextjs';
import classNames from 'classnames';
import dynamic from 'next/dynamic';
Expand All @@ -14,7 +16,7 @@ import { useEffect, useRef, useState } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';

import { useDevice, useThemeSettings } from '@/hooks';
import { IconClose, IconImage, IconMenu, IconSearch } from '@/icons';
import { IconClose, IconImage, IconMenu, IconSearch, IconEmail } from '@/icons';

Check failure on line 19 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L19

Member 'IconEmail' of the import declaration should be sorted alphabetically (sort-imports)
import { Button, ButtonLink } from '@/ui';

import CategoriesDropdown from './CategoriesDropdown';
Expand All @@ -31,6 +33,8 @@ interface Props {

function Header({ hasError }: Props) {
const { newsroom_logo, display_name, public_galleries_number } = useNewsroom();
const { contacts } = useNewsroomContext();
const currentLocale = useCurrentLocale() as unknown as { localeCode: string };
const { logoSize } = useThemeSettings();
const categories = useCategories();
const { name } = useCompanyInformation();
Expand Down Expand Up @@ -154,6 +158,28 @@ function Header({ hasError }: Props) {
>
<div role="none" className={styles.backdrop} onClick={closeMenu} />
<ul id="menu" className={styles.navigationInner}>
{contacts && contacts.length > 0 && contacts.some(contact =>

Check failure on line 161 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L161

Replace `·contacts.length·>·0·&&·contacts.some(contact·=>·⏎····································contact.display_locales.some(locale` with `⏎····································contacts.length·>·0·&&⏎····································contacts.some((contact)·=>⏎········································contact.display_locales.some((locale)` (prettier/prettier)
contact.display_locales.some(locale => {
const normalizedLocaleCode = locale.code.replace('_', '-');

Check failure on line 163 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L163

Replace `········································const·normalizedLocaleCode·=·locale.code.replace('_',·'-'` with `············································const·normalizedLocaleCode·=·locale.code.replace(⏎················································'_',⏎················································'-',⏎············································` (prettier/prettier)
const normalizedCurrentLocale = currentLocale.localeCode.replace('_', '-');

Check failure on line 164 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L164

Replace `········································const·normalizedCurrentLocale·=` with `············································const·normalizedCurrentLocale·=⏎···············································` (prettier/prettier)
return normalizedLocaleCode === normalizedCurrentLocale ||

Check failure on line 165 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L165

Replace `return·normalizedLocaleCode·===·normalizedCurrentLocale·||·` with `····return·(⏎················································normalizedLocaleCode·===·normalizedCurrentLocale·||` (prettier/prettier)
locale.language_code === currentLocale.localeCode;

Check failure on line 166 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L166

Replace `···············································locale.language_code·===·currentLocale.localeCode` with `················································locale.language_code·===·currentLocale.localeCode⏎············································)` (prettier/prettier)
})

Check failure on line 167 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L167

Replace `····································})` with `········································}),` (prettier/prettier)
) && (

Check failure on line 168 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L168

Insert `····` (prettier/prettier)
<li className={styles.navigationItem}>

Check failure on line 169 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L169

Replace `····································` with `········································` (prettier/prettier)
<ButtonLink

Check failure on line 170 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L170

Insert `····` (prettier/prettier)
href="/#contacts"

Check failure on line 171 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L171

Insert `····` (prettier/prettier)
localeCode={getLinkLocaleSlug()}

Check failure on line 172 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L172

Replace `············································` with `················································` (prettier/prettier)
variation="navigation"

Check failure on line 173 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L173

Insert `····` (prettier/prettier)
className={styles.navigationButton}

Check failure on line 174 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L174

Replace `············································` with `················································` (prettier/prettier)
icon={IconEmail}

Check failure on line 175 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L175

Insert `····` (prettier/prettier)
>

Check failure on line 176 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L176

Replace `········································` with `············································` (prettier/prettier)
<FormattedMessage

Check failure on line 177 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L177

Insert `····` (prettier/prettier)
{...translations.contacts.title}

Check failure on line 178 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L178

Insert `····` (prettier/prettier)
/>

Check failure on line 179 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L179

Replace `············································` with `················································` (prettier/prettier)
</ButtonLink>

Check failure on line 180 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L180

Insert `····` (prettier/prettier)
</li>

Check failure on line 181 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L181

Insert `····` (prettier/prettier)
)}

Check failure on line 182 in modules/Layout/Header/Header.tsx

View workflow job for this annotation

GitHub Actions / ESLint

modules/Layout/Header/Header.tsx#L182

Insert `····` (prettier/prettier)
{public_galleries_number > 0 && (
<li className={styles.navigationItem}>
<ButtonLink
Expand Down
24 changes: 18 additions & 6 deletions pages/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Story as PrezlyStory } from '@prezly/sdk';
import { useCurrentStory } from '@prezly/theme-kit-nextjs';
import { getStoryPageServerSideProps } from '@prezly/theme-kit-nextjs/server';
import { getStoryPageServerSideProps, NextContentDelivery } from '@prezly/theme-kit-nextjs/server';
import type { NextPage } from 'next';
import dynamic from 'next/dynamic';

Expand All @@ -16,11 +16,23 @@ const StoryPage: NextPage<BasePageProps> = () => {
};

export const getServerSideProps = getStoryPageServerSideProps<BasePageProps>(
async (context, { newsroomContextProps }) => ({
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
}),
[PrezlyStory.FormatVersion.SLATEJS_V6],
async (context, { newsroomContextProps }) => {
const api = NextContentDelivery.initClient(context.req);
const { newsroomContextProps: contextWithContacts } = await api.getNewsroomServerSideProps(
newsroomContextProps.localeCode,
undefined,
true

Check failure on line 24 in pages/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/[slug].tsx#L24

Insert `,` (prettier/prettier)
);
return {
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
newsroomContextProps: {
...newsroomContextProps,
contacts: contextWithContacts.contacts

Check failure on line 31 in pages/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/[slug].tsx#L31

Insert `,` (prettier/prettier)
}

Check failure on line 32 in pages/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/[slug].tsx#L32

Insert `,` (prettier/prettier)
};
},
[PrezlyStory.FormatVersion.SLATEJS_V6]

Check failure on line 35 in pages/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/[slug].tsx#L35

Insert `,` (prettier/prettier)
);

export default StoryPage;
26 changes: 20 additions & 6 deletions pages/category/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type PaginationProps, useCurrentCategory } from '@prezly/theme-kit-nextjs';
import { getCategoryPageServerSideProps } from '@prezly/theme-kit-nextjs/server';
import { getCategoryPageServerSideProps, NextContentDelivery } from '@prezly/theme-kit-nextjs/server';

Check failure on line 2 in pages/category/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/category/[slug].tsx#L2

Replace `·getCategoryPageServerSideProps,·NextContentDelivery·` with `⏎····getCategoryPageServerSideProps,⏎····NextContentDelivery,⏎` (prettier/prettier)
import dynamic from 'next/dynamic';
import type { FunctionComponent } from 'react';

Expand All @@ -18,12 +18,26 @@ const CategoryPage: FunctionComponent<Props> = ({ stories, pagination }) => {

return <Category category={currentCategory!} stories={stories} pagination={pagination} />;
};

export const getServerSideProps = getCategoryPageServerSideProps<BasePageProps, 'thumbnail_image'>(
async (context, { newsroomContextProps }) => ({
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
}),
{ extraStoryFields: ['thumbnail_image'] },
async (context, { newsroomContextProps }) => {
const api = NextContentDelivery.initClient(context.req);
const { newsroomContextProps: contextWithContacts } = await api.getNewsroomServerSideProps(
newsroomContextProps.localeCode,
undefined,
true

Check failure on line 28 in pages/category/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/category/[slug].tsx#L28

Insert `,` (prettier/prettier)
);

return {
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
newsroomContextProps: {
...newsroomContextProps,
contacts: contextWithContacts.contacts ?? null

Check failure on line 36 in pages/category/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/category/[slug].tsx#L36

Insert `,` (prettier/prettier)
}

Check failure on line 37 in pages/category/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/category/[slug].tsx#L37

Insert `,` (prettier/prettier)
};
},
{ extraStoryFields: ['thumbnail_image'] }

Check failure on line 40 in pages/category/[slug].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/category/[slug].tsx#L40

Insert `,` (prettier/prettier)
);

export default CategoryPage;
22 changes: 18 additions & 4 deletions pages/media/album/[uuid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from '@prezly/theme-kit-nextjs/server';
import dynamic from 'next/dynamic';
import type { FunctionComponent } from 'react';
import { NextContentDelivery } from '@prezly/theme-kit-nextjs/server';

Check failure on line 7 in pages/media/album/[uuid].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/album/[uuid].tsx#L7

`@prezly/theme-kit-nextjs/server` import should occur before import of `next/dynamic` (import/order)

import { importMessages, isTrackingEnabled } from '@/utils';
import type { BasePageProps } from 'types';
Expand All @@ -15,10 +16,23 @@ type Props = BasePageProps & GalleryAlbumPageProps;
const GalleryPage: FunctionComponent<Props> = ({ gallery }) => <Gallery gallery={gallery} />;

export const getServerSideProps = getGalleryAlbumPageServerSideProps<BasePageProps>(
async (context, { newsroomContextProps }) => ({
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
}),
async (context, { newsroomContextProps }) => {
const api = NextContentDelivery.initClient(context.req);
const { newsroomContextProps: contextWithContacts } = await api.getNewsroomServerSideProps(
newsroomContextProps.localeCode,
undefined,
true

Check failure on line 24 in pages/media/album/[uuid].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/album/[uuid].tsx#L24

Insert `,` (prettier/prettier)
);

return {
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
newsroomContextProps: {
...newsroomContextProps,
contacts: contextWithContacts.contacts ?? null

Check failure on line 32 in pages/media/album/[uuid].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/album/[uuid].tsx#L32

Insert `,` (prettier/prettier)
}

Check failure on line 33 in pages/media/album/[uuid].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/album/[uuid].tsx#L33

Insert `,` (prettier/prettier)
};
}

Check failure on line 35 in pages/media/album/[uuid].tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/album/[uuid].tsx#L35

Insert `,` (prettier/prettier)
);

export default GalleryPage;
24 changes: 20 additions & 4 deletions pages/media/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from '@prezly/theme-kit-nextjs/server';
import dynamic from 'next/dynamic';
import type { FunctionComponent } from 'react';
import { NextContentDelivery } from '@prezly/theme-kit-nextjs/server';

Check failure on line 7 in pages/media/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/index.tsx#L7

`@prezly/theme-kit-nextjs/server` import should occur before import of `next/dynamic` (import/order)

import { importMessages, isTrackingEnabled } from '@/utils';
import type { BasePageProps } from 'types';
Expand All @@ -17,10 +18,25 @@ const GalleriesPage: FunctionComponent<Props> = ({ galleries, pagination }) => (
);

export const getServerSideProps = getGalleryPageServerSideProps<BasePageProps>(
async (context, { newsroomContextProps }) => ({
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
}),
async (context, { newsroomContextProps }) => {
const api = NextContentDelivery.initClient(context.req);
const { newsroomContextProps: contextWithContacts } = await api.getNewsroomServerSideProps(
newsroomContextProps.localeCode,
undefined,
true

Check failure on line 26 in pages/media/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/index.tsx#L26

Insert `,` (prettier/prettier)
);

console.log('Gallery page contacts:', contextWithContacts.contacts);

return {
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
newsroomContextProps: {
...newsroomContextProps,
contacts: contextWithContacts.contacts ?? null

Check failure on line 36 in pages/media/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/index.tsx#L36

Insert `,` (prettier/prettier)
}

Check failure on line 37 in pages/media/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/index.tsx#L37

Insert `,` (prettier/prettier)
};
}

Check failure on line 39 in pages/media/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/media/index.tsx#L39

Insert `,` (prettier/prettier)
);

export default GalleriesPage;
28 changes: 22 additions & 6 deletions pages/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getSearchPageServerSideProps } from '@prezly/theme-kit-nextjs/server';
import dynamic from 'next/dynamic';
import { notFound } from 'next/navigation';
import type { FunctionComponent } from 'react';
import { NextContentDelivery } from '@prezly/theme-kit-nextjs/server';

Check failure on line 6 in pages/search.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/search.tsx#L6

`@prezly/theme-kit-nextjs/server` import should occur before import of `next/dynamic` (import/order)

Check failure on line 6 in pages/search.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/search.tsx#L6

'/home/runner/work/theme-nextjs-lena/theme-nextjs-lena/node_modules/@prezly/theme-kit-nextjs/build/server.js' imported multiple times (import/no-duplicates)

import { importMessages } from '@/utils/lang';
import type { BasePageProps } from 'types';
Expand All @@ -22,12 +23,27 @@ const SearchResultsPage: FunctionComponent<Props> = ({ searchSettings }) => {
return <SearchPage settings={searchSettings} />;
};

export const getServerSideProps = getSearchPageServerSideProps<ExtraProps>(
async (context, { newsroomContextProps }) => ({
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
searchSettings: newsroomContextProps.searchSettings,
}),
export const getServerSideProps = getSearchPageServerSideProps<BasePageProps>(
async (context, { newsroomContextProps }) => {
const api = NextContentDelivery.initClient(context.req);
const { newsroomContextProps: contextWithContacts } = await api.getNewsroomServerSideProps(
newsroomContextProps.localeCode,
undefined,
true

Check failure on line 32 in pages/search.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/search.tsx#L32

Insert `,` (prettier/prettier)
);

console.log('Search page contacts:', contextWithContacts.contacts);

return {
isTrackingEnabled: isTrackingEnabled(context),
translations: await importMessages(newsroomContextProps.localeCode),
newsroomContextProps: {
...newsroomContextProps,
contacts: contextWithContacts.contacts ?? null

Check failure on line 42 in pages/search.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/search.tsx#L42

Insert `,` (prettier/prettier)
},
searchSettings: newsroomContextProps.searchSettings

Check failure on line 44 in pages/search.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/search.tsx#L44

Insert `,` (prettier/prettier)
};
}

Check failure on line 46 in pages/search.tsx

View workflow job for this annotation

GitHub Actions / ESLint

pages/search.tsx#L46

Insert `,` (prettier/prettier)
);

export default SearchResultsPage;

0 comments on commit c1c4e82

Please sign in to comment.