diff options
| author | Bobby <[email protected]> | 2022-05-03 16:20:01 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-05-03 16:20:01 -0400 |
| commit | f807467dca2f08060b0bd4aa6b30ed231bb383b7 (patch) | |
| tree | fb511ea1d13aa022ae431163415284e55e27c1b5 /interface/public | |
| parent | 40eac9bcc99f0dc0139a9356464df66e9cf5c7dc (diff) | |
| parent | cce1d920245f7ee128bde6d2e978138cbbdc6e46 (diff) | |
| download | Welfare-Schemes-DMQL-f807467dca2f08060b0bd4aa6b30ed231bb383b7.tar.xz Welfare-Schemes-DMQL-f807467dca2f08060b0bd4aa6b30ed231bb383b7.zip | |
Merge pull request #5 from luciferreeves/main
Working Models
Diffstat (limited to 'interface/public')
| -rw-r--r-- | interface/public/citizens.js | 43 | ||||
| -rw-r--r-- | interface/public/verify.js | 5 |
2 files changed, 47 insertions, 1 deletions
diff --git a/interface/public/citizens.js b/interface/public/citizens.js new file mode 100644 index 0000000..ef112d1 --- /dev/null +++ b/interface/public/citizens.js @@ -0,0 +1,43 @@ +$(".ui.form").form({ + fields: { + address: "empty", + mobile_number: "empty", + dob: "empty", + marital_status: "empty", + }, +}); + +function editCitizensRecord(citizen) { + citizen = JSON.parse(citizen); + $(".edit.modal").modal("show"); + $("#address").val(citizen.address); + $("#mobile_number").val(citizen.mobile_num); + $("#dob").val(citizen.dob); + $("#marital_status").val(citizen.marital_status); + $('#marital_status').dropdown('set selected', citizen.marital_status); + $("#citizen_id").html(citizen.citizen_id); +} + +const editCitizenButton = document.getElementById("editCitizen"); +editCitizenButton.addEventListener("click", editCitizen); + +function editCitizen(event) { + event.preventDefault(); + var data = { + address: $("#address").val(), + mobile_num: $("#mobile_number").val(), + dob: $("#dob").val(), + marital_status: $("#marital_status").val(), + citizen_id: $("#citizen_id").html(), + }; + $.ajax({ + url: "/api/citizens/edit", + type: "POST", + data: data, + success: function (response) { + console.log(response); + $(".edit.modal").modal("hide"); + location.reload(); + }, + }); +} diff --git a/interface/public/verify.js b/interface/public/verify.js index 94025f8..2351bad 100644 --- a/interface/public/verify.js +++ b/interface/public/verify.js @@ -10,7 +10,10 @@ if (token) { $('#loginButton').hide(); $('#logoutButton').show(); } else { - window.location.href = "/"; + localStorage.removeItem("token"); + if (window.location.pathname !== "/") { + window.location.href = "/"; + } $('#loginButton').show(); $('#logoutButton').hide(); } |
