chore: update to match latest API for retrieving plans

This commit is contained in:
2023-01-25 09:10:16 -07:00
parent 1bedbe17c0
commit 5638798ca8
4 changed files with 59 additions and 32 deletions

View File

@@ -60,10 +60,14 @@
><fa icon="ellipsis-vertical" class="fa-fw"></fa
></a>
View Project
View Plan
</h1>
</div>
<div>
{{ errorMessage }}
</div>
<!-- Project Details -->
<div class="bg-slate-100 rounded-md overflow-hidden px-4 py-3 mb-4">
<div>
@@ -158,6 +162,7 @@ export default class ProjectViewView extends Vue {
truncateLength = 40;
timeSince = "";
projectId = localStorage.getItem("projectId") || "";
errorMessage = "";
onEditClick() {
localStorage.setItem("projectId", this.projectId as string);
@@ -178,8 +183,8 @@ export default class ProjectViewView extends Vue {
async LoadProject(identity: IIdentifier) {
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
const url =
endorserApiServer + "/api/plan/" + encodeURIComponent(this.projectId);
// eslint-disable-next-line prettier/prettier
const url = endorserApiServer + "/api/claim/byHandle/" + encodeURIComponent(this.projectId);
const token = await accessToken(identity);
const headers = {
"Content-Type": "application/json",
@@ -191,15 +196,27 @@ export default class ProjectViewView extends Vue {
console.log(resp.status, resp.data);
if (resp.status === 200) {
const startTime = resp.data.startTime;
const eventDate = new Date(startTime);
const now = moment.now();
this.timeSince = moment.utc(now).to(eventDate);
this.name = resp.data.name;
this.description = resp.data.description;
if (startTime != null) {
const eventDate = new Date(startTime);
const now = moment.now();
this.timeSince = moment.utc(now).to(eventDate);
}
this.name = resp.data.claim?.name || "(no name)";
this.description = resp.data.claim?.description || "(no description)";
this.truncatedDesc = this.description.slice(0, this.truncateLength);
} else if (resp.status === 404) {
// actually, axios throws an error so we never get here
this.errorMessage = "That project does not exist.";
}
} catch (error: any) {
if (error?.response?.status === 404) {
this.errorMessage = "That project does not exist.";
} else {
this.errorMessage =
"Something went wrong retrieving that project." +
" See logs for more info.";
console.log("Error retrieving project:", error);
}
} catch (error) {
console.log(error);
}
}