Skip to content

Commit

Permalink
Merge pull request #1193 from hypersign-protocol/backlog
Browse files Browse the repository at this point in the history
Backlog
  • Loading branch information
Pratap2018 authored May 26, 2022
2 parents 1cf7210 + 5f7441c commit a6a792e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/views/admin/Events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ i {
style="cursor: pointer"
>
<i class="fa fa-clone"></i>
</span>
<span
@click="deleteProject(project)"
title="Click to delete this event"
style="cursor: pointer"
>
<i class="fas fa-trash"></i>
</span>
<span
v-if="project.projectStatus == true"
Expand Down Expand Up @@ -1004,6 +1011,61 @@ export default {
this.tagsTemp = project.tags;
await this.saveProject();
},
async deleteProject(project) {
try {
this.isLoading = true;
this.project = { ...project };
if (!this.project._id) throw new Error("No project found");
const url = `${this.$config.studioServer.BASE_URL}api/v1/project/${project._id}`;
const headers = {
Authorization: `Bearer ${this.authToken}`,
AccessToken: `Bearer ${this.accessToken}`,
};
const resp = await fetch(url, {
headers,
method: "DELETE",
});
const json = await resp.json();
//ToDO:- check if its a json
if(!json || !json.isArchived){
throw new Error("Could not delete the event")
}
console.log(this.projects.length)
const index = this.projects
.map((project) => project._id)
.indexOf(json._id);
console.log(index)
this.projects.splice(index, 1);
console.log(this.projects.length)
this.projectsToShow = this.projects.slice(0, this.perPage);
const tempProject = JSON.parse(localStorage.getItem("userProjects"));
localStorage.removeItem("userProjects");
tempProject.projects.splice(index, 1);
localStorage.setItem(
"userProjects",
JSON.stringify({
projects: tempProject.projects,
count: tempProject.projects.length,
})
);
if (json) {
if (!resp.ok) {
return this.notifyErr(json);
} else {
this.notifySuccess("Event is deleted successfully");
}
} else {
throw new Error("Error while deleting event");
}
} catch (e) {
this.notifyErr(e.message);
} finally {
this.isLoading = false;
}
},
async saveProject() {
try {
if (this.checkIfEverythingIsFilled() !== true) {
Expand Down
4 changes: 4 additions & 0 deletions src/views/participant/Event.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<ErrorMessage v-if="!eventData.projectStatus" errorMessage="Event is over" />
<Action v-if="eventData.projectStatus" :userProfile="userProfileData" :ActionSchema="eventActionsToShow" :prizeData="prizeData" @UserUpdateEvent="updateUserData" />
</template>
<div class="footer">
<b>Disclaimer:</b>
Anyone can create campaigns on HyperFyre, rewards are distributed by the campaign creator and HyperFyre is not responsible for reward distribution.
</div>
</div>
</template>
<script>
Expand Down

0 comments on commit a6a792e

Please sign in to comment.