forked from trent_larson/crowd-funder-for-time-pwa
add 'isRegistered' flag to encrypted contents in an onboarding meeting
This commit is contained in:
@@ -171,13 +171,13 @@ interface Member {
|
||||
admitted: boolean;
|
||||
content: string;
|
||||
memberId: number;
|
||||
registered: boolean;
|
||||
}
|
||||
|
||||
interface DecryptedMember {
|
||||
member: Member;
|
||||
name: string;
|
||||
did: string;
|
||||
isRegistered: boolean;
|
||||
}
|
||||
|
||||
@Component
|
||||
@@ -258,6 +258,7 @@ export default class MembersList extends Vue {
|
||||
member: member,
|
||||
name: content.name,
|
||||
did: content.did,
|
||||
isRegistered: !!content.isRegistered,
|
||||
});
|
||||
if (isFirstEntry && content.did === this.activeDid) {
|
||||
this.isOrganizer = true;
|
||||
@@ -293,7 +294,7 @@ export default class MembersList extends Vue {
|
||||
group: "alert",
|
||||
type: "info",
|
||||
title: "Admission info",
|
||||
text: "This is to register people and admit them to the meeting. A '+' symbol means they are not yet admitted and you can register and admit them. A '-' means you can remove them, but they will stay registered.",
|
||||
text: "This is to register people in Time Safari and to admit them to the meeting. A '+' symbol means they are not yet admitted and you can register and admit them. A '-' means you can remove them, but they will stay registered.",
|
||||
},
|
||||
10000,
|
||||
);
|
||||
@@ -331,67 +332,73 @@ export default class MembersList extends Vue {
|
||||
return this.contacts.find((contact) => contact.did === did);
|
||||
}
|
||||
|
||||
checkWhetherContactBeforeAdmitting(member: DecryptedMember) {
|
||||
const contact = this.getContactFor(member.did);
|
||||
if (!member.member.admitted && !contact) {
|
||||
checkWhetherContactBeforeAdmitting(decrMember: DecryptedMember) {
|
||||
const contact = this.getContactFor(decrMember.did);
|
||||
if (!decrMember.member.admitted && !contact) {
|
||||
// If not a contact, show confirmation dialog
|
||||
this.$notify({
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: "Add as Contact First?",
|
||||
text: "This person is not in your contacts. Would you like to add them as a contact first?",
|
||||
yesText: "Add as Contact",
|
||||
noText: "Skip Adding Contact",
|
||||
onYes: async () => {
|
||||
await this.addAsContact(member);
|
||||
// After adding as contact, proceed with admission
|
||||
await this.toggleAdmission(member);
|
||||
},
|
||||
onNo: async () => {
|
||||
// If they choose not to add as contact, show second confirmation
|
||||
this.$notify({
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: "Continue Without Adding?",
|
||||
text: "Are you sure you want to proceed with admission even though they are not a contact?",
|
||||
yesText: "Continue",
|
||||
onYes: async () => {
|
||||
await this.toggleAdmission(member);
|
||||
},
|
||||
onCancel: async () => {
|
||||
// Do nothing, effectively canceling the operation
|
||||
},
|
||||
this.$notify(
|
||||
{
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: "Add as Contact First?",
|
||||
text: "This person is not in your contacts. Would you like to add them as a contact first?",
|
||||
yesText: "Add as Contact",
|
||||
noText: "Skip Adding Contact",
|
||||
onYes: async () => {
|
||||
await this.addAsContact(decrMember);
|
||||
// After adding as contact, proceed with admission
|
||||
await this.toggleAdmission(decrMember);
|
||||
},
|
||||
-1,
|
||||
);
|
||||
},
|
||||
},
|
||||
-1,
|
||||
);
|
||||
onNo: async () => {
|
||||
// If they choose not to add as contact, show second confirmation
|
||||
this.$notify(
|
||||
{
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: "Continue Without Adding?",
|
||||
text: "Are you sure you want to proceed with admission even though they are not a contact?",
|
||||
yesText: "Continue",
|
||||
onYes: async () => {
|
||||
await this.toggleAdmission(decrMember);
|
||||
},
|
||||
onCancel: async () => {
|
||||
// Do nothing, effectively canceling the operation
|
||||
},
|
||||
},
|
||||
-1,
|
||||
);
|
||||
},
|
||||
},
|
||||
-1,
|
||||
);
|
||||
} else {
|
||||
// If already a contact, proceed directly with admission
|
||||
this.toggleAdmission(member);
|
||||
this.toggleAdmission(decrMember);
|
||||
}
|
||||
}
|
||||
|
||||
async toggleAdmission(member: DecryptedMember) {
|
||||
async toggleAdmission(decrMember: DecryptedMember) {
|
||||
try {
|
||||
const headers = await getHeaders(this.activeDid);
|
||||
await this.axios.put(
|
||||
`${this.apiServer}/api/partner/groupOnboardMember/${member.member.memberId}`,
|
||||
{ admitted: !member.member.admitted },
|
||||
`${this.apiServer}/api/partner/groupOnboardMember/${decrMember.member.memberId}`,
|
||||
{ admitted: !decrMember.member.admitted },
|
||||
{ headers },
|
||||
);
|
||||
// Update local state
|
||||
member.member.admitted = !member.member.admitted;
|
||||
decrMember.member.admitted = !decrMember.member.admitted;
|
||||
|
||||
const oldContact = this.getContactFor(member.did);
|
||||
const oldContact = this.getContactFor(decrMember.did);
|
||||
// if admitted, now register that user if they are not registered
|
||||
if (member.member.admitted && !oldContact?.registered) {
|
||||
if (
|
||||
decrMember.member.admitted &&
|
||||
!decrMember.isRegistered &&
|
||||
!oldContact?.registered
|
||||
) {
|
||||
const contactOldOrNew: Contact = oldContact || {
|
||||
did: member.did,
|
||||
name: member.name,
|
||||
}
|
||||
did: decrMember.did,
|
||||
name: decrMember.name,
|
||||
};
|
||||
try {
|
||||
const result = await register(
|
||||
this.activeDid,
|
||||
@@ -400,9 +407,9 @@ export default class MembersList extends Vue {
|
||||
contactOldOrNew,
|
||||
);
|
||||
if (result.success) {
|
||||
member.member.registered = true;
|
||||
decrMember.isRegistered = true;
|
||||
if (oldContact) {
|
||||
await db.contacts.update(member.did, { registered: true });
|
||||
await db.contacts.update(decrMember.did, { registered: true });
|
||||
oldContact.registered = true;
|
||||
}
|
||||
this.$notify(
|
||||
@@ -417,16 +424,18 @@ export default class MembersList extends Vue {
|
||||
} else {
|
||||
throw result;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (error: any) {
|
||||
// registration failure is likely explained by a message from the server
|
||||
const additionalInfo = serverMessageForUser(error) || error?.error || "";
|
||||
const additionalInfo =
|
||||
serverMessageForUser(error) || error?.error || "";
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "warning",
|
||||
title: "Registration failed",
|
||||
text: "They were admitted to the meeting. However, registration failed. You can register them from the contacts screen. " +
|
||||
text:
|
||||
"They were admitted to the meeting. However, registration failed. You can register them from the contacts screen. " +
|
||||
additionalInfo,
|
||||
},
|
||||
12000,
|
||||
|
||||
Reference in New Issue
Block a user