Show unconfirmed USt-IdNr. in red, auto-select the field on blur

Makes the "konnte nicht bestätigt werden" message read as an actual
error instead of neutral status text, and re-focuses + selects the
whole VAT ID on an unconfirmed result — the customer almost certainly
needs to retype it, so the next keystroke should just replace it
outright.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Marco
2026-07-23 19:45:15 +00:00
parent 80b82e0117
commit 0c9050cc8a
+13 -2
View File
@@ -354,7 +354,8 @@ export function CheckoutContent({
// wherever vatExemptPreview/exemptTotalsPreview are computed below — a
// validated German VAT ID never zero-rates a domestic sale).
async function handleVatIdBlur(e: React.FocusEvent<HTMLInputElement>) {
const value = e.target.value;
const input = e.target;
const value = input.value;
const formatError = validateVatIdFormat(value);
setFieldError("vatId", formatError);
if (!value.trim() || formatError) {
@@ -374,6 +375,14 @@ export function CheckoutContent({
return;
}
setVatIdViesStatus(data.valid ? "valid" : "invalid");
// Re-focus + select the whole value on an unconfirmed VAT ID — the
// customer almost certainly needs to retype it (a typo, or the
// wrong id entirely), so the next keystroke should just replace it
// outright rather than requiring a manual select-all first.
if (!data.valid) {
input.focus();
input.select();
}
} catch {
setVatIdViesStatus("unavailable");
}
@@ -732,7 +741,9 @@ export function CheckoutContent({
{isExemptionEligibleCountry(buyerDestinationCountry) ? " — Lieferung wird steuerfrei berechnet." : "."}
</span>
)}
{vatIdViesStatus === "invalid" && "USt-IdNr. konnte nicht bestätigt werden."}
{vatIdViesStatus === "invalid" && (
<span className="text-red-600">USt-IdNr. konnte nicht bestätigt werden.</span>
)}
{vatIdViesStatus === "unavailable" && "USt-IdNr.-Prüfung derzeit nicht möglich."}
</p>
</div>