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. 15
      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 class="dialog">
<h1 class="text-xl font-bold text-center mb-4">
{{ customTitle || message + " " + giver?.name || "somebody not named" }}
{{ customTitle }}
</h1>
<input
type="text"
@ -42,11 +42,9 @@
name: 'gifted-details',
query: {
amountInput,
customTitle,
description,
giverDid: giver?.did,
giverName: giver?.name,
message,
offerId,
projectId,
recipientDid: receiver?.did,
@ -104,7 +102,6 @@ import { Contact } from "@/db/tables/contacts";
export default class GiftedDialog extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
@Prop message = "";
@Prop projectId = "";
activeDid = "";
@ -337,7 +334,7 @@ export default class GiftedDialog extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.error("Error with give recordation caught:", error);
const message =
const errorMessage =
error.userMessage ||
error.response?.data?.error?.message ||
"There was an error recording the give.";
@ -346,7 +343,7 @@ export default class GiftedDialog extends Vue {
group: "alert",
type: "danger",
title: "Error",
text: message,
text: errorMessage,
},
-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 identity nullable -- which means no private info will be returned
* @param handleId nullable, in which case "undefined" will be returned
* @param identity nullable, in which case no private info will be returned
* @param axios
* @param apiServer
*/
@ -464,7 +464,7 @@ export async function getPlanFromCache(
identity: IIdentifier | null,
axios: Axios,
apiServer: string,
) {
): Promise<PlanSummaryRecord | undefined> {
if (!handleId) {
return undefined;
}

3
src/views/ClaimView.vue

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

13
src/views/ContactGiftingView.vue

@ -66,11 +66,7 @@
</li>
</ul>
<GiftedDialog
ref="customDialog"
message="Received from"
:projectId="projectId"
/>
<GiftedDialog ref="customDialog" :projectId="projectId" />
</section>
</template>
@ -167,7 +163,12 @@ export default class ContactGiftingView extends Vue {
const recipient = this.projectId
? undefined
: { 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>

6
src/views/ContactsView.vue

@ -1101,7 +1101,7 @@ export default class ContactsView extends Vue {
}
let callback: (amount: number) => void;
let customTitle = "Given";
let customTitle = "";
// choose whether to open dialog to user or from user
if (giverDid == this.activeDid) {
callback = (amount: number) => {
@ -1109,7 +1109,7 @@ export default class ContactsView extends Vue {
newList[recipientDid] = (newList[recipientDid] || 0) + amount;
this.givenByMeUnconfirmed = newList;
};
customTitle = "To " + receiver.name;
customTitle = "Given to " + receiver.name;
} else {
// must be (recipientDid == this.activeDid)
callback = (amount: number) => {
@ -1117,7 +1117,7 @@ export default class ContactsView extends Vue {
newList[giverDid] = (newList[giverDid] || 0) + amount;
this.givenToMeUnconfirmed = newList;
};
customTitle = "From " + giver.name;
customTitle = "Received from " + giver.name;
}
(this.$refs.customGivenDialog as GiftedDialog).open(
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-xl font-bold text-center mb-4">
{{ customTitle || message + " " + giverName || "somebody not named" }}
</h1>
<div>
<span>From {{ giverName || "somebody not named" }}</span>
<span> to {{ recipientName || "somebody not named" }}</span>
</div>
</h1>
<textarea
class="block w-full rounded border border-slate-400 mb-2 px-3 py-2"
placeholder="What was received"
@ -81,7 +78,7 @@
icon="check"
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 v-if="showGivenToUser" class="mt-4">
@ -127,7 +124,7 @@ 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 { createAndSubmitGive, getPlanFromCache } from "@/libs/endorserServer";
import * as libsUtil from "@/libs/util";
import { accessToken } from "@/libs/crypto";
import GiftedPhotoDialog from "@/components/GiftedPhotoDialog.vue";
@ -146,7 +143,6 @@ export default class GiftedDetails extends Vue {
apiServer = "";
amountInput = "0";
customTitle = "";
description = "";
givenToUser = false;
giverDid: string | undefined;
@ -156,6 +152,7 @@ export default class GiftedDetails extends Vue {
message = "";
offerId = "";
projectId = "";
projectName = "a project";
recipientDid = "";
recipientName = "";
showGivenToUser = false;
@ -165,7 +162,6 @@ export default class GiftedDetails extends Vue {
async mounted() {
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.giverDid = this.$route.query.giverDid as string;
this.giverName = this.$route.query.giverName as string;
@ -209,6 +205,21 @@ export default class GiftedDetails extends Vue {
-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() {
@ -429,7 +440,7 @@ export default class GiftedDetails extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.error("Error with give recordation caught:", error);
const message =
const errorMessage =
error.userMessage ||
error.response?.data?.error?.message ||
"There was an error recording the give.";
@ -438,7 +449,7 @@ export default class GiftedDetails extends Vue {
group: "alert",
type: "danger",
title: "Error",
text: message,
text: errorMessage,
},
-1,
);

15
src/views/HomeView.vue

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

16
src/views/ProjectViewView.vue

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

Loading…
Cancel
Save