diff --git a/mobile/lib/api/review.dart b/mobile/lib/api/review.dart index 1bf406e..2cc18b1 100644 --- a/mobile/lib/api/review.dart +++ b/mobile/lib/api/review.dart @@ -64,7 +64,7 @@ Future createReview( if (e.response != null) { var response = e.response!; if (response.statusCode == 401) { - profile.setLoggedOut(); + await profile.setLoggedOut(); return Future.error("Session expired"); } if (response.statusCode == 400) { diff --git a/mobile/lib/api/tikum.dart b/mobile/lib/api/tikum.dart index 5ffce7d..ee3235a 100644 --- a/mobile/lib/api/tikum.dart +++ b/mobile/lib/api/tikum.dart @@ -31,7 +31,7 @@ Future> getMyTikum() async { ); if (response.statusCode == 401) { - profile.setLoggedOut(); + await profile.setLoggedOut(); return Future.error("Session expired"); } @@ -64,7 +64,7 @@ Future deleteMyTikum(int id) async { ); if (response.statusCode == 401) { - profile.setLoggedOut(); + await profile.setLoggedOut(); return Future.error("Session expired"); } @@ -106,7 +106,7 @@ Future createTikum({ if (e.response != null) { var response = e.response!; if (response.statusCode == 401) { - profile.setLoggedOut(); + await profile.setLoggedOut(); return Future.error("Session expired"); } if (response.statusCode == 400) { diff --git a/mobile/lib/api/user.dart b/mobile/lib/api/user.dart index 74b74e8..aa49bb7 100644 --- a/mobile/lib/api/user.dart +++ b/mobile/lib/api/user.dart @@ -20,7 +20,7 @@ Future loginUser(String email, String password) async { var id = decoded["user"]["id"]; var profile = await SecureProfile.getStorage(); - profile.setLoggedIn(id, token); + await profile.setLoggedIn(id, token); } else if (response.statusCode == 400) { return Future.error("Email atau password salah"); } else { @@ -59,7 +59,7 @@ Future> getMyReviewById() async { ); if (response.statusCode == 401) { - profile.setLoggedOut(); + await profile.setLoggedOut(); return Future.error("Session expired, please login again"); } @@ -88,7 +88,7 @@ Future getMyProfileById() async { ); if (response.statusCode == 401) { - profile.setLoggedOut(); + await profile.setLoggedOut(); return Future.error("Session expired, please login again"); } @@ -118,7 +118,7 @@ Future deleteMyReview(int id) async { ); if (response.statusCode == 401) { - profile.setLoggedOut(); + await profile.setLoggedOut(); return Future.error("Session expired, please login again"); } @@ -144,7 +144,7 @@ Future userLogout() async { ); if (res.statusCode == 401) { - profile.setLoggedOut(); + await profile.setLoggedOut(); return Future.error("Session expired, please login again"); } @@ -152,7 +152,7 @@ Future userLogout() async { return Future.error("Failed to logout"); } - profile.setLoggedOut(); + await profile.setLoggedOut(); } Future getUserProfileById(int id) async { diff --git a/mobile/lib/model/profile_secure.dart b/mobile/lib/model/profile_secure.dart index 375d869..a0a1ba4 100644 --- a/mobile/lib/model/profile_secure.dart +++ b/mobile/lib/model/profile_secure.dart @@ -63,13 +63,13 @@ class SecureProfile { return userId; } - void setLoggedIn(int userId, String apiKey) async { + Future setLoggedIn(int userId, String apiKey) async { await storage.setInt("user_id", userId); await storage.setString("api_key", apiKey); isLoggedIn = true; } - void setLoggedOut() async { + Future setLoggedOut() async { await storage.remove("api_key"); await storage.remove("user_id"); isLoggedIn = false; diff --git a/mobile/lib/screen/home/components/tikum/tikum.dart b/mobile/lib/screen/home/components/tikum/tikum.dart index 0bcca26..9df1d4f 100644 --- a/mobile/lib/screen/home/components/tikum/tikum.dart +++ b/mobile/lib/screen/home/components/tikum/tikum.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mobile/model/profile_secure.dart'; import 'package:mobile/screen/form_tikum/form_tikum_screen.dart'; -import 'package:mobile/screen/test_screen/test_screen.dart'; import 'package:mobile/screen/home/components/tikum/global_tikum.dart'; import 'package:mobile/screen/home/components/tikum/my_tikum.dart'; diff --git a/mobile/lib/screen/home/home_screen.dart b/mobile/lib/screen/home/home_screen.dart index 696e070..63a4074 100644 --- a/mobile/lib/screen/home/home_screen.dart +++ b/mobile/lib/screen/home/home_screen.dart @@ -19,7 +19,7 @@ class HomeScreen extends StatefulWidget { class _HomeScreenState extends State { final List section = [ const Timeline(), - TikumLayout(), + const TikumLayout(), ProfileSection() ]; var sectionidx = 0; @@ -34,7 +34,7 @@ class _HomeScreenState extends State { return Scaffold( appBar: AppBar( - actions: [Image(image: AssetImage("assets/Logos.png"))], + actions: const [Image(image: AssetImage("assets/Logos.png"))], title: const Text("Travelliu", style: TextStyle(fontWeight: FontWeight.bold)), backgroundColor: Colors.white,