|
@ -205,10 +205,17 @@ import GiftedDialog from "@/components/GiftedDialog.vue"; |
|
|
import { db, accountsDB } from "@/db"; |
|
|
import { db, accountsDB } from "@/db"; |
|
|
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; |
|
|
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; |
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
import { createAndSubmitGive, didInfo } from "@/libs/endorserServer"; |
|
|
import { |
|
|
|
|
|
createAndSubmitGive, |
|
|
|
|
|
didInfo, |
|
|
|
|
|
GiverInputInfo, |
|
|
|
|
|
GiverOutputInfo, |
|
|
|
|
|
} from "@/libs/endorserServer"; |
|
|
import { Contact } from "@/db/tables/contacts"; |
|
|
import { Contact } from "@/db/tables/contacts"; |
|
|
import QuickNav from "@/components/QuickNav"; |
|
|
import QuickNav from "@/components/QuickNav"; |
|
|
import EntityIcon from "@/components/EntityIcon"; |
|
|
import EntityIcon from "@/components/EntityIcon"; |
|
|
|
|
|
import { IIdentifier } from "@veramo/core"; |
|
|
|
|
|
import { RawAxiosRequestHeaders } from "axios"; |
|
|
|
|
|
|
|
|
interface Notification { |
|
|
interface Notification { |
|
|
group: string; |
|
|
group: string; |
|
@ -230,7 +237,7 @@ export default class HomeView extends Vue { |
|
|
feedAllLoaded = false; |
|
|
feedAllLoaded = false; |
|
|
feedData = []; |
|
|
feedData = []; |
|
|
feedPreviousOldestId = null; |
|
|
feedPreviousOldestId = null; |
|
|
feedLastViewedId = null; |
|
|
feedLastViewedId?: string; |
|
|
isHiddenSpinner = true; |
|
|
isHiddenSpinner = true; |
|
|
numAccounts = 0; |
|
|
numAccounts = 0; |
|
|
|
|
|
|
|
@ -239,7 +246,7 @@ export default class HomeView extends Vue { |
|
|
this.numAccounts = await accountsDB.accounts.count(); |
|
|
this.numAccounts = await accountsDB.accounts.count(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async getIdentity(activeDid) { |
|
|
public async getIdentity(activeDid: string) { |
|
|
await accountsDB.open(); |
|
|
await accountsDB.open(); |
|
|
const account = await accountsDB.accounts |
|
|
const account = await accountsDB.accounts |
|
|
.where("did") |
|
|
.where("did") |
|
@ -255,7 +262,7 @@ export default class HomeView extends Vue { |
|
|
return identity; |
|
|
return identity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async getHeaders(identity) { |
|
|
public async getHeaders(identity: IIdentifier) { |
|
|
const token = await accessToken(identity); |
|
|
const token = await accessToken(identity); |
|
|
const headers = { |
|
|
const headers = { |
|
|
"Content-Type": "application/json", |
|
|
"Content-Type": "application/json", |
|
@ -293,7 +300,9 @@ export default class HomeView extends Vue { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async buildHeaders() { |
|
|
public async buildHeaders() { |
|
|
const headers = { "Content-Type": "application/json" }; |
|
|
const headers: RawAxiosRequestHeaders = { |
|
|
|
|
|
"Content-Type": "application/json", |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
if (this.activeDid) { |
|
|
if (this.activeDid) { |
|
|
await accountsDB.open(); |
|
|
await accountsDB.open(); |
|
@ -404,19 +413,19 @@ export default class HomeView extends Vue { |
|
|
return giverInfo + " gave " + gaveAmount + gaveRecipientInfo; |
|
|
return giverInfo + " gave " + gaveAmount + gaveRecipientInfo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
displayAmount(code, amt) { |
|
|
displayAmount(code: string, amt: number) { |
|
|
return "" + amt + " " + this.currencyShortWordForCode(code, amt === 1); |
|
|
return "" + amt + " " + this.currencyShortWordForCode(code, amt === 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
currencyShortWordForCode(unitCode, single) { |
|
|
currencyShortWordForCode(unitCode: string, single: number) { |
|
|
return unitCode === "HUR" ? (single ? "hour" : "hours") : unitCode; |
|
|
return unitCode === "HUR" ? (single ? "hour" : "hours") : unitCode; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
openDialog(giver) { |
|
|
openDialog(giver: GiverInputInfo) { |
|
|
this.$refs.customDialog.open(giver); |
|
|
this.$refs.customDialog.open(giver); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
handleDialogResult(result) { |
|
|
handleDialogResult(result: GiverInputInfo) { |
|
|
if (result.action === "confirm") { |
|
|
if (result.action === "confirm") { |
|
|
return new Promise((resolve) => { |
|
|
return new Promise((resolve) => { |
|
|
this.recordGive(result.giver?.did, result.description, result.hours); |
|
|
this.recordGive(result.giver?.did, result.description, result.hours); |
|
@ -433,7 +442,11 @@ export default class HomeView extends Vue { |
|
|
* @param description may be an empty string |
|
|
* @param description may be an empty string |
|
|
* @param hours may be 0 |
|
|
* @param hours may be 0 |
|
|
*/ |
|
|
*/ |
|
|
public async recordGive(giverDid, description, hours) { |
|
|
public async recordGive( |
|
|
|
|
|
giverDid?: string, |
|
|
|
|
|
description?: string, |
|
|
|
|
|
hours?: string, |
|
|
|
|
|
) { |
|
|
if (!this.activeDid) { |
|
|
if (!this.activeDid) { |
|
|
this.$notify( |
|
|
this.$notify( |
|
|
{ |
|
|
{ |
|
@ -469,7 +482,7 @@ export default class HomeView extends Vue { |
|
|
giverDid, |
|
|
giverDid, |
|
|
this.activeDid, |
|
|
this.activeDid, |
|
|
description, |
|
|
description, |
|
|
hours, |
|
|
hours ? parseFloat(hours) : undefined, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if (this.isGiveCreationError(result)) { |
|
|
if (this.isGiveCreationError(result)) { |
|
@ -513,15 +526,15 @@ export default class HomeView extends Vue { |
|
|
|
|
|
|
|
|
// Helper functions for readability |
|
|
// Helper functions for readability |
|
|
|
|
|
|
|
|
isGiveCreationError(result) { |
|
|
isGiveCreationError(result: any) { |
|
|
return result.status !== 201 || result.data?.error; |
|
|
return result.status !== 201 || result.data?.error; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getGiveCreationErrorMessage(result) { |
|
|
getGiveCreationErrorMessage(result: any) { |
|
|
return result.data?.error?.message; |
|
|
return result.data?.error?.message; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getGiveErrorMessage(error) { |
|
|
getGiveErrorMessage(error: any) { |
|
|
return error.userMessage || error.response?.data?.error?.message; |
|
|
return error.userMessage || error.response?.data?.error?.message; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|