|
@@ -2,7 +2,6 @@ import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
|
import { useOutletContext } from 'react-router-dom';
|
|
import { useOutletContext } from 'react-router-dom';
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
-import { DiagnosticModal } from '../../components/spoolbuddy/DiagnosticModal';
|
|
|
|
|
import type { SpoolBuddyOutletContext } from '../../components/spoolbuddy/SpoolBuddyLayout';
|
|
import type { SpoolBuddyOutletContext } from '../../components/spoolbuddy/SpoolBuddyLayout';
|
|
|
import {
|
|
import {
|
|
|
api,
|
|
api,
|
|
@@ -45,7 +44,7 @@ export function SpoolBuddyWriteTagPage() {
|
|
|
const [untagging, setUntagging] = useState(false);
|
|
const [untagging, setUntagging] = useState(false);
|
|
|
const [tagOnReader, setTagOnReader] = useState(false);
|
|
const [tagOnReader, setTagOnReader] = useState(false);
|
|
|
const [tagUid, setTagUid] = useState<string | null>(null);
|
|
const [tagUid, setTagUid] = useState<string | null>(null);
|
|
|
- const [diagnosticOpen, setDiagnosticOpen] = useState<'scale' | 'nfc' | null>(null);
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
const { data: spools = [], refetch: refetchSpools } = useQuery({
|
|
const { data: spools = [], refetch: refetchSpools } = useQuery({
|
|
|
queryKey: ['inventory-spools'],
|
|
queryKey: ['inventory-spools'],
|
|
@@ -216,24 +215,8 @@ export function SpoolBuddyWriteTagPage() {
|
|
|
|
|
|
|
|
const canWrite = selectedSpool && deviceOnline && writeStatus !== 'writing' && writeStatus !== 'success';
|
|
const canWrite = selectedSpool && deviceOnline && writeStatus !== 'writing' && writeStatus !== 'success';
|
|
|
|
|
|
|
|
- const handleOpenNfcDiagnostics = useCallback(() => {
|
|
|
|
|
- setDiagnosticOpen('nfc');
|
|
|
|
|
- }, []);
|
|
|
|
|
-
|
|
|
|
|
- const handleOpenScaleDiagnostics = useCallback(() => {
|
|
|
|
|
- setDiagnosticOpen('scale');
|
|
|
|
|
- }, []);
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className="flex flex-col h-full">
|
|
<div className="flex flex-col h-full">
|
|
|
- {diagnosticOpen && (
|
|
|
|
|
- <DiagnosticModal
|
|
|
|
|
- type={diagnosticOpen}
|
|
|
|
|
- onClose={() => setDiagnosticOpen(null)}
|
|
|
|
|
- deviceId={device?.device_id || ''}
|
|
|
|
|
- />
|
|
|
|
|
- )}
|
|
|
|
|
-
|
|
|
|
|
{/* Tab bar */}
|
|
{/* Tab bar */}
|
|
|
<div className="flex border-b border-bambu-dark-tertiary shrink-0">
|
|
<div className="flex border-b border-bambu-dark-tertiary shrink-0">
|
|
|
{([
|
|
{([
|
|
@@ -324,8 +307,6 @@ export function SpoolBuddyWriteTagPage() {
|
|
|
onUntag={handleUntagSpool}
|
|
onUntag={handleUntagSpool}
|
|
|
onCancel={handleCancelWrite}
|
|
onCancel={handleCancelWrite}
|
|
|
onRetry={() => { setWriteStatus('idle'); setWriteMessage(''); }}
|
|
onRetry={() => { setWriteStatus('idle'); setWriteMessage(''); }}
|
|
|
- onOpenNfcDiagnostics={handleOpenNfcDiagnostics}
|
|
|
|
|
- onOpenScaleDiagnostics={handleOpenScaleDiagnostics}
|
|
|
|
|
t={t}
|
|
t={t}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
@@ -918,7 +899,7 @@ function NewSpoolTouchForm({ currencySymbol, onCreated, selectedSpool, t }: {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// --- NFC status panel ---
|
|
// --- NFC status panel ---
|
|
|
-function NfcStatusPanel({ writeStatus, writeMessage, selectedSpool, tagOnReader, tagUid, deviceOnline, canWrite, isReplace, canUntag, untagging, onWrite, onUntag, onCancel, onRetry, onOpenNfcDiagnostics, onOpenScaleDiagnostics, t }: {
|
|
|
|
|
|
|
+function NfcStatusPanel({ writeStatus, writeMessage, selectedSpool, tagOnReader, tagUid, deviceOnline, canWrite, isReplace, canUntag, untagging, onWrite, onUntag, onCancel, onRetry, t }: {
|
|
|
writeStatus: WriteStatus;
|
|
writeStatus: WriteStatus;
|
|
|
writeMessage: string;
|
|
writeMessage: string;
|
|
|
selectedSpool: InventorySpool | null;
|
|
selectedSpool: InventorySpool | null;
|
|
@@ -933,8 +914,6 @@ function NfcStatusPanel({ writeStatus, writeMessage, selectedSpool, tagOnReader,
|
|
|
onUntag: () => void;
|
|
onUntag: () => void;
|
|
|
onCancel: () => void;
|
|
onCancel: () => void;
|
|
|
onRetry: () => void;
|
|
onRetry: () => void;
|
|
|
- onOpenNfcDiagnostics: () => void;
|
|
|
|
|
- onOpenScaleDiagnostics: () => void;
|
|
|
|
|
t: (key: string, fallback: string) => string;
|
|
t: (key: string, fallback: string) => string;
|
|
|
}) {
|
|
}) {
|
|
|
// Success state
|
|
// Success state
|
|
@@ -1097,21 +1076,6 @@ function NfcStatusPanel({ writeStatus, writeMessage, selectedSpool, tagOnReader,
|
|
|
</button>
|
|
</button>
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
- {/* Diagnostic buttons */}
|
|
|
|
|
- <div className="w-full flex gap-2 pt-2">
|
|
|
|
|
- <button
|
|
|
|
|
- onClick={onOpenNfcDiagnostics}
|
|
|
|
|
- className="flex-1 py-2 px-2 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary text-zinc-300 text-xs rounded transition-colors"
|
|
|
|
|
- >
|
|
|
|
|
- {t('spoolbuddy.writeTag.nfcDiagnostics', 'NFC Diag')}
|
|
|
|
|
- </button>
|
|
|
|
|
- <button
|
|
|
|
|
- onClick={onOpenScaleDiagnostics}
|
|
|
|
|
- className="flex-1 py-2 px-2 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary text-zinc-300 text-xs rounded transition-colors"
|
|
|
|
|
- >
|
|
|
|
|
- {t('spoolbuddy.writeTag.scaleDiagnostics', 'Scale Diag')}
|
|
|
|
|
- </button>
|
|
|
|
|
- </div>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|