2022-10-28 08:56:26 +03:00
|
|
|
import Image from 'next/image';
|
2022-09-07 10:00:28 +03:00
|
|
|
import { FC } from 'react';
|
2023-03-18 21:49:20 +03:00
|
|
|
import { ErrorBoundary } from 'react-error-boundary';
|
2022-05-17 07:44:09 +03:00
|
|
|
import { SocialLink } from '../../../interfaces/social-link.model';
|
2023-03-18 21:49:20 +03:00
|
|
|
import { ComponentError } from '../ComponentError/ComponentError';
|
2022-09-07 10:00:28 +03:00
|
|
|
import styles from './SocialLinks.module.scss';
|
2022-05-17 07:44:09 +03:00
|
|
|
|
2022-09-07 10:00:28 +03:00
|
|
|
export type SocialLinksProps = {
|
2022-05-17 07:44:09 +03:00
|
|
|
links: SocialLink[];
|
2022-09-07 10:00:28 +03:00
|
|
|
};
|
2022-05-17 07:44:09 +03:00
|
|
|
|
2023-03-18 21:49:20 +03:00
|
|
|
export const SocialLinks: FC<SocialLinksProps> = ({ links }) => {
|
|
|
|
if (!links?.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ErrorBoundary
|
|
|
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
|
|
fallbackRender={({ error, resetErrorBoundary }) => (
|
|
|
|
<ComponentError
|
|
|
|
componentName="SocialLinks"
|
|
|
|
message={error.message}
|
|
|
|
retryFunction={resetErrorBoundary}
|
2022-10-19 09:35:36 +03:00
|
|
|
/>
|
2023-03-18 21:49:20 +03:00
|
|
|
)}
|
|
|
|
>
|
|
|
|
<div className={styles.links}>
|
|
|
|
{links?.map(link => (
|
|
|
|
<a
|
|
|
|
key={link.platform}
|
|
|
|
href={link.url}
|
|
|
|
className={styles.link}
|
|
|
|
target="_blank"
|
|
|
|
// eslint-disable-next-line react/no-invalid-html-attribute
|
|
|
|
rel="noreferrer me"
|
|
|
|
>
|
|
|
|
<Image
|
|
|
|
src={link.icon || '/img/platformlogos/default.svg'}
|
|
|
|
alt={link.platform}
|
|
|
|
className={styles.link}
|
|
|
|
width="30"
|
|
|
|
height="30"
|
|
|
|
/>
|
|
|
|
</a>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</ErrorBoundary>
|
|
|
|
);
|
|
|
|
};
|