summaryrefslogtreecommitdiff
path: root/website/src/scripts/contact/post-error-message.ts
blob: 9846635ae412e7f27c4d7bbe2791138650715dbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import type { Selectors } from "./selectors";

export function postErrorMessageOnContactForm(
  { contactForm }: Selectors,
  errorMsg: string,
) {
  const errorElem = contactForm.errorElem();
  if (errorElem) {
    errorElem.textContent = errorMsg;
    errorElem.removeAttribute("hidden");
  } else {
    alert(errorMsg);
  }
}

export function postErrorMessageOnOtpForm(
  { otpDialog }: Selectors,
  errorMsg: string,
) {
  const errorElem = otpDialog.errorElem();
  if (errorElem) {
    errorElem.textContent = errorMsg;
    errorElem.removeAttribute("hidden");
  } else {
    alert(errorMsg);
  }
  for (const input of otpDialog.allOtpInputs()) {
    (input as HTMLInputElement).value = "";
  }
}