From ca5124ec0dfe14d1ac5ce4059b5b85b646999873 Mon Sep 17 00:00:00 2001 From: Ruslan Ihnatenko Date: Mon, 21 Aug 2023 18:24:09 +0200 Subject: [PATCH 1/2] Task solution --- src/App.jsx | 20 ++++---------------- src/components/Person/Person.jsx | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index dcf8509c8..fddd88727 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..32953780a 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1 +1,14 @@ -// export const Person = ({ person }) => (); + +export function Person({ person }) { + const { name, age, sex, isMarried, partnerName } = person; + + const partnerText = `${partnerName} is my ${sex === 'f' ? 'husband' : 'wife'}`; + + return ( +
+

{`My name is ${name}`}

+ {age !== undefined && (

{`I am ${age}`}

)} +

{isMarried ? partnerText : `I am not married`}

+
+ ); +} From f8e80b504adc9e85b1f1c432ab41324cf7af24e5 Mon Sep 17 00:00:00 2001 From: Ruslan Ihnatenko Date: Tue, 22 Aug 2023 13:46:16 +0200 Subject: [PATCH 2/2] Fixed 1 --- src/App.jsx | 6 +++--- src/components/Person/Person.jsx | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index fddd88727..c09fddf21 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -26,8 +26,8 @@ export const alex = { export const App = () => (
- - - + + +
); diff --git a/src/components/Person/Person.jsx b/src/components/Person/Person.jsx index 32953780a..6680209ff 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1,8 +1,11 @@ export function Person({ person }) { const { name, age, sex, isMarried, partnerName } = person; + let partnerText; - const partnerText = `${partnerName} is my ${sex === 'f' ? 'husband' : 'wife'}`; + if (partnerName) { + partnerText = `${person.partnerName} is my ${sex === 'f' ? 'husband' : 'wife'}`; + } return (