Skip to content

Commit 3bfe010

Browse files
authored
Merge pull request #40 from geobrowser/list-invitations
list invitations
2 parents 61bcf41 + f056db2 commit 3bfe010

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { Invitation } from 'graph-framework';
2+
import { Button } from './ui/button';
3+
4+
export function DebugInvitations({ invitations }: { invitations: Invitation[] }) {
5+
return (
6+
<ul className="text-xs">
7+
{invitations.map((invitation) => {
8+
return (
9+
<li key={invitation.spaceId} className="border border-gray-300">
10+
<pre>{JSON.stringify(invitation, null, 2)}</pre>
11+
<Button
12+
onClick={() => {
13+
alert('TODO');
14+
}}
15+
>
16+
Accept
17+
</Button>
18+
</li>
19+
);
20+
})}
21+
</ul>
22+
);
23+
}

apps/events/src/routes/playground.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DebugInvitations } from '@/components/debug-invitations';
12
import { DebugSpaceEvents } from '@/components/debug-space-events';
23
import { DebugSpaceState } from '@/components/debug-space-state';
34
import { Button } from '@/components/ui/button';
@@ -7,6 +8,7 @@ import { Effect, Exit } from 'effect';
78
import * as Schema from 'effect/Schema';
89
import type {
910
EventMessage,
11+
Invitation,
1012
RequestListInvitations,
1113
RequestListSpaces,
1214
RequestSubscribeToSpace,
@@ -46,6 +48,7 @@ export const Route = createFileRoute('/playground')({
4648
const App = ({ accountId, signaturePrivateKey }: { accountId: string; signaturePrivateKey: string }) => {
4749
const [websocketConnection, setWebsocketConnection] = useState<WebSocket>();
4850
const [spaces, setSpaces] = useState<SpaceStorageEntry[]>([]);
51+
const [invitations, setInvitations] = useState<Invitation[]>([]);
4952

5053
useEffect(() => {
5154
// temporary until we have a way to create accounts and authenticate them
@@ -109,7 +112,7 @@ const App = ({ accountId, signaturePrivateKey }: { accountId: string; signatureP
109112
break;
110113
}
111114
case 'list-invitations': {
112-
console.log('list-invitations', response);
115+
setInvitations(response.invitations.map((invitation) => invitation));
113116
break;
114117
}
115118
default:
@@ -182,7 +185,9 @@ const App = ({ accountId, signaturePrivateKey }: { accountId: string; signatureP
182185
List Invitations
183186
</Button>
184187
</div>
185-
<h2>Spaces</h2>
188+
<h2 className="text-lg">Invitations</h2>
189+
<DebugInvitations invitations={invitations} />
190+
<h2 className="text-lg">Spaces</h2>
186191
<ul>
187192
{spaces.map((space) => {
188193
return (

packages/graph-framework-messages/src/types.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ export const ResponseListSpaces = Schema.Struct({
4848

4949
export type ResponseListSpaces = Schema.Schema.Type<typeof ResponseListSpaces>;
5050

51+
export const Invitation = Schema.Struct({
52+
id: Schema.String,
53+
previousEventHash: Schema.String,
54+
spaceId: Schema.String,
55+
});
56+
57+
export type Invitation = Schema.Schema.Type<typeof Invitation>;
58+
5159
export const ResponseListInvitations = Schema.Struct({
5260
type: Schema.Literal('list-invitations'),
53-
invitations: Schema.Array(
54-
Schema.Struct({
55-
id: Schema.String,
56-
previousEventHash: Schema.String,
57-
spaceId: Schema.String,
58-
}),
59-
),
61+
invitations: Schema.Array(Invitation),
6062
});
6163

6264
export type ResponseListInvitations = Schema.Schema.Type<typeof ResponseListInvitations>;

0 commit comments

Comments
 (0)