added password reset - resend invite link (#10)
Co-authored-by: Copilot <copilot@github.com> Reviewed-on: #10 Co-authored-by: Mark M2 Macbook <marco@catelli.it> Co-committed-by: Mark M2 Macbook <marco@catelli.it>
This commit is contained in:
@@ -102,6 +102,15 @@ class StaffCubit extends Cubit<StaffState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> resetPasswordOrResendInviteLink(String email) async {
|
||||||
|
try {
|
||||||
|
await _repository.resetPasswordOrResendInviteLink(email);
|
||||||
|
emit(state.copyWith(status: StaffStatus.emailSent, error: null));
|
||||||
|
} catch (e) {
|
||||||
|
emit(state.copyWith(status: StaffStatus.error, error: e.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Associa un dipendente a un negozio
|
// Associa un dipendente a un negozio
|
||||||
Future<void> assignMemberToStore(String staffId, String storeId) async {
|
Future<void> assignMemberToStore(String staffId, String storeId) async {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
part of 'staff_cubit.dart';
|
part of 'staff_cubit.dart';
|
||||||
|
|
||||||
enum StaffStatus { initial, loading, success, error }
|
enum StaffStatus { initial, loading, success, emailSent, error }
|
||||||
|
|
||||||
class StaffState extends Equatable {
|
class StaffState extends Equatable {
|
||||||
final StaffStatus status;
|
final StaffStatus status;
|
||||||
|
|||||||
@@ -60,6 +60,17 @@ class StaffRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> resetPasswordOrResendInviteLink(String email) async {
|
||||||
|
try {
|
||||||
|
await _supabase.auth.resetPasswordForEmail(
|
||||||
|
email,
|
||||||
|
redirectTo: 'https://flux-web-invite.marco-6ba.workers.dev/',
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception("Errore nell'invio del link: $e");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- LOGICA DI GIUNZIONE (Staff <-> Store) ---
|
// --- LOGICA DI GIUNZIONE (Staff <-> Store) ---
|
||||||
|
|
||||||
// Recupera i membri assegnati a uno specifico negozio
|
// Recupera i membri assegnati a uno specifico negozio
|
||||||
|
|||||||
@@ -174,7 +174,46 @@ class _StaffScreenState extends State<StaffScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
trailing: canManageStaff ? const Icon(Icons.edit_note) : null,
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
if (member.jobTitle != null && member.jobTitle!.isNotEmpty) ...[
|
||||||
|
Text('Qualifica: ${member.jobTitle!}'),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
],
|
||||||
|
|
||||||
|
if (canManageStaff) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
|
||||||
|
if (!member.hasJoined)
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: const Icon(Icons.send),
|
||||||
|
label: const Text("Re-invia Invito (In Attesa)"),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.orange,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// Chiama la funzione di reset password mascherata da invito
|
||||||
|
context.read<StaffCubit>().resetPasswordOrResendInviteLink(
|
||||||
|
member.email!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
else
|
||||||
|
OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.lock_reset),
|
||||||
|
label: const Text("Invia Reset Password"),
|
||||||
|
onPressed: () {
|
||||||
|
// Chiama LA STESSA IDENTICA FUNZIONE!
|
||||||
|
context.read<StaffCubit>().resetPasswordOrResendInviteLink(
|
||||||
|
member.email!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
canManageStaff ? _openStaffForm(context, member: member) : null,
|
canManageStaff ? _openStaffForm(context, member: member) : null,
|
||||||
),
|
),
|
||||||
@@ -395,6 +434,32 @@ class _StaffScreenState extends State<StaffScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
/* const SizedBox(height: 16),
|
||||||
|
if (!member!.hasJoined)
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: const Icon(Icons.send),
|
||||||
|
label: const Text("Re-invia Invito (In Attesa)"),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.orange,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
// Chiama la funzione di reset password mascherata da invito
|
||||||
|
context
|
||||||
|
.read<StaffCubit>()
|
||||||
|
.resetPasswordOrResendInviteLink(member.email!);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
else
|
||||||
|
OutlinedButton.icon(
|
||||||
|
icon: const Icon(Icons.lock_reset),
|
||||||
|
label: const Text("Invia Reset Password"),
|
||||||
|
onPressed: () {
|
||||||
|
// Chiama LA STESSA IDENTICA FUNZIONE!
|
||||||
|
context
|
||||||
|
.read<StaffCubit>()
|
||||||
|
.resetPasswordOrResendInviteLink(member.email!);
|
||||||
|
},
|
||||||
|
), */
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user