implementing organisation/customer-specific graphs

This commit is contained in:
Felix 2019-08-19 15:02:02 +01:00
parent 05a57e8203
commit 6cd65b8ac6
6 changed files with 250 additions and 154 deletions

View file

@ -86,12 +86,27 @@ class GraphData {
];
}
/// Graph types:
// TODO: Show available graph types based on whether or not the user is an Organisation or User
/// Customer graph types: https://dev.peartrade.org/api/v1/customer/graphs
/// - total_last_week
/// - avg_spend_last_week
/// - total_last_month
/// - avg_spend_last_month
///
/// Organisations' graphs types: to fetch, POST to https://dev.peartrade.org/api/stats/[name] as {"session_key":"[boop beep]"}
/// - organisations_all : organisation
/// - pies : organisation/pies
/// - snippets : organisation/snippets
/// - graphs : organisation/graphs
/// - {"graph":"customers_last_7_days","session_key":"[bleep]"}
/// - {"graph":"customers_last_30_days","session_key":"[blah]"}
/// - {"graph":"sales_last_7_days","session_key":"[bloop]"}
/// - {"graph":"sales_last_7_days","session_key":"[reee]"}
/// - {"graph":"purchases_last_7_days","session_key":"[yee]"}
/// - {"graph":"purchases_last_30_days","session_key":"[yah]"}
/// - {"graph":"purchases_all;","session_key":"[kappa]"} // I don't think this one works
///
/// HTTP POST request sample:
/// {"graph":"total_last_week","session_key":"blahblahblah"}

View file

@ -16,6 +16,9 @@ saveCurrentLogin(Map responseJson, loginEmail) async {
var email = (loginEmail != null)
? loginEmail
: "";
var userType = (responseJson != null && responseJson.isNotEmpty)
? LoginModel.fromJson(responseJson).userType
: "";
await preferences.setString(
'LastUser', (user != null && user.length > 0) ? user : "");
@ -23,4 +26,6 @@ saveCurrentLogin(Map responseJson, loginEmail) async {
'LastToken', (token != null && token.length > 0) ? token : "");
await preferences.setString(
'LastEmail', (email != null && email.length > 0) ? email : "");
await preferences.setString(
'LastUserType', (userType != null && userType.length > 0) ? userType : "");
}