forked from jsnbuchanan/crowd-funder-for-time-pwa
Add flow from project list to view
This commit is contained in:
@@ -116,9 +116,7 @@ export default class NewEditProjectView extends Vue {
|
||||
|
||||
try {
|
||||
const resp = await this.axios.post(url, payload, { headers });
|
||||
console.log(resp.status, resp.data);
|
||||
useAppStore().setProjectId(resp.data);
|
||||
console.log("TEST", useAppStore().projectId);
|
||||
setTimeout(
|
||||
function (that: Vue) {
|
||||
console.log("THAT:", localStorage.getItem("projectId"));
|
||||
|
||||
@@ -34,7 +34,10 @@
|
||||
v-for="project in projects"
|
||||
:key="project.id"
|
||||
>
|
||||
<a href="project-view.html" class="block py-4 flex gap-4">
|
||||
<a
|
||||
@click="onClickLoadProject(project.id)"
|
||||
class="block py-4 flex gap-4"
|
||||
>
|
||||
<div class="flex-none w-12">
|
||||
<img
|
||||
src="https://picsum.photos/200/200?random=1"
|
||||
@@ -66,7 +69,18 @@ import { AppString } from "@/constants/app";
|
||||
})
|
||||
export default class ProjectsView extends Vue {
|
||||
projects: { id: string; name: string; description: string }[] = [];
|
||||
async LoadProject(identity: IIdentifier) {
|
||||
|
||||
onClickLoadProject(id: string) {
|
||||
console.log("projectId", id);
|
||||
localStorage.setItem("projectId", id);
|
||||
const route = {
|
||||
name: "project",
|
||||
};
|
||||
console.log(route);
|
||||
this.$router.push(route);
|
||||
}
|
||||
|
||||
async LoadProjects(identity: IIdentifier) {
|
||||
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
|
||||
const url = endorserApiServer + "/api/claim/?claimContents=" + identity.did;
|
||||
const token = await accessToken(identity);
|
||||
@@ -77,16 +91,17 @@ export default class ProjectsView extends Vue {
|
||||
|
||||
try {
|
||||
const resp = await this.axios.get(url, { headers });
|
||||
console.log(resp.status, resp.data);
|
||||
if (resp.status === 200) {
|
||||
const claims = resp.data;
|
||||
for (let i = 0; i < claims.length; i++) {
|
||||
console.log(claims[i]);
|
||||
const claim = claims[i].claim;
|
||||
this.projects.push({
|
||||
id: claim.id,
|
||||
const data = {
|
||||
id: claims[i].id,
|
||||
name: claim.name,
|
||||
description: claim.description,
|
||||
});
|
||||
};
|
||||
this.projects.push(data);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -102,7 +117,7 @@ export default class ProjectsView extends Vue {
|
||||
} else {
|
||||
const accounts = await db.accounts.toArray();
|
||||
const identity = JSON.parse(accounts[0].identity);
|
||||
this.LoadProject(identity);
|
||||
this.LoadProjects(identity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user