import { useCollection, useIdentity, share } from '@deplixo/sdk';
import SetupPanel from './components/SetupPanel.jsx';
import AuctionPanel from './components/AuctionPanel.jsx';
import ResultsPanel from './components/ResultsPanel.jsx';
function App() {
const { user, loading: idLoading } = useIdentity();
const participants = useCollection('participants');
const captains = useCollection('captains');
const bids = useCollection('bids');
const auction = useCollection('auction_state');
const [tab, setTab] = useState('auction');
const [shareMsg, setShareMsg] = useState('');
if (idLoading || participants.loading || captains.loading || bids.loading || auction.loading) {
return (
);
}
const handleShare = async () => {
try {
await share({
title: '친구 팀 편성 경매장',
text: '친구들과 함께 팀을 편성해봐요!',
url: window.location.href,
});
setShareMsg('공유 링크가 열렸어요!');
} catch (e) {
try {
await navigator.clipboard.writeText(window.location.href);
setShareMsg('링크가 복사되었어요!');
} catch {
setShareMsg('링크: ' + window.location.href);
}
}
setTimeout(() => setShareMsg(''), 3000);
};
const tabs = [
{ id: 'auction', label: '경매장' },
{ id: 'setup', label: '명단 설정' },
{ id: 'results', label: '팀 결과' },
];
return (
친구 팀 편성 경매장
{user ? <>안녕하세요, {user.name}님> : '친구들과 함께 팀을 짜보세요'}
{shareMsg && (
{shareMsg}
)}
{tab === 'auction' && (
)}
{tab === 'setup' && (
)}
{tab === 'results' && (
)}
);
}
ReactDOM.createRoot(document.getElementById('root')).render();