fix(name,title): handle empty states in "did you know" section

This commit is contained in:
zyachel
2025-06-01 13:08:06 +00:00
committed by ngn
parent e98ab85034
commit 34bcdc3b05
2 changed files with 53 additions and 36 deletions

View File

@ -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
);

View File

@ -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>