refactor(frontend): ApiError interface, tempIdSuffix rename, NET_GRID constants, extract onPaletteDrop handlers

ApiError: defined once in utils/api.ts, replaces 9 ad-hoc anonymous casts
across MazeNET, Inspector, DeckyFleet, SwarmHosts, Webhooks, PersonaGeneration,
ServiceConfigFields, CanaryTokens.

hex4 renamed to tempIdSuffix — the name now matches the comment that already
explained its purpose.

NET_GRID_{W,H,GAP,COLS} extracted from inline magic numbers to module-level
constants in MazeNET.tsx.

onPaletteDrop (130-line useCallback) split into three module-level handlers
(_dropNetwork, _dropArchetype, _dropService); the callback becomes a 10-line
router.
This commit is contained in:
2026-04-30 22:14:20 -04:00
parent b754e9aa8b
commit 57fecb8071
9 changed files with 169 additions and 153 deletions

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useMemo, useState } from 'react';
import api from '../utils/api';
import api, { type ApiError } from '../utils/api';
import './ServiceConfigForm.css';
export interface ServiceConfigFieldDTO {
@@ -57,7 +57,7 @@ export function compactPayload(
}
export const fmtSchemaError = (err: unknown, fallback: string): string =>
(err as { response?: { data?: { detail?: string } } })?.response?.data?.detail
(err as ApiError)?.response?.data?.detail
?? fallback;
interface Props {