Hapus fitur registrasi dan tautan terkait
- Hapus tampilan register_view.dart - Hapus metode register() dari AuthController - Hapus tautan pendaftaran di halaman login - Perbarui konfigurasi rute untuk menghapus rute registrasi - Bersihkan kode yang tidak digunakan terkait registrasi
This commit is contained in:
@ -23,7 +23,6 @@ class AuthController extends GetxController {
|
|||||||
|
|
||||||
// Form keys
|
// Form keys
|
||||||
final GlobalKey<FormState> loginFormKey = GlobalKey<FormState>();
|
final GlobalKey<FormState> loginFormKey = GlobalKey<FormState>();
|
||||||
final GlobalKey<FormState> registerFormKey = GlobalKey<FormState>();
|
|
||||||
final GlobalKey<FormState> wargaProfileFormKey = GlobalKey<FormState>();
|
final GlobalKey<FormState> wargaProfileFormKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -123,7 +122,6 @@ class AuthController extends GetxController {
|
|||||||
|
|
||||||
// Reset form state jika ada
|
// Reset form state jika ada
|
||||||
loginFormKey.currentState?.reset();
|
loginFormKey.currentState?.reset();
|
||||||
registerFormKey.currentState?.reset();
|
|
||||||
wargaProfileFormKey.currentState?.reset();
|
wargaProfileFormKey.currentState?.reset();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error clearing form dependencies: $e');
|
print('Error clearing form dependencies: $e');
|
||||||
@ -173,31 +171,8 @@ class AuthController extends GetxController {
|
|||||||
_user.value = user;
|
_user.value = user;
|
||||||
clearControllers();
|
clearControllers();
|
||||||
|
|
||||||
// Periksa apakah profil warga sudah lengkap
|
|
||||||
await checkWargaProfileStatus();
|
|
||||||
|
|
||||||
// Arahkan ke dashboard sesuai peran
|
// Arahkan ke dashboard sesuai peran
|
||||||
navigateBasedOnRole(user.role);
|
navigateBasedOnRole(user.role);
|
||||||
|
|
||||||
// Tampilkan notifikasi jika profil belum lengkap untuk warga
|
|
||||||
if (user.role == 'WARGA' && !isWargaProfileComplete.value) {
|
|
||||||
Get.snackbar(
|
|
||||||
'Informasi',
|
|
||||||
'Profil Anda belum lengkap. Silakan lengkapi profil Anda melalui menu Profil',
|
|
||||||
snackPosition: SnackPosition.BOTTOM,
|
|
||||||
backgroundColor: Colors.blue,
|
|
||||||
colorText: Colors.white,
|
|
||||||
duration: const Duration(seconds: 5),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Get.snackbar(
|
|
||||||
'Berhasil',
|
|
||||||
'Login berhasil',
|
|
||||||
snackPosition: SnackPosition.BOTTOM,
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
colorText: Colors.white,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error login: $e');
|
print('Error login: $e');
|
||||||
@ -213,66 +188,6 @@ class AuthController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metode untuk register
|
|
||||||
Future<void> register() async {
|
|
||||||
if (!registerFormKey.currentState!.validate()) return;
|
|
||||||
|
|
||||||
// Simpan nilai dari controller sebelum melakukan operasi asinkron
|
|
||||||
final email = emailController.text.trim();
|
|
||||||
final password = passwordController.text;
|
|
||||||
final confirmPassword = confirmPasswordController.text;
|
|
||||||
|
|
||||||
if (password != confirmPassword) {
|
|
||||||
Get.snackbar(
|
|
||||||
'Error',
|
|
||||||
'Password dan konfirmasi password tidak sama',
|
|
||||||
snackPosition: SnackPosition.BOTTOM,
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
colorText: Colors.white,
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
isLoading.value = true;
|
|
||||||
final user = await _authProvider.signUp(
|
|
||||||
email,
|
|
||||||
password,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (user != null) {
|
|
||||||
_user.value = user;
|
|
||||||
clearControllers();
|
|
||||||
|
|
||||||
// Periksa status profil
|
|
||||||
await checkWargaProfileStatus();
|
|
||||||
|
|
||||||
// Arahkan ke dashboard sesuai peran
|
|
||||||
navigateBasedOnRole(user.role);
|
|
||||||
|
|
||||||
// Tampilkan notifikasi untuk melengkapi profil
|
|
||||||
Get.snackbar(
|
|
||||||
'Berhasil',
|
|
||||||
'Registrasi berhasil. Silakan lengkapi profil Anda melalui menu Profil',
|
|
||||||
snackPosition: SnackPosition.BOTTOM,
|
|
||||||
backgroundColor: Colors.green,
|
|
||||||
colorText: Colors.white,
|
|
||||||
duration: const Duration(seconds: 5),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
Get.snackbar(
|
|
||||||
'Error',
|
|
||||||
'Registrasi gagal: ${e.toString()}',
|
|
||||||
snackPosition: SnackPosition.BOTTOM,
|
|
||||||
backgroundColor: Colors.red,
|
|
||||||
colorText: Colors.white,
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Metode untuk logout
|
// Metode untuk logout
|
||||||
Future<void> logout() async {
|
Future<void> logout() async {
|
||||||
try {
|
try {
|
||||||
@ -349,36 +264,6 @@ class AuthController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validasi NIK
|
|
||||||
String? validateNIK(String? value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return 'NIK tidak boleh kosong';
|
|
||||||
}
|
|
||||||
if (value.length != 16) {
|
|
||||||
return 'NIK harus 16 digit';
|
|
||||||
}
|
|
||||||
if (!GetUtils.isNumericOnly(value)) {
|
|
||||||
return 'NIK harus berupa angka';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validasi nama lengkap
|
|
||||||
String? validateNamaLengkap(String? value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return 'Nama lengkap tidak boleh kosong';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validasi jenis kelamin
|
|
||||||
String? validateJenisKelamin(String? value) {
|
|
||||||
if (value == null || value.isEmpty) {
|
|
||||||
return 'Jenis kelamin tidak boleh kosong';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mendapatkan rute target berdasarkan peran
|
// Mendapatkan rute target berdasarkan peran
|
||||||
String _getTargetRouteForRole(String role) {
|
String _getTargetRouteForRole(String role) {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
@ -110,18 +110,6 @@ class LoginView extends GetView<AuthController> {
|
|||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
// Register Link
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Text('Belum punya akun?'),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Get.toNamed(Routes.register),
|
|
||||||
child: const Text('Daftar'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1,140 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
|
||||||
import 'package:penyaluran_app/app/modules/auth/controllers/auth_controller.dart';
|
|
||||||
import 'package:penyaluran_app/app/routes/app_pages.dart';
|
|
||||||
|
|
||||||
class RegisterView extends GetView<AuthController> {
|
|
||||||
const RegisterView({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Daftar Akun'),
|
|
||||||
elevation: 0,
|
|
||||||
),
|
|
||||||
body: SafeArea(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(20.0),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Form(
|
|
||||||
key: controller.registerFormKey,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
// Logo atau Judul
|
|
||||||
const Center(
|
|
||||||
child: Text(
|
|
||||||
'Penyaluran App',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 28,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
const Center(
|
|
||||||
child: Text(
|
|
||||||
'Buat akun baru',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
|
|
||||||
// Email Field
|
|
||||||
TextFormField(
|
|
||||||
controller: controller.emailController,
|
|
||||||
keyboardType: TextInputType.emailAddress,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Email',
|
|
||||||
prefixIcon: const Icon(Icons.email),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
validator: controller.validateEmail,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
|
|
||||||
// Password Field
|
|
||||||
TextFormField(
|
|
||||||
controller: controller.passwordController,
|
|
||||||
obscureText: true,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Password',
|
|
||||||
prefixIcon: const Icon(Icons.lock),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
validator: controller.validatePassword,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
|
|
||||||
// Confirm Password Field
|
|
||||||
TextFormField(
|
|
||||||
controller: controller.confirmPasswordController,
|
|
||||||
obscureText: true,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
labelText: 'Konfirmasi Password',
|
|
||||||
prefixIcon: const Icon(Icons.lock_outline),
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
validator: controller.validateConfirmPassword,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
|
|
||||||
// Register Button
|
|
||||||
Obx(() => ElevatedButton(
|
|
||||||
onPressed: controller.isLoading.value
|
|
||||||
? null
|
|
||||||
: controller.register,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: controller.isLoading.value
|
|
||||||
? const SpinKitThreeBounce(
|
|
||||||
color: Colors.white,
|
|
||||||
size: 24,
|
|
||||||
)
|
|
||||||
: const Text(
|
|
||||||
'DAFTAR',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
|
|
||||||
// Login Link
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Text('Sudah punya akun?'),
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Get.offAllNamed(Routes.login),
|
|
||||||
child: const Text('Masuk'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:penyaluran_app/app/modules/auth/views/login_view.dart';
|
import 'package:penyaluran_app/app/modules/auth/views/login_view.dart';
|
||||||
import 'package:penyaluran_app/app/modules/auth/views/register_view.dart';
|
|
||||||
import 'package:penyaluran_app/app/modules/home/views/home_view.dart';
|
import 'package:penyaluran_app/app/modules/home/views/home_view.dart';
|
||||||
import 'package:penyaluran_app/app/modules/dashboard/views/warga_dashboard_view.dart';
|
import 'package:penyaluran_app/app/modules/dashboard/views/warga_dashboard_view.dart';
|
||||||
import 'package:penyaluran_app/app/modules/dashboard/views/petugas_verifikasi_dashboard_view.dart';
|
import 'package:penyaluran_app/app/modules/dashboard/views/petugas_verifikasi_dashboard_view.dart';
|
||||||
@ -28,11 +27,6 @@ class AppPages {
|
|||||||
page: () => const LoginView(),
|
page: () => const LoginView(),
|
||||||
binding: AuthBinding(),
|
binding: AuthBinding(),
|
||||||
),
|
),
|
||||||
GetPage(
|
|
||||||
name: _Paths.register,
|
|
||||||
page: () => const RegisterView(),
|
|
||||||
binding: AuthBinding(),
|
|
||||||
),
|
|
||||||
GetPage(
|
GetPage(
|
||||||
name: _Paths.wargaDashboard,
|
name: _Paths.wargaDashboard,
|
||||||
page: () => const WargaDashboardView(),
|
page: () => const WargaDashboardView(),
|
||||||
|
Reference in New Issue
Block a user