From db955f44b2617f1494d775824190fce8bc372ebe Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Wed, 23 Jun 2021 15:12:36 -0400 Subject: [PATCH] add grouplist, eventstream --- src/components/NewUI/App.tsx | 21 ++++++++++++++++----- src/components/NewUI/EventStream.tsx | 11 +++++++++++ src/components/NewUI/Group.tsx | 12 ++++++------ src/components/NewUI/GroupList.tsx | 20 ++++++++++++++++++++ 4 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 src/components/NewUI/EventStream.tsx create mode 100644 src/components/NewUI/GroupList.tsx diff --git a/src/components/NewUI/App.tsx b/src/components/NewUI/App.tsx index bebaf7e..821b2ab 100644 --- a/src/components/NewUI/App.tsx +++ b/src/components/NewUI/App.tsx @@ -1,9 +1,19 @@ -import EventCreator from './EventCreator'; -import Group from './Group'; +import { useEffect, useState } from 'react'; +import EventStream from './EventStream'; +import { IGroup } from './Group'; import GroupCreator from './GroupCreator'; +import GroupList from './GroupList'; import UIPrimaryTitle from './UIPrimaryTitle'; export default function App() { + const [groups, setGroups] = useState([]); + + useEffect(() => { + fetch('http://localhost:5000/api/groups') + .then((res) => res.json()) + .then(setGroups); + }, []); + return (
WheelShare - - Groups + +

Events

+
); diff --git a/src/components/NewUI/EventStream.tsx b/src/components/NewUI/EventStream.tsx new file mode 100644 index 0000000..3c180a8 --- /dev/null +++ b/src/components/NewUI/EventStream.tsx @@ -0,0 +1,11 @@ +import Event, { IEvent } from './Event'; + +export default function EventStream({ events }: { events: IEvent[] }) { + return ( +
+ {events.map((event) => ( + + ))} +
+ ); +} diff --git a/src/components/NewUI/Group.tsx b/src/components/NewUI/Group.tsx index a508b19..b04aedd 100644 --- a/src/components/NewUI/Group.tsx +++ b/src/components/NewUI/Group.tsx @@ -1,6 +1,9 @@ -import Event, { IEvent } from './Event'; +import { IEvent } from './Event'; +import EventCreator from './EventCreator'; +import EventStream from './EventStream'; export type IGroup = { + id: number; events: IEvent[]; name: string; }; @@ -8,12 +11,9 @@ export type IGroup = { export default function Group({ events, name }: IGroup) { return (
+

{name}

-
- {events.map((event) => ( - - ))} -
+
); // diff --git a/src/components/NewUI/GroupList.tsx b/src/components/NewUI/GroupList.tsx new file mode 100644 index 0000000..1dc49ca --- /dev/null +++ b/src/components/NewUI/GroupList.tsx @@ -0,0 +1,20 @@ +import { IGroup } from './Group'; +import UISecondaryBox from './UISecondaryBox'; + +function GroupListItem({ group }: { group: IGroup }) { + return ( + +

{group.name}

+
+ ); +} + +export default function GroupList({ groups }: { groups: IGroup[] }) { + return ( +
+ {groups.map((group) => ( + + ))} +
+ ); +}