feat(frontend): team + engineer dropdowns on join screen
Replace free-text name/pod inputs with select-only dropdowns (pick a team, then yourself from its members) for fast R&D iteration. Demo teams live in lib/teams.ts until pods are persisted. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+49
-21
@@ -1,20 +1,28 @@
|
|||||||
import { useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import type { Room } from 'livekit-client';
|
import type { Room } from 'livekit-client';
|
||||||
import { joinPod } from './lib/pod.js';
|
import { joinPod } from './lib/pod.js';
|
||||||
|
import { TEAMS } from './lib/teams.js';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [podId, setPodId] = useState('demo-pod');
|
const [teamId, setTeamId] = useState(TEAMS[0]!.id);
|
||||||
const [name, setName] = useState('');
|
const team = useMemo(() => TEAMS.find((t) => t.id === teamId) ?? TEAMS[0]!, [teamId]);
|
||||||
|
const [member, setMember] = useState(team.members[0]!);
|
||||||
const [room, setRoom] = useState<Room | null>(null);
|
const [room, setRoom] = useState<Room | null>(null);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [connecting, setConnecting] = useState(false);
|
const [connecting, setConnecting] = useState(false);
|
||||||
|
|
||||||
|
function handleTeamChange(id: string) {
|
||||||
|
setTeamId(id);
|
||||||
|
const next = TEAMS.find((t) => t.id === id);
|
||||||
|
if (next) setMember(next.members[0]!);
|
||||||
|
}
|
||||||
|
|
||||||
async function handleJoin() {
|
async function handleJoin() {
|
||||||
setError(null);
|
setError(null);
|
||||||
setConnecting(true);
|
setConnecting(true);
|
||||||
try {
|
try {
|
||||||
const identity = `${name || 'engineer'}-${Math.random().toString(36).slice(2, 7)}`;
|
const identity = `${member}-${Math.random().toString(36).slice(2, 7)}`;
|
||||||
setRoom(await joinPod(podId, identity, name || identity));
|
setRoom(await joinPod(team.id, identity, member));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError((err as Error).message);
|
setError((err as Error).message);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -33,29 +41,49 @@ export default function App() {
|
|||||||
|
|
||||||
{room ? (
|
{room ? (
|
||||||
<section className="rounded-lg border border-slate-700 bg-slate-900/50 p-4">
|
<section className="rounded-lg border border-slate-700 bg-slate-900/50 p-4">
|
||||||
<p className="font-medium text-emerald-400">Connected to “{podId}”.</p>
|
<p className="font-medium text-emerald-400">
|
||||||
|
{member} connected to “{team.name}”.
|
||||||
|
</p>
|
||||||
<p className="mt-1 text-sm text-slate-400">Sharing screen + mic. PodMan is watching.</p>
|
<p className="mt-1 text-sm text-slate-400">Sharing screen + mic. PodMan is watching.</p>
|
||||||
</section>
|
</section>
|
||||||
) : (
|
) : (
|
||||||
<section className="flex flex-col gap-3">
|
<section className="flex flex-col gap-4">
|
||||||
<input
|
<label className="flex flex-col gap-1 text-sm text-slate-400">
|
||||||
className="rounded-md border border-slate-700 bg-slate-900 px-3 py-2"
|
Team
|
||||||
placeholder="Your name"
|
<select
|
||||||
value={name}
|
className="rounded-md border border-slate-700 bg-slate-900 px-3 py-2 text-base text-slate-100"
|
||||||
onChange={(e) => setName(e.target.value)}
|
value={teamId}
|
||||||
/>
|
onChange={(e) => handleTeamChange(e.target.value)}
|
||||||
<input
|
>
|
||||||
className="rounded-md border border-slate-700 bg-slate-900 px-3 py-2"
|
{TEAMS.map((t) => (
|
||||||
placeholder="Pod id"
|
<option key={t.id} value={t.id}>
|
||||||
value={podId}
|
{t.name} · {t.repo}
|
||||||
onChange={(e) => setPodId(e.target.value)}
|
</option>
|
||||||
/>
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label className="flex flex-col gap-1 text-sm text-slate-400">
|
||||||
|
You
|
||||||
|
<select
|
||||||
|
className="rounded-md border border-slate-700 bg-slate-900 px-3 py-2 text-base text-slate-100"
|
||||||
|
value={member}
|
||||||
|
onChange={(e) => setMember(e.target.value)}
|
||||||
|
>
|
||||||
|
{team.members.map((m) => (
|
||||||
|
<option key={m} value={m}>
|
||||||
|
{m}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
className="rounded-md bg-emerald-600 px-3 py-2 font-medium hover:bg-emerald-500 disabled:opacity-50"
|
className="rounded-md bg-emerald-600 px-3 py-2 font-medium hover:bg-emerald-500 disabled:opacity-50"
|
||||||
onClick={handleJoin}
|
onClick={handleJoin}
|
||||||
disabled={connecting || !podId}
|
disabled={connecting}
|
||||||
>
|
>
|
||||||
{connecting ? 'Joining…' : 'Join pod'}
|
{connecting ? 'Joining…' : `Join ${team.name} as ${member}`}
|
||||||
</button>
|
</button>
|
||||||
{error && <p className="text-sm text-red-400">{error}</p>}
|
{error && <p className="text-sm text-red-400">{error}</p>}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Hardcoded teams/engineers for R&D so the join screen is select-only (no typing)
|
||||||
|
* while we develop. Swap for real data (backend/Atlas) once pods are persisted.
|
||||||
|
*/
|
||||||
|
export interface DemoTeam {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
repo: string;
|
||||||
|
members: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TEAMS: DemoTeam[] = [
|
||||||
|
{
|
||||||
|
id: 'demo-pod',
|
||||||
|
name: 'Demo Pod',
|
||||||
|
repo: 'karti-ai/podman',
|
||||||
|
members: ['Karti', 'Yahya', 'Ramis', 'Zander', 'Shakthi'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'frontend-squad',
|
||||||
|
name: 'Frontend Squad',
|
||||||
|
repo: 'karti-ai/podman',
|
||||||
|
members: ['Karti', 'Zander'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'backend-squad',
|
||||||
|
name: 'Backend Squad',
|
||||||
|
repo: 'karti-ai/podman',
|
||||||
|
members: ['Yahya', 'Ramis'],
|
||||||
|
},
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user