summaryrefslogtreecommitdiff
path: root/assets/create.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-07-11 18:54:20 +0200
committerMinteck <contact@minteck.org>2022-07-11 18:54:20 +0200
commitf2824f51f8ed407a8633ba968d35d56ea6a36f49 (patch)
treedb0c625ccd8ae4ada52f4e30956a9627270dec31 /assets/create.js
parent5abe8cba55965f70e07e1163239bcc9d797c864a (diff)
downloadbits-client-f2824f51f8ed407a8633ba968d35d56ea6a36f49.tar.gz
bits-client-f2824f51f8ed407a8633ba968d35d56ea6a36f49.tar.bz2
bits-client-f2824f51f8ed407a8633ba968d35d56ea6a36f49.zip
Diffstat (limited to 'assets/create.js')
-rw-r--r--assets/create.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/assets/create.js b/assets/create.js
index cd787af..72d64be 100644
--- a/assets/create.js
+++ b/assets/create.js
@@ -25,4 +25,34 @@ async function createTransaction() {
document.getElementById('create-currency').value = '£';
document.getElementById('create-description').value = '';
document.getElementById('create-amount').value = '';
+}
+
+async function newCreate() {
+ if (!addAmount.valid || !addDescription.valid || document.querySelector(".mdc-add-dialog .mdc-text-field-add-amount > input").value.trim() === "" || document.querySelector(".mdc-add-dialog .mdc-text-field-add-description > input").value.length > 100) return;
+
+ document.getElementById("action-remove").disabled = true;
+ document.getElementById("action-add").disabled = true;
+ document.getElementById("currency-eur").disabled = true;
+ document.getElementById("currency-gbp").disabled = true;
+ document.querySelector(".mdc-add-dialog .mdc-text-field-add-amount > input").disabled = true;
+ document.querySelector(".mdc-add-dialog .mdc-text-field-add-description > input").disabled = true;
+ Array.from(document.querySelectorAll(".mdc-add-dialog .mdc-dialog__actions button")).map((e) => e.disabled = true);
+
+ await (await window.fetch("https://money-v1.equestria.dev/Application/AddTransaction/?Currency=" + (document.getElementById("currency-eur").checked ? "€" : "£") + "&Amount=" + document.querySelector(".mdc-add-dialog .mdc-text-field-add-amount > input").value + "&Operation=" + (document.getElementById("action-add").checked ? "+" : "-") + "&Description=" + btoa(document.querySelector(".mdc-add-dialog .mdc-text-field-add-description > input").value).replaceAll("+", "-").replaceAll("/", "_"))).text();
+
+ await refresh();
+
+ document.getElementById("action-remove").disabled = false;
+ document.getElementById("action-add").disabled = false;
+ document.getElementById("currency-eur").disabled = false;
+ document.getElementById("currency-gbp").disabled = false;
+ document.querySelector(".mdc-add-dialog .mdc-text-field-add-amount > input").disabled = false;
+ document.querySelector(".mdc-add-dialog .mdc-text-field-add-description > input").disabled = false;
+ Array.from(document.querySelectorAll(".mdc-add-dialog .mdc-dialog__actions button")).map((e) => e.disabled = false);
+ addDialog.close();
+
+ document.getElementById("action-add").checked = true;
+ document.getElementById("currency-gbp").checked = true;
+ document.querySelector(".mdc-add-dialog .mdc-text-field-add-amount > input").value = "";
+ document.querySelector(".mdc-add-dialog .mdc-text-field-add-description > input").value = "";
} \ No newline at end of file