forked from trent_larson/crowd-funder-for-time-pwa
add ability to edit & resubmit any raw claim
This commit is contained in:
@@ -32,10 +32,12 @@
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { Router } from "vue-router";
|
||||
|
||||
import { NotificationIface } from "@/constants/app";
|
||||
import { retrieveSettingsForActiveAccount } from "@/db/index";
|
||||
import * as serverUtil from "@/libs/endorserServer";
|
||||
import QuickNav from "@/components/QuickNav.vue";
|
||||
import { NotificationIface } from "@/constants/app";
|
||||
import { logConsoleAndDb, retrieveSettingsForActiveAccount } from "@/db/index";
|
||||
import * as serverUtil from "@/libs/endorserServer";
|
||||
import * as libsUtil from "@/libs/util";
|
||||
import { errorStringForLog } from "@/libs/endorserServer";
|
||||
|
||||
@Component({
|
||||
components: { QuickNav },
|
||||
@@ -54,11 +56,55 @@ export default class ClaimAddRawView extends Vue {
|
||||
this.apiServer = settings.apiServer || "";
|
||||
|
||||
this.claimStr = (this.$route as Router).query["claim"];
|
||||
try {
|
||||
this.veriClaim = JSON.parse(this.claimStr);
|
||||
this.claimStr = JSON.stringify(this.veriClaim, null, 2);
|
||||
} catch (e) {
|
||||
// ignore a parse
|
||||
if (this.claimStr) {
|
||||
try {
|
||||
const veriClaim = JSON.parse(this.claimStr);
|
||||
this.claimStr = JSON.stringify(veriClaim, null, 2);
|
||||
} catch (e) {
|
||||
// ignore a parse error
|
||||
}
|
||||
} else {
|
||||
// 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"];
|
||||
if (claimJwtId) {
|
||||
const urlPath = libsUtil.isGlobalUri(claimJwtId)
|
||||
? "/api/claim/byHandle/"
|
||||
: "/api/claim/";
|
||||
const url = this.apiServer + urlPath + encodeURIComponent(claimJwtId);
|
||||
const headers = await serverUtil.getHeaders(this.activeDid);
|
||||
|
||||
try {
|
||||
const response = await this.axios.get(url, { headers });
|
||||
if (response.status === 200) {
|
||||
const claim = response.data?.claim;
|
||||
claim.lastClaimId = serverUtil.stripEndorserPrefix(claimJwtId);
|
||||
this.claimStr = JSON.stringify(claim, null, 2);
|
||||
} else {
|
||||
throw {
|
||||
message: "Got an error loading that claim.",
|
||||
response: {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
// url is in "fetch" response but not in AxiosResponse
|
||||
},
|
||||
};
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
logConsoleAndDb(
|
||||
"Error retrieving claim: " + errorStringForLog(error),
|
||||
true,
|
||||
);
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "Got an error retrieving claim data.",
|
||||
},
|
||||
3000,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user