diff --git a/react-typescript/src/App.test.tsx b/react-typescript/src/App.test.tsx
index 2a68616d..783ed7d1 100644
--- a/react-typescript/src/App.test.tsx
+++ b/react-typescript/src/App.test.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
-import App from './App';
+import App from './components/App';
test('renders learn react link', () => {
render();
diff --git a/react-typescript/src/App.tsx b/react-typescript/src/App.tsx
deleted file mode 100644
index 6cdb3476..00000000
--- a/react-typescript/src/App.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import './App.css';
-import Item from './Item';
-
-function App() {
- return (
-
-
-
-
-
-
-
-
- );
-}
-
-export default App;
diff --git a/react-typescript/src/Item.tsx b/react-typescript/src/Item.tsx
deleted file mode 100644
index 2ea7b70e..00000000
--- a/react-typescript/src/Item.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-import { useEffect, useState } from "react";
-
-function calculateQuality(name:string, quality: number, sellIn: number,isConjured: boolean): number {
- const sellInAmount = sellIn;
-
- let calculatedQuality = quality;
- let degradeRate = 1;
- let qualityIdentifier = 1;
-
- if(sellInAmount <= 0) {
- return calculatedQuality;
- }
-
- if(name.includes("Sulfuras")) {
- return 80;
- };
-
- if(calculatedQuality >= 50) {
- return 50;
- } else if(calculatedQuality <= 0) {
- return 0;
- }
-
- if(isConjured) {
- degradeRate = 2;
- }
-
- if(name.includes('Aged Brie')) {
- qualityIdentifier = -1;
- }
-
- if(name.includes('Backstage passes')) {
- if(sellInAmount <= 10 && sellInAmount > 5) {
- qualityIdentifier = -3;
- } else if(sellInAmount <= 5 && sellInAmount > 0) {
- qualityIdentifier = -2;
- } else if(sellInAmount <= 0) {
- qualityIdentifier = 0;
- degradeRate = 0;
- }
- }
-
- return degradeRate * calculatedQuality - qualityIdentifier;
-};
-
-function calculateSellIn(name:string, sellIn: number): number {
- let sellInAmount = sellIn;
-
- if(name.includes("Sulfuras")) {
- return sellInAmount;
- };
-
- if(sellInAmount <= 0) {
- return 0;
- }
-
- return sellIn - 1;
-};
-
-type ItemProps = {
- name: string,
- quality: number,
- sellIn: number,
- isConjured: boolean
-};
-
-const Item = (props: ItemProps) => {
- const [name, setName] = useState(props.name);
- useEffect(() => {
- setName(props.name);
- }, [props.name]);
-
- const [quality, setQuality] = useState(props.quality);
- useEffect(() => {
- setQuality(props.quality);
- }, [props.quality]);
-
- const [sellIn, setSellIn] = useState(props.sellIn);
- useEffect(() => {
- setSellIn(props.sellIn);
- }, [props.sellIn]);
-
- const [isConjured, setIsConjured] = useState(props.isConjured);
- useEffect(() => {
- setIsConjured(props.isConjured);
- }, [props.isConjured]);
-
- return (
-
-
{name}
-
-
{quality}
-
-
{sellIn}
-
-
-
-
- );
-};
-
-export default Item;
\ No newline at end of file
diff --git a/react-typescript/src/App.css b/react-typescript/src/components/App.css
similarity index 100%
rename from react-typescript/src/App.css
rename to react-typescript/src/components/App.css
diff --git a/react-typescript/src/components/App.tsx b/react-typescript/src/components/App.tsx
new file mode 100644
index 00000000..50c89f89
--- /dev/null
+++ b/react-typescript/src/components/App.tsx
@@ -0,0 +1,12 @@
+import './App.css';
+import Items from './Item';
+
+function App() {
+ return (
+
+
+
+ );
+}
+
+export default App;
diff --git a/react-typescript/src/components/Item.tsx b/react-typescript/src/components/Item.tsx
new file mode 100644
index 00000000..79d0c13a
--- /dev/null
+++ b/react-typescript/src/components/Item.tsx
@@ -0,0 +1,21 @@
+import useItem from "../hooks/useItem";
+import Item from "../types"
+
+function Items() {
+ const { items, updateItem } = useItem();
+ return (
+
+
+ {items.map((item: Item) => {
+ return (
+ -
+ Name: {item.name} Quality: {item.quality} SellIn: {item.sellIn}
+
+ );
+ })}
+
+
+ );
+};
+
+export default Items;
\ No newline at end of file
diff --git a/react-typescript/src/index.tsx b/react-typescript/src/index.tsx
index 032464fb..024fa737 100644
--- a/react-typescript/src/index.tsx
+++ b/react-typescript/src/index.tsx
@@ -1,8 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
-import App from './App';
-import reportWebVitals from './reportWebVitals';
+import App from './components/App';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
@@ -12,8 +11,3 @@ root.render(
);
-
-// If you want to start measuring performance in your app, pass a function
-// to log results (for example: reportWebVitals(console.log))
-// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
-reportWebVitals();
diff --git a/react-typescript/src/reportWebVitals.ts b/react-typescript/src/reportWebVitals.ts
deleted file mode 100644
index 49a2a16e..00000000
--- a/react-typescript/src/reportWebVitals.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { ReportHandler } from 'web-vitals';
-
-const reportWebVitals = (onPerfEntry?: ReportHandler) => {
- if (onPerfEntry && onPerfEntry instanceof Function) {
- import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
- getCLS(onPerfEntry);
- getFID(onPerfEntry);
- getFCP(onPerfEntry);
- getLCP(onPerfEntry);
- getTTFB(onPerfEntry);
- });
- }
-};
-
-export default reportWebVitals;
diff --git a/react-typescript/src/setupTests.ts b/react-typescript/src/setupTests.ts
deleted file mode 100644
index 8f2609b7..00000000
--- a/react-typescript/src/setupTests.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-// jest-dom adds custom jest matchers for asserting on DOM nodes.
-// allows you to do things like:
-// expect(element).toHaveTextContent(/react/i)
-// learn more: https://github.com/testing-library/jest-dom
-import '@testing-library/jest-dom';