From 6c226648a7bbc9fc54dfa5aed02a055f1f77a7e7 Mon Sep 17 00:00:00 2001 From: Stas Date: Wed, 2 Oct 2024 16:41:00 +0200 Subject: [PATCH 1/2] solution --- README.md | 2 +- src/App.jsx | 20 ++++---------------- src/components/Person/Person.jsx | 14 +++++++++++++- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 009a2977c..ed0c5acdc 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,4 @@ and use it 3 times inside the `App` instead of static markup. - Install Prettier Extention and use this [VSCode settings](https://mate-academy.github.io/fe-program/tools/vscode/settings.json) to enable format on save. - 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://StanislavKapytsia.github.io/react_person/) and add it to the PR description. 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..07427fcfd 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1 +1,13 @@ -// export const Person = ({ person }) => (); +export const Person = ({ person }) => ( +
+

My name is {person.name}

+ + {person.age &&

I am {person.age}

} + +

+ {person.isMarried === true + ? `${person.partnerName} is my ${person.sex === 'm' ? 'wife' : 'husband'}` + : 'I am not married'} +

+
+); From 882474c07665d2f626b2a1275349af3fdb0ef8d8 Mon Sep 17 00:00:00 2001 From: Stas Date: Thu, 3 Oct 2024 16:38:05 +0200 Subject: [PATCH 2/2] Suggested change --- src/components/Person/Person.jsx | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/components/Person/Person.jsx b/src/components/Person/Person.jsx index 07427fcfd..73e3a1402 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1,13 +1,18 @@ -export const Person = ({ person }) => ( -
-

My name is {person.name}

+export function Person({ person }) { + const { name, age, sex, isMarried, partnerName } = person; + const MAN = 'm'; - {person.age &&

I am {person.age}

} + return ( +
+

My name is {name}

-

- {person.isMarried === true - ? `${person.partnerName} is my ${person.sex === 'm' ? 'wife' : 'husband'}` - : 'I am not married'} -

-
-); + {age &&

I am {age}

} + +

+ {isMarried + ? `${partnerName} is my ${sex === MAN ? 'wife' : 'husband'}` + : 'I am not married'} +

+
+ ); +}