fix many, many more type errors

This commit is contained in:
2023-09-03 10:02:17 -06:00
parent b8aaffbf8d
commit b05b602acd
15 changed files with 170 additions and 97 deletions

View File

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