forked from jsnbuchanan/crowd-funder-for-time-pwa
Added the flow from New Project to View Project
This commit is contained in:
@@ -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);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user