fix(email-checker): success can have no suggestions

This commit is contained in:
Paul Chavard 2024-10-24 13:17:34 +02:00
parent 69e1b1be41
commit 406516a346
No known key found for this signature in database

View file

@ -4,7 +4,7 @@ import { ApplicationController } from './application_controller';
type CheckEmailResponse = type CheckEmailResponse =
| { | {
success: true; success: true;
suggestions: string[]; suggestions?: string[];
} }
| { success: false }; | { success: false };
@ -38,7 +38,7 @@ export class EmailInputController extends ApplicationController {
.catch(() => null); .catch(() => null);
if (data?.success) { if (data?.success) {
const suggestion = data.suggestions.at(0); const suggestion = data.suggestions?.at(0);
if (suggestion) { if (suggestion) {
this.suggestionTarget.innerHTML = suggestion; this.suggestionTarget.innerHTML = suggestion;
show(this.ariaRegionTarget); show(this.ariaRegionTarget);