summaryrefslogtreecommitdiff
path: root/http/public/scripts/contact/actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'http/public/scripts/contact/actions.js')
-rw-r--r--http/public/scripts/contact/actions.js60
1 files changed, 0 insertions, 60 deletions
diff --git a/http/public/scripts/contact/actions.js b/http/public/scripts/contact/actions.js
deleted file mode 100644
index 5a7e32a..0000000
--- a/http/public/scripts/contact/actions.js
+++ /dev/null
@@ -1,60 +0,0 @@
-export const actions = {
- /**
- * @param {{type: 'email', name: string, email: string}}
- * @returns {Promise<void>}
- */
- sendOtp: async ({ type, name, email }) => {
- const url = "/do/send_otp.php";
- const req = new Request(url, {
- method: "POST",
- body: JSON.stringify({ type, name, email }),
- });
- const res = await fetch(req);
- if (!res.ok) {
- throw new Error(
- `Request to ${url} failed: ${res.status} ${res.statusText} ${await res.text()}`,
- );
- }
- },
-
- /**
- * @param {{guess: string, lenient?: bool, userId: string}}
- * @returns {Promise<string | false>}
- */
- verifyOtp: async ({ guess, lenient, userId }) => {
- const url = "/do/verify_otp.php";
- const req = new Request(url, {
- method: "POST",
- body: JSON.stringify({ guess, lenient, userId }),
- });
- const res = await fetch(req);
-
- if (res.status === 400) {
- return false;
- } else if (!res.ok) {
- throw new Error(
- `Request to ${url} failed: ${res.status} ${res.statusText} ${await res.text()}`,
- );
- }
-
- return res.text();
- },
-
- /**
- * @param {{email: string, message: string, name: string, userId: string, token: string}}
- * @returns {Promise<void>}
- */
- sendEmail: async ({ email, message, name, userId, token }) => {
- const url = "/do/send_email.php";
- const req = new Request(url, {
- method: "POST",
- body: JSON.stringify({ email, message, name, userId, token }),
- });
- const res = await fetch(req);
- if (!res.ok) {
- throw new Error(
- `Request to ${url} failed: ${res.status} ${res.statusText} ${await res.text()}`,
- );
- }
- },
-};