fix: improve TypeScript type safety across views
Changes: - Add proper type annotations for component properties - Fix null checks with optional chaining - Add missing interface properties - Replace any with proper types where possible - Move interfaces from endorserServer to interfaces/ - Add proper Router and Route typing - Add default empty string for optional text fields This improves type safety and reduces TypeScript errors across views.
This commit is contained in:
@@ -30,7 +30,12 @@ export interface OfferVerifiableCredential extends GenericVerifiableCredential {
|
|||||||
includesObject?: { amountOfThisGood: number; unitCode: string };
|
includesObject?: { amountOfThisGood: number; unitCode: string };
|
||||||
itemOffered?: {
|
itemOffered?: {
|
||||||
description?: string;
|
description?: string;
|
||||||
isPartOf?: { identifier?: string; lastClaimId?: string; "@type"?: string };
|
isPartOf?: {
|
||||||
|
identifier?: string;
|
||||||
|
lastClaimId?: string;
|
||||||
|
"@type"?: string;
|
||||||
|
name?: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
offeredBy?: { identifier: string };
|
offeredBy?: { identifier: string };
|
||||||
recipient?: { identifier: string };
|
recipient?: { identifier: string };
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { GiveVerifiableCredential, OfferVerifiableCredential } from "./claims";
|
|||||||
|
|
||||||
// a summary record; the VC is found the fullClaim field
|
// a summary record; the VC is found the fullClaim field
|
||||||
export interface GiveSummaryRecord {
|
export interface GiveSummaryRecord {
|
||||||
|
type?: string;
|
||||||
agentDid: string;
|
agentDid: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
amountConfirmed: number;
|
amountConfirmed: number;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue } from "vue-facing-decorator";
|
import { Component, Vue } from "vue-facing-decorator";
|
||||||
import { Router } from "vue-router";
|
|
||||||
|
|
||||||
import QuickNav from "../components/QuickNav.vue";
|
import QuickNav from "../components/QuickNav.vue";
|
||||||
import { NotificationIface } from "../constants/app";
|
import { NotificationIface } from "../constants/app";
|
||||||
@@ -38,12 +37,15 @@ import { logConsoleAndDb, retrieveSettingsForActiveAccount } from "../db/index";
|
|||||||
import * as serverUtil from "../libs/endorserServer";
|
import * as serverUtil from "../libs/endorserServer";
|
||||||
import * as libsUtil from "../libs/util";
|
import * as libsUtil from "../libs/util";
|
||||||
import { errorStringForLog } from "../libs/endorserServer";
|
import { errorStringForLog } from "../libs/endorserServer";
|
||||||
|
import { Router, RouteLocationNormalizedLoaded } from "vue-router";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
components: { QuickNav },
|
components: { QuickNav },
|
||||||
})
|
})
|
||||||
export default class ClaimAddRawView extends Vue {
|
export default class ClaimAddRawView extends Vue {
|
||||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||||
|
$route!: RouteLocationNormalizedLoaded;
|
||||||
|
$router!: Router;
|
||||||
|
|
||||||
accountIdentityStr: string = "null";
|
accountIdentityStr: string = "null";
|
||||||
activeDid = "";
|
activeDid = "";
|
||||||
@@ -55,7 +57,7 @@ export default class ClaimAddRawView extends Vue {
|
|||||||
this.activeDid = settings.activeDid || "";
|
this.activeDid = settings.activeDid || "";
|
||||||
this.apiServer = settings.apiServer || "";
|
this.apiServer = settings.apiServer || "";
|
||||||
|
|
||||||
this.claimStr = (this.$route as Router).query["claim"];
|
this.claimStr = (this.$route.query["claim"] as string) || "";
|
||||||
if (this.claimStr) {
|
if (this.claimStr) {
|
||||||
try {
|
try {
|
||||||
const veriClaim = JSON.parse(this.claimStr);
|
const veriClaim = JSON.parse(this.claimStr);
|
||||||
@@ -65,7 +67,7 @@ export default class ClaimAddRawView extends Vue {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// there may be no link that uses this, meaning you'd have to enter it in a browser
|
// there may be no link that uses this, meaning you'd have to enter it in a browser
|
||||||
const claimJwtId = (this.$route as Router).query["claimJwtId"];
|
const claimJwtId = (this.$route.query["claimJwtId"] as string) || "";
|
||||||
if (claimJwtId) {
|
if (claimJwtId) {
|
||||||
const urlPath = libsUtil.isGlobalUri(claimJwtId)
|
const urlPath = libsUtil.isGlobalUri(claimJwtId)
|
||||||
? "/api/claim/byHandle/"
|
? "/api/claim/byHandle/"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
import { Component, Vue } from "vue-facing-decorator";
|
import { Component, Vue } from "vue-facing-decorator";
|
||||||
import { nextTick } from "vue";
|
import { nextTick } from "vue";
|
||||||
import QRCode from "qrcode";
|
import QRCode from "qrcode";
|
||||||
|
import { GenericVerifiableCredential } from "../interfaces";
|
||||||
import { APP_SERVER, NotificationIface } from "../constants/app";
|
import { APP_SERVER, NotificationIface } from "../constants/app";
|
||||||
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
||||||
import * as serverUtil from "../libs/endorserServer";
|
import * as serverUtil from "../libs/endorserServer";
|
||||||
@@ -81,7 +81,7 @@ export default class ClaimCertificateView extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async drawCanvas(
|
async drawCanvas(
|
||||||
claimData: serverUtil.GenericCredWrapper<serverUtil.GenericVerifiableCredential>,
|
claimData: serverUtil.GenericCredWrapper<GenericVerifiableCredential>,
|
||||||
confirmerIds: Array<string>,
|
confirmerIds: Array<string>,
|
||||||
) {
|
) {
|
||||||
await db.open();
|
await db.open();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<div class="w-full">
|
<div class="w-full">
|
||||||
<div class="flex columns-3">
|
<div class="flex columns-3">
|
||||||
<h2 class="text-md font-bold w-full">
|
<h2 class="text-md font-bold w-full">
|
||||||
{{ capitalizeAndInsertSpacesBeforeCaps(veriClaim.claimType) }}
|
{{ capitalizeAndInsertSpacesBeforeCaps(veriClaim.claimType || '') }}
|
||||||
<button
|
<button
|
||||||
v-if="
|
v-if="
|
||||||
['GiveAction', 'Offer', 'PlanAction'].includes(
|
['GiveAction', 'Offer', 'PlanAction'].includes(
|
||||||
@@ -64,8 +64,9 @@
|
|||||||
<div data-testId="description">
|
<div data-testId="description">
|
||||||
<font-awesome icon="message" class="fa-fw text-slate-400" />
|
<font-awesome icon="message" class="fa-fw text-slate-400" />
|
||||||
{{
|
{{
|
||||||
veriClaim.claim?.itemOffered?.description ||
|
(veriClaim.claim?.itemOffered as any)?.description ||
|
||||||
veriClaim.claim?.description
|
(veriClaim.claim as any)?.description ||
|
||||||
|
''
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@@ -77,9 +78,9 @@
|
|||||||
Recorded
|
Recorded
|
||||||
{{ veriClaim.issuedAt?.replace(/T/, " ").replace(/Z/, " UTC") }}
|
{{ veriClaim.issuedAt?.replace(/T/, " ").replace(/Z/, " UTC") }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="veriClaim.claim.image" class="flex justify-center">
|
<div v-if="(veriClaim.claim as any).image" class="flex justify-center">
|
||||||
<a :href="veriClaim.claim.image" target="_blank">
|
<a :href="(veriClaim.claim as any).image" target="_blank">
|
||||||
<img :src="veriClaim.claim.image" class="h-24 rounded-xl" />
|
<img :src="(veriClaim.claim as any).image" class="h-24 rounded-xl" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -507,7 +508,7 @@ import * as R from "ramda";
|
|||||||
import { Component, Vue } from "vue-facing-decorator";
|
import { Component, Vue } from "vue-facing-decorator";
|
||||||
import { Router, RouteLocationNormalizedLoaded } from "vue-router";
|
import { Router, RouteLocationNormalizedLoaded } from "vue-router";
|
||||||
import { useClipboard } from "@vueuse/core";
|
import { useClipboard } from "@vueuse/core";
|
||||||
|
import { GenericVerifiableCredential } from "../interfaces";
|
||||||
import GiftedDialog from "../components/GiftedDialog.vue";
|
import GiftedDialog from "../components/GiftedDialog.vue";
|
||||||
import QuickNav from "../components/QuickNav.vue";
|
import QuickNav from "../components/QuickNav.vue";
|
||||||
import { NotificationIface } from "../constants/app";
|
import { NotificationIface } from "../constants/app";
|
||||||
@@ -542,8 +543,8 @@ export default class ClaimView extends Vue {
|
|||||||
confirmerIdList: string[] = []; // list of DIDs that have confirmed this claim excluding the issuer
|
confirmerIdList: string[] = []; // list of DIDs that have confirmed this claim excluding the issuer
|
||||||
confsVisibleErrorMessage = "";
|
confsVisibleErrorMessage = "";
|
||||||
confsVisibleToIdList: string[] = []; // list of DIDs that can see any confirmer
|
confsVisibleToIdList: string[] = []; // list of DIDs that can see any confirmer
|
||||||
detailsForGive = null;
|
detailsForGive: { fulfillsPlanHandleId?: string; fulfillsType?: string; fulfillsHandleId?: string } | null = null;
|
||||||
detailsForOffer = null;
|
detailsForOffer: { fulfillsPlanHandleId?: string } | null = null;
|
||||||
fullClaim = null;
|
fullClaim = null;
|
||||||
fullClaimDump = "";
|
fullClaimDump = "";
|
||||||
fullClaimMessage = "";
|
fullClaimMessage = "";
|
||||||
@@ -556,7 +557,7 @@ export default class ClaimView extends Vue {
|
|||||||
showVeriClaimDump = false;
|
showVeriClaimDump = false;
|
||||||
veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
|
veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
|
||||||
veriClaimDump = "";
|
veriClaimDump = "";
|
||||||
veriClaimDidsVisible = {};
|
veriClaimDidsVisible: { [key: string]: string[] } = {};
|
||||||
windowLocation = window.location.href;
|
windowLocation = window.location.href;
|
||||||
|
|
||||||
R = R;
|
R = R;
|
||||||
@@ -877,7 +878,7 @@ export default class ClaimView extends Vue {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const confirmationClaim: serverUtil.GenericVerifiableCredential = {
|
const confirmationClaim: GenericVerifiableCredential = {
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type": "AgreeAction",
|
"@type": "AgreeAction",
|
||||||
object: goodClaim,
|
object: goodClaim,
|
||||||
|
|||||||
@@ -408,24 +408,26 @@ import * as yaml from "js-yaml";
|
|||||||
import * as R from "ramda";
|
import * as R from "ramda";
|
||||||
import { Component, Vue } from "vue-facing-decorator";
|
import { Component, Vue } from "vue-facing-decorator";
|
||||||
import { useClipboard } from "@vueuse/core";
|
import { useClipboard } from "@vueuse/core";
|
||||||
import { Router } from "vue-router";
|
import { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||||
|
import { GenericVerifiableCredential } from "../interfaces";
|
||||||
import QuickNav from "../components/QuickNav.vue";
|
import QuickNav from "../components/QuickNav.vue";
|
||||||
import { NotificationIface } from "../constants/app";
|
import { NotificationIface } from "../constants/app";
|
||||||
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
||||||
import { Contact } from "../db/tables/contacts";
|
import { Contact } from "../db/tables/contacts";
|
||||||
import * as serverUtil from "../libs/endorserServer";
|
import * as serverUtil from "../libs/endorserServer";
|
||||||
import { displayAmount, GiveSummaryRecord } from "../libs/endorserServer";
|
import { GiveSummaryRecord } from "../interfaces";
|
||||||
|
import { displayAmount } from "../libs/endorserServer";
|
||||||
import * as libsUtil from "../libs/util";
|
import * as libsUtil from "../libs/util";
|
||||||
import { isGiveAction, retrieveAccountDids } from "../libs/util";
|
import { isGiveAction, retrieveAccountDids } from "../libs/util";
|
||||||
import TopMessage from "../components/TopMessage.vue";
|
import TopMessage from "../components/TopMessage.vue";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
methods: { displayAmount },
|
|
||||||
components: { TopMessage, QuickNav },
|
components: { TopMessage, QuickNav },
|
||||||
})
|
})
|
||||||
export default class ClaimView extends Vue {
|
export default class ConfirmGiftView extends Vue {
|
||||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||||
|
$route!: RouteLocationNormalizedLoaded;
|
||||||
|
$router!: Router;
|
||||||
|
|
||||||
activeDid = "";
|
activeDid = "";
|
||||||
allMyDids: Array<string> = [];
|
allMyDids: Array<string> = [];
|
||||||
@@ -447,13 +449,14 @@ export default class ClaimView extends Vue {
|
|||||||
urlForNewGive = "";
|
urlForNewGive = "";
|
||||||
veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
|
veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
|
||||||
veriClaimDump = "";
|
veriClaimDump = "";
|
||||||
veriClaimDidsVisible = {};
|
veriClaimDidsVisible: { [key: string]: string[] } = {};
|
||||||
windowLocation = window.location.href;
|
windowLocation = window.location.href;
|
||||||
|
|
||||||
R = R;
|
R = R;
|
||||||
yaml = yaml;
|
yaml = yaml;
|
||||||
libsUtil = libsUtil;
|
libsUtil = libsUtil;
|
||||||
serverUtil = serverUtil;
|
serverUtil = serverUtil;
|
||||||
|
displayAmount = displayAmount;
|
||||||
|
|
||||||
resetThisValues() {
|
resetThisValues() {
|
||||||
this.confirmerIdList = [];
|
this.confirmerIdList = [];
|
||||||
@@ -719,7 +722,7 @@ export default class ClaimView extends Vue {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const confirmationClaim: serverUtil.GenericVerifiableCredential = {
|
const confirmationClaim: GenericVerifiableCredential = {
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type": "AgreeAction",
|
"@type": "AgreeAction",
|
||||||
object: goodClaim,
|
object: goodClaim,
|
||||||
|
|||||||
@@ -261,21 +261,20 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue } from "vue-facing-decorator";
|
import { Component, Vue } from "vue-facing-decorator";
|
||||||
import { Router } from "vue-router";
|
import { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||||
|
|
||||||
import ImageMethodDialog from "../components/ImageMethodDialog.vue";
|
import ImageMethodDialog from "../components/ImageMethodDialog.vue";
|
||||||
import QuickNav from "../components/QuickNav.vue";
|
import QuickNav from "../components/QuickNav.vue";
|
||||||
import TopMessage from "../components/TopMessage.vue";
|
import TopMessage from "../components/TopMessage.vue";
|
||||||
import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "../constants/app";
|
import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "../constants/app";
|
||||||
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
||||||
|
import { GenericCredWrapper, GiveVerifiableCredential } from "../interfaces";
|
||||||
import {
|
import {
|
||||||
createAndSubmitGive,
|
createAndSubmitGive,
|
||||||
didInfo,
|
didInfo,
|
||||||
editAndSubmitGive,
|
editAndSubmitGive,
|
||||||
GenericCredWrapper,
|
|
||||||
getHeaders,
|
getHeaders,
|
||||||
getPlanFromCache,
|
getPlanFromCache,
|
||||||
GiveVerifiableCredential,
|
|
||||||
hydrateGive,
|
hydrateGive,
|
||||||
} from "../libs/endorserServer";
|
} from "../libs/endorserServer";
|
||||||
import * as libsUtil from "../libs/util";
|
import * as libsUtil from "../libs/util";
|
||||||
@@ -290,6 +289,8 @@ import { retrieveAccountDids } from "../libs/util";
|
|||||||
})
|
})
|
||||||
export default class GiftedDetails extends Vue {
|
export default class GiftedDetails extends Vue {
|
||||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||||
|
$route!: RouteLocationNormalizedLoaded;
|
||||||
|
$router!: Router;
|
||||||
|
|
||||||
activeDid = "";
|
activeDid = "";
|
||||||
apiServer = "";
|
apiServer = "";
|
||||||
@@ -322,9 +323,9 @@ export default class GiftedDetails extends Vue {
|
|||||||
|
|
||||||
async mounted() {
|
async mounted() {
|
||||||
try {
|
try {
|
||||||
this.prevCredToEdit = (this.$route as Router).query["prevCredToEdit"]
|
this.prevCredToEdit = (this.$route.query["prevCredToEdit"] as string)
|
||||||
? (JSON.parse(
|
? (JSON.parse(
|
||||||
(this.$route as Router).query["prevCredToEdit"],
|
(this.$route.query["prevCredToEdit"] as string),
|
||||||
) as GenericCredWrapper<GiveVerifiableCredential>)
|
) as GenericCredWrapper<GiveVerifiableCredential>)
|
||||||
: undefined;
|
: undefined;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -341,24 +342,22 @@ export default class GiftedDetails extends Vue {
|
|||||||
|
|
||||||
const prevAmount = this.prevCredToEdit?.claim?.object?.amountOfThisGood;
|
const prevAmount = this.prevCredToEdit?.claim?.object?.amountOfThisGood;
|
||||||
this.amountInput =
|
this.amountInput =
|
||||||
(this.$route as Router).query["amountInput"] ||
|
(this.$route.query["amountInput"] as string) ||
|
||||||
(prevAmount ? String(prevAmount) : "") ||
|
(prevAmount ? String(prevAmount) : "") ||
|
||||||
this.amountInput;
|
this.amountInput;
|
||||||
this.description =
|
this.description =
|
||||||
(this.$route as Router).query["description"] ||
|
(this.$route.query["description"] as string) ||
|
||||||
this.prevCredToEdit?.claim?.description ||
|
this.prevCredToEdit?.claim?.description ||
|
||||||
this.description;
|
this.description;
|
||||||
this.destinationPathAfter = (this.$route as Router).query[
|
this.destinationPathAfter = (this.$route.query["destinationPathAfter"] as string) || "";
|
||||||
"destinationPathAfter"
|
this.giverDid = ((this.$route.query["giverDid"] as string) ||
|
||||||
];
|
(this.prevCredToEdit?.claim?.agent as any)?.identifier ||
|
||||||
this.giverDid = ((this.$route as Router).query["giverDid"] ||
|
|
||||||
this.prevCredToEdit?.claim?.agent?.identifier ||
|
|
||||||
this.giverDid) as string;
|
this.giverDid) as string;
|
||||||
this.giverName =
|
this.giverName =
|
||||||
((this.$route as Router).query["giverName"] as string) || "";
|
((this.$route.query["giverName"] as string) || "");
|
||||||
this.hideBackButton =
|
this.hideBackButton =
|
||||||
(this.$route as Router).query["hideBackButton"] === "true";
|
(this.$route.query["hideBackButton"] as string) === "true";
|
||||||
this.message = ((this.$route as Router).query["message"] as string) || "";
|
this.message = ((this.$route.query["message"] as string) || "");
|
||||||
|
|
||||||
// find any offer ID
|
// find any offer ID
|
||||||
const fulfills = this.prevCredToEdit?.claim?.fulfills;
|
const fulfills = this.prevCredToEdit?.claim?.fulfills;
|
||||||
@@ -368,7 +367,7 @@ export default class GiftedDetails extends Vue {
|
|||||||
? [fulfills]
|
? [fulfills]
|
||||||
: [];
|
: [];
|
||||||
const offer = fulfillsArray.find((rec) => rec["@type"] === "Offer");
|
const offer = fulfillsArray.find((rec) => rec["@type"] === "Offer");
|
||||||
this.offerId = ((this.$route as Router).query["offerId"] ||
|
this.offerId = ((this.$route.query["offerId"] as string) ||
|
||||||
offer?.identifier ||
|
offer?.identifier ||
|
||||||
this.offerId) as string;
|
this.offerId) as string;
|
||||||
|
|
||||||
@@ -378,7 +377,7 @@ export default class GiftedDetails extends Vue {
|
|||||||
);
|
);
|
||||||
// eslint-disable-next-line prettier/prettier
|
// eslint-disable-next-line prettier/prettier
|
||||||
this.fulfillsProjectId =
|
this.fulfillsProjectId =
|
||||||
((this.$route as Router).query["fulfillsProjectId"] ||
|
((this.$route.query["fulfillsProjectId"] as string) ||
|
||||||
fulfillsProject?.identifier ||
|
fulfillsProject?.identifier ||
|
||||||
this.fulfillsProjectId) as string;
|
this.fulfillsProjectId) as string;
|
||||||
|
|
||||||
@@ -392,40 +391,38 @@ export default class GiftedDetails extends Vue {
|
|||||||
const providerProject = providerArray.find(
|
const providerProject = providerArray.find(
|
||||||
(rec) => rec["@type"] === "PlanAction",
|
(rec) => rec["@type"] === "PlanAction",
|
||||||
);
|
);
|
||||||
this.providerProjectId = ((this.$route as Router).query[
|
this.providerProjectId = ((this.$route.query["providerProjectId"] as string) ||
|
||||||
"providerProjectId"
|
|
||||||
] ||
|
|
||||||
providerProject?.identifier ||
|
providerProject?.identifier ||
|
||||||
this.providerProjectId) as string;
|
this.providerProjectId) as string;
|
||||||
|
|
||||||
this.recipientDid = ((this.$route as Router).query["recipientDid"] ||
|
this.recipientDid = ((this.$route.query["recipientDid"] as string) ||
|
||||||
this.prevCredToEdit?.claim?.recipient?.identifier) as string;
|
this.prevCredToEdit?.claim?.recipient?.identifier) as string;
|
||||||
this.recipientName =
|
this.recipientName =
|
||||||
((this.$route as Router).query["recipientName"] as string) || "";
|
((this.$route.query["recipientName"] as string) || "");
|
||||||
this.unitCode = ((this.$route as Router).query["unitCode"] ||
|
this.unitCode = ((this.$route.query["unitCode"] as string) ||
|
||||||
this.prevCredToEdit?.claim?.object?.unitCode ||
|
this.prevCredToEdit?.claim?.object?.unitCode ||
|
||||||
this.unitCode) as string;
|
this.unitCode) as string;
|
||||||
|
|
||||||
this.imageUrl =
|
this.imageUrl =
|
||||||
((this.$route as Router).query["imageUrl"] as string) ||
|
((this.$route.query["imageUrl"] as string) ||
|
||||||
this.prevCredToEdit?.claim?.image ||
|
this.prevCredToEdit?.claim?.image ||
|
||||||
localStorage.getItem("imageUrl") ||
|
localStorage.getItem("imageUrl") ||
|
||||||
this.imageUrl;
|
this.imageUrl) as string;
|
||||||
|
|
||||||
// this is an endpoint for sharing project info to highlight something given
|
// this is an endpoint for sharing project info to highlight something given
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/Manifest/share_target
|
// https://developer.mozilla.org/en-US/docs/Web/Manifest/share_target
|
||||||
if ((this.$route as Router).query["shareTitle"]) {
|
if ((this.$route.query["shareTitle"] as string)) {
|
||||||
this.description =
|
this.description =
|
||||||
((this.$route as Router).query["shareTitle"] as string) +
|
((this.$route.query["shareTitle"] as string) || "") +
|
||||||
(this.description ? "\n" + this.description : "");
|
(this.description ? "\n" + this.description : "");
|
||||||
}
|
}
|
||||||
if ((this.$route as Router).query["shareText"]) {
|
if ((this.$route.query["shareText"] as string)) {
|
||||||
this.description =
|
this.description =
|
||||||
(this.description ? this.description + "\n" : "") +
|
(this.description ? this.description + "\n" : "") +
|
||||||
((this.$route as Router).query["shareText"] as string);
|
((this.$route.query["shareText"] as string) || "");
|
||||||
}
|
}
|
||||||
if ((this.$route as Router).query["shareUrl"]) {
|
if ((this.$route.query["shareUrl"] as string)) {
|
||||||
this.imageUrl = (this.$route as Router).query["shareUrl"] as string;
|
this.imageUrl = (this.$route.query["shareUrl"] as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
const settings = await retrieveSettingsForActiveAccount();
|
const settings = await retrieveSettingsForActiveAccount();
|
||||||
|
|||||||
@@ -176,20 +176,19 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Vue } from "vue-facing-decorator";
|
import { Component, Vue } from "vue-facing-decorator";
|
||||||
import { Router } from "vue-router";
|
import { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||||
|
|
||||||
import QuickNav from "../components/QuickNav.vue";
|
import QuickNav from "../components/QuickNav.vue";
|
||||||
import TopMessage from "../components/TopMessage.vue";
|
import TopMessage from "../components/TopMessage.vue";
|
||||||
import { NotificationIface } from "../constants/app";
|
import { NotificationIface } from "../constants/app";
|
||||||
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
import { db, retrieveSettingsForActiveAccount } from "../db/index";
|
||||||
|
import { GenericCredWrapper, OfferVerifiableCredential } from "../interfaces";
|
||||||
import {
|
import {
|
||||||
createAndSubmitOffer,
|
createAndSubmitOffer,
|
||||||
didInfo,
|
didInfo,
|
||||||
editAndSubmitOffer,
|
editAndSubmitOffer,
|
||||||
GenericCredWrapper,
|
|
||||||
getPlanFromCache,
|
getPlanFromCache,
|
||||||
hydrateOffer,
|
hydrateOffer,
|
||||||
OfferVerifiableCredential,
|
|
||||||
} from "../libs/endorserServer";
|
} from "../libs/endorserServer";
|
||||||
import * as libsUtil from "../libs/util";
|
import * as libsUtil from "../libs/util";
|
||||||
import { retrieveAccountDids } from "../libs/util";
|
import { retrieveAccountDids } from "../libs/util";
|
||||||
@@ -202,6 +201,8 @@ import { retrieveAccountDids } from "../libs/util";
|
|||||||
})
|
})
|
||||||
export default class OfferDetailsView extends Vue {
|
export default class OfferDetailsView extends Vue {
|
||||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||||
|
$route!: RouteLocationNormalizedLoaded;
|
||||||
|
$router!: Router;
|
||||||
|
|
||||||
activeDid = "";
|
activeDid = "";
|
||||||
apiServer = "";
|
apiServer = "";
|
||||||
@@ -229,9 +230,9 @@ export default class OfferDetailsView extends Vue {
|
|||||||
|
|
||||||
async mounted() {
|
async mounted() {
|
||||||
try {
|
try {
|
||||||
this.prevCredToEdit = (this.$route as Router).query["prevCredToEdit"]
|
this.prevCredToEdit = (this.$route.query["prevCredToEdit"] as string)
|
||||||
? (JSON.parse(
|
? (JSON.parse(
|
||||||
(this.$route as Router).query["prevCredToEdit"],
|
(this.$route.query["prevCredToEdit"] as string),
|
||||||
) as GenericCredWrapper<OfferVerifiableCredential>)
|
) as GenericCredWrapper<OfferVerifiableCredential>)
|
||||||
: undefined;
|
: undefined;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -249,28 +250,26 @@ export default class OfferDetailsView extends Vue {
|
|||||||
const prevAmount =
|
const prevAmount =
|
||||||
this.prevCredToEdit?.claim?.includesObject?.amountOfThisGood;
|
this.prevCredToEdit?.claim?.includesObject?.amountOfThisGood;
|
||||||
this.amountInput =
|
this.amountInput =
|
||||||
(this.$route as Router).query["amountInput"] ||
|
(this.$route.query["amountInput"] as string) ||
|
||||||
(prevAmount ? String(prevAmount) : "") ||
|
(prevAmount ? String(prevAmount) : "") ||
|
||||||
this.amountInput;
|
this.amountInput;
|
||||||
this.unitCode = ((this.$route as Router).query["unitCode"] ||
|
this.unitCode = ((this.$route.query["unitCode"] as string) ||
|
||||||
this.prevCredToEdit?.claim?.includesObject?.unitCode ||
|
this.prevCredToEdit?.claim?.includesObject?.unitCode ||
|
||||||
this.unitCode) as string;
|
this.unitCode) as string;
|
||||||
|
|
||||||
this.descriptionOfCondition =
|
this.descriptionOfCondition =
|
||||||
this.prevCredToEdit?.claim?.description || this.descriptionOfCondition;
|
this.prevCredToEdit?.claim?.description || this.descriptionOfCondition;
|
||||||
this.descriptionOfItem =
|
this.descriptionOfItem =
|
||||||
(this.$route as Router).query["description"] ||
|
(this.$route.query["description"] as string) ||
|
||||||
this.prevCredToEdit?.claim?.itemOffered?.description ||
|
this.prevCredToEdit?.claim?.itemOffered?.description ||
|
||||||
this.descriptionOfItem;
|
this.descriptionOfItem;
|
||||||
this.destinationPathAfter = (this.$route as Router).query[
|
this.destinationPathAfter = (this.$route.query["destinationPathAfter"] as string) || "";
|
||||||
"destinationPathAfter"
|
this.offererDid = ((this.$route.query["offererDid"] as string) ||
|
||||||
];
|
(this.prevCredToEdit?.claim?.agent as any)?.identifier ||
|
||||||
this.offererDid = ((this.$route as Router).query["offererDid"] ||
|
|
||||||
this.prevCredToEdit?.claim?.agent?.identifier ||
|
|
||||||
this.offererDid) as string;
|
this.offererDid) as string;
|
||||||
this.hideBackButton =
|
this.hideBackButton =
|
||||||
(this.$route as Router).query["hideBackButton"] === "true";
|
(this.$route.query["hideBackButton"] as string) === "true";
|
||||||
this.message = ((this.$route as Router).query["message"] as string) || "";
|
this.message = ((this.$route.query["message"] as string) || "");
|
||||||
|
|
||||||
// find any project ID
|
// find any project ID
|
||||||
let project;
|
let project;
|
||||||
@@ -280,17 +279,17 @@ export default class OfferDetailsView extends Vue {
|
|||||||
) {
|
) {
|
||||||
project = this.prevCredToEdit?.claim?.itemOffered?.isPartOf;
|
project = this.prevCredToEdit?.claim?.itemOffered?.isPartOf;
|
||||||
}
|
}
|
||||||
this.projectId = ((this.$route as Router).query["projectId"] ||
|
this.projectId = ((this.$route.query["projectId"] as string) ||
|
||||||
project?.identifier ||
|
project?.identifier ||
|
||||||
this.projectId) as string;
|
this.projectId) as string;
|
||||||
this.projectName = ((this.$route as Router).query["projectName"] ||
|
this.projectName = ((this.$route.query["projectName"] as string) ||
|
||||||
project?.name ||
|
project?.name ||
|
||||||
this.projectName) as string;
|
this.projectName) as string;
|
||||||
|
|
||||||
this.recipientDid = ((this.$route as Router).query["recipientDid"] ||
|
this.recipientDid = ((this.$route.query["recipientDid"] as string) ||
|
||||||
this.prevCredToEdit?.claim?.recipient?.identifier) as string;
|
this.prevCredToEdit?.claim?.recipient?.identifier) as string;
|
||||||
this.recipientName =
|
this.recipientName =
|
||||||
((this.$route as Router).query["recipientName"] as string) || "";
|
((this.$route.query["recipientName"] as string) || "");
|
||||||
|
|
||||||
this.validThroughDateInput =
|
this.validThroughDateInput =
|
||||||
this.prevCredToEdit?.claim?.validThrough || this.validThroughDateInput;
|
this.prevCredToEdit?.claim?.validThrough || this.validThroughDateInput;
|
||||||
|
|||||||
@@ -496,7 +496,15 @@
|
|||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
import { Component, Vue } from "vue-facing-decorator";
|
import { Component, Vue } from "vue-facing-decorator";
|
||||||
import { Router } from "vue-router";
|
import { Router } from "vue-router";
|
||||||
|
import {
|
||||||
|
GenericVerifiableCredential,
|
||||||
|
GenericCredWrapper,
|
||||||
|
GiveSummaryRecord,
|
||||||
|
GiveVerifiableCredential,
|
||||||
|
OfferSummaryRecord,
|
||||||
|
OfferVerifiableCredential,
|
||||||
|
PlanSummaryRecord,
|
||||||
|
} from "../interfaces";
|
||||||
import GiftedDialog from "../components/GiftedDialog.vue";
|
import GiftedDialog from "../components/GiftedDialog.vue";
|
||||||
import OfferDialog from "../components/OfferDialog.vue";
|
import OfferDialog from "../components/OfferDialog.vue";
|
||||||
import TopMessage from "../components/TopMessage.vue";
|
import TopMessage from "../components/TopMessage.vue";
|
||||||
@@ -511,14 +519,6 @@ import {
|
|||||||
} from "../db/index";
|
} from "../db/index";
|
||||||
import { Contact } from "../db/tables/contacts";
|
import { Contact } from "../db/tables/contacts";
|
||||||
import * as libsUtil from "../libs/util";
|
import * as libsUtil from "../libs/util";
|
||||||
import {
|
|
||||||
GenericCredWrapper,
|
|
||||||
GiveSummaryRecord,
|
|
||||||
GiveVerifiableCredential,
|
|
||||||
OfferSummaryRecord,
|
|
||||||
OfferVerifiableCredential,
|
|
||||||
PlanSummaryRecord,
|
|
||||||
} from "../libs/endorserServer";
|
|
||||||
import * as serverUtil from "../libs/endorserServer";
|
import * as serverUtil from "../libs/endorserServer";
|
||||||
import { retrieveAccountDids } from "../libs/util";
|
import { retrieveAccountDids } from "../libs/util";
|
||||||
import HiddenDidDialog from "../components/HiddenDidDialog.vue";
|
import HiddenDidDialog from "../components/HiddenDidDialog.vue";
|
||||||
@@ -1156,7 +1156,7 @@ export default class ProjectViewView extends Vue {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const confirmationClaim: serverUtil.GenericVerifiableCredential = {
|
const confirmationClaim: GenericVerifiableCredential = {
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type": "AgreeAction",
|
"@type": "AgreeAction",
|
||||||
object: goodClaim,
|
object: goodClaim,
|
||||||
|
|||||||
Reference in New Issue
Block a user