This commit is contained in:
@@ -688,7 +688,7 @@ Projektarbeit
|
|||||||
- Debugging-Techniken – Chrome Debugger
|
- Debugging-Techniken – Chrome Debugger
|
||||||
- Webentwickler Developer Tools
|
- Webentwickler Developer Tools
|
||||||
- Einrichtung von Eslint und AirBnB-Richtlinien
|
- Einrichtung von Eslint und AirBnB-Richtlinien
|
||||||
- Debugging-Techniken – VSCode Debugger
|
|
||||||
|
|
||||||
**Übungen:**
|
**Übungen:**
|
||||||
Projektarbeit
|
Projektarbeit
|
||||||
@@ -700,6 +700,7 @@ Projektarbeit
|
|||||||
|
|
||||||
**Inhalt:**
|
**Inhalt:**
|
||||||
|
|
||||||
|
- Debugging-Techniken – VSCode Debugger
|
||||||
- Einführung in Vitest und Unit Testing
|
- Einführung in Vitest und Unit Testing
|
||||||
- Installieren von Vitest und Schreiben unseres ersten Tests
|
- Installieren von Vitest und Schreiben unseres ersten Tests
|
||||||
- Einführung in die React Testing Library
|
- Einführung in die React Testing Library
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,26 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
import Table from './components/Table';
|
import Table from './components/Table';
|
||||||
|
import { Product } from './lib/datatypes';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [salesData, setSalesData] = useState(null);
|
const [salesData, setSalesData] = useState(null);
|
||||||
|
|
||||||
const fetchSalesData = async () => {
|
const fetchSalesData = async () => {
|
||||||
const response = await fetch('./src/lib/db/sales.json');
|
try {
|
||||||
const data = await response.json();
|
const response = await fetch('./src/lib/db/sales.json');
|
||||||
setSalesData(data);
|
if (!response.ok) {
|
||||||
|
throw Error('HTTP-Request went wrong');
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
const filterData = data.filter((product: Product) => product !== null);
|
||||||
|
setSalesData(filterData);
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
console.error(error.message);
|
||||||
|
throw Error(error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -21,17 +33,13 @@ function App() {
|
|||||||
<div className="header-container">
|
<div className="header-container">
|
||||||
<div className="header-title-wrapper">
|
<div className="header-title-wrapper">
|
||||||
<h1 className="title">Product Sales</h1>
|
<h1 className="title">Product Sales</h1>
|
||||||
<p className="subtitle">
|
<p className="subtitle">A table of product sales data for the current month.</p>
|
||||||
A table of product sales data for the current month.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="table-wrapper">
|
<div className="table-wrapper">
|
||||||
<div className="table-container">
|
<div className="table-container">
|
||||||
<div className="table-box">
|
<div className="table-box">{salesData && <Table salesData={salesData} />}</div>
|
||||||
{salesData && <Table salesData={salesData} />}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import TableRow from './TableRow';
|
|||||||
import { Product } from '../lib/datatypes';
|
import { Product } from '../lib/datatypes';
|
||||||
|
|
||||||
const Table = ({ salesData }: { salesData: Product[] }) => {
|
const Table = ({ salesData }: { salesData: Product[] }) => {
|
||||||
|
console.log(salesData);
|
||||||
return (
|
return (
|
||||||
<table className="divide-y divide-gray-300">
|
<table className="divide-y divide-gray-300">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
(() => {
|
(() => {
|
||||||
const findings = [{"file":"dev/js/modules/Counter.js","line":22,"column":37,"rule":"no-use-before-define","message":"'onClickIncrement' was used before it was defined."},{"file":"dev/js/modules/ternaryLintExample.js","line":39,"column":12,"rule":"@stylistic/no-extra-parens","message":"Unnecessary parentheses around expression."}];
|
const findings = [{"file":"dev/js/modules/Counter.js","line":22,"column":37,"rule":"no-use-before-define","message":"'onClickIncrement' was used before it was defined."}];
|
||||||
if (findings.length === 0) {
|
if (findings.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export default [
|
|||||||
'no-extra-parens': 'off',
|
'no-extra-parens': 'off',
|
||||||
'no-nested-ternary': 'off',
|
'no-nested-ternary': 'off',
|
||||||
'no-use-before-define': 'off',
|
'no-use-before-define': 'off',
|
||||||
|
'no-plusplus': 'off',
|
||||||
// Erzwingt Klammern um die Ternary-Bedingung. Stylistic kann das nur erlauben.
|
// Erzwingt Klammern um die Ternary-Bedingung. Stylistic kann das nur erlauben.
|
||||||
'local/ternary-condition-parens': 'error',
|
'local/ternary-condition-parens': 'error',
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user