Browse Source

remove message confusion, add project name during give-details

pull/115/head
Trent Larson 5 months ago
parent
commit
ab6d2e3d4b
  1. 9
      src/components/GiftedDialog.vue
  2. 6
      src/libs/endorserServer.ts
  3. 3
      src/views/ClaimView.vue
  4. 13
      src/views/ContactGiftingView.vue
  5. 6
      src/views/ContactsView.vue
  6. 31
      src/views/GiftedDetails.vue
  7. 11
      src/views/HomeView.vue
  8. 16
      src/views/ProjectViewView.vue

9
src/components/GiftedDialog.vue

@ -2,7 +2,7 @@
<div v-if="visible" class="dialog-overlay"> <div v-if="visible" class="dialog-overlay">
<div class="dialog"> <div class="dialog">
<h1 class="text-xl font-bold text-center mb-4"> <h1 class="text-xl font-bold text-center mb-4">
{{ customTitle || message + " " + giver?.name || "somebody not named" }} {{ customTitle }}
</h1> </h1>
<input <input
type="text" type="text"
@ -42,11 +42,9 @@
name: 'gifted-details', name: 'gifted-details',
query: { query: {
amountInput, amountInput,
customTitle,
description, description,
giverDid: giver?.did, giverDid: giver?.did,
giverName: giver?.name, giverName: giver?.name,
message,
offerId, offerId,
projectId, projectId,
recipientDid: receiver?.did, recipientDid: receiver?.did,
@ -104,7 +102,6 @@ import { Contact } from "@/db/tables/contacts";
export default class GiftedDialog extends Vue { export default class GiftedDialog extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void; $notify!: (notification: NotificationIface, timeout?: number) => void;
@Prop message = "";
@Prop projectId = ""; @Prop projectId = "";
activeDid = ""; activeDid = "";
@ -337,7 +334,7 @@ export default class GiftedDialog extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) { } catch (error: any) {
console.error("Error with give recordation caught:", error); console.error("Error with give recordation caught:", error);
const message = const errorMessage =
error.userMessage || error.userMessage ||
error.response?.data?.error?.message || error.response?.data?.error?.message ||
"There was an error recording the give."; "There was an error recording the give.";
@ -346,7 +343,7 @@ export default class GiftedDialog extends Vue {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: message, text: errorMessage,
}, },
-1, -1,
); );

6
src/libs/endorserServer.ts

@ -454,8 +454,8 @@ async function getHeaders(identity: IIdentifier | null) {
} }
/** /**
* @param handleId nullable -- which means that "undefined" will be returned * @param handleId nullable, in which case "undefined" will be returned
* @param identity nullable -- which means no private info will be returned * @param identity nullable, in which case no private info will be returned
* @param axios * @param axios
* @param apiServer * @param apiServer
*/ */
@ -464,7 +464,7 @@ export async function getPlanFromCache(
identity: IIdentifier | null, identity: IIdentifier | null,
axios: Axios, axios: Axios,
apiServer: string, apiServer: string,
) { ): Promise<PlanSummaryRecord | undefined> {
if (!handleId) { if (!handleId) {
return undefined; return undefined;
} }

3
src/views/ClaimView.vue

@ -146,7 +146,7 @@
<fa icon="hand-holding-heart" class="ml-2 text-white cursor-pointer" /> <fa icon="hand-holding-heart" class="ml-2 text-white cursor-pointer" />
</button> </button>
</div> </div>
<GiftedDialog ref="customGiveDialog" message="Offer fulfilled by" /> <GiftedDialog ref="customGiveDialog" />
<div v-if="libsUtil.giveIsConfirmable(veriClaim)"> <div v-if="libsUtil.giveIsConfirmable(veriClaim)">
<h2 class="font-bold uppercase text-xl mt-8 mb-2">Confirmations</h2> <h2 class="font-bold uppercase text-xl mt-8 mb-2">Confirmations</h2>
@ -782,6 +782,7 @@ export default class ClaimView extends Vue {
giver, giver,
undefined, undefined,
this.veriClaim.handleId, this.veriClaim.handleId,
"Offer fulfilled by " + (giver?.name || "someone not named"),
); );
} }

13
src/views/ContactGiftingView.vue

@ -66,11 +66,7 @@
</li> </li>
</ul> </ul>
<GiftedDialog <GiftedDialog ref="customDialog" :projectId="projectId" />
ref="customDialog"
message="Received from"
:projectId="projectId"
/>
</section> </section>
</template> </template>
@ -167,7 +163,12 @@ export default class ContactGiftingView extends Vue {
const recipient = this.projectId const recipient = this.projectId
? undefined ? undefined
: { did: this.activeDid, name: "you" }; : { did: this.activeDid, name: "you" };
(this.$refs.customDialog as GiftedDialog).open(giver, recipient); (this.$refs.customDialog as GiftedDialog).open(
giver,
recipient,
undefined,
"Given by " + (giver?.name || "someone not named"),
);
} }
} }
</script> </script>

6
src/views/ContactsView.vue

@ -1101,7 +1101,7 @@ export default class ContactsView extends Vue {
} }
let callback: (amount: number) => void; let callback: (amount: number) => void;
let customTitle = "Given"; let customTitle = "";
// choose whether to open dialog to user or from user // choose whether to open dialog to user or from user
if (giverDid == this.activeDid) { if (giverDid == this.activeDid) {
callback = (amount: number) => { callback = (amount: number) => {
@ -1109,7 +1109,7 @@ export default class ContactsView extends Vue {
newList[recipientDid] = (newList[recipientDid] || 0) + amount; newList[recipientDid] = (newList[recipientDid] || 0) + amount;
this.givenByMeUnconfirmed = newList; this.givenByMeUnconfirmed = newList;
}; };
customTitle = "To " + receiver.name; customTitle = "Given to " + receiver.name;
} else { } else {
// must be (recipientDid == this.activeDid) // must be (recipientDid == this.activeDid)
callback = (amount: number) => { callback = (amount: number) => {
@ -1117,7 +1117,7 @@ export default class ContactsView extends Vue {
newList[giverDid] = (newList[giverDid] || 0) + amount; newList[giverDid] = (newList[giverDid] || 0) + amount;
this.givenToMeUnconfirmed = newList; this.givenToMeUnconfirmed = newList;
}; };
customTitle = "From " + giver.name; customTitle = "Received from " + giver.name;
} }
(this.$refs.customGivenDialog as GiftedDialog).open( (this.$refs.customGivenDialog as GiftedDialog).open(
giver, giver,

31
src/views/GiftedDetails.vue

@ -18,12 +18,9 @@
<h1 class="text-4xl text-center font-light px-4 mb-4">What Was Given</h1> <h1 class="text-4xl text-center font-light px-4 mb-4">What Was Given</h1>
<h1 class="text-xl font-bold text-center mb-4"> <h1 class="text-xl font-bold text-center mb-4">
{{ customTitle || message + " " + giverName || "somebody not named" }}
</h1>
<div>
<span>From {{ giverName || "somebody not named" }}</span> <span>From {{ giverName || "somebody not named" }}</span>
<span> to {{ recipientName || "somebody not named" }}</span> <span> to {{ recipientName || "somebody not named" }}</span>
</div> </h1>
<textarea <textarea
class="block w-full rounded border border-slate-400 mb-2 px-3 py-2" class="block w-full rounded border border-slate-400 mb-2 px-3 py-2"
placeholder="What was received" placeholder="What was received"
@ -81,7 +78,7 @@
icon="check" icon="check"
class="bg-slate-500 text-white h-5 w-5 px-0.5 py-0.5 mr-2 rounded" class="bg-slate-500 text-white h-5 w-5 px-0.5 py-0.5 mr-2 rounded"
/> />
<label class="text-sm">This is given to a project</label> <label class="text-sm">This is given to {{ projectName }}</label>
</div> </div>
<div v-if="showGivenToUser" class="mt-4"> <div v-if="showGivenToUser" class="mt-4">
@ -127,7 +124,7 @@ import QuickNav from "@/components/QuickNav.vue";
import TopMessage from "@/components/TopMessage.vue"; import TopMessage from "@/components/TopMessage.vue";
import { db } from "@/db/index"; import { db } from "@/db/index";
import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings";
import { createAndSubmitGive } from "@/libs/endorserServer"; import { createAndSubmitGive, getPlanFromCache } from "@/libs/endorserServer";
import * as libsUtil from "@/libs/util"; import * as libsUtil from "@/libs/util";
import { accessToken } from "@/libs/crypto"; import { accessToken } from "@/libs/crypto";
import GiftedPhotoDialog from "@/components/GiftedPhotoDialog.vue"; import GiftedPhotoDialog from "@/components/GiftedPhotoDialog.vue";
@ -146,7 +143,6 @@ export default class GiftedDetails extends Vue {
apiServer = ""; apiServer = "";
amountInput = "0"; amountInput = "0";
customTitle = "";
description = ""; description = "";
givenToUser = false; givenToUser = false;
giverDid: string | undefined; giverDid: string | undefined;
@ -156,6 +152,7 @@ export default class GiftedDetails extends Vue {
message = ""; message = "";
offerId = ""; offerId = "";
projectId = ""; projectId = "";
projectName = "a project";
recipientDid = ""; recipientDid = "";
recipientName = ""; recipientName = "";
showGivenToUser = false; showGivenToUser = false;
@ -165,7 +162,6 @@ export default class GiftedDetails extends Vue {
async mounted() { async mounted() {
this.amountInput = this.$route.query.amountInput as string; this.amountInput = this.$route.query.amountInput as string;
this.customTitle = this.$route.query.customTitle as string;
this.description = this.$route.query.description as string; this.description = this.$route.query.description as string;
this.giverDid = this.$route.query.giverDid as string; this.giverDid = this.$route.query.giverDid as string;
this.giverName = this.$route.query.giverName as string; this.giverName = this.$route.query.giverName as string;
@ -209,6 +205,21 @@ export default class GiftedDetails extends Vue {
-1, -1,
); );
} }
if (this.projectId) {
console.log("Getting project name from cache", this.projectId);
const identity = await libsUtil.getIdentity(this.activeDid);
const project = await getPlanFromCache(
this.projectId,
identity,
this.axios,
this.apiServer,
);
console.log("Got project name from cache", project);
this.projectName = project?.name
? "the project " + project.name
: "a project";
}
} }
changeUnitCode() { changeUnitCode() {
@ -429,7 +440,7 @@ export default class GiftedDetails extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) { } catch (error: any) {
console.error("Error with give recordation caught:", error); console.error("Error with give recordation caught:", error);
const message = const errorMessage =
error.userMessage || error.userMessage ||
error.response?.data?.error?.message || error.response?.data?.error?.message ||
"There was an error recording the give."; "There was an error recording the give.";
@ -438,7 +449,7 @@ export default class GiftedDetails extends Vue {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: message, text: errorMessage,
}, },
-1, -1,
); );

11
src/views/HomeView.vue

@ -168,7 +168,7 @@
</div> </div>
</div> </div>
<GiftedDialog ref="customDialog" message="Received from" /> <GiftedDialog ref="customDialog" />
<GiftedPrompts ref="giftedPrompts" /> <GiftedPrompts ref="giftedPrompts" />
<FeedFilters ref="feedFilters" /> <FeedFilters ref="feedFilters" />
@ -719,10 +719,15 @@ export default class HomeView extends Vue {
} }
openDialog(giver?: GiverReceiverInputInfo) { openDialog(giver?: GiverReceiverInputInfo) {
(this.$refs.customDialog as GiftedDialog).open(giver, { (this.$refs.customDialog as GiftedDialog).open(
giver,
{
did: this.activeDid, did: this.activeDid,
name: "you", name: "you",
}); },
undefined,
"Given by " + (giver?.name || "someone not named"),
);
} }
openGiftedPrompts() { openGiftedPrompts() {

16
src/views/ProjectViewView.vue

@ -125,12 +125,6 @@
<OfferDialog ref="customOfferDialog" :projectId="this.projectId" /> <OfferDialog ref="customOfferDialog" :projectId="this.projectId" />
<div v-if="activeDid"> <div v-if="activeDid">
<GiftedDialog
ref="customGiveDialog"
message="Received from"
:projectId="this.projectId"
>
</GiftedDialog>
<div class="text-center"> <div class="text-center">
<p class="mt-2 mb-4 text-center">Record a contribution from:</p> <p class="mt-2 mb-4 text-center">Record a contribution from:</p>
</div> </div>
@ -182,6 +176,8 @@
> >
Show More Contacts&hellip; Show More Contacts&hellip;
</a> </a>
<GiftedDialog ref="customGiveDialog" :projectId="this.projectId" />
</div> </div>
<!-- Gifts to & from this --> <!-- Gifts to & from this -->
@ -698,7 +694,12 @@ export default class ProjectViewView extends Vue {
} }
openGiftDialog(contact?: GiverReceiverInputInfo) { openGiftDialog(contact?: GiverReceiverInputInfo) {
(this.$refs.customGiveDialog as GiftedDialog).open(contact); (this.$refs.customGiveDialog as GiftedDialog).open(
contact,
undefined,
undefined,
"Given by " + (contact?.name || "someone not named"),
);
} }
openOfferDialog() { openOfferDialog() {
@ -743,6 +744,7 @@ export default class ProjectViewView extends Vue {
giver, giver,
undefined, undefined,
offer.handleId, offer.handleId,
"Given by " + (giver?.name || "someone not named"),
); );
} }

Loading…
Cancel
Save