feat(app): implement Product Scan review flow, dynamic batch expiry picker, custom PDFs, PO relationships, and aligned card layouts
This commit is contained in:
1 parent
9ff4a4a922
commit
577be04308
69 files changed
+5645
-1657
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user