Skip to content

Commit 2d8a480

Browse files
authored
Merge pull request #30 from woosignal/master
v5.7.1 - updates
2 parents e0a57da + 6ee4a2a commit 2d8a480

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

LabelStoreMax/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
## [5.7.1] - 2022-02-07
22

33
* Refactor account order detail page
4-
* Fix continuous loading if users has no orders
4+
* Fix continuous loading if a user has no orders
55
* New styling for tabs in the account order detail page
66
* Small refactor to controller loading
7+
* Handle invalid tokens on the account page
78
* Pubspec.yaml dependency updates
89

910
## [5.7.0] - 2022-01-29

LabelStoreMax/lib/resources/pages/account_detail.dart

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:flutter_app/resources/widgets/app_loader_widget.dart';
1818
import 'package:flutter_app/resources/widgets/safearea_widget.dart';
1919
import 'package:flutter_app/resources/widgets/woosignal_ui.dart';
2020
import 'package:nylo_framework/nylo_framework.dart';
21+
import 'package:wp_json_api/exceptions/invalid_user_token_exception.dart';
2122
import 'package:wp_json_api/models/responses/wc_customer_info_response.dart';
2223
import 'package:wp_json_api/wp_json_api.dart';
2324

@@ -49,6 +50,14 @@ class _AccountDetailPageState extends State<AccountDetailPage>
4950
try {
5051
wcCustomerInfoResponse = await WPJsonAPI.instance
5152
.api((request) => request.wcCustomerInfo(userToken));
53+
} on InvalidUserTokenException catch (_) {
54+
showToastNotification(
55+
context,
56+
title: trans("Oops!"),
57+
description: trans("Something went wrong"),
58+
style: ToastNotificationStyleType.DANGER,
59+
);
60+
await authLogout(context);
5261
} on Exception catch (_) {
5362
showToastNotification(
5463
context,
@@ -89,7 +98,17 @@ class _AccountDetailPageState extends State<AccountDetailPage>
8998
if (activeBody == null) {
9099
return SizedBox.shrink();
91100
}
101+
String userAvatar;
102+
String userFirstName = "";
103+
String userLastName = "";
104+
if (_wcCustomerInfoResponse != null && _wcCustomerInfoResponse.data != null) {
105+
userAvatar = _wcCustomerInfoResponse.data.avatar;
92106

107+
userFirstName = _wcCustomerInfoResponse
108+
.data.firstName;
109+
userLastName = _wcCustomerInfoResponse
110+
.data.lastName;
111+
}
93112
return Scaffold(
94113
appBar: AppBar(
95114
leading: widget.showLeadingBackButton
@@ -123,13 +142,9 @@ class _AccountDetailPageState extends State<AccountDetailPage>
123142
children: <Widget>[
124143
Container(
125144
margin: EdgeInsets.only(top: 10),
126-
child: CircleAvatar(
127-
backgroundImage: NetworkImage(
128-
_wcCustomerInfoResponse != null
129-
? _wcCustomerInfoResponse.data.avatar
130-
: "",
131-
),
132-
),
145+
child: userAvatar != null ? CircleAvatar(
146+
backgroundImage: NetworkImage(userAvatar),
147+
) : Icon(Icons.account_circle_rounded, size: 65,),
133148
height: 90,
134149
width: 90,
135150
),
@@ -146,18 +161,13 @@ class _AccountDetailPageState extends State<AccountDetailPage>
146161
MainAxisAlignment.spaceAround,
147162
children: <Widget>[
148163
Text(
149-
(_wcCustomerInfoResponse == null
150-
? ""
151-
: [
152-
_wcCustomerInfoResponse
153-
.data.firstName,
154-
_wcCustomerInfoResponse
155-
.data.lastName
156-
]
157-
.where((t) =>
158-
(t != null || t != ""))
159-
.toList()
160-
.join(" ")),
164+
[
165+
userFirstName,
166+
userLastName
167+
].where((t) =>
168+
(t != null || t != ""))
169+
.toList()
170+
.join(" "),
161171
style: TextStyle(
162172
fontSize: 20,
163173
fontWeight: FontWeight.w600,

0 commit comments

Comments
 (0)