forked from jsnbuchanan/crowd-funder-for-time-pwa
Add edit project flow in anticipation of API method. Ugly Edit button needs to be replaced.
This commit is contained in:
@@ -67,6 +67,48 @@ import { useAppStore } from "@/store/app";
|
||||
export default class NewEditProjectView extends Vue {
|
||||
projectName = "";
|
||||
description = "";
|
||||
projectId =
|
||||
localStorage.getItem("projectId") === null
|
||||
? ""
|
||||
: localStorage.getItem("projectId");
|
||||
|
||||
async created() {
|
||||
if (this.projectId === "") {
|
||||
console.log("This is a new project");
|
||||
} else {
|
||||
await db.open();
|
||||
const num_accounts = await db.accounts.count();
|
||||
if (num_accounts === 0) {
|
||||
console.log("Problem! Should have a profile!");
|
||||
} else {
|
||||
const accounts = await db.accounts.toArray();
|
||||
const identity = JSON.parse(accounts[0].identity);
|
||||
this.LoadProject(identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async LoadProject(identity: IIdentifier) {
|
||||
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
|
||||
const url = endorserApiServer + "/api/claim/" + this.projectId;
|
||||
const token = await accessToken(identity);
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer " + token,
|
||||
};
|
||||
|
||||
try {
|
||||
const resp = await this.axios.get(url, { headers });
|
||||
console.log(resp.status, resp.data);
|
||||
if (resp.status === 200) {
|
||||
const claim = resp.data.claim;
|
||||
this.projectName = claim.name;
|
||||
this.description = claim.description;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
private async SaveProject(identity: IIdentifier) {
|
||||
const address = identity.did;
|
||||
|
||||
Reference in New Issue
Block a user