|
|
@ -52,12 +52,23 @@ |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="flex justify-center mb-4 mt-4"> |
|
|
|
<span v-if="imageUrl"> |
|
|
|
Includes Image: |
|
|
|
<a :href="imageUrl" target="_blank" class="text-blue-500 ml-4">View</a> |
|
|
|
<fa |
|
|
|
icon="trash-can" |
|
|
|
@click="confirmDeleteImage" |
|
|
|
class="text-red-500 fa-fw ml-8" |
|
|
|
/> |
|
|
|
</span> |
|
|
|
<span v-else> |
|
|
|
<router-link |
|
|
|
:to="{ name: 'gifted-photo' }" |
|
|
|
class="bg-blue-500 text-white px-1.5 py-1 rounded-md" |
|
|
|
> |
|
|
|
<fa icon="camera" class="fa-fw" /> |
|
|
|
</router-link> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
<div class="mt-4"> |
|
|
|
<input type="checkbox" class="h-6 w-6 mr-2" v-model="givenToUser" /> |
|
|
@ -88,13 +99,14 @@ |
|
|
|
<script lang="ts"> |
|
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
|
|
|
|
|
import { NotificationIface } from "@/constants/app"; |
|
|
|
import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "@/constants/app"; |
|
|
|
import QuickNav from "@/components/QuickNav.vue"; |
|
|
|
import TopMessage from "@/components/TopMessage.vue"; |
|
|
|
import { db } from "@/db/index"; |
|
|
|
import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; |
|
|
|
import { createAndSubmitGive } from "@/libs/endorserServer"; |
|
|
|
import * as libsUtil from "@/libs/util"; |
|
|
|
import { accessToken } from "@/libs/crypto"; |
|
|
|
|
|
|
|
@Component({ |
|
|
|
components: { |
|
|
@ -113,6 +125,7 @@ export default class GiftedDetails extends Vue { |
|
|
|
givenToUser = false; |
|
|
|
giverDid: string | undefined; |
|
|
|
giverName = ""; |
|
|
|
imageUrl = ""; |
|
|
|
isTrade = false; |
|
|
|
message = ""; |
|
|
|
offerId = ""; |
|
|
@ -126,6 +139,7 @@ export default class GiftedDetails extends Vue { |
|
|
|
this.description = this.$route.query.description as string; |
|
|
|
this.giverDid = this.$route.query.giverDid as string; |
|
|
|
this.giverName = this.$route.query.giverName as string; |
|
|
|
this.imageUrl = localStorage.getItem("imageUrl") || ""; |
|
|
|
this.message = this.$route.query.message as string; |
|
|
|
this.offerId = this.$route.query.offerId as string; |
|
|
|
this.projectId = this.$route.query.projectId as string; |
|
|
@ -173,6 +187,57 @@ export default class GiftedDetails extends Vue { |
|
|
|
this.$router.back(); |
|
|
|
} |
|
|
|
|
|
|
|
confirmDeleteImage() { |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "modal", |
|
|
|
type: "confirm", |
|
|
|
title: "Are you sure you want to delete the image?", |
|
|
|
text: "", |
|
|
|
onYes: this.deleteImage, |
|
|
|
}, |
|
|
|
-1, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
async deleteImage() { |
|
|
|
const identity = await libsUtil.getIdentity(this.activeDid); |
|
|
|
const token = await accessToken(identity); |
|
|
|
const response = await this.axios.delete( |
|
|
|
DEFAULT_IMAGE_API_SERVER + "/image/" + encodeURIComponent(this.imageUrl), |
|
|
|
{ |
|
|
|
headers: { |
|
|
|
Authorization: `Bearer ${token}`, |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
if (response.status === 204) { |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "success", |
|
|
|
title: "Deleted", |
|
|
|
text: "That image record was deleted.", |
|
|
|
}, |
|
|
|
5000, |
|
|
|
); |
|
|
|
} else { |
|
|
|
console.error("Error deleting image:", response); |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: "There was an error deleting the image.", |
|
|
|
}, |
|
|
|
5000, |
|
|
|
); |
|
|
|
return; |
|
|
|
} |
|
|
|
localStorage.removeItem("imageUrl"); |
|
|
|
this.imageUrl = ""; |
|
|
|
} |
|
|
|
|
|
|
|
async confirm() { |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|