Update Terms of Use Modal and fix message flashing.

This commit is contained in:
Patrick Jentsch
2025-06-03 13:51:28 +02:00
parent c28d534942
commit 56844e0898
8 changed files with 53 additions and 28 deletions

View File

@ -5,6 +5,7 @@ nopaque.app.Client = class Client {
// Endpoints
this.corpora = new nopaque.app.endpoints.Corpora(this);
this.jobs = new nopaque.app.endpoints.Jobs(this);
this.main = new nopaque.app.endpoints.Main(this);
this.settings = new nopaque.app.endpoints.Settings(this);
this.users = new nopaque.app.endpoints.Users(this);

View File

@ -0,0 +1,22 @@
nopaque.app.endpoints.Main = class Main {
constructor(app) {
this.app = app;
}
async acceptTermsOfUse() {
const options = {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
method: 'POST',
};
const response = await fetch(`/accept-terms-of-use`, options);
const data = await response.json();
if (!response.ok) {throw new Error(`${data.name}: ${data.description}`);}
return data;
}
}

View File

@ -71,10 +71,7 @@ nopaque.app.extensions.UI = class UI {
M.Modal.init(
document.querySelector('#terms-of-use-modal'),
{
dismissible: false,
onCloseEnd: (modalElement) => {
nopaque.requests.users.entity.acceptTermsOfUse();
}
dismissible: false
}
);
// #endregion