forked from jsnbuchanan/crowd-funder-for-time-pwa
fix problem switching projects where old link data remained
This commit is contained in:
@@ -657,49 +657,20 @@ export default class ProjectViewView extends Vue {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.givesToThis = [];
|
||||||
this.loadGives();
|
this.loadGives();
|
||||||
|
|
||||||
|
this.givesProvidedByThis = [];
|
||||||
this.loadGivesProvidedBy();
|
this.loadGivesProvidedBy();
|
||||||
|
|
||||||
|
this.offersToThis = [];
|
||||||
this.loadOffers();
|
this.loadOffers();
|
||||||
|
|
||||||
|
this.fulfillersToThis = [];
|
||||||
this.loadPlanFulfillersTo();
|
this.loadPlanFulfillersTo();
|
||||||
|
|
||||||
const fulfilledByUrl =
|
this.fulfilledByThis = null;
|
||||||
this.apiServer +
|
this.loadPlanFulfilledBy();
|
||||||
"/api/v2/report/planFulfilledByPlan?planHandleId=" +
|
|
||||||
encodeURIComponent(projectId);
|
|
||||||
try {
|
|
||||||
const resp = await this.axios.get(fulfilledByUrl, { headers });
|
|
||||||
if (resp.status === 200) {
|
|
||||||
this.fulfilledByThis = resp.data.data;
|
|
||||||
} else {
|
|
||||||
this.$notify(
|
|
||||||
{
|
|
||||||
group: "alert",
|
|
||||||
type: "danger",
|
|
||||||
title: "Error",
|
|
||||||
text: "Failed to retrieve plans fulfilled by this project.",
|
|
||||||
},
|
|
||||||
5000,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error: unknown) {
|
|
||||||
const serverError = error as AxiosError;
|
|
||||||
this.$notify(
|
|
||||||
{
|
|
||||||
group: "alert",
|
|
||||||
type: "danger",
|
|
||||||
title: "Error",
|
|
||||||
text: "Something went wrong retrieving plans fulfilled by this project.",
|
|
||||||
},
|
|
||||||
5000,
|
|
||||||
);
|
|
||||||
console.error(
|
|
||||||
"Error retrieving plans fulfilled by this project:",
|
|
||||||
serverError.message,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadGives() {
|
async loadGives() {
|
||||||
@@ -749,6 +720,56 @@ export default class ProjectViewView extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async loadGivesProvidedBy() {
|
||||||
|
const providedByUrl =
|
||||||
|
this.apiServer +
|
||||||
|
"/api/v2/report/givesProvidedBy?providerId=" +
|
||||||
|
encodeURIComponent(this.projectId);
|
||||||
|
let postfix = "";
|
||||||
|
if (this.givesProvidedByThis.length > 0) {
|
||||||
|
postfix =
|
||||||
|
"&beforeId=" +
|
||||||
|
this.givesProvidedByThis[this.givesProvidedByThis.length - 1].jwtId;
|
||||||
|
}
|
||||||
|
const providedByFullUrl = providedByUrl + postfix;
|
||||||
|
|
||||||
|
const headers = await serverUtil.getHeaders(this.activeDid);
|
||||||
|
try {
|
||||||
|
const resp = await this.axios.get(providedByFullUrl, { headers });
|
||||||
|
if (resp.status === 200) {
|
||||||
|
this.givesProvidedByThis = this.givesProvidedByThis.concat(
|
||||||
|
resp.data.data,
|
||||||
|
);
|
||||||
|
this.givesProvidedByHitLimit = resp.data.hitLimit;
|
||||||
|
} else {
|
||||||
|
this.$notify(
|
||||||
|
{
|
||||||
|
group: "alert",
|
||||||
|
type: "danger",
|
||||||
|
title: "Error",
|
||||||
|
text: "Failed to retrieve gives that were provided by this project.",
|
||||||
|
},
|
||||||
|
5000,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error: unknown) {
|
||||||
|
const serverError = error as AxiosError;
|
||||||
|
this.$notify(
|
||||||
|
{
|
||||||
|
group: "alert",
|
||||||
|
type: "danger",
|
||||||
|
title: "Error",
|
||||||
|
text: "Something went wrong retrieving gives that were provided by this project.",
|
||||||
|
},
|
||||||
|
5000,
|
||||||
|
);
|
||||||
|
console.error(
|
||||||
|
"Something went wrong retrieving gives that were provided by this project:",
|
||||||
|
serverError.message,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async loadOffers() {
|
async loadOffers() {
|
||||||
const offersUrl =
|
const offersUrl =
|
||||||
this.apiServer +
|
this.apiServer +
|
||||||
@@ -844,34 +865,23 @@ export default class ProjectViewView extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadGivesProvidedBy() {
|
async loadPlanFulfilledBy() {
|
||||||
const providedByUrl =
|
const fulfilledByUrl =
|
||||||
this.apiServer +
|
this.apiServer +
|
||||||
"/api/v2/report/givesProvidedBy?providerId=" +
|
"/api/v2/report/planFulfilledByPlan?planHandleId=" +
|
||||||
encodeURIComponent(this.projectId);
|
encodeURIComponent(this.projectId);
|
||||||
let postfix = "";
|
|
||||||
if (this.givesProvidedByThis.length > 0) {
|
|
||||||
postfix =
|
|
||||||
"&beforeId=" +
|
|
||||||
this.givesProvidedByThis[this.givesProvidedByThis.length - 1].jwtId;
|
|
||||||
}
|
|
||||||
const providedByFullUrl = providedByUrl + postfix;
|
|
||||||
|
|
||||||
const headers = await serverUtil.getHeaders(this.activeDid);
|
const headers = await serverUtil.getHeaders(this.activeDid);
|
||||||
try {
|
try {
|
||||||
const resp = await this.axios.get(providedByFullUrl, { headers });
|
const resp = await this.axios.get(fulfilledByUrl, { headers });
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
this.givesProvidedByThis = this.givesProvidedByThis.concat(
|
this.fulfilledByThis = resp.data.data;
|
||||||
resp.data.data,
|
|
||||||
);
|
|
||||||
this.givesProvidedByHitLimit = resp.data.hitLimit;
|
|
||||||
} else {
|
} else {
|
||||||
this.$notify(
|
this.$notify(
|
||||||
{
|
{
|
||||||
group: "alert",
|
group: "alert",
|
||||||
type: "danger",
|
type: "danger",
|
||||||
title: "Error",
|
title: "Error",
|
||||||
text: "Failed to retrieve gives that were provided by this project.",
|
text: "Failed to retrieve plans fulfilled by this project.",
|
||||||
},
|
},
|
||||||
5000,
|
5000,
|
||||||
);
|
);
|
||||||
@@ -883,12 +893,12 @@ export default class ProjectViewView extends Vue {
|
|||||||
group: "alert",
|
group: "alert",
|
||||||
type: "danger",
|
type: "danger",
|
||||||
title: "Error",
|
title: "Error",
|
||||||
text: "Something went wrong retrieving gives that were provided by this project.",
|
text: "Something went wrong retrieving plans fulfilled by this project.",
|
||||||
},
|
},
|
||||||
5000,
|
5000,
|
||||||
);
|
);
|
||||||
console.error(
|
console.error(
|
||||||
"Something went wrong retrieving gives that were provided by this project:",
|
"Error retrieving plans fulfilled by this project:",
|
||||||
serverError.message,
|
serverError.message,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user