diff --git a/src/pages/People.tsx b/src/pages/People.tsx new file mode 100644 index 0000000..1afe403 --- /dev/null +++ b/src/pages/People.tsx @@ -0,0 +1,62 @@ +import { component$, useComputed$ } from '@builder.io/qwik'; +import { UserProfile } from '@models/user'; +import { getUserProfiles } from 'src/services/user'; + +export const People = component$(() => { + const usersSig = useComputed$(async () => { + return (await getUserProfiles()).sort((a, b) => a.name.localeCompare(b.name)); + }); + + const convertToGrouped = useComputed$(() => { + return usersSig.value.reduce( + (acc, user) => { + const { crew } = user; + if (!acc[crew]) { + acc[crew] = []; + } + acc[crew].push(user); + return acc; + }, + {} as Record + ); + }); + + return ( +
+
+

{'People'}

+
+
+ {Object.entries(convertToGrouped.value).map(([crew, members]) => ( +
+

Crew: {crew}

+
+ {members.map((user) => ( +
+

+ ID: {user.id} +

+

+ Name: {user.name} +

+

+ Email: {user.email} +

+
+ ))} +
+
+ ))} +
+ +
+

JSON

+
+
+						{JSON.stringify(convertToGrouped.value, null, 2)}
+					
+
+
+
+ ); +}); diff --git a/src/router.tsx b/src/router.tsx index a476174..a5815c5 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -2,6 +2,7 @@ import { Signal, useSignal, useTask$ } from '@builder.io/qwik'; import { AuthManager } from './pages/AuthManager'; import { ChartPreview } from './pages/ChartPreview'; import { Effort } from './pages/Effort'; +import { People } from './pages/People'; import { Profile } from './pages/Profile'; import { Registry } from './pages/Registry'; import { Report } from './pages/Report'; @@ -21,6 +22,7 @@ export const routes = { search: , registry: , chartpreview: , + people: , }; export const navigateTo = (route: Route, params?: Record): void => {