@ -111,7 +111,7 @@
? 'bg-blue-600 text-white cursor-pointer'
? 'bg-blue-600 text-white cursor-pointer'
: 'bg-slate-400 text-slate-200 cursor-not-allowed' ,
: 'bg-slate-400 text-slate-200 cursor-not-allowed' ,
] "
] "
@ click = "handleMainAction "
@ click = "processSelectedMembers "
>
>
{ { buttonText } }
{ { buttonText } }
< / button >
< / button >
@ -252,16 +252,7 @@ export default class BulkMembersDialog extends Vue {
return this . selectedMembers . includes ( memberDid ) ;
return this . selectedMembers . includes ( memberDid ) ;
}
}
async handleMainAction ( ) {
async processSelectedMembers ( ) {
/ / i s O r g a n i z e r : t r u e = a d m i t m o d e , f a l s e = v i s i b i l i t y m o d e
if ( this . isOrganizer ) {
await this . organizerAdmitAndAddWithVisibility ( ) ;
} else {
await this . memberAddContactWithVisibility ( ) ;
}
}
async organizerAdmitAndAddWithVisibility ( ) {
try {
try {
const selectedMembers : MemberData [ ] = this . membersData . filter ( ( member ) =>
const selectedMembers : MemberData [ ] = this . membersData . filter ( ( member ) =>
this . selectedMembers . includes ( member . did ) ,
this . selectedMembers . includes ( member . did ) ,
@ -276,16 +267,20 @@ export default class BulkMembersDialog extends Vue {
for ( const member of selectedMembers ) {
for ( const member of selectedMembers ) {
try {
try {
/ / F i r s t , a d m i t t h e m e m b e r
/ / O r g a n i z e r m o d e : a d m i t a n d r e g i s t e r t h e m e m b e r f i r s t
if ( this . isOrganizer ) {
await this . admitMember ( member ) ;
await this . admitMember ( member ) ;
/ / R e g i s t e r t h e m
await this . registerMember ( member ) ;
await this . registerMember ( member ) ;
admittedCount ++ ;
admittedCount ++ ;
}
/ / I f t h e y ' r e n o t a c o n t a c t y e t , a d d t h e m a s a c o n t a c t
/ / I f t h e y ' r e n o t a c o n t a c t y e t , a d d t h e m a s a c o n t a c t
if ( ! member . isContact ) {
if ( ! member . isContact ) {
await this . addAsContact ( member , true ) ;
/ / O r g a n i z e r m o d e : s e t i s R e g i s t e r e d t o t r u e , m e m b e r m o d e : u n d e f i n e d
await this . addAsContact (
member ,
this . isOrganizer ? true : undefined ,
) ;
contactAddedCount ++ ;
contactAddedCount ++ ;
}
}
@ -300,6 +295,7 @@ export default class BulkMembersDialog extends Vue {
}
}
/ / S h o w s u c c e s s n o t i f i c a t i o n
/ / S h o w s u c c e s s n o t i f i c a t i o n
if ( this . isOrganizer ) {
if ( admittedCount > 0 ) {
if ( admittedCount > 0 ) {
this . $notify (
this . $notify (
{
{
@ -308,7 +304,7 @@ export default class BulkMembersDialog extends Vue {
title : "Members Admitted Successfully" ,
title : "Members Admitted Successfully" ,
text : ` ${ admittedCount } member ${ admittedCount === 1 ? "" : "s" } admitted and registered ${ contactAddedCount === 0 ? "" : admittedCount === contactAddedCount ? " and" : ` , ${ contactAddedCount } ` } ${ contactAddedCount === 0 ? "" : ` added as contact ${ contactAddedCount === 1 ? "" : "s" } ` } . ` ,
text : ` ${ admittedCount } member ${ admittedCount === 1 ? "" : "s" } admitted and registered ${ contactAddedCount === 0 ? "" : admittedCount === contactAddedCount ? " and" : ` , ${ contactAddedCount } ` } ${ contactAddedCount === 0 ? "" : ` added as contact ${ contactAddedCount === 1 ? "" : "s" } ` } . ` ,
} ,
} ,
10 000,
5 000 ,
) ;
) ;
}
}
if ( errors > 0 ) {
if ( errors > 0 ) {
@ -322,66 +318,28 @@ export default class BulkMembersDialog extends Vue {
5000 ,
5000 ,
) ;
) ;
}
}
} else {
this . close ( notSelectedMembers . map ( ( member ) => member . did ) ) ;
/ / M e m b e r m o d e : s h o w c o n t a c t s a d d e d n o t i f i c a t i o n
} catch ( error ) {
if ( contactAddedCount > 0 ) {
/ / e s l i n t - d i s a b l e - n e x t - l i n e n o - c o n s o l e
console . error ( "Error admitting members:" , error ) ;
this . $notify (
{
group : "alert" ,
type : "danger" ,
title : "Error" ,
text : "Some errors occurred. Work with members individually below." ,
} ,
5000 ,
) ;
}
}
async memberAddContactWithVisibility ( ) {
try {
const selectedMembers : MemberData [ ] = this . membersData . filter ( ( member ) =>
this . selectedMembers . includes ( member . did ) ,
) ;
const notSelectedMembers : MemberData [ ] = this . membersData . filter (
( member ) => ! this . selectedMembers . includes ( member . did ) ,
) ;
let contactsAddedCount = 0 ;
for ( const member of selectedMembers ) {
try {
/ / I f t h e y ' r e n o t a c o n t a c t y e t , a d d t h e m a s a c o n t a c t f i r s t
if ( ! member . isContact ) {
await this . addAsContact ( member , undefined ) ;
contactsAddedCount ++ ;
}
/ / S e t t h e i r s e e s M e t o t r u e
await this . updateContactVisibility ( member . did , true ) ;
} catch ( error ) {
/ / e s l i n t - d i s a b l e - n e x t - l i n e n o - c o n s o l e
console . error ( ` Error processing member ${ member . did } : ` , error ) ;
/ / C o n t i n u e w i t h o t h e r m e m b e r s e v e n i f o n e f a i l s
}
}
/ / S h o w s u c c e s s n o t i f i c a t i o n
this . $notify (
this . $notify (
{
{
group : "alert" ,
group : "alert" ,
type : "success" ,
type : "success" ,
title : "Contacts Added Successfully" ,
title : "Contacts Added Successfully" ,
text : ` ${ contacts AddedCount } member ${ contacts AddedCount === 1 ? "" : "s" } added as contact ${ contacts AddedCount === 1 ? "" : "s" } . ` ,
text : ` ${ contactAddedCount } member ${ contactAddedCount === 1 ? "" : "s" } added as contact ${ contactAddedCount === 1 ? "" : "s" } . ` ,
} ,
} ,
5000 ,
5000 ,
) ;
) ;
}
}
this . close ( notSelectedMembers . map ( ( member ) => member . did ) ) ;
this . close ( notSelectedMembers . map ( ( member ) => member . did ) ) ;
} catch ( error ) {
} catch ( error ) {
/ / e s l i n t - d i s a b l e - n e x t - l i n e n o - c o n s o l e
/ / e s l i n t - d i s a b l e - n e x t - l i n e n o - c o n s o l e
console . error ( "Error adding contacts:" , error ) ;
console . error (
` Error ${ this . isOrganizer ? "admitting members" : "adding contacts" } : ` ,
error ,
) ;
this . $notify (
this . $notify (
{
{
group : "alert" ,
group : "alert" ,