diff --git a/frontend/src/pages/Index.tsx b/frontend/src/pages/Index.tsx index c9355f1..bbdcd49 100644 --- a/frontend/src/pages/Index.tsx +++ b/frontend/src/pages/Index.tsx @@ -1,11 +1,11 @@ import React, { useEffect, useState } from "react"; -import { State } from "../proto"; +import { Computer, State } from "../proto"; import { TokenContext } from "../tokenStorage"; export const Index: React.FC = () => { const tokenStorage = React.useContext(TokenContext); - + const [state, setState] = useState(); useEffect(() => { @@ -24,11 +24,52 @@ export const Index: React.FC = () => { }, [tokenStorage.token]); return <> -

Hallo i bims 1 index u d1 token bimst {tokenStorage.token}

- -

Der State ist:

- {JSON.stringify(state)} + +

State:

+ { + state + ? + :

loading

+ } } -export default Index; \ No newline at end of file +export default Index; + +const Groups: React.FC<{ computers: Array }> = ({ computers }) => { + const groupMap = new Map>(); + + for (const computer of computers) { + if (!groupMap.has(computer.group)) { + groupMap.set(computer.group, []); + } + groupMap.get(computer.group)!.push(computer); + } + + return <> + { + Array.from(groupMap.entries()).map((entry, index) => { + const [group, computers] = entry; + return
+

{group}:

+ +
+ }) + } + +} + + +const CardList: React.FC<{ computers: Array }> = ({ computers }) => { + return <> + {computers.map( + (computer, index) => + )} + +} + +const ComputerCard: React.FC<{ computer: Computer }> = ({ computer }) => { + return
+ {computer.label} +
+} \ No newline at end of file