SIM-Karten: PIN/PUK-Fehler statt stummer Alert-Meldung
Der bisherige alert() maskierte die eigentliche Ursache (Vertrag nicht gefunden / Kein Zugriff / Decrypt-Fehler). Ersetzt durch Toast mit Backend-Message + console.error mit Stacktrace, plus Info-Toast wenn die SIM in der DB gar keine PIN/PUK hinterlegt hat. Endpoint (GET /contracts/simcard/:id/credentials) und Auditing unverändert. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import Input from '../../components/ui/Input';
|
|||||||
import Modal from '../../components/ui/Modal';
|
import Modal from '../../components/ui/Modal';
|
||||||
import FileUpload from '../../components/ui/FileUpload';
|
import FileUpload from '../../components/ui/FileUpload';
|
||||||
import { Edit, Trash2, Copy, Eye, EyeOff, ArrowLeft, ArrowRight, Download, ExternalLink, Plus, ChevronDown, ChevronUp, Gauge, CheckCircle, Circle, ClipboardList, MessageSquare, Calculator, Info, X, BellOff, Lock, Shield, FileText, Images } from 'lucide-react';
|
import { Edit, Trash2, Copy, Eye, EyeOff, ArrowLeft, ArrowRight, Download, ExternalLink, Plus, ChevronDown, ChevronUp, Gauge, CheckCircle, Circle, ClipboardList, MessageSquare, Calculator, Info, X, BellOff, Lock, Shield, FileText, Images } from 'lucide-react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
import JpgToPdfModal from '../../components/ui/JpgToPdfModal';
|
import JpgToPdfModal from '../../components/ui/JpgToPdfModal';
|
||||||
import { calculateConsumption, calculateCosts, calculateMultiMeterConsumption } from '../../utils/energyCalculations';
|
import { calculateConsumption, calculateCosts, calculateMultiMeterConsumption } from '../../utils/energyCalculations';
|
||||||
import CopyButton, { CopyableBlock } from '../../components/ui/CopyButton';
|
import CopyButton, { CopyableBlock } from '../../components/ui/CopyButton';
|
||||||
@@ -122,20 +123,28 @@ function SimCardDisplay({ simCard }: { simCard: SimCard }) {
|
|||||||
if (showCredentials) {
|
if (showCredentials) {
|
||||||
setShowCredentials(false);
|
setShowCredentials(false);
|
||||||
setCredentials(null);
|
setCredentials(null);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await contractApi.getSimCardCredentials(simCard.id);
|
const res = await contractApi.getSimCardCredentials(simCard.id);
|
||||||
if (res.data) {
|
if (!res?.data) {
|
||||||
|
toast.error('Backend lieferte keine PIN/PUK-Daten zurück');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!res.data.pin && !res.data.puk) {
|
||||||
|
toast('Für diese SIM sind keine PIN/PUK hinterlegt', { icon: 'ℹ️' });
|
||||||
|
}
|
||||||
setCredentials(res.data);
|
setCredentials(res.data);
|
||||||
setShowCredentials(true);
|
setShowCredentials(true);
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('PIN/PUK konnte nicht geladen werden');
|
const msg = err instanceof Error ? err.message : 'Unbekannter Fehler';
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error('[SimCardDisplay] getSimCardCredentials failed:', err);
|
||||||
|
toast.error(`PIN/PUK konnte nicht geladen werden: ${msg}`);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user