fix(name,title): handle empty states in "did you know" section
This commit is contained in:
@ -9,6 +9,10 @@ type Props = {
|
|||||||
const DidYouKnow = ({ data }: Props) => (
|
const DidYouKnow = ({ data }: Props) => (
|
||||||
<section className={styles.container}>
|
<section className={styles.container}>
|
||||||
<h2 className='heading heading__secondary'>Did you know</h2>
|
<h2 className='heading heading__secondary'>Did you know</h2>
|
||||||
|
{isEmpty(data) ? (
|
||||||
|
<p>Nothing interesting to show.</p>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
{!!data.trivia?.total && (
|
{!!data.trivia?.total && (
|
||||||
<section>
|
<section>
|
||||||
<h3 className='heading heading__tertiary'>Trivia</h3>
|
<h3 className='heading heading__tertiary'>Trivia</h3>
|
||||||
@ -45,7 +49,14 @@ const DidYouKnow = ({ data }: Props) => (
|
|||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default DidYouKnow;
|
export default DidYouKnow;
|
||||||
|
|
||||||
|
const isEmpty = (data: Props['data']) =>
|
||||||
|
Boolean(
|
||||||
|
!data.nicknames.length && !data.quotes && !data.salary && !data.trademark && !data.trivia
|
||||||
|
);
|
@ -7,7 +7,13 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const DidYouKnow = ({ data }: Props) => {
|
const DidYouKnow = ({ data }: Props) => {
|
||||||
if (!Object.keys(data).length) return <></>;
|
if (!Object.keys(data).length)
|
||||||
|
return (
|
||||||
|
<section className={styles.didYouKnow}>
|
||||||
|
<h2 className='heading heading__secondary'>Did you know</h2>
|
||||||
|
<p>Nothing interesting to show.</p>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
<section className={styles.didYouKnow}>
|
<section className={styles.didYouKnow}>
|
||||||
<h2 className='heading heading__secondary'>Did you know</h2>
|
<h2 className='heading heading__secondary'>Did you know</h2>
|
||||||
|
Reference in New Issue
Block a user