refactor invite link & add test

This commit is contained in:
2024-10-08 08:36:32 -06:00
parent 2e100aedf5
commit 98afa8a259
8 changed files with 81 additions and 37 deletions

View File

@@ -46,11 +46,14 @@
>
<td
class="py-2 text-center text-blue-500"
@click="copyInviteAndNotify(invite.jwt)"
@click="copyInviteAndNotify(invite.inviteIdentifier, invite.jwt)"
title="{{ inviteLink(invite.jwt) }}"
>
{{ getTruncatedInviteId(invite.inviteIdentifier) }}
</td>
<td class="py-2 text-left">{{ invite.notes }}</td>
<td class="py-2 text-left" :data-testId="inviteLink(invite.jwt)">
{{ invite.notes }}
</td>
<td class="py-2 text-center">
{{ invite.expiresAt.substring(0, 10) }}
</td>
@@ -134,31 +137,31 @@ export default class InviteOneView extends Vue {
return `${redeemedBy.slice(0, 13)}...${redeemedBy.slice(-3)}`;
}
copyInviteAndNotify(jwt: string) {
const link = APP_SERVER + "/contacts?inviteJwt=" + jwt;
useClipboard().copy(link);
inviteLink(jwt: string): string {
return APP_SERVER + "/contacts?inviteJwt=" + jwt;
}
copyInviteAndNotify(inviteId: string, jwt: string) {
useClipboard().copy(this.inviteLink(jwt));
this.$notify(
{
group: "alert",
type: "success",
title: "Copied",
text: "Invitation link is copied to clipboard.",
text: "Link for invite " + inviteId + " is copied to clipboard.",
},
3000,
);
}
async createInvite() {
const inviteIdentifier =
Math.random().toString(36).substring(2) +
Math.random().toString(36).substring(2) +
Math.random().toString(36).substring(2);
(this.$refs.inviteDialog as InviteDialog).open(
"Invitation Note",
`These notes are only for your use, to make comments for a link to recall later if redeemed by someone.
Note that this is sent to the server.`,
inviteIdentifier,
async (notes, expiresAt) => {
try {
const inviteIdentifier =
Math.random().toString(36).substring(2) +
Math.random().toString(36).substring(2) +
Math.random().toString(36).substring(2);
const headers = await getHeaders(this.activeDid);
if (!expiresAt) {
throw {