-
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 status checks…
EPMGCIP-180: Decrease quantity of warnings to 0 (#36)
* EPMGCIP-180: Add configuration to ESLint to extend "react/recommended" plugin * EPMGCIP-180: Resolve ESLint warnings in "i18n.ts" file * EPMGCIP-180: Resolve ESLint warnings in "getExhibit" function * EPMGCIP-180: Resolve ESLint warnings in "sendContactForm" function * EPMGCIP-180: Resolve ESLint warnings related to "IExhibit" interface * EPMGCIP-180: Split "Exhibit" page into separate subcomponents, update usages * EPMGCIP-180: Suppress complexity issue on "ExhibitDetails" due to simple structure * EPMGCIP-180: Ignore blank lines and comments in "max-lines" ESLint rules * EPMGCIP-180: Resolve ESLint warnings related to "ImageGallery" component * EPMGCIP-180: Decrease max warnings level in Git hooks to 0 allowed
1 parent
77c60aa
commit 7b29fc9
Showing
11 changed files
with
224 additions
and
159 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
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from 'react'; | ||
|
||
import { documentToReactComponents } from '@contentful/rich-text-react-renderer'; | ||
import { useTranslations } from 'next-intl'; | ||
|
||
import ImageGallery from '@/components/organisms/ImageGallery/ImageGallery'; | ||
import Player from '@/components/organisms/Player/Player'; | ||
import IExhibit from '@/interfaces/IExhibit'; | ||
import { LocaleCodeCamelcase } from '@/locales'; | ||
|
||
import styles from './Exhibit.module.scss'; | ||
|
||
interface Props { | ||
exhibit: IExhibit; | ||
selectedLocale: LocaleCodeCamelcase; | ||
} | ||
|
||
// eslint-disable-next-line complexity | ||
export const ExhibitDetails: React.FC<Props> = (props) => { | ||
const t = useTranslations(); | ||
|
||
const title = props.exhibit[`name${props.selectedLocale}`]; | ||
const author = props.exhibit[`author${props.selectedLocale}`]; | ||
const audioFile = props.exhibit[`audioFile${props.selectedLocale}`]?.url; | ||
const description = props.exhibit[`description${props.selectedLocale}`]?.json; | ||
const yearOfCreation = props.exhibit.yearOfCreation; | ||
|
||
const images = | ||
props.exhibit.imagesCollection?.items?.map((i) => ({ | ||
id: i?.sys.id || '', | ||
url: i?.url || '', | ||
})) ?? []; | ||
|
||
return ( | ||
<article className={styles.exhibit} data-testid="exhibit"> | ||
<h2 className={styles.title}>{title}</h2> | ||
|
||
{author && <div className={styles.author}>{author}</div>} | ||
|
||
{images.length > 0 && ( | ||
<div className={styles.gallery}> | ||
<ImageGallery images={images} isLinkImage={false} displayArrows={false} /> | ||
</div> | ||
)} | ||
|
||
{audioFile && ( | ||
<div className={styles.audioPlayer}> | ||
<Player url={audioFile || ''} /> | ||
</div> | ||
)} | ||
|
||
{yearOfCreation && ( | ||
<div className={styles.description}> | ||
<div className={styles.descriptionName}>{t('date')}</div> | ||
<div>{yearOfCreation}</div> | ||
</div> | ||
)} | ||
|
||
{description && ( | ||
<div className={styles.description}> | ||
<div className={styles.descriptionName}>{t('description')}</div> | ||
<div id="exhibit-description" className={styles.descriptionContent}> | ||
{documentToReactComponents(description)} | ||
</div> | ||
</div> | ||
)} | ||
</article> | ||
); | ||
}; |
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,41 @@ | ||
import React from 'react'; | ||
|
||
import { useTranslations } from 'next-intl'; | ||
|
||
import IExhibit from '@/interfaces/IExhibit'; | ||
import { LocaleCodeCamelcase, localesCamelcase } from '@/locales'; | ||
|
||
import styles from './Exhibit.module.scss'; | ||
|
||
interface Props { | ||
exhibit: IExhibit; | ||
setLocale: (locale: LocaleCodeCamelcase) => void; | ||
} | ||
|
||
export const ExhibitNotFoundMessage: React.FC<Props> = (props) => { | ||
const t = useTranslations(); | ||
|
||
const handleLinkOnClick = | ||
(lang: LocaleCodeCamelcase) => | ||
(e: React.SyntheticEvent<HTMLButtonElement>): void => { | ||
e.preventDefault(); | ||
|
||
props.setLocale(lang); | ||
}; | ||
|
||
const links = localesCamelcase | ||
.filter((lang) => props.exhibit?.[`name${lang}`]) | ||
.map((lang) => ( | ||
<span key={lang}> | ||
<button className={styles.link} onClick={handleLinkOnClick(lang)}> | ||
{t(`exhibitNotFound${lang}`)} | ||
</button>{' '} | ||
</span> | ||
)); | ||
|
||
return ( | ||
<div className={styles.error}> | ||
{t('exhibitNotFoundForLanguage')} {links} | ||
</div> | ||
); | ||
}; |
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