From 8d9bb5d5f911342b203a9bc9258233ff3aa52f57 Mon Sep 17 00:00:00 2001 From: Daniel Hladkyi Date: Fri, 11 Aug 2023 17:14:15 +0300 Subject: [PATCH] Solution --- README.md | 2 +- src/App.jsx | 20 ++++---------------- src/components/Person/Person.jsx | 27 ++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3424ccb86..f60743956 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,4 @@ and use it 3 times inside the `App` instead of static markup. ## Instructions - Implement a solution following the [React task guideline](https://github.com/mate-academy/react_task-guideline#react-tasks-guideline). - Open one more terminal and run tests with `npm test` to ensure your solution is correct. -- Replace `` with your Github username in the [DEMO LINK](https://.github.io/react_person/) and add it to the PR description. +- Replace `` with your Github username in the [DEMO LINK](https://Hladkyi03.github.io/react_person/) and add it to the PR description. diff --git a/src/App.jsx b/src/App.jsx index dcf8509c8..eb6735128 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import { Person } from './components/Person/Person'; import './App.scss'; export const 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..925f02354 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1 +1,26 @@ -// export const Person = ({ person }) => (); +import React from 'react'; + +export const Person = ({ person }) => { + const { name, age, sex, isMarried, partnerName } = person; + + return ( +
+

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

+ {age && ( +

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

+ )} + + {isMarried ? ( +

+ {sex === 'm' ? `${partnerName} is my wife` : `${partnerName} is my husband`} +

+ ) : ( +

I am not married

+ )} +
+ ); +};