From c4578629dccf93ab39b4d9ef3dc480008e96bdd1 Mon Sep 17 00:00:00 2001 From: Szymon Pachucki Date: Mon, 21 Aug 2023 14:11:20 +0200 Subject: [PATCH 1/2] Solution --- src/App.jsx | 20 ++++--------------- src/components/Person/Person.jsx | 34 +++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index dcf8509c8..c09fddf21 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,5 +1,6 @@ import React from 'react'; import './App.scss'; +import { Person } from './components/Person/Person'; export const misha = { name: 'Misha', @@ -25,21 +26,8 @@ export const alex = { export const App = () => (
-
-

My name is Misha

-

I am 37

-

Natasha is my wife

-
- -
-

My name is Olya

-

Maksym is my husband

-
- -
-

My name is Alex

-

I am 25

-

I am not married

-
+ + +
); diff --git a/src/components/Person/Person.jsx b/src/components/Person/Person.jsx index eccf156a3..2b31fd8b6 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1 +1,33 @@ -// export const Person = ({ person }) => (); +export const Person = (props) => { + const { name, age, partnerName, sex, isMarried } = props.person; + + const partnerRole = sex === 'm' ? 'wife' : 'husband'; + + return ( +
+

+ My name is + {' '} + {name} +

+ {age && ( +

+ I am + {' '} + {age} +

+ )} + {isMarried ? ( +

+ {partnerName} + {' '} + is my + {' '} + {partnerRole} +

+ ) : ( +

I am not married

+ )} +
+ ); +}; From e78efc4bbd3e08b88b016dc7c48f56b95b0f4224 Mon Sep 17 00:00:00 2001 From: Szymon Pachucki Date: Tue, 22 Aug 2023 10:04:36 +0200 Subject: [PATCH 2/2] Solution --- src/components/Person/Person.jsx | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/Person/Person.jsx b/src/components/Person/Person.jsx index 2b31fd8b6..3e16298e1 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -6,24 +6,16 @@ export const Person = (props) => { return (

- My name is - {' '} - {name} + {`My name is ${name}`}

{age && (

- I am - {' '} - {age} + {`I am ${age}`}

)} {isMarried ? (

- {partnerName} - {' '} - is my - {' '} - {partnerRole} + {`${partnerName} is my ${partnerRole}`}

) : (

I am not married