forked from trent_larson/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.givesProvidedByThis = [];
|
||||
this.loadGivesProvidedBy();
|
||||
|
||||
this.offersToThis = [];
|
||||
this.loadOffers();
|
||||
|
||||
this.fulfillersToThis = [];
|
||||
this.loadPlanFulfillersTo();
|
||||
|
||||
const fulfilledByUrl =
|
||||
this.apiServer +
|
||||
"/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,
|
||||
);
|
||||
}
|
||||
this.fulfilledByThis = null;
|
||||
this.loadPlanFulfilledBy();
|
||||
}
|
||||
|
||||
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() {
|
||||
const offersUrl =
|
||||
this.apiServer +
|
||||
@@ -844,34 +865,23 @@ export default class ProjectViewView extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async loadGivesProvidedBy() {
|
||||
const providedByUrl =
|
||||
async loadPlanFulfilledBy() {
|
||||
const fulfilledByUrl =
|
||||
this.apiServer +
|
||||
"/api/v2/report/givesProvidedBy?providerId=" +
|
||||
"/api/v2/report/planFulfilledByPlan?planHandleId=" +
|
||||
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 });
|
||||
const resp = await this.axios.get(fulfilledByUrl, { headers });
|
||||
if (resp.status === 200) {
|
||||
this.givesProvidedByThis = this.givesProvidedByThis.concat(
|
||||
resp.data.data,
|
||||
);
|
||||
this.givesProvidedByHitLimit = resp.data.hitLimit;
|
||||
this.fulfilledByThis = resp.data.data;
|
||||
} else {
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "Failed to retrieve gives that were provided by this project.",
|
||||
text: "Failed to retrieve plans fulfilled by this project.",
|
||||
},
|
||||
5000,
|
||||
);
|
||||
@@ -883,12 +893,12 @@ export default class ProjectViewView extends Vue {
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
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,
|
||||
);
|
||||
console.error(
|
||||
"Something went wrong retrieving gives that were provided by this project:",
|
||||
"Error retrieving plans fulfilled by this project:",
|
||||
serverError.message,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user