update to profile

This commit is contained in:
Aiman Hafiz 2025-12-15 16:04:14 +08:00
parent c21384fb92
commit d93c603573
8 changed files with 145 additions and 86 deletions

View File

@ -20,6 +20,7 @@ import 'screens/admin/item_movement/item_movement_station.dart';
import 'screens/admin/product_request/technician_to_invMaster.dart'; import 'screens/admin/product_request/technician_to_invMaster.dart';
import 'screens/admin/product_request/invMaster_to_invMaster.dart'; import 'screens/admin/product_request/invMaster_to_invMaster.dart';
import 'screens/admin/product_request/product_request_form.dart'; import 'screens/admin/product_request/product_request_form.dart';
import 'screens/profile/profile_screen.dart'; // Add this import
import 'routes/slide_route.dart'; import 'routes/slide_route.dart';
import 'package:inventory_system/services/api_service.dart'; import 'package:inventory_system/services/api_service.dart';
@ -111,6 +112,9 @@ class InventorySystemApp extends StatelessWidget {
case '/scan-user': case '/scan-user':
page = const ScanUserScreen(); page = const ScanUserScreen();
break; break;
case '/profile':
page = const ProfileScreen();
break;
case '/item_movement_all': case '/item_movement_all':
page = const ItemMovementAllScreen(); page = const ItemMovementAllScreen();
break; break;

View File

@ -328,7 +328,7 @@ class _ItemScreenState extends State<ItemScreen> {
extentRatio: 0.45, extentRatio: 0.45,
children: [ children: [
SlidableAction(onPressed: (context) => Navigator.push(context, MaterialPageRoute(builder: (context) => ItemFormScreen(item: item))).then((success) => {if(success == true) _fetchItems()}), backgroundColor: Colors.blue, foregroundColor: Colors.white, icon: Icons.edit, label: 'Edit'), SlidableAction(onPressed: (context) => Navigator.push(context, MaterialPageRoute(builder: (context) => ItemFormScreen(item: item))).then((success) => {if(success == true) _fetchItems()}), backgroundColor: Colors.blue, foregroundColor: Colors.white, icon: Icons.edit, label: 'Edit'),
SlidableAction(onPressed: (context) => _confirmDelete(item['itemID'], item['productName']), backgroundColor: Colors.red, foregroundColor: Colors.white, icon: Icons.delete, label: 'Delete'), SlidableAction(onPressed: (context) => _confirmDelete(item['itemID'], item['productName']), backgroundColor: Colors.red, foregroundColor: Colors.white, icon: Icons.delete, label: 'Delete', borderRadius: const BorderRadius.horizontal(right: Radius.circular(16))),
], ],
), ),
child: Container( child: Container(

View File

@ -246,7 +246,9 @@ class _ManufacturerScreenState extends State<ManufacturerScreen> {
final name = manufacturer['manufacturerName'] ?? 'No Name'; final name = manufacturer['manufacturerName'] ?? 'No Name';
final id = manufacturer['manufacturerId']; final id = manufacturer['manufacturerId'];
return Slidable( return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Slidable(
key: Key(id.toString()), key: Key(id.toString()),
endActionPane: ActionPane( endActionPane: ActionPane(
motion: const StretchMotion(), motion: const StretchMotion(),
@ -264,11 +266,13 @@ class _ManufacturerScreenState extends State<ManufacturerScreen> {
foregroundColor: Colors.white, foregroundColor: Colors.white,
icon: Icons.delete, icon: Icons.delete,
label: 'Delete', label: 'Delete',
borderRadius: const BorderRadius.horizontal(
right: Radius.circular(16)),
), ),
], ],
), ),
child: Card( child: Card(
margin: const EdgeInsets.only(bottom: 12), margin: EdgeInsets.zero,
color: Colors.white, color: Colors.white,
elevation: 1, elevation: 1,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -286,6 +290,7 @@ class _ManufacturerScreenState extends State<ManufacturerScreen> {
), ),
), ),
), ),
),
); );
}, },
); );

View File

@ -249,6 +249,7 @@ class _ProductScreenState extends State<ProductScreen> {
foregroundColor: Colors.white, foregroundColor: Colors.white,
label: 'Delete', label: 'Delete',
icon: Icons.delete, icon: Icons.delete,
borderRadius: const BorderRadius.horizontal(right: Radius.circular(16)),
), ),
], ],
), ),

View File

@ -186,7 +186,9 @@ class _StationScreenState extends State<StationScreen> {
itemCount: _filteredStations.length, itemCount: _filteredStations.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final station = _filteredStations[index]; final station = _filteredStations[index];
return Slidable( return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Slidable(
key: Key(station['stationId'].toString()), key: Key(station['stationId'].toString()),
endActionPane: ActionPane( endActionPane: ActionPane(
motion: const StretchMotion(), motion: const StretchMotion(),
@ -214,11 +216,13 @@ class _StationScreenState extends State<StationScreen> {
foregroundColor: Colors.white, foregroundColor: Colors.white,
icon: Icons.delete, icon: Icons.delete,
label: 'Delete', label: 'Delete',
borderRadius: const BorderRadius.horizontal(
right: Radius.circular(16)),
), ),
], ],
), ),
child: Card( child: Card(
margin: const EdgeInsets.only(bottom: 12), margin: EdgeInsets.zero,
color: Colors.white, color: Colors.white,
elevation: 1, elevation: 1,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -241,6 +245,7 @@ class _StationScreenState extends State<StationScreen> {
station['departmentName'] ?? 'No Department'), station['departmentName'] ?? 'No Department'),
), ),
), ),
),
); );
}, },
); );

View File

@ -52,6 +52,16 @@ class BottomNavBar extends StatelessWidget {
return; return;
} }
if (index == 2) {
final currentRoute = ModalRoute.of(context)?.settings.name;
const profileRoute = '/profile';
if (currentRoute != profileRoute) {
Navigator.pushNamed(context, profileRoute);
}
return;
}
onItemTapped(index); onItemTapped(index);
}, },
backgroundColor: Colors.blue[800], backgroundColor: Colors.blue[800],

View File

@ -14,6 +14,7 @@ enum AppScreen {
productRequestUser, productRequestUser,
itemMovementUser, itemMovementUser,
scan, scan,
profile,
} }
class NavBar extends StatelessWidget { class NavBar extends StatelessWidget {

View File

@ -50,6 +50,39 @@ class AuthService {
} }
} }
Future<Map<String, dynamic>> fetchUserProfile() async {
final String? sessionCookie = SessionManager.instance.getCookie();
if (sessionCookie == null) {
return {'success': false, 'message': 'No active session found.'};
}
final Uri userInfoUri = Uri.parse('${ApiService.baseUrl}/IdentityAPI/GetUserInformation');
final headers = {'Cookie': sessionCookie};
try {
final response = await http.post(userInfoUri, headers: headers);
if (response.statusCode == 200) {
final userInfoResponse = jsonDecode(response.body);
final Map<String, dynamic>? userData = userInfoResponse['userInfo'];
if (userData == null) {
return {'success': false, 'message': 'User profile data is missing from the API response.'};
}
return {
'success': true,
'data': userData // Return raw user data as requested for display
};
} else {
return {'success': false, 'message': 'Failed to retrieve user profile. Status: ${response.statusCode}'};
}
} catch (e) {
debugPrint('Error fetching user profile: $e');
return {'success': false, 'message': 'Error fetching user details.'};
}
}
Future<Map<String, dynamic>> _fetchLdapUserDetails(String sessionCookie, String username) async { Future<Map<String, dynamic>> _fetchLdapUserDetails(String sessionCookie, String username) async {
final Uri userInfoUri = Uri.parse('${ApiService.baseUrl}/IdentityAPI/GetUserInformation'); final Uri userInfoUri = Uri.parse('${ApiService.baseUrl}/IdentityAPI/GetUserInformation');
final headers = {'Cookie': sessionCookie}; final headers = {'Cookie': sessionCookie};