Purchase orders

This commit is contained in:
Hillel Coren 2022-06-20 12:37:26 +03:00
parent 599aa190c1
commit 94944ae90c
5 changed files with 31 additions and 23 deletions

View File

@ -5,6 +5,7 @@ import 'dart:convert';
import 'package:built_collection/built_collection.dart';
import 'package:built_value/built_value.dart';
import 'package:built_value/serializer.dart';
import 'package:flutter/foundation.dart';
// Project imports:
import 'package:invoiceninja_flutter/.env.dart';
@ -579,11 +580,9 @@ abstract class CompanyEntity extends Object
);
bool isModuleEnabled(EntityType entityType) {
/*
if (entityType == EntityType.purchaseOrder) {
if (kReleaseMode && entityType == EntityType.purchaseOrder) {
return false;
}
*/
if ((entityType == EntityType.invoice ||
entityType == EntityType.payment) &&

View File

@ -225,9 +225,8 @@ class LoginVM {
try {
WebUtils.microsoftLogin((idToken, accessToken) {
print('## RESULT: acces: $accessToken id: $idToken');
});
/*
/*
store.dispatch(OAuthLoginRequest(
completer: completer,
idToken: idToken,
@ -240,6 +239,9 @@ class LoginVM {
));
completer.future.then((_) => _handleLogin(context: context));
*/
}, (dynamic error) {
completer.completeError(error);
});
} catch (error) {
completer.completeError(error);
print('## onMicrosoftLoginPressed: $error');
@ -249,19 +251,17 @@ class LoginVM {
(BuildContext context, Completer<Null> completer) async {
try {
WebUtils.microsoftLogin((idToken, accessToken) {
print('## RESULT: acces: $accessToken id: $idToken');
store.dispatch(OAuthSignUpRequest(
completer: completer,
idToken: idToken,
provider: UserEntity.OAUTH_PROVIDER_MICROSOFT,
accessToken: accessToken,
));
completer.future
.then((_) => _handleLogin(context: context, isSignUp: true));
}, (dynamic error) {
completer.completeError(error);
});
/*
store.dispatch(OAuthSignUpRequest(
completer: completer,
idToken: idToken,
provider: kOAuthProviderMicrosoft,
accessToken: accessToken,
));
completer.future
.then((_) => _handleLogin(context: context, isSignUp: true));
*/
} catch (error) {
completer.completeError(error);
print('## onMicrosoftSignUpPressed: $error');

View File

@ -271,6 +271,8 @@ class UserDetailsVM {
completer: completer,
),
);
}, (dynamic error) {
showErrorDialog(context: context, message: error);
});
} catch (error) {
showErrorDialog(context: context, message: error);

View File

@ -69,7 +69,10 @@ class WebUtils {
});
}
static void microsoftLogin(Function(String, String) callback) async {
static void microsoftLogin(
Function(String, String) succesCallback,
Function(dynamic) failureCallback,
) async {
final config = Configuration()
..auth = (BrowserAuthOptions()
//..redirectUri = 'https://invoicing.co/auth/microsoft'
@ -81,10 +84,11 @@ class WebUtils {
final loginRequest = PopupRequest()..scopes = ['user.read'];
final AuthenticationResult result =
await publicClientApp.loginPopup(loginRequest);
callback(result?.idToken, result?.accessToken);
publicClientApp.loginPopup(loginRequest).then((result) {
succesCallback(result?.idToken, result?.accessToken);
}).catchError((dynamic error) {
failureCallback(error);
});
}
/*

View File

@ -24,7 +24,10 @@ class WebUtils {
static void warnChanges(Store<AppState> store) {}
static void microsoftLogin(Function(String, String) callback) async {}
static void microsoftLogin(
Function(String, String) successCallback,
Function(dynamic) failureCallback,
) async {}
/*
static String loadToken() => null;