fix: resolve invite overflow and member removal lookup
This commit is contained in:
parent
d566621033
commit
bd177cedcc
2 changed files with 47 additions and 41 deletions
|
|
@ -146,45 +146,50 @@ class _ManageCollectionScreenState extends State<ManageCollectionScreen> {
|
|||
child: const Icon(Icons.person_add, color: Colors.white, size: 28),
|
||||
),
|
||||
title: const Text('Invite Member'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Enter the email address of the person you want to invite. '
|
||||
'They must already have an account.',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: emailCtrl,
|
||||
autofocus: true,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email address',
|
||||
hintText: 'user@example.com',
|
||||
prefixIcon: Icon(Icons.email_outlined),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: inviteRole,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Role',
|
||||
prefixIcon: Icon(Icons.security_outlined),
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'member', child: Text('Member (can add/copy/edit)')),
|
||||
DropdownMenuItem(value: 'viewer', child: Text('Viewer (read-only)')),
|
||||
content: SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 420),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Enter the email address of the person you want to invite. '
|
||||
'They must already have an account.',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: emailCtrl,
|
||||
autofocus: true,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Email address',
|
||||
hintText: 'user@example.com',
|
||||
prefixIcon: Icon(Icons.email_outlined),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
DropdownButtonFormField<String>(
|
||||
initialValue: inviteRole,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Role',
|
||||
prefixIcon: Icon(Icons.security_outlined),
|
||||
),
|
||||
items: const [
|
||||
DropdownMenuItem(value: 'member', child: Text('Member (can add/copy/edit)')),
|
||||
DropdownMenuItem(value: 'viewer', child: Text('Viewer (read-only)')),
|
||||
],
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
setSheetState(() => inviteRole = value);
|
||||
},
|
||||
),
|
||||
],
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
setSheetState(() => inviteRole = value);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
|
|
@ -256,7 +261,7 @@ class _ManageCollectionScreenState extends State<ManageCollectionScreen> {
|
|||
try {
|
||||
await CollectionService.removeMember(
|
||||
collectionId: _collection.id,
|
||||
membershipId: member.id,
|
||||
memberUserId: member.userId,
|
||||
);
|
||||
showGlobalSnackBar('Member removed.');
|
||||
await _loadMembers();
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ class CollectionService {
|
|||
/// Remove a member from a collection.
|
||||
static Future<void> removeMember({
|
||||
required String collectionId,
|
||||
required String membershipId,
|
||||
required String memberUserId,
|
||||
}) async {
|
||||
final currentUserId = supabase.auth.currentUser!.id;
|
||||
|
||||
|
|
@ -346,7 +346,7 @@ class CollectionService {
|
|||
final target = await supabase
|
||||
.from('collection_members')
|
||||
.select('role, user_id')
|
||||
.eq('id', membershipId)
|
||||
.eq('user_id', memberUserId)
|
||||
.eq('collection_id', collectionId)
|
||||
.maybeSingle();
|
||||
|
||||
|
|
@ -360,7 +360,8 @@ class CollectionService {
|
|||
await supabase
|
||||
.from('collection_members')
|
||||
.delete()
|
||||
.eq('id', membershipId);
|
||||
.eq('user_id', memberUserId)
|
||||
.eq('collection_id', collectionId);
|
||||
}
|
||||
|
||||
/// Leave a collection (for non-owners).
|
||||
|
|
|
|||
Loading…
Reference in a new issue