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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user