feat(app): implement Product Scan review flow, dynamic batch expiry picker, custom PDFs, PO relationships, and aligned card layouts

This commit is contained in:
Rafhan Mazaya Fathurrahman committed 2026-07-09 12:36:06 +07:00
1 parent 9ff4a4a922
commit 577be04308
69 files changed
+5645 -1657

No files matched your search

+24
View File
@@ -13,6 +13,23 @@ class AuthNotifier extends StateNotifier<bool> {
final token = prefs.getString('auth_token');
if (token != null) {
state = true;
try {
final apiClient = _ref.read(apiClientProvider);
final response = await apiClient.client.get('/auth/me');
if (response.data is Map && response.data['data'] is Map) {
final profile = response.data['data']['profile'];
if (profile != null) {
await prefs.setString('nama_toko', profile['namaToko'] ?? '');
await prefs.setString('kode_toko', profile['kodeToko'] ?? '');
}
}
} catch (e) {
// If unauthorized, perform clean logout
if (e.toString().contains('401') || e.toString().contains('Unauthorized')) {
await logout();
return false;
}
}
return true;
}
state = false;
@@ -35,12 +52,17 @@ class AuthNotifier extends StateNotifier<bool> {
}
final token = response.data['data']['token'];
final profile = response.data['data']['profile'];
if (token == null) {
throw Exception("Token otentikasi tidak ditemukan dalam respon");
}
final prefs = await SharedPreferences.getInstance();
await prefs.setString('auth_token', token);
if (profile != null) {
await prefs.setString('nama_toko', profile['namaToko'] ?? '');
await prefs.setString('kode_toko', profile['kodeToko'] ?? '');
}
state = true;
} catch (e) {
@@ -52,6 +74,8 @@ class AuthNotifier extends StateNotifier<bool> {
Future<void> logout() async {
final prefs = await SharedPreferences.getInstance();
await prefs.remove('auth_token');
await prefs.remove('nama_toko');
await prefs.remove('kode_toko');
state = false;
}
}
+10 -7
View File
@@ -56,7 +56,10 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
body: SafeArea(
child: Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(32.0),
padding: const EdgeInsets.symmetric(
horizontal: AppConfig.spaceXXL,
vertical: AppConfig.spaceXL,
),
child: Form(
key: _formKey,
child: Column(
@@ -73,19 +76,19 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
color: AppConfig.primaryColor
),
),
const SizedBox(height: 24),
const SizedBox(height: AppConfig.spaceXL),
Text(
'Selamat Datang Kembali',
style: AppConfig.h1,
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
const SizedBox(height: AppConfig.spaceSmall),
Text(
'Masuk untuk menyinkronkan dokumen Anda ke server pusat',
style: AppConfig.bodyMedium,
textAlign: TextAlign.center,
),
const SizedBox(height: 48),
const SizedBox(height: AppConfig.spaceXXL * 1.5),
TextFormField(
controller: _idController,
decoration: const InputDecoration(
@@ -99,7 +102,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
return null;
},
),
const SizedBox(height: 16),
const SizedBox(height: AppConfig.spaceLarge),
TextFormField(
controller: _passwordController,
obscureText: true,
@@ -117,7 +120,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
return null;
},
),
const SizedBox(height: 32),
const SizedBox(height: AppConfig.spaceXXL),
SizedBox(
height: 56,
child: ElevatedButton(
@@ -131,7 +134,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
: const Text('Masuk'),
),
),
const SizedBox(height: 24),
const SizedBox(height: AppConfig.spaceXL),
Text(
'Hubungi admin pusat untuk mendapatkan kredensial akun.',
style: AppConfig.bodySmall,