+ );
+};
diff --git a/src/GoodsList.tsx b/src/GoodsList.tsx
index b56a4331e..c55c552af 100644
--- a/src/GoodsList.tsx
+++ b/src/GoodsList.tsx
@@ -2,13 +2,17 @@ import React from 'react';
import { Good } from './types/Good';
type Props = {
- goods: Good[]
+ goods: Good[];
};
export const GoodsList: React.FC = ({ goods }) => (
{goods.map(good => (
-
+
{good.name}
))}
diff --git a/src/api/goods.ts b/src/api/goods.ts
index f0d1659f8..0db9cc417 100644
--- a/src/api/goods.ts
+++ b/src/api/goods.ts
@@ -4,16 +4,17 @@ import { Good } from '../types/Good';
const API_URL = `https://mate-academy.github.io/react_dynamic-list-of-goods/goods.json`;
export function getAll(): Promise {
- return fetch(API_URL)
- .then(response => response.json());
+ return fetch(API_URL).then(response => response.json());
}
export const get5First = () => {
return getAll()
- .then(goods => goods); // sort and get the first 5
+ .then(goods => goods
+ .sort((a, b) => a.name.localeCompare(b.name))
+ .slice(0, 5));
};
-export const getRedGoods = () => {
+export const getRed = () => {
return getAll()
- .then(goods => goods); // get only red
+ .then(goods => goods.filter(good => good.color === 'red'));
};
From b1bc5f808643321ba971475d2816134805441d09 Mon Sep 17 00:00:00 2001
From: Heorhii Savostikov <116906180+GeorgeSavostikov@users.noreply.github.com>
Date: Sat, 20 Jan 2024 22:38:27 +0200
Subject: [PATCH 2/2] oops
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index aa688e6f2..ab7f3a1ad 100644
--- a/README.md
+++ b/README.md
@@ -15,4 +15,4 @@ You have 3 button that should load [the goods](https://mate-academy.github.io/re
- Implement a solution following the [React task guideline](https://github.com/mate-academy/react_task-guideline#react-tasks-guideline).
- Use the [React TypeScript cheat sheet](https://mate-academy.github.io/fe-program/js/extra/react-typescript).
- 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_dynamic-list-of-goods/) and add it to the PR description.
+- Replace `` with your Github username in the [DEMO LINK](https://GeorgeSavostikov.github.io/react_dynamic-list-of-goods/) and add it to the PR description.