fix many more typescript errors

This commit is contained in:
2023-09-03 21:40:40 -06:00
parent b05b602acd
commit b59bcf249a
10 changed files with 80 additions and 106 deletions

View File

@@ -210,6 +210,7 @@ import {
didInfo,
GiverInputInfo,
GiverOutputInfo,
GiveServerRecord,
} from "@/libs/endorserServer";
import { Contact } from "@/db/tables/contacts";
import QuickNav from "@/components/QuickNav";
@@ -236,7 +237,7 @@ export default class HomeView extends Vue {
apiServer = "";
feedAllLoaded = false;
feedData = [];
feedPreviousOldestId = null;
feedPreviousOldestId?: string;
feedLastViewedId?: string;
isHiddenSpinner = true;
numAccounts = 0;
@@ -300,7 +301,7 @@ export default class HomeView extends Vue {
}
public async buildHeaders() {
const headers: RawAxiosRequestHeaders = {
const headers: HeadersInit = {
"Content-Type": "application/json",
};
@@ -325,7 +326,7 @@ export default class HomeView extends Vue {
public async updateAllFeed() {
this.isHiddenSpinner = false;
await this.retrieveClaims(this.apiServer, null, this.feedPreviousOldestId)
await this.retrieveClaims(this.apiServer, this.feedPreviousOldestId)
.then(async (results) => {
if (results.data.length > 0) {
this.feedData = this.feedData.concat(results.data);
@@ -360,7 +361,7 @@ export default class HomeView extends Vue {
this.isHiddenSpinner = true;
}
public async retrieveClaims(endorserApiServer, identifier, beforeId) {
public async retrieveClaims(endorserApiServer: string, beforeId?: string) {
const beforeQuery = beforeId == null ? "" : "&beforeId=" + beforeId;
const response = await fetch(
endorserApiServer + "/api/v2/report/gives?" + beforeQuery,
@@ -383,13 +384,14 @@ export default class HomeView extends Vue {
}
}
giveDescription(giveRecord) {
giveDescription(giveRecord: GiveServerRecord) {
let claim = giveRecord.fullClaim;
if (claim.claim) {
claim = claim.claim;
if ((claim as any).claim) {
// can happen for some claims wrapped in a Verifiable Credential
claim = (claim as any).claim;
}
// agent.did is for legacy data, before March 2023
const giverDid = claim.agent?.identifier || claim.agent?.did;
const giverDid = claim.agent?.identifier || (claim.agent as any)?.did;
const giverInfo = didInfo(
giverDid,
this.activeDid,
@@ -400,7 +402,8 @@ export default class HomeView extends Vue {
? this.displayAmount(claim.object.unitCode, claim.object.amountOfThisGood)
: claim.description || "something unknown";
// recipient.did is for legacy data, before March 2023
const gaveRecipientId = claim.recipient?.identifier || claim.recipient?.did;
const gaveRecipientId =
claim.recipient?.identifier || (claim.recipient as any)?.did;
const gaveRecipientInfo = gaveRecipientId
? " to " +
didInfo(
@@ -417,7 +420,7 @@ export default class HomeView extends Vue {
return "" + amt + " " + this.currencyShortWordForCode(code, amt === 1);
}
currencyShortWordForCode(unitCode: string, single: number) {
currencyShortWordForCode(unitCode: string, single: boolean) {
return unitCode === "HUR" ? (single ? "hour" : "hours") : unitCode;
}
@@ -425,11 +428,16 @@ export default class HomeView extends Vue {
this.$refs.customDialog.open(giver);
}
handleDialogResult(result: GiverInputInfo) {
handleDialogResult(result: GiverOutputInfo) {
if (result.action === "confirm") {
return new Promise((resolve) => {
this.recordGive(result.giver?.did, result.description, result.hours);
resolve();
this.recordGive(
result.giver?.did,
result.description,
result.hours,
).then(() => {
resolve(null);
});
});
} else {
// action was "cancel" so do nothing
@@ -445,7 +453,7 @@ export default class HomeView extends Vue {
public async recordGive(
giverDid?: string,
description?: string,
hours?: string,
hours?: number,
) {
if (!this.activeDid) {
this.$notify(
@@ -482,7 +490,7 @@ export default class HomeView extends Vue {
giverDid,
this.activeDid,
description,
hours ? parseFloat(hours) : undefined,
hours,
);
if (this.isGiveCreationError(result)) {