Browse Source

Added the flow from New Project to View Project

pull/6/head
Matthew Aaron Raymer 2 years ago
parent
commit
c84e597047
  1. 2
      src/store/app.ts
  2. 18
      src/views/NewEditProjectView.vue
  3. 41
      src/views/ProjectViewView.vue

2
src/store/app.ts

@ -28,7 +28,7 @@ export const useAppStore = defineStore({
setCondition(newCondition: string) {
localStorage.setItem("condition", newCondition);
},
setProjectId(newProjectId: string) {
async setProjectId(newProjectId: string) {
localStorage.setItem("projectId", newProjectId);
},
},

18
src/views/NewEditProjectView.vue

@ -135,11 +135,19 @@ export default class NewEditProjectView extends Vue {
const resp = await this.axios.post(url, payload, { headers });
console.log(resp.status, resp.data);
useAppStore().setProjectId(resp.data);
const route = {
name: "project",
};
console.log(route);
this.$router.push(route);
console.log("TEST", useAppStore().projectId);
setTimeout(
function (that: Vue) {
console.log("THAT:", localStorage.getItem("projectId"));
const route = {
name: "project",
};
console.log(route);
that.$router.push(route);
},
2000,
this
);
} catch (error) {
console.log(error);
}

41
src/views/ProjectViewView.vue

@ -126,16 +126,47 @@
<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { useAppStore } from "@/store/app";
import { accessToken } from "@/libs/crypto";
import { db } from "../db";
import { IIdentifier } from "@veramo/core";
import { AppString } from "@/constants/app";
@Options({
components: {},
})
export default class ProjectViewView extends Vue {
projectId = "";
created(): void {
this.projectId = useAppStore().projectId;
console.log(this.projectId);
projectId =
localStorage.getItem("projectId") === null
? ""
: localStorage.getItem("projectId");
async LoadProject(identity: IIdentifier) {
console.log("LoadProject", this.projectId);
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);
} catch (error) {
console.log(error);
}
}
async created() {
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);
}
}
}
</script>

Loading…
Cancel
Save