diff --git a/src/App.vue b/src/App.vue index 39a8292..8a01476 100644 --- a/src/App.vue +++ b/src/App.vue @@ -27,12 +27,36 @@ class="w-full max-w-sm mx-auto mb-3 overflow-hidden bg-slate-900/90 text-white rounded-lg shadow-md" >
+ {{ notification.title }}

{{ notification.text }}

+
+ +
+ +
+ {{ notification.title }} +

{{ notification.text }}

+ + +
+
+ +
= R.sort( @@ -206,8 +225,15 @@ export default class ContactsView extends Vue { ); this.giveRecords = sortedResult; } catch (error) { - this.alertTitle = "Error With Server"; - this.alertMessage = error as string; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: error as string, + }, + -1, + ); } } @@ -276,15 +302,29 @@ export default class ContactsView extends Vue { userMessage = error as string; } // Now set that error for the user to see. - this.alertTitle = "Error With Server"; - this.alertMessage = userMessage; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: userMessage, + }, + -1, + ); } } } cannotConfirmMessage() { - this.alertTitle = "Not Allowed"; - this.alertMessage = "Only the recipient can confirm final receipt."; + this.$notify( + { + group: "alert", + type: "danger", + title: "Not Allowed", + text: "Only the recipient can confirm final receipt.", + }, + -1, + ); } } diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index 11b7821..dc32988 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -145,10 +145,17 @@ export default class HomeView extends Vue { this.feedLastViewedId = settings?.lastViewedClaimId; this.updateAllFeed(); } catch (err) { - this.alertTitle = "Error"; - this.alertMessage = - err.userMessage || - "There was an error retrieving the latest sweet, sweet action."; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: + err.userMessage || + "There was an error retrieving the latest sweet, sweet action.", + }, + -1, + ); } } @@ -197,17 +204,27 @@ export default class HomeView extends Vue { */ public async recordGive(giverDid, description, hours) { if (!this.activeDid) { - this.setAlert( - "Error", - "You must select an identity before you can record a give.", + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: "You must select an identity before you can record a give.", + }, + -1, ); return; } if (!description && !hours) { - this.setAlert( - "Error", - "You must enter a description or some number of hours.", + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: "You must enter a description or some number of hours.", + }, + -1, ); return; } @@ -227,18 +244,38 @@ export default class HomeView extends Vue { if (isGiveCreationError(result)) { const errorMessage = getGiveCreationErrorMessage(result); console.log("Error with give result:", result); - this.setAlert( - "Error", - errorMessage || "There was an error recording the give.", + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: errorMessage || "There was an error recording the give.", + }, + -1, ); } else { - this.setAlert("Success", "That gift was recorded."); + this.$notify( + { + group: "alert", + type: "success", + title: "Success", + text: "That gift was recorded.", + }, + -1, + ); } } catch (error) { console.log("Error with give caught:", error); - this.setAlert( - "Error", - getGiveErrorMessage(error) || "There was an error recording the give.", + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: + getGiveErrorMessage(error) || + "There was an error recording the give.", + }, + -1, ); } } diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index acef71f..08a6b91 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -85,7 +85,15 @@ export default class ContactQRScanShow extends Vue { const accounts = await accountsDB.accounts.toArray(); const account = R.find((acc) => acc.did === this.activeDid, accounts); if (!account) { - this.alertMessage = "You have no identity yet."; + this.$notify( + { + group: "alert", + type: "warning", + title: "", + text: "You have no identity yet.", + }, + -1, + ); } else { const identity = await this.getIdentity(this.activeDid); const publicKeyHex = identity.keys[0].publicKeyHex; diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index e3f3c6c..a7919b5 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -317,12 +317,19 @@ export default class ContactsView extends Vue { resp.status, resp.data, ); - this.alertTitle = "Error With Server"; - this.alertMessage = - "Got an error retrieving your " + - resp.config.url.includes("recipientDid") - ? "received" - : "given" + " time from the server."; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: + "Got an error retrieving your " + + resp.config.url.includes("recipientDid") + ? "received" + : "given" + " time from the server.", + }, + -1, + ); } }; @@ -370,8 +377,15 @@ export default class ContactsView extends Vue { this.givenToMeConfirmed = givenToMeConfirmed; this.givenToMeUnconfirmed = givenToMeUnconfirmed; } catch (error) { - this.alertTitle = "Error With Server"; - this.alertMessage = error as string; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: error as string, + }, + -1, + ); } } @@ -464,18 +478,32 @@ export default class ContactsView extends Vue { try { const resp = await this.axios.post(url, payload, { headers }); if (resp.data?.success?.embeddedRecordError) { - this.alertTitle = "Registration Still Unknown"; let message = "There was some problem with the registration."; if (typeof resp.data.success.embeddedRecordError == "string") { message += " " + resp.data.success.embeddedRecordError; } - this.alertMessage = message; + this.$notify( + { + group: "alert", + type: "danger", + title: "Registration Still Unknown", + text: message, + }, + -1, + ); } else if (resp.data?.success?.handleId) { contact.registered = true; db.contacts.update(contact.did, { registered: true }); - this.alertTitle = "Registration Success"; - this.alertMessage = contact.name + " has been registered."; + this.$notify( + { + group: "alert", + type: "info", + title: "Registration Success", + text: contact.name + " has been registered.", + }, + -1, + ); } } catch (error) { let userMessage = "There was an error. See logs for more info."; @@ -490,8 +518,15 @@ export default class ContactsView extends Vue { userMessage = error as string; } // Now set that error for the user to see. - this.alertTitle = "Error With Server"; - this.alertMessage = userMessage; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: userMessage, + }, + -1, + ); } } } @@ -512,17 +547,39 @@ export default class ContactsView extends Vue { contact.seesMe = visibility; db.contacts.update(contact.did, { seesMe: visibility }); } else { - this.alertTitle = "Error With Server"; console.error("Bad response setting visibility: ", resp.data); if (resp.data.error?.message) { - this.alertMessage = resp.data.error?.message; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: resp.data.error?.message, + }, + -1, + ); } else { - this.alertMessage = "Bad server response of " + resp.status; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: "Bad server response of " + resp.status, + }, + -1, + ); } } } catch (err) { - this.alertTitle = "Error With Server"; - this.alertMessage = err as string; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: err as string, + }, + -1, + ); } } @@ -539,23 +596,52 @@ export default class ContactsView extends Vue { contact.seesMe = visibility; db.contacts.update(contact.did, { seesMe: visibility }); - this.alertTitle = "Refreshed"; - this.alertMessage = - this.nameForContact(contact, true) + - " can " + - (visibility ? "" : "not ") + - "see your activity."; + this.$notify( + { + group: "alert", + type: "toast", + title: "Refreshed", + text: + this.nameForContact(contact, true) + + " can " + + (visibility ? "" : "not ") + + "see your activity.", + }, + 5000, + ); } else { - this.alertTitle = "Error With Server"; if (resp.data.error?.message) { - this.alertMessage = resp.data.error?.message; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: resp.data.error?.message, + }, + -1, + ); } else { - this.alertMessage = "Bad server response of " + resp.status; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: "Bad server response of " + resp.status, + }, + -1, + ); } } } catch (err) { - this.alertTitle = "Error With Server"; - this.alertMessage = err as string; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: err as string, + }, + -1, + ); } } @@ -594,15 +680,35 @@ export default class ContactsView extends Vue { } } if (!this.isNumeric(this.hourInput)) { - this.alertTitle = "Input Error"; - this.alertMessage = - "This is not a valid number of hours: " + this.hourInput; + this.$notify( + { + group: "alert", + type: "danger", + title: "Input Error", + text: "This is not a valid number of hours: " + this.hourInput, + }, + -1, + ); } else if (!parseFloat(this.hourInput)) { - this.alertTitle = "Input Error"; - this.alertMessage = "Giving 0 hours does nothing."; + this.$notify( + { + group: "alert", + type: "danger", + title: "Input Error", + text: "Giving 0 hours does nothing.", + }, + -1, + ); } else if (!identity) { - this.alertTitle = "Status Error"; - this.alertMessage = "No identity is available."; + this.$notify( + { + group: "alert", + type: "danger", + title: "Status Error", + text: "No identity is available.", + }, + -1, + ); } else { // ask to confirm amount let toFrom; @@ -686,8 +792,15 @@ export default class ContactsView extends Vue { try { const resp = await this.axios.post(url, payload, { headers }); if (resp.data?.success?.handleId) { - this.alertTitle = "Done"; - this.alertMessage = "Successfully logged time to the server."; + this.$notify( + { + group: "alert", + type: "success", + title: "Done", + text: "Successfully logged time to the server.", + }, + -1, + ); if (fromDid === identity.did) { const newList = R.clone(this.givenByMeUnconfirmed); @@ -712,8 +825,15 @@ export default class ContactsView extends Vue { userMessage = error as string; } // Now set that error for the user to see. - this.alertTitle = "Error With Server"; - this.alertMessage = userMessage; + this.$notify( + { + group: "alert", + type: "danger", + title: "Error With Server", + text: userMessage, + }, + -1, + ); } } } diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 37d47d1..ddb6d66 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -37,11 +37,28 @@ -1, ) " - class="font-bold uppercase bg-emerald-600 text-white px-3 py-2 rounded-md mr-2" + class="font-bold uppercase bg-slate-600 text-white px-3 py-2 rounded-md mr-2" > Info + +