Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions apps/events/src/components/debug-invitations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Invitation } from 'graph-framework';
import { Button } from './ui/button';

export function DebugInvitations({ invitations }: { invitations: Invitation[] }) {
return (
<ul className="text-xs">
{invitations.map((invitation) => {
return (
<li key={invitation.spaceId} className="border border-gray-300">
<pre>{JSON.stringify(invitation, null, 2)}</pre>
<Button
onClick={() => {
alert('TODO');
}}
>
Accept
</Button>
</li>
);
})}
</ul>
);
}
9 changes: 7 additions & 2 deletions apps/events/src/routes/playground.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DebugInvitations } from '@/components/debug-invitations';
import { DebugSpaceEvents } from '@/components/debug-space-events';
import { DebugSpaceState } from '@/components/debug-space-state';
import { Button } from '@/components/ui/button';
Expand All @@ -7,6 +8,7 @@ import { Effect, Exit } from 'effect';
import * as Schema from 'effect/Schema';
import type {
EventMessage,
Invitation,
RequestListInvitations,
RequestListSpaces,
RequestSubscribeToSpace,
Expand Down Expand Up @@ -46,6 +48,7 @@ export const Route = createFileRoute('/playground')({
const App = ({ accountId, signaturePrivateKey }: { accountId: string; signaturePrivateKey: string }) => {
const [websocketConnection, setWebsocketConnection] = useState<WebSocket>();
const [spaces, setSpaces] = useState<SpaceStorageEntry[]>([]);
const [invitations, setInvitations] = useState<Invitation[]>([]);

useEffect(() => {
// temporary until we have a way to create accounts and authenticate them
Expand Down Expand Up @@ -109,7 +112,7 @@ const App = ({ accountId, signaturePrivateKey }: { accountId: string; signatureP
break;
}
case 'list-invitations': {
console.log('list-invitations', response);
setInvitations(response.invitations.map((invitation) => invitation));
break;
}
default:
Expand Down Expand Up @@ -182,7 +185,9 @@ const App = ({ accountId, signaturePrivateKey }: { accountId: string; signatureP
List Invitations
</Button>
</div>
<h2>Spaces</h2>
<h2 className="text-lg">Invitations</h2>
<DebugInvitations invitations={invitations} />
<h2 className="text-lg">Spaces</h2>
<ul>
{spaces.map((space) => {
return (
Expand Down
16 changes: 9 additions & 7 deletions packages/graph-framework-messages/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ export const ResponseListSpaces = Schema.Struct({

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

export const Invitation = Schema.Struct({
id: Schema.String,
previousEventHash: Schema.String,
spaceId: Schema.String,
});

export type Invitation = Schema.Schema.Type<typeof Invitation>;

export const ResponseListInvitations = Schema.Struct({
type: Schema.Literal('list-invitations'),
invitations: Schema.Array(
Schema.Struct({
id: Schema.String,
previousEventHash: Schema.String,
spaceId: Schema.String,
}),
),
invitations: Schema.Array(Invitation),
});

export type ResponseListInvitations = Schema.Schema.Type<typeof ResponseListInvitations>;
Expand Down
Loading