fix: display platform registration errors inside the creation modal

This commit is contained in:
2026-09-29 13:25:52 +09:00
parent 662b64afb1
commit 53c6ada470
+9 -1
View File
@@ -68,6 +68,7 @@ export function PlatformsPage({ session }: { session: AuthSession }) {
const [selectedMasterId, setSelectedMasterId] = useState(''); const [selectedMasterId, setSelectedMasterId] = useState('');
const [selectedAgentId, setSelectedAgentId] = useState(''); const [selectedAgentId, setSelectedAgentId] = useState('');
const [platformName, setPlatformName] = useState(''); const [platformName, setPlatformName] = useState('');
const [createError, setCreateError] = useState<string | null>(null);
const [agentsLoading, setAgentsLoading] = useState(false); const [agentsLoading, setAgentsLoading] = useState(false);
const [agentsError, setAgentsError] = useState<string | null>(null); const [agentsError, setAgentsError] = useState<string | null>(null);
const [registrationCode, setRegistrationCode] = useState<string | null>(null); const [registrationCode, setRegistrationCode] = useState<string | null>(null);
@@ -203,6 +204,7 @@ export function PlatformsPage({ session }: { session: AuthSession }) {
}; };
const handleOpenCreateModal = () => { const handleOpenCreateModal = () => {
setCreateError(null);
setModalOpen(true); setModalOpen(true);
setSelectedAgentId(''); setSelectedAgentId('');
setAgents([]); setAgents([]);
@@ -222,6 +224,7 @@ export function PlatformsPage({ session }: { session: AuthSession }) {
}; };
const handleCreatePlatform = async () => { const handleCreatePlatform = async () => {
setCreateError(null);
if (!selectedMasterId) return; if (!selectedMasterId) return;
if (!selectedAgentId) { if (!selectedAgentId) {
setAgentsError('플랫폼에 연결할 에이전트를 선택해 주세요.'); setAgentsError('플랫폼에 연결할 에이전트를 선택해 주세요.');
@@ -244,7 +247,7 @@ export function PlatformsPage({ session }: { session: AuthSession }) {
message: created?.name ?? masterPlatforms.find((platform) => platform.id === selectedMasterId)?.name, message: created?.name ?? masterPlatforms.find((platform) => platform.id === selectedMasterId)?.name,
}); });
} catch (reason) { } catch (reason) {
setError(reason instanceof Error ? reason.message : '플랫폼을 등록하지 못했습니다.'); setCreateError(reason instanceof Error ? reason.message : '플랫폼을 등록하지 못했습니다.');
} finally { } finally {
setSaving(false); setSaving(false);
} }
@@ -674,6 +677,11 @@ export function PlatformsPage({ session }: { session: AuthSession }) {
placeholder="예: F1Tenth #01" placeholder="예: F1Tenth #01"
/> />
</label> </label>
{createError ? (
<p role="alert" className="mt-3 rounded-md border border-[#fecdd3] bg-[#fff1f2] px-3 py-2 text-[12px] font-bold text-[#be123c]">
{createError}
</p>
) : null}
</div> </div>
<div className="flex justify-end gap-2 border-t border-[#cbd5e1] px-5 py-4"> <div className="flex justify-end gap-2 border-t border-[#cbd5e1] px-5 py-4">