import { useEffect, useState } from 'react'; import { api } from './api'; import { hotelTime } from './time'; type Member={id:string;name:string;email:string;role:string;legacyRole:boolean;active:boolean;pending:boolean;mfaEnabled:boolean;version:number;linkPurpose:string;linkExpiresAt:string|null}; type Link={userId:string;link?:string;deliveryState:string;expiresAt:string}; export function TeamPage({owner,actorRole,timeZone}:{owner:boolean;actorRole:string;timeZone:string}) { const [members,setMembers]=useState([]),[name,setName]=useState(''),[email,setEmail]=useState(''),[role,setRole]=useState('Agent'),[error,setError]=useState(''),[busy,setBusy]=useState(false),[link,setLink]=useState(null),[copied,setCopied]=useState(false); async function refresh(){setMembers(await api('/team'));} useEffect(()=>{if(owner)refresh().catch(e=>setError(e.message));},[owner]); async function act(path:string,body:unknown,method='POST'){if(busy)return;setBusy(true);setError('');setLink(null);setCopied(false);try{const result=await api(path,method,body);if(result?.deliveryState)setLink(result);await refresh();}catch(e){setError(e instanceof Error?e.message:'Please try again.');}finally{setBusy(false);}} if(!owner)return

Team access

Your hotel owner manages staff accounts.

; return
A place for everyone

Your team

Give each colleague their own access to the hotel workspace.

{error&&
{error}
} {link&&

{link.link?'Share this preview link privately':'Account email queued'}

For {members.find(m=>m.id===link.userId)?.email||"the selected colleague"}

Delivery state: {link.deliveryState}. Expires {hotelTime(link.expiresAt,timeZone)}.

{link.link&&<>