Login...
This commit is contained in:
parent
3aad3b385e
commit
096b106eaf
|
|
@ -14,7 +14,6 @@ abstract class CompanyEntity
|
||||||
return _$CompanyEntity._(
|
return _$CompanyEntity._(
|
||||||
companyKey: '',
|
companyKey: '',
|
||||||
name: '',
|
name: '',
|
||||||
token: '',
|
|
||||||
plan: '',
|
plan: '',
|
||||||
logoUrl: '',
|
logoUrl: '',
|
||||||
appUrl: '',
|
appUrl: '',
|
||||||
|
|
@ -84,8 +83,6 @@ abstract class CompanyEntity
|
||||||
|
|
||||||
String get name;
|
String get name;
|
||||||
|
|
||||||
String get token;
|
|
||||||
|
|
||||||
String get plan;
|
String get plan;
|
||||||
|
|
||||||
@BuiltValueField(wireName: 'account_key')
|
@BuiltValueField(wireName: 'account_key')
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,6 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
|
||||||
final result = <Object>[
|
final result = <Object>[
|
||||||
'name',
|
'name',
|
||||||
serializers.serialize(object.name, specifiedType: const FullType(String)),
|
serializers.serialize(object.name, specifiedType: const FullType(String)),
|
||||||
'token',
|
|
||||||
serializers.serialize(object.token,
|
|
||||||
specifiedType: const FullType(String)),
|
|
||||||
'plan',
|
'plan',
|
||||||
serializers.serialize(object.plan, specifiedType: const FullType(String)),
|
serializers.serialize(object.plan, specifiedType: const FullType(String)),
|
||||||
'account_key',
|
'account_key',
|
||||||
|
|
@ -274,10 +271,6 @@ class _$CompanyEntitySerializer implements StructuredSerializer<CompanyEntity> {
|
||||||
result.name = serializers.deserialize(value,
|
result.name = serializers.deserialize(value,
|
||||||
specifiedType: const FullType(String)) as String;
|
specifiedType: const FullType(String)) as String;
|
||||||
break;
|
break;
|
||||||
case 'token':
|
|
||||||
result.token = serializers.deserialize(value,
|
|
||||||
specifiedType: const FullType(String)) as String;
|
|
||||||
break;
|
|
||||||
case 'plan':
|
case 'plan':
|
||||||
result.plan = serializers.deserialize(value,
|
result.plan = serializers.deserialize(value,
|
||||||
specifiedType: const FullType(String)) as String;
|
specifiedType: const FullType(String)) as String;
|
||||||
|
|
@ -885,8 +878,6 @@ class _$CompanyEntity extends CompanyEntity {
|
||||||
@override
|
@override
|
||||||
final String name;
|
final String name;
|
||||||
@override
|
@override
|
||||||
final String token;
|
|
||||||
@override
|
|
||||||
final String plan;
|
final String plan;
|
||||||
@override
|
@override
|
||||||
final String companyKey;
|
final String companyKey;
|
||||||
|
|
@ -1018,7 +1009,6 @@ class _$CompanyEntity extends CompanyEntity {
|
||||||
|
|
||||||
_$CompanyEntity._(
|
_$CompanyEntity._(
|
||||||
{this.name,
|
{this.name,
|
||||||
this.token,
|
|
||||||
this.plan,
|
this.plan,
|
||||||
this.companyKey,
|
this.companyKey,
|
||||||
this.logoUrl,
|
this.logoUrl,
|
||||||
|
|
@ -1086,9 +1076,6 @@ class _$CompanyEntity extends CompanyEntity {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyEntity', 'name');
|
throw new BuiltValueNullFieldError('CompanyEntity', 'name');
|
||||||
}
|
}
|
||||||
if (token == null) {
|
|
||||||
throw new BuiltValueNullFieldError('CompanyEntity', 'token');
|
|
||||||
}
|
|
||||||
if (plan == null) {
|
if (plan == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyEntity', 'plan');
|
throw new BuiltValueNullFieldError('CompanyEntity', 'plan');
|
||||||
}
|
}
|
||||||
|
|
@ -1289,7 +1276,6 @@ class _$CompanyEntity extends CompanyEntity {
|
||||||
if (identical(other, this)) return true;
|
if (identical(other, this)) return true;
|
||||||
return other is CompanyEntity &&
|
return other is CompanyEntity &&
|
||||||
name == other.name &&
|
name == other.name &&
|
||||||
token == other.token &&
|
|
||||||
plan == other.plan &&
|
plan == other.plan &&
|
||||||
companyKey == other.companyKey &&
|
companyKey == other.companyKey &&
|
||||||
logoUrl == other.logoUrl &&
|
logoUrl == other.logoUrl &&
|
||||||
|
|
@ -1375,7 +1361,7 @@ class _$CompanyEntity extends CompanyEntity {
|
||||||
$jc(
|
$jc(
|
||||||
$jc(
|
$jc(
|
||||||
$jc(
|
$jc(
|
||||||
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, name.hashCode), token.hashCode), plan.hashCode), companyKey.hashCode), logoUrl.hashCode), appUrl.hashCode), companyCurrencyId.hashCode), timezoneId.hashCode), countryId.hashCode), dateFormatId.hashCode), datetimeFormatId.hashCode), defaultInvoiceTerms.hashCode), enableInvoiceTaxes.hashCode), enableInvoiceItemTaxes.hashCode), defaultInvoiceDesignId.hashCode), defaultQuoteDesignId.hashCode), languageId.hashCode), defaultInvoiceFooter.hashCode), showInvoiceItemTaxes.hashCode), enableMilitaryTime.hashCode), defaultTaxName1.hashCode), defaultTaxRate1.hashCode), defaultTaxName2.hashCode), defaultTaxRate2.hashCode), defaultQuoteTerms.hashCode), showCurrencyCode.hashCode), enableSecondTaxRate.hashCode), startOfWeek.hashCode), financialYearStart.hashCode), enabledModules.hashCode), defaultPaymentTerms.hashCode), defaultPaymentTypeId.hashCode), defaultTaskRate.hashCode), enableInclusiveTaxes.hashCode), convertProductExchangeRate.hashCode), enableCustomInvoiceTaxes1.hashCode), enableCustomInvoiceTaxes2.hashCode), taxRates.hashCode), taskStatuses.hashCode), taskStatusMap.hashCode), expenseCategories.hashCode), expenseCategoryMap.hashCode), users.hashCode), userMap.hashCode), customFields.hashCode), customPaymentTerms.hashCode),
|
$jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, name.hashCode), plan.hashCode), companyKey.hashCode), logoUrl.hashCode), appUrl.hashCode), companyCurrencyId.hashCode), timezoneId.hashCode), countryId.hashCode), dateFormatId.hashCode), datetimeFormatId.hashCode), defaultInvoiceTerms.hashCode), enableInvoiceTaxes.hashCode), enableInvoiceItemTaxes.hashCode), defaultInvoiceDesignId.hashCode), defaultQuoteDesignId.hashCode), languageId.hashCode), defaultInvoiceFooter.hashCode), showInvoiceItemTaxes.hashCode), enableMilitaryTime.hashCode), defaultTaxName1.hashCode), defaultTaxRate1.hashCode), defaultTaxName2.hashCode), defaultTaxRate2.hashCode), defaultQuoteTerms.hashCode), showCurrencyCode.hashCode), enableSecondTaxRate.hashCode), startOfWeek.hashCode), financialYearStart.hashCode), enabledModules.hashCode), defaultPaymentTerms.hashCode), defaultPaymentTypeId.hashCode), defaultTaskRate.hashCode), enableInclusiveTaxes.hashCode), convertProductExchangeRate.hashCode), enableCustomInvoiceTaxes1.hashCode), enableCustomInvoiceTaxes2.hashCode), taxRates.hashCode), taskStatuses.hashCode), taskStatusMap.hashCode), expenseCategories.hashCode), expenseCategoryMap.hashCode), users.hashCode), userMap.hashCode), customFields.hashCode), customPaymentTerms.hashCode),
|
||||||
invoiceFields.hashCode),
|
invoiceFields.hashCode),
|
||||||
emailFooter.hashCode),
|
emailFooter.hashCode),
|
||||||
emailSubjectInvoice.hashCode),
|
emailSubjectInvoice.hashCode),
|
||||||
|
|
@ -1401,7 +1387,6 @@ class _$CompanyEntity extends CompanyEntity {
|
||||||
String toString() {
|
String toString() {
|
||||||
return (newBuiltValueToStringHelper('CompanyEntity')
|
return (newBuiltValueToStringHelper('CompanyEntity')
|
||||||
..add('name', name)
|
..add('name', name)
|
||||||
..add('token', token)
|
|
||||||
..add('plan', plan)
|
..add('plan', plan)
|
||||||
..add('companyKey', companyKey)
|
..add('companyKey', companyKey)
|
||||||
..add('logoUrl', logoUrl)
|
..add('logoUrl', logoUrl)
|
||||||
|
|
@ -1477,10 +1462,6 @@ class CompanyEntityBuilder
|
||||||
String get name => _$this._name;
|
String get name => _$this._name;
|
||||||
set name(String name) => _$this._name = name;
|
set name(String name) => _$this._name = name;
|
||||||
|
|
||||||
String _token;
|
|
||||||
String get token => _$this._token;
|
|
||||||
set token(String token) => _$this._token = token;
|
|
||||||
|
|
||||||
String _plan;
|
String _plan;
|
||||||
String get plan => _$this._plan;
|
String get plan => _$this._plan;
|
||||||
set plan(String plan) => _$this._plan = plan;
|
set plan(String plan) => _$this._plan = plan;
|
||||||
|
|
@ -1800,7 +1781,6 @@ class CompanyEntityBuilder
|
||||||
CompanyEntityBuilder get _$this {
|
CompanyEntityBuilder get _$this {
|
||||||
if (_$v != null) {
|
if (_$v != null) {
|
||||||
_name = _$v.name;
|
_name = _$v.name;
|
||||||
_token = _$v.token;
|
|
||||||
_plan = _$v.plan;
|
_plan = _$v.plan;
|
||||||
_companyKey = _$v.companyKey;
|
_companyKey = _$v.companyKey;
|
||||||
_logoUrl = _$v.logoUrl;
|
_logoUrl = _$v.logoUrl;
|
||||||
|
|
@ -1889,7 +1869,6 @@ class CompanyEntityBuilder
|
||||||
_$result = _$v ??
|
_$result = _$v ??
|
||||||
new _$CompanyEntity._(
|
new _$CompanyEntity._(
|
||||||
name: name,
|
name: name,
|
||||||
token: token,
|
|
||||||
plan: plan,
|
plan: plan,
|
||||||
companyKey: companyKey,
|
companyKey: companyKey,
|
||||||
logoUrl: logoUrl,
|
logoUrl: logoUrl,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ Serializers _$serializers = (new Serializers().toBuilder()
|
||||||
..add(ClientState.serializer)
|
..add(ClientState.serializer)
|
||||||
..add(ClientUIState.serializer)
|
..add(ClientUIState.serializer)
|
||||||
..add(CompanyEntity.serializer)
|
..add(CompanyEntity.serializer)
|
||||||
..add(UserCompanyState.serializer)
|
|
||||||
..add(ContactEntity.serializer)
|
..add(ContactEntity.serializer)
|
||||||
..add(CountryEntity.serializer)
|
..add(CountryEntity.serializer)
|
||||||
..add(CountryItemResponse.serializer)
|
..add(CountryItemResponse.serializer)
|
||||||
|
|
@ -119,6 +118,7 @@ Serializers _$serializers = (new Serializers().toBuilder()
|
||||||
..add(TokenEntity.serializer)
|
..add(TokenEntity.serializer)
|
||||||
..add(UIState.serializer)
|
..add(UIState.serializer)
|
||||||
..add(UserCompanyEntity.serializer)
|
..add(UserCompanyEntity.serializer)
|
||||||
|
..add(UserCompanyState.serializer)
|
||||||
..add(UserEntity.serializer)
|
..add(UserEntity.serializer)
|
||||||
..add(VendorContactEntity.serializer)
|
..add(VendorContactEntity.serializer)
|
||||||
..add(VendorEntity.serializer)
|
..add(VendorEntity.serializer)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
|
|
@ -16,15 +17,15 @@ class ClientRepository {
|
||||||
|
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<ClientEntity> loadItem(CompanyEntity company, AuthState auth,
|
Future<ClientEntity> loadItem(
|
||||||
String entityId, bool loadActivities) async {
|
Credentials credentials, String entityId, bool loadActivities) async {
|
||||||
String url = '${auth.url}/clients/$entityId';
|
String url = '${credentials.url}/clients/$entityId';
|
||||||
|
|
||||||
if (loadActivities) {
|
if (loadActivities) {
|
||||||
url += '?include=activities';
|
url += '?include=activities';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final ClientItemResponse clientResponse =
|
final ClientItemResponse clientResponse =
|
||||||
serializers.deserializeWith(ClientItemResponse.serializer, response);
|
serializers.deserializeWith(ClientItemResponse.serializer, response);
|
||||||
|
|
@ -33,14 +34,14 @@ class ClientRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<ClientEntity>> loadList(
|
Future<BuiltList<ClientEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/clients?';
|
String url = credentials.url + '/clients?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final ClientListResponse clientResponse =
|
final ClientListResponse clientResponse =
|
||||||
serializers.deserializeWith(ClientListResponse.serializer, response);
|
serializers.deserializeWith(ClientListResponse.serializer, response);
|
||||||
|
|
@ -48,21 +49,22 @@ class ClientRepository {
|
||||||
return clientResponse.data;
|
return clientResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ClientEntity> saveData(
|
Future<ClientEntity> saveData(Credentials credentials, ClientEntity client,
|
||||||
CompanyEntity company, AuthState auth, ClientEntity client,
|
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
final data = serializers.serializeWith(ClientEntity.serializer, client);
|
final data = serializers.serializeWith(ClientEntity.serializer, client);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (client.isNew) {
|
if (client.isNew) {
|
||||||
response = await webClient.post(auth.url + '/clients?include=activities',
|
response = await webClient.post(
|
||||||
company.token, json.encode(data));
|
credentials.url + '/clients?include=activities',
|
||||||
|
credentials.token,
|
||||||
|
json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = auth.url + '/clients/${client.id}?include=activities';
|
var url = credentials.url + '/clients/${client.id}?include=activities';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '&action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ClientItemResponse clientResponse =
|
final ClientItemResponse clientResponse =
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
import 'package:invoiceninja_flutter/data/models/entities.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
|
|
@ -13,10 +14,10 @@ class DashboardRepository {
|
||||||
|
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<DashboardEntity> loadItem(
|
Future<DashboardEntity> loadItem(Credentials connectionInfo) async {
|
||||||
CompanyEntity company, AuthState auth) async {
|
|
||||||
final dynamic response = await webClient.get(
|
final dynamic response = await webClient.get(
|
||||||
auth.url + '/dashboard?only_activity=true', company.token);
|
connectionInfo.url + '/dashboard?only_activity=true',
|
||||||
|
connectionInfo.token);
|
||||||
|
|
||||||
final DashboardResponse dashboardResponse =
|
final DashboardResponse dashboardResponse =
|
||||||
serializers.deserializeWith(DashboardResponse.serializer, response);
|
serializers.deserializeWith(DashboardResponse.serializer, response);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
|
|
@ -16,9 +17,9 @@ class DocumentRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<DocumentEntity> loadItem(
|
Future<DocumentEntity> loadItem(
|
||||||
CompanyEntity company, AuthState auth, String entityId) async {
|
Credentials credentials, String entityId) async {
|
||||||
final dynamic response =
|
final dynamic response = await webClient.get(
|
||||||
await webClient.get('${auth.url}/documents/$entityId', company.token);
|
'${credentials.url}/documents/$entityId', credentials.token);
|
||||||
|
|
||||||
final DocumentItemResponse documentResponse =
|
final DocumentItemResponse documentResponse =
|
||||||
serializers.deserializeWith(DocumentItemResponse.serializer, response);
|
serializers.deserializeWith(DocumentItemResponse.serializer, response);
|
||||||
|
|
@ -27,14 +28,14 @@ class DocumentRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<DocumentEntity>> loadList(
|
Future<BuiltList<DocumentEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/documents?';
|
String url = credentials.url + '/documents?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final DocumentListResponse documentResponse =
|
final DocumentListResponse documentResponse =
|
||||||
serializers.deserializeWith(DocumentListResponse.serializer, response);
|
serializers.deserializeWith(DocumentListResponse.serializer, response);
|
||||||
|
|
@ -43,7 +44,7 @@ class DocumentRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<DocumentEntity> saveData(
|
Future<DocumentEntity> saveData(
|
||||||
CompanyEntity company, AuthState auth, DocumentEntity document,
|
Credentials credentials, DocumentEntity document,
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
|
|
@ -55,19 +56,20 @@ class DocumentRepository {
|
||||||
fields['invoice_id'] = '${document.invoiceId}';
|
fields['invoice_id'] = '${document.invoiceId}';
|
||||||
}
|
}
|
||||||
|
|
||||||
response = await webClient.post(
|
response = await webClient.post('${credentials.url}/documents',
|
||||||
'${auth.url}/documents', company.token, fields, document.path);
|
credentials.token, fields, document.path);
|
||||||
} else {
|
} else {
|
||||||
final data =
|
final data =
|
||||||
serializers.serializeWith(DocumentEntity.serializer, document);
|
serializers.serializeWith(DocumentEntity.serializer, document);
|
||||||
var url = '${auth.url}/documents/${document.id}';
|
var url = '${credentials.url}/documents/${document.id}';
|
||||||
if (action == EntityAction.delete) {
|
if (action == EntityAction.delete) {
|
||||||
response = await webClient.delete(url, company.token);
|
response = await webClient.delete(url, credentials.token);
|
||||||
} else {
|
} else {
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response =
|
||||||
|
await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
|
|
@ -16,9 +17,9 @@ class ExpenseRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<ExpenseEntity> loadItem(
|
Future<ExpenseEntity> loadItem(
|
||||||
CompanyEntity company, AuthState auth, String entityId) async {
|
Credentials credentials, String entityId) async {
|
||||||
final dynamic response =
|
final dynamic response = await webClient.get(
|
||||||
await webClient.get('${auth.url}/expenses/$entityId', company.token);
|
'${credentials.url}/expenses/$entityId', credentials.token);
|
||||||
|
|
||||||
final ExpenseItemResponse expenseResponse =
|
final ExpenseItemResponse expenseResponse =
|
||||||
serializers.deserializeWith(ExpenseItemResponse.serializer, response);
|
serializers.deserializeWith(ExpenseItemResponse.serializer, response);
|
||||||
|
|
@ -27,14 +28,14 @@ class ExpenseRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<ExpenseEntity>> loadList(
|
Future<BuiltList<ExpenseEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/expenses?';
|
String url = credentials.url + '/expenses?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final ExpenseListResponse expenseResponse =
|
final ExpenseListResponse expenseResponse =
|
||||||
serializers.deserializeWith(ExpenseListResponse.serializer, response);
|
serializers.deserializeWith(ExpenseListResponse.serializer, response);
|
||||||
|
|
@ -42,21 +43,20 @@ class ExpenseRepository {
|
||||||
return expenseResponse.data;
|
return expenseResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ExpenseEntity> saveData(
|
Future<ExpenseEntity> saveData(Credentials credentials, ExpenseEntity expense,
|
||||||
CompanyEntity company, AuthState auth, ExpenseEntity expense,
|
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
final data = serializers.serializeWith(ExpenseEntity.serializer, expense);
|
final data = serializers.serializeWith(ExpenseEntity.serializer, expense);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (expense.isNew) {
|
if (expense.isNew) {
|
||||||
response = await webClient.post(
|
response = await webClient.post(
|
||||||
auth.url + '/expenses', company.token, json.encode(data));
|
credentials.url + '/expenses', credentials.token, json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = auth.url + '/expenses/' + expense.id.toString();
|
var url = credentials.url + '/expenses/' + expense.id.toString();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ExpenseItemResponse expenseResponse =
|
final ExpenseItemResponse expenseResponse =
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
|
|
@ -17,9 +18,10 @@ class InvoiceRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<InvoiceEntity> loadItem(
|
Future<InvoiceEntity> loadItem(
|
||||||
CompanyEntity company, AuthState auth, String entityId) async {
|
Credentials credentials, String entityId) async {
|
||||||
final dynamic response = await webClient.get(
|
final dynamic response = await webClient.get(
|
||||||
'${auth.url}/invoices/$entityId?include=invitations', company.token);
|
'${credentials.url}/invoices/$entityId?include=invitations',
|
||||||
|
credentials.token);
|
||||||
|
|
||||||
final InvoiceItemResponse invoiceResponse =
|
final InvoiceItemResponse invoiceResponse =
|
||||||
serializers.deserializeWith(InvoiceItemResponse.serializer, response);
|
serializers.deserializeWith(InvoiceItemResponse.serializer, response);
|
||||||
|
|
@ -28,15 +30,15 @@ class InvoiceRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<InvoiceEntity>> loadList(
|
Future<BuiltList<InvoiceEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url +
|
String url = credentials.url +
|
||||||
'/invoices?include=invitations&invoice_type_id=1&is_recurring=0'; // invoice_type_id=1
|
'/invoices?include=invitations&invoice_type_id=1&is_recurring=0'; // invoice_type_id=1
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final InvoiceListResponse invoiceResponse =
|
final InvoiceListResponse invoiceResponse =
|
||||||
serializers.deserializeWith(InvoiceListResponse.serializer, response);
|
serializers.deserializeWith(InvoiceListResponse.serializer, response);
|
||||||
|
|
@ -44,23 +46,22 @@ class InvoiceRepository {
|
||||||
return invoiceResponse.data;
|
return invoiceResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<InvoiceEntity> saveData(
|
Future<InvoiceEntity> saveData(Credentials credentials, InvoiceEntity invoice,
|
||||||
CompanyEntity company, AuthState auth, InvoiceEntity invoice,
|
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
final data = serializers.serializeWith(InvoiceEntity.serializer, invoice);
|
final data = serializers.serializeWith(InvoiceEntity.serializer, invoice);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (invoice.isNew) {
|
if (invoice.isNew) {
|
||||||
response = await webClient.post(
|
response = await webClient.post(
|
||||||
auth.url + '/invoices?include=invitations',
|
credentials.url + '/invoices?include=invitations',
|
||||||
company.token,
|
credentials.token,
|
||||||
json.encode(data));
|
json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = '${auth.url}/invoices/${invoice.id}';
|
var url = '${credentials.url}/invoices/${invoice.id}';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final InvoiceItemResponse invoiceResponse =
|
final InvoiceItemResponse invoiceResponse =
|
||||||
|
|
@ -69,13 +70,8 @@ class InvoiceRepository {
|
||||||
return invoiceResponse.data;
|
return invoiceResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> emailInvoice(
|
Future<Null> emailInvoice(Credentials credentials, InvoiceEntity invoice,
|
||||||
CompanyEntity company,
|
EmailTemplate template, String subject, String body) async {
|
||||||
AuthState auth,
|
|
||||||
InvoiceEntity invoice,
|
|
||||||
EmailTemplate template,
|
|
||||||
String subject,
|
|
||||||
String body) async {
|
|
||||||
final data = {
|
final data = {
|
||||||
'reminder': template == EmailTemplate.initial ? '' : template.toString(),
|
'reminder': template == EmailTemplate.initial ? '' : template.toString(),
|
||||||
'template': {
|
'template': {
|
||||||
|
|
@ -84,13 +80,15 @@ class InvoiceRepository {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await webClient.post(auth.url + '/email_invoice?invoice_id=${invoice.id}',
|
await webClient.post(
|
||||||
company.token, json.encode(data));
|
credentials.url + '/email_invoice?invoice_id=${invoice.id}',
|
||||||
|
credentials.token,
|
||||||
|
json.encode(data));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
final Future<dynamic> response = await webClient.post(
|
final Future<dynamic> response = await webClient.post(
|
||||||
auth.url + '/email_invoice?invoice_id=${invoice.id}',
|
credentials.url + '/email_invoice?invoice_id=${invoice.id}',
|
||||||
company.token,
|
credentials.token,
|
||||||
json.encode(data));
|
json.encode(data));
|
||||||
|
|
||||||
final InvoiceItemResponse invoiceResponse =
|
final InvoiceItemResponse invoiceResponse =
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
|
|
@ -17,14 +18,14 @@ class PaymentRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<BuiltList<PaymentEntity>> loadList(
|
Future<BuiltList<PaymentEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/payments?';
|
String url = credentials.url + '/payments?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final PaymentListResponse paymentResponse =
|
final PaymentListResponse paymentResponse =
|
||||||
serializers.deserializeWith(PaymentListResponse.serializer, response);
|
serializers.deserializeWith(PaymentListResponse.serializer, response);
|
||||||
|
|
@ -32,27 +33,27 @@ class PaymentRepository {
|
||||||
return paymentResponse.data;
|
return paymentResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<PaymentEntity> saveData(
|
Future<PaymentEntity> saveData(Credentials credentials, PaymentEntity payment,
|
||||||
CompanyEntity company, AuthState auth, PaymentEntity payment,
|
|
||||||
{EntityAction action, bool sendEmail = false}) async {
|
{EntityAction action, bool sendEmail = false}) async {
|
||||||
final data = serializers.serializeWith(PaymentEntity.serializer, payment);
|
final data = serializers.serializeWith(PaymentEntity.serializer, payment);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (payment.isNew) {
|
if (payment.isNew) {
|
||||||
var url = auth.url + '/payments';
|
var url = credentials.url + '/payments';
|
||||||
if (sendEmail) {
|
if (sendEmail) {
|
||||||
url += '?email_receipt=true';
|
url += '?email_receipt=true';
|
||||||
}
|
}
|
||||||
response = await webClient.post(url, company.token, json.encode(data));
|
response =
|
||||||
|
await webClient.post(url, credentials.token, json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = '${auth.url}/payments/${payment.id}?';
|
var url = '${credentials.url}/payments/${payment.id}?';
|
||||||
if (sendEmail) {
|
if (sendEmail) {
|
||||||
url += '&email_receipt=true';
|
url += '&email_receipt=true';
|
||||||
}
|
}
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '&action=' + action.toString();
|
url += '&action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final PaymentItemResponse paymentResponse =
|
final PaymentItemResponse paymentResponse =
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
|
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
|
|
@ -17,14 +18,14 @@ class ProductRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<BuiltList<ProductEntity>> loadList(
|
Future<BuiltList<ProductEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/products?';
|
String url = credentials.url + '/products?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final ProductListResponse productResponse =
|
final ProductListResponse productResponse =
|
||||||
serializers.deserializeWith(ProductListResponse.serializer, response);
|
serializers.deserializeWith(ProductListResponse.serializer, response);
|
||||||
|
|
@ -32,21 +33,20 @@ class ProductRepository {
|
||||||
return productResponse.data;
|
return productResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ProductEntity> saveData(
|
Future<ProductEntity> saveData(Credentials credentials, ProductEntity product,
|
||||||
CompanyEntity company, AuthState auth, ProductEntity product,
|
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
final data = serializers.serializeWith(ProductEntity.serializer, product);
|
final data = serializers.serializeWith(ProductEntity.serializer, product);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (product.isNew) {
|
if (product.isNew) {
|
||||||
response = await webClient.post(
|
response = await webClient.post(
|
||||||
auth.url + '/products', company.token, json.encode(data));
|
credentials.url + '/products', credentials.token, json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = auth.url + '/products/' + product.id.toString();
|
var url = credentials.url + '/products/' + product.id.toString();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ProductItemResponse productResponse =
|
final ProductItemResponse productResponse =
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
|
|
@ -16,9 +17,9 @@ class ProjectRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<ProjectEntity> loadItem(
|
Future<ProjectEntity> loadItem(
|
||||||
CompanyEntity company, AuthState auth, String entityId) async {
|
Credentials credentials, String entityId) async {
|
||||||
final dynamic response =
|
final dynamic response = await webClient.get(
|
||||||
await webClient.get('${auth.url}/projects/$entityId', company.token);
|
'${credentials.url}/projects/$entityId', credentials.token);
|
||||||
|
|
||||||
final ProjectItemResponse projectResponse =
|
final ProjectItemResponse projectResponse =
|
||||||
serializers.deserializeWith(ProjectItemResponse.serializer, response);
|
serializers.deserializeWith(ProjectItemResponse.serializer, response);
|
||||||
|
|
@ -27,14 +28,14 @@ class ProjectRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<ProjectEntity>> loadList(
|
Future<BuiltList<ProjectEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/projects?';
|
String url = credentials.url + '/projects?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final ProjectListResponse projectResponse =
|
final ProjectListResponse projectResponse =
|
||||||
serializers.deserializeWith(ProjectListResponse.serializer, response);
|
serializers.deserializeWith(ProjectListResponse.serializer, response);
|
||||||
|
|
@ -42,21 +43,20 @@ class ProjectRepository {
|
||||||
return projectResponse.data;
|
return projectResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<ProjectEntity> saveData(
|
Future<ProjectEntity> saveData(Credentials credentials, ProjectEntity project,
|
||||||
CompanyEntity company, AuthState auth, ProjectEntity project,
|
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
final data = serializers.serializeWith(ProjectEntity.serializer, project);
|
final data = serializers.serializeWith(ProjectEntity.serializer, project);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (project.isNew) {
|
if (project.isNew) {
|
||||||
response = await webClient.post(
|
response = await webClient.post(
|
||||||
auth.url + '/projects', company.token, json.encode(data));
|
credentials.url + '/projects', credentials.token, json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = auth.url + '/projects/' + project.id.toString();
|
var url = credentials.url + '/projects/' + project.id.toString();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ProjectItemResponse projectResponse =
|
final ProjectItemResponse projectResponse =
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
|
|
@ -16,9 +17,10 @@ class QuoteRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<InvoiceEntity> loadItem(
|
Future<InvoiceEntity> loadItem(
|
||||||
CompanyEntity company, AuthState auth, String entityId) async {
|
Credentials credentials, String entityId) async {
|
||||||
final dynamic response = await webClient.get(
|
final dynamic response = await webClient.get(
|
||||||
'${auth.url}/invoices/$entityId?include=invitations', company.token);
|
'${credentials.url}/invoices/$entityId?include=invitations',
|
||||||
|
credentials.token);
|
||||||
|
|
||||||
final InvoiceItemResponse quoteResponse =
|
final InvoiceItemResponse quoteResponse =
|
||||||
serializers.deserializeWith(InvoiceItemResponse.serializer, response);
|
serializers.deserializeWith(InvoiceItemResponse.serializer, response);
|
||||||
|
|
@ -27,15 +29,15 @@ class QuoteRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<InvoiceEntity>> loadList(
|
Future<BuiltList<InvoiceEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url +
|
String url = credentials.url +
|
||||||
'/invoices?include=invitations&invoice_type_id=2&is_recurring=0';
|
'/invoices?include=invitations&invoice_type_id=2&is_recurring=0';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final InvoiceListResponse quoteResponse =
|
final InvoiceListResponse quoteResponse =
|
||||||
serializers.deserializeWith(InvoiceListResponse.serializer, response);
|
serializers.deserializeWith(InvoiceListResponse.serializer, response);
|
||||||
|
|
@ -43,23 +45,22 @@ class QuoteRepository {
|
||||||
return quoteResponse.data;
|
return quoteResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<InvoiceEntity> saveData(
|
Future<InvoiceEntity> saveData(Credentials credentials, InvoiceEntity quote,
|
||||||
CompanyEntity company, AuthState auth, InvoiceEntity quote,
|
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
final data = serializers.serializeWith(InvoiceEntity.serializer, quote);
|
final data = serializers.serializeWith(InvoiceEntity.serializer, quote);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (quote.isNew) {
|
if (quote.isNew) {
|
||||||
response = await webClient.post(
|
response = await webClient.post(
|
||||||
auth.url + '/invoices?include=invitations',
|
credentials.url + '/invoices?include=invitations',
|
||||||
company.token,
|
credentials.token,
|
||||||
json.encode(data));
|
json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = '${auth.url}/invoices/${quote.id}';
|
var url = '${credentials.url}/invoices/${quote.id}';
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final InvoiceItemResponse quoteResponse =
|
final InvoiceItemResponse quoteResponse =
|
||||||
|
|
@ -68,13 +69,8 @@ class QuoteRepository {
|
||||||
return quoteResponse.data;
|
return quoteResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Null> emailQuote(
|
Future<Null> emailQuote(Credentials credentials, InvoiceEntity quote,
|
||||||
CompanyEntity company,
|
EmailTemplate template, String subject, String body) async {
|
||||||
AuthState auth,
|
|
||||||
InvoiceEntity quote,
|
|
||||||
EmailTemplate template,
|
|
||||||
String subject,
|
|
||||||
String body) async {
|
|
||||||
final data = {
|
final data = {
|
||||||
'reminder': template == EmailTemplate.initial ? '' : template.toString(),
|
'reminder': template == EmailTemplate.initial ? '' : template.toString(),
|
||||||
'template': {
|
'template': {
|
||||||
|
|
@ -83,7 +79,9 @@ class QuoteRepository {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await webClient.post(auth.url + '/email_invoice?invoice_id=${quote.id}',
|
await webClient.post(
|
||||||
company.token, json.encode(data));
|
credentials.url + '/email_invoice?invoice_id=${quote.id}',
|
||||||
|
credentials.token,
|
||||||
|
json.encode(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
|
|
@ -13,10 +14,9 @@ class StaticRepository {
|
||||||
|
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<StaticDataEntity> loadList(
|
Future<StaticDataEntity> loadList(Credentials credentials) async {
|
||||||
CompanyEntity company, AuthState auth) async {
|
|
||||||
final dynamic response =
|
final dynamic response =
|
||||||
await webClient.get(auth.url + '/static', company.token);
|
await webClient.get(credentials.url + '/static', credentials.token);
|
||||||
|
|
||||||
final StaticDataItemResponse staticDataResponse = serializers
|
final StaticDataItemResponse staticDataResponse = serializers
|
||||||
.deserializeWith(StaticDataItemResponse.serializer, response);
|
.deserializeWith(StaticDataItemResponse.serializer, response);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
|
|
@ -15,10 +16,9 @@ class TaskRepository {
|
||||||
|
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<TaskEntity> loadItem(
|
Future<TaskEntity> loadItem(Credentials credentials, String entityId) async {
|
||||||
CompanyEntity company, AuthState auth, String entityId) async {
|
final dynamic response = await webClient.get(
|
||||||
final dynamic response =
|
'${credentials.url}/tasks/$entityId', credentials.token);
|
||||||
await webClient.get('${auth.url}/tasks/$entityId', company.token);
|
|
||||||
|
|
||||||
final TaskItemResponse taskResponse =
|
final TaskItemResponse taskResponse =
|
||||||
serializers.deserializeWith(TaskItemResponse.serializer, response);
|
serializers.deserializeWith(TaskItemResponse.serializer, response);
|
||||||
|
|
@ -27,14 +27,14 @@ class TaskRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<TaskEntity>> loadList(
|
Future<BuiltList<TaskEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/tasks?';
|
String url = credentials.url + '/tasks?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final TaskListResponse taskResponse =
|
final TaskListResponse taskResponse =
|
||||||
serializers.deserializeWith(TaskListResponse.serializer, response);
|
serializers.deserializeWith(TaskListResponse.serializer, response);
|
||||||
|
|
@ -42,8 +42,7 @@ class TaskRepository {
|
||||||
return taskResponse.data;
|
return taskResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<TaskEntity> saveData(
|
Future<TaskEntity> saveData(Credentials credentials, TaskEntity task,
|
||||||
CompanyEntity company, AuthState auth, TaskEntity task,
|
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
// Workaround for API issue
|
// Workaround for API issue
|
||||||
if (task.isNew) {
|
if (task.isNew) {
|
||||||
|
|
@ -56,13 +55,13 @@ class TaskRepository {
|
||||||
|
|
||||||
if (task.isNew) {
|
if (task.isNew) {
|
||||||
response = await webClient.post(
|
response = await webClient.post(
|
||||||
auth.url + '/tasks', company.token, json.encode(data));
|
credentials.url + '/tasks', credentials.token, json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = auth.url + '/tasks/' + task.id.toString();
|
var url = credentials.url + '/tasks/' + task.id.toString();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final TaskItemResponse taskResponse =
|
final TaskItemResponse taskResponse =
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:core';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
import 'package:invoiceninja_flutter/data/models/serializers.dart';
|
||||||
|
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
import 'package:invoiceninja_flutter/redux/auth/auth_state.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||||
|
|
@ -16,9 +17,9 @@ class VendorRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<VendorEntity> loadItem(
|
Future<VendorEntity> loadItem(
|
||||||
CompanyEntity company, AuthState auth, String entityId) async {
|
Credentials credentials, String entityId) async {
|
||||||
final dynamic response =
|
final dynamic response = await webClient.get(
|
||||||
await webClient.get('${auth.url}/vendors/$entityId', company.token);
|
'${credentials.url}/vendors/$entityId', credentials.token);
|
||||||
|
|
||||||
final VendorItemResponse vendorResponse =
|
final VendorItemResponse vendorResponse =
|
||||||
serializers.deserializeWith(VendorItemResponse.serializer, response);
|
serializers.deserializeWith(VendorItemResponse.serializer, response);
|
||||||
|
|
@ -27,14 +28,14 @@ class VendorRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<VendorEntity>> loadList(
|
Future<BuiltList<VendorEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/vendors?';
|
String url = credentials.url + '/vendors?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final VendorListResponse vendorResponse =
|
final VendorListResponse vendorResponse =
|
||||||
serializers.deserializeWith(VendorListResponse.serializer, response);
|
serializers.deserializeWith(VendorListResponse.serializer, response);
|
||||||
|
|
@ -42,21 +43,20 @@ class VendorRepository {
|
||||||
return vendorResponse.data;
|
return vendorResponse.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<VendorEntity> saveData(
|
Future<VendorEntity> saveData(Credentials credentials, VendorEntity vendor,
|
||||||
CompanyEntity company, AuthState auth, VendorEntity vendor,
|
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
final data = serializers.serializeWith(VendorEntity.serializer, vendor);
|
final data = serializers.serializeWith(VendorEntity.serializer, vendor);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (vendor.isNew) {
|
if (vendor.isNew) {
|
||||||
response = await webClient.post(
|
response = await webClient.post(
|
||||||
auth.url + '/vendors', company.token, json.encode(data));
|
credentials.url + '/vendors', credentials.token, json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = auth.url + '/vendors/' + vendor.id.toString();
|
var url = credentials.url + '/vendors/' + vendor.id.toString();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final VendorItemResponse vendorResponse =
|
final VendorItemResponse vendorResponse =
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ Middleware<AppState> _createAccountLoaded() {
|
||||||
final UserCompanyEntity userCompany = data.userCompanies[i];
|
final UserCompanyEntity userCompany = data.userCompanies[i];
|
||||||
|
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
prefs.setString(getCompanyTokenKey(i), userCompany.company.token);
|
prefs.setString(getCompanyTokenKey(i), userCompany.token.token);
|
||||||
|
|
||||||
store.dispatch(SelectCompany(i + 1, userCompany));
|
store.dispatch(SelectCompany(i + 1, userCompany));
|
||||||
store.dispatch(LoadCompanySuccess(userCompany));
|
store.dispatch(LoadCompanySuccess(userCompany));
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,9 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
|
|
||||||
UserEntity get user => selectedCompanyState.user;
|
UserEntity get user => selectedCompanyState.user;
|
||||||
|
|
||||||
|
Credentials get credentials =>
|
||||||
|
Credentials(token: selectedCompanyState.token.token, url: authState.url);
|
||||||
|
|
||||||
EntityUIState getUIState(EntityType type) {
|
EntityUIState getUIState(EntityType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EntityType.product:
|
case EntityType.product:
|
||||||
|
|
@ -277,3 +280,9 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
//return 'Route: ${uiState.currentRoute}, Previous: ${uiState.previousRoute}, Layout: ${uiState.layout}, Menu: ${uiState.isMenuVisible}, History: ${uiState.isHistoryVisible}';
|
//return 'Route: ${uiState.currentRoute}, Previous: ${uiState.previousRoute}, Layout: ${uiState.layout}, Menu: ${uiState.isMenuVisible}, History: ${uiState.isHistoryVisible}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Credentials {
|
||||||
|
Credentials({this.url, this.token});
|
||||||
|
String url;
|
||||||
|
String token;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -278,34 +278,34 @@ class AppStateBuilder implements Builder<AppState, AppStateBuilder> {
|
||||||
UIStateBuilder get uiState => _$this._uiState ??= new UIStateBuilder();
|
UIStateBuilder get uiState => _$this._uiState ??= new UIStateBuilder();
|
||||||
set uiState(UIStateBuilder uiState) => _$this._uiState = uiState;
|
set uiState(UIStateBuilder uiState) => _$this._uiState = uiState;
|
||||||
|
|
||||||
CompanyStateBuilder _companyState1;
|
UserCompanyStateBuilder _companyState1;
|
||||||
CompanyStateBuilder get companyState1 =>
|
UserCompanyStateBuilder get companyState1 =>
|
||||||
_$this._companyState1 ??= new CompanyStateBuilder();
|
_$this._companyState1 ??= new UserCompanyStateBuilder();
|
||||||
set companyState1(CompanyStateBuilder companyState1) =>
|
set companyState1(UserCompanyStateBuilder companyState1) =>
|
||||||
_$this._companyState1 = companyState1;
|
_$this._companyState1 = companyState1;
|
||||||
|
|
||||||
CompanyStateBuilder _companyState2;
|
UserCompanyStateBuilder _companyState2;
|
||||||
CompanyStateBuilder get companyState2 =>
|
UserCompanyStateBuilder get companyState2 =>
|
||||||
_$this._companyState2 ??= new CompanyStateBuilder();
|
_$this._companyState2 ??= new UserCompanyStateBuilder();
|
||||||
set companyState2(CompanyStateBuilder companyState2) =>
|
set companyState2(UserCompanyStateBuilder companyState2) =>
|
||||||
_$this._companyState2 = companyState2;
|
_$this._companyState2 = companyState2;
|
||||||
|
|
||||||
CompanyStateBuilder _companyState3;
|
UserCompanyStateBuilder _companyState3;
|
||||||
CompanyStateBuilder get companyState3 =>
|
UserCompanyStateBuilder get companyState3 =>
|
||||||
_$this._companyState3 ??= new CompanyStateBuilder();
|
_$this._companyState3 ??= new UserCompanyStateBuilder();
|
||||||
set companyState3(CompanyStateBuilder companyState3) =>
|
set companyState3(UserCompanyStateBuilder companyState3) =>
|
||||||
_$this._companyState3 = companyState3;
|
_$this._companyState3 = companyState3;
|
||||||
|
|
||||||
CompanyStateBuilder _companyState4;
|
UserCompanyStateBuilder _companyState4;
|
||||||
CompanyStateBuilder get companyState4 =>
|
UserCompanyStateBuilder get companyState4 =>
|
||||||
_$this._companyState4 ??= new CompanyStateBuilder();
|
_$this._companyState4 ??= new UserCompanyStateBuilder();
|
||||||
set companyState4(CompanyStateBuilder companyState4) =>
|
set companyState4(UserCompanyStateBuilder companyState4) =>
|
||||||
_$this._companyState4 = companyState4;
|
_$this._companyState4 = companyState4;
|
||||||
|
|
||||||
CompanyStateBuilder _companyState5;
|
UserCompanyStateBuilder _companyState5;
|
||||||
CompanyStateBuilder get companyState5 =>
|
UserCompanyStateBuilder get companyState5 =>
|
||||||
_$this._companyState5 ??= new CompanyStateBuilder();
|
_$this._companyState5 ??= new UserCompanyStateBuilder();
|
||||||
set companyState5(CompanyStateBuilder companyState5) =>
|
set companyState5(UserCompanyStateBuilder companyState5) =>
|
||||||
_$this._companyState5 = companyState5;
|
_$this._companyState5 = companyState5;
|
||||||
|
|
||||||
AppStateBuilder();
|
AppStateBuilder();
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,7 @@ Middleware<AppState> _archiveClient(ClientRepository repository) {
|
||||||
final action = dynamicAction as ArchiveClientRequest;
|
final action = dynamicAction as ArchiveClientRequest;
|
||||||
final origClient = store.state.clientState.map[action.clientId];
|
final origClient = store.state.clientState.map[action.clientId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origClient, EntityAction.archive)
|
||||||
origClient, EntityAction.archive)
|
|
||||||
.then((ClientEntity client) {
|
.then((ClientEntity client) {
|
||||||
store.dispatch(ArchiveClientSuccess(client));
|
store.dispatch(ArchiveClientSuccess(client));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -127,8 +126,7 @@ Middleware<AppState> _deleteClient(ClientRepository repository) {
|
||||||
final action = dynamicAction as DeleteClientRequest;
|
final action = dynamicAction as DeleteClientRequest;
|
||||||
final origClient = store.state.clientState.map[action.clientId];
|
final origClient = store.state.clientState.map[action.clientId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origClient, EntityAction.delete)
|
||||||
origClient, EntityAction.delete)
|
|
||||||
.then((ClientEntity client) {
|
.then((ClientEntity client) {
|
||||||
store.dispatch(DeleteClientSuccess(client));
|
store.dispatch(DeleteClientSuccess(client));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -151,8 +149,7 @@ Middleware<AppState> _restoreClient(ClientRepository repository) {
|
||||||
final action = dynamicAction as RestoreClientRequest;
|
final action = dynamicAction as RestoreClientRequest;
|
||||||
final origClient = store.state.clientState.map[action.clientId];
|
final origClient = store.state.clientState.map[action.clientId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origClient, EntityAction.restore)
|
||||||
origClient, EntityAction.restore)
|
|
||||||
.then((ClientEntity client) {
|
.then((ClientEntity client) {
|
||||||
store.dispatch(RestoreClientSuccess(client));
|
store.dispatch(RestoreClientSuccess(client));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -174,8 +171,7 @@ Middleware<AppState> _saveClient(ClientRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as SaveClientRequest;
|
final action = dynamicAction as SaveClientRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.client)
|
||||||
store.state.selectedCompany, store.state.authState, action.client)
|
|
||||||
.then((ClientEntity client) {
|
.then((ClientEntity client) {
|
||||||
if (action.client.isNew) {
|
if (action.client.isNew) {
|
||||||
store.dispatch(AddClientSuccess(client));
|
store.dispatch(AddClientSuccess(client));
|
||||||
|
|
@ -211,8 +207,8 @@ Middleware<AppState> _loadClient(ClientRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadClientRequest());
|
store.dispatch(LoadClientRequest());
|
||||||
repository
|
repository
|
||||||
.loadItem(state.selectedCompany, state.authState, action.clientId,
|
.loadItem(
|
||||||
action.loadActivities)
|
store.state.credentials, action.clientId, action.loadActivities)
|
||||||
.then((client) {
|
.then((client) {
|
||||||
store.dispatch(LoadClientSuccess(client));
|
store.dispatch(LoadClientSuccess(client));
|
||||||
|
|
||||||
|
|
@ -249,9 +245,7 @@ Middleware<AppState> _loadClients(ClientRepository repository) {
|
||||||
final int updatedAt = (state.clientState.lastUpdated / 1000).round();
|
final int updatedAt = (state.clientState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadClientsRequest());
|
store.dispatch(LoadClientsRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadClientsSuccess(data));
|
store.dispatch(LoadClientsSuccess(data));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ import 'package:invoiceninja_flutter/redux/quote/quote_state.dart';
|
||||||
part 'company_state.g.dart';
|
part 'company_state.g.dart';
|
||||||
|
|
||||||
abstract class UserCompanyState
|
abstract class UserCompanyState
|
||||||
implements Built<UserCompanyState, CompanyStateBuilder> {
|
implements Built<UserCompanyState, UserCompanyStateBuilder> {
|
||||||
factory UserCompanyState() {
|
factory UserCompanyState() {
|
||||||
return _$CompanyState._(
|
return _$UserCompanyState._(
|
||||||
userCompany: UserCompanyEntity(),
|
userCompany: UserCompanyEntity(),
|
||||||
documentState: DocumentState(),
|
documentState: DocumentState(),
|
||||||
dashboardState: DashboardState(),
|
dashboardState: DashboardState(),
|
||||||
|
|
@ -80,5 +80,5 @@ abstract class UserCompanyState
|
||||||
|
|
||||||
//factory CompanyState([void updates(CompanyStateBuilder b)]) = _$CompanyState;
|
//factory CompanyState([void updates(CompanyStateBuilder b)]) = _$CompanyState;
|
||||||
static Serializer<UserCompanyState> get serializer =>
|
static Serializer<UserCompanyState> get serializer =>
|
||||||
_$companyStateSerializer;
|
_$userCompanyStateSerializer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,15 @@ part of 'company_state.dart';
|
||||||
// BuiltValueGenerator
|
// BuiltValueGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
Serializer<UserCompanyState> _$companyStateSerializer =
|
Serializer<UserCompanyState> _$userCompanyStateSerializer =
|
||||||
new _$CompanyStateSerializer();
|
new _$UserCompanyStateSerializer();
|
||||||
|
|
||||||
class _$CompanyStateSerializer
|
class _$UserCompanyStateSerializer
|
||||||
implements StructuredSerializer<UserCompanyState> {
|
implements StructuredSerializer<UserCompanyState> {
|
||||||
@override
|
@override
|
||||||
final Iterable<Type> types = const [UserCompanyState, _$CompanyState];
|
final Iterable<Type> types = const [UserCompanyState, _$UserCompanyState];
|
||||||
@override
|
@override
|
||||||
final String wireName = 'CompanyState';
|
final String wireName = 'UserCompanyState';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Iterable<Object> serialize(Serializers serializers, UserCompanyState object,
|
Iterable<Object> serialize(Serializers serializers, UserCompanyState object,
|
||||||
|
|
@ -67,7 +67,7 @@ class _$CompanyStateSerializer
|
||||||
UserCompanyState deserialize(
|
UserCompanyState deserialize(
|
||||||
Serializers serializers, Iterable<Object> serialized,
|
Serializers serializers, Iterable<Object> serialized,
|
||||||
{FullType specifiedType = FullType.unspecified}) {
|
{FullType specifiedType = FullType.unspecified}) {
|
||||||
final result = new CompanyStateBuilder();
|
final result = new UserCompanyStateBuilder();
|
||||||
|
|
||||||
final iterator = serialized.iterator;
|
final iterator = serialized.iterator;
|
||||||
while (iterator.moveNext()) {
|
while (iterator.moveNext()) {
|
||||||
|
|
@ -131,7 +131,7 @@ class _$CompanyStateSerializer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _$CompanyState extends UserCompanyState {
|
class _$UserCompanyState extends UserCompanyState {
|
||||||
@override
|
@override
|
||||||
final UserCompanyEntity userCompany;
|
final UserCompanyEntity userCompany;
|
||||||
@override
|
@override
|
||||||
|
|
@ -157,10 +157,11 @@ class _$CompanyState extends UserCompanyState {
|
||||||
@override
|
@override
|
||||||
final QuoteState quoteState;
|
final QuoteState quoteState;
|
||||||
|
|
||||||
factory _$CompanyState([void Function(CompanyStateBuilder) updates]) =>
|
factory _$UserCompanyState(
|
||||||
(new CompanyStateBuilder()..update(updates)).build();
|
[void Function(UserCompanyStateBuilder) updates]) =>
|
||||||
|
(new UserCompanyStateBuilder()..update(updates)).build();
|
||||||
|
|
||||||
_$CompanyState._(
|
_$UserCompanyState._(
|
||||||
{this.userCompany,
|
{this.userCompany,
|
||||||
this.documentState,
|
this.documentState,
|
||||||
this.dashboardState,
|
this.dashboardState,
|
||||||
|
|
@ -175,46 +176,47 @@ class _$CompanyState extends UserCompanyState {
|
||||||
this.quoteState})
|
this.quoteState})
|
||||||
: super._() {
|
: super._() {
|
||||||
if (documentState == null) {
|
if (documentState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'documentState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'documentState');
|
||||||
}
|
}
|
||||||
if (dashboardState == null) {
|
if (dashboardState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'dashboardState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'dashboardState');
|
||||||
}
|
}
|
||||||
if (productState == null) {
|
if (productState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'productState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'productState');
|
||||||
}
|
}
|
||||||
if (clientState == null) {
|
if (clientState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'clientState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'clientState');
|
||||||
}
|
}
|
||||||
if (invoiceState == null) {
|
if (invoiceState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'invoiceState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'invoiceState');
|
||||||
}
|
}
|
||||||
if (expenseState == null) {
|
if (expenseState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'expenseState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'expenseState');
|
||||||
}
|
}
|
||||||
if (vendorState == null) {
|
if (vendorState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'vendorState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'vendorState');
|
||||||
}
|
}
|
||||||
if (taskState == null) {
|
if (taskState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'taskState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'taskState');
|
||||||
}
|
}
|
||||||
if (projectState == null) {
|
if (projectState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'projectState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'projectState');
|
||||||
}
|
}
|
||||||
if (paymentState == null) {
|
if (paymentState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'paymentState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'paymentState');
|
||||||
}
|
}
|
||||||
if (quoteState == null) {
|
if (quoteState == null) {
|
||||||
throw new BuiltValueNullFieldError('CompanyState', 'quoteState');
|
throw new BuiltValueNullFieldError('UserCompanyState', 'quoteState');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
UserCompanyState rebuild(void Function(CompanyStateBuilder) updates) =>
|
UserCompanyState rebuild(void Function(UserCompanyStateBuilder) updates) =>
|
||||||
(toBuilder()..update(updates)).build();
|
(toBuilder()..update(updates)).build();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
CompanyStateBuilder toBuilder() => new CompanyStateBuilder()..replace(this);
|
UserCompanyStateBuilder toBuilder() =>
|
||||||
|
new UserCompanyStateBuilder()..replace(this);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
|
|
@ -262,7 +264,7 @@ class _$CompanyState extends UserCompanyState {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return (newBuiltValueToStringHelper('CompanyState')
|
return (newBuiltValueToStringHelper('UserCompanyState')
|
||||||
..add('userCompany', userCompany)
|
..add('userCompany', userCompany)
|
||||||
..add('documentState', documentState)
|
..add('documentState', documentState)
|
||||||
..add('dashboardState', dashboardState)
|
..add('dashboardState', dashboardState)
|
||||||
|
|
@ -279,9 +281,9 @@ class _$CompanyState extends UserCompanyState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CompanyStateBuilder
|
class UserCompanyStateBuilder
|
||||||
implements Builder<UserCompanyState, CompanyStateBuilder> {
|
implements Builder<UserCompanyState, UserCompanyStateBuilder> {
|
||||||
_$CompanyState _$v;
|
_$UserCompanyState _$v;
|
||||||
|
|
||||||
UserCompanyEntityBuilder _userCompany;
|
UserCompanyEntityBuilder _userCompany;
|
||||||
UserCompanyEntityBuilder get userCompany =>
|
UserCompanyEntityBuilder get userCompany =>
|
||||||
|
|
@ -354,9 +356,9 @@ class CompanyStateBuilder
|
||||||
set quoteState(QuoteStateBuilder quoteState) =>
|
set quoteState(QuoteStateBuilder quoteState) =>
|
||||||
_$this._quoteState = quoteState;
|
_$this._quoteState = quoteState;
|
||||||
|
|
||||||
CompanyStateBuilder();
|
UserCompanyStateBuilder();
|
||||||
|
|
||||||
CompanyStateBuilder get _$this {
|
UserCompanyStateBuilder get _$this {
|
||||||
if (_$v != null) {
|
if (_$v != null) {
|
||||||
_userCompany = _$v.userCompany?.toBuilder();
|
_userCompany = _$v.userCompany?.toBuilder();
|
||||||
_documentState = _$v.documentState?.toBuilder();
|
_documentState = _$v.documentState?.toBuilder();
|
||||||
|
|
@ -380,20 +382,20 @@ class CompanyStateBuilder
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
throw new ArgumentError.notNull('other');
|
throw new ArgumentError.notNull('other');
|
||||||
}
|
}
|
||||||
_$v = other as _$CompanyState;
|
_$v = other as _$UserCompanyState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void update(void Function(CompanyStateBuilder) updates) {
|
void update(void Function(UserCompanyStateBuilder) updates) {
|
||||||
if (updates != null) updates(this);
|
if (updates != null) updates(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_$CompanyState build() {
|
_$UserCompanyState build() {
|
||||||
_$CompanyState _$result;
|
_$UserCompanyState _$result;
|
||||||
try {
|
try {
|
||||||
_$result = _$v ??
|
_$result = _$v ??
|
||||||
new _$CompanyState._(
|
new _$UserCompanyState._(
|
||||||
userCompany: _userCompany?.build(),
|
userCompany: _userCompany?.build(),
|
||||||
documentState: documentState.build(),
|
documentState: documentState.build(),
|
||||||
dashboardState: dashboardState.build(),
|
dashboardState: dashboardState.build(),
|
||||||
|
|
@ -435,7 +437,7 @@ class CompanyStateBuilder
|
||||||
quoteState.build();
|
quoteState.build();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new BuiltValueNestedFieldError(
|
throw new BuiltValueNestedFieldError(
|
||||||
'CompanyState', _$failedField, e.toString());
|
'UserCompanyState', _$failedField, e.toString());
|
||||||
}
|
}
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ Middleware<AppState> _createLoadDashboard(DashboardRepository repository) {
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch(LoadDashboardRequest());
|
store.dispatch(LoadDashboardRequest());
|
||||||
repository.loadItem(state.selectedCompany, state.authState).then((data) {
|
repository.loadItem(state.credentials).then((data) {
|
||||||
store.dispatch(LoadDashboardSuccess(data));
|
store.dispatch(LoadDashboardSuccess(data));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,7 @@ Middleware<AppState> _archiveDocument(DocumentRepository repository) {
|
||||||
final action = dynamicAction as ArchiveDocumentRequest;
|
final action = dynamicAction as ArchiveDocumentRequest;
|
||||||
final origDocument = store.state.documentState.map[action.documentId];
|
final origDocument = store.state.documentState.map[action.documentId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origDocument, EntityAction.archive)
|
||||||
origDocument, EntityAction.archive)
|
|
||||||
.then((DocumentEntity document) {
|
.then((DocumentEntity document) {
|
||||||
store.dispatch(ArchiveDocumentSuccess(document));
|
store.dispatch(ArchiveDocumentSuccess(document));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -108,8 +107,7 @@ Middleware<AppState> _deleteDocument(DocumentRepository repository) {
|
||||||
final action = dynamicAction as DeleteDocumentRequest;
|
final action = dynamicAction as DeleteDocumentRequest;
|
||||||
final origDocument = store.state.documentState.map[action.documentId];
|
final origDocument = store.state.documentState.map[action.documentId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origDocument, EntityAction.delete)
|
||||||
origDocument, EntityAction.delete)
|
|
||||||
.then((DocumentEntity document) {
|
.then((DocumentEntity document) {
|
||||||
store.dispatch(DeleteDocumentSuccess(document));
|
store.dispatch(DeleteDocumentSuccess(document));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -132,8 +130,7 @@ Middleware<AppState> _restoreDocument(DocumentRepository repository) {
|
||||||
final action = dynamicAction as RestoreDocumentRequest;
|
final action = dynamicAction as RestoreDocumentRequest;
|
||||||
final origDocument = store.state.documentState.map[action.documentId];
|
final origDocument = store.state.documentState.map[action.documentId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origDocument, EntityAction.restore)
|
||||||
origDocument, EntityAction.restore)
|
|
||||||
.then((DocumentEntity document) {
|
.then((DocumentEntity document) {
|
||||||
store.dispatch(RestoreDocumentSuccess(document));
|
store.dispatch(RestoreDocumentSuccess(document));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -156,8 +153,7 @@ Middleware<AppState> _saveDocument(DocumentRepository repository) {
|
||||||
final action = dynamicAction as SaveDocumentRequest;
|
final action = dynamicAction as SaveDocumentRequest;
|
||||||
if (store.state.selectedCompany.isEnterprisePlan) {
|
if (store.state.selectedCompany.isEnterprisePlan) {
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, action.document)
|
||||||
action.document)
|
|
||||||
.then((DocumentEntity document) {
|
.then((DocumentEntity document) {
|
||||||
if (action.document.isNew) {
|
if (action.document.isNew) {
|
||||||
store.dispatch(AddDocumentSuccess(document));
|
store.dispatch(AddDocumentSuccess(document));
|
||||||
|
|
@ -192,7 +188,7 @@ Middleware<AppState> _loadDocument(DocumentRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadDocumentRequest());
|
store.dispatch(LoadDocumentRequest());
|
||||||
repository
|
repository
|
||||||
.loadItem(state.selectedCompany, state.authState, action.documentId)
|
.loadItem(store.state.credentials, action.documentId)
|
||||||
.then((document) {
|
.then((document) {
|
||||||
store.dispatch(LoadDocumentSuccess(document));
|
store.dispatch(LoadDocumentSuccess(document));
|
||||||
|
|
||||||
|
|
@ -229,9 +225,7 @@ Middleware<AppState> _loadDocuments(DocumentRepository repository) {
|
||||||
final int updatedAt = (state.documentState.lastUpdated / 1000).round();
|
final int updatedAt = (state.documentState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadDocumentsRequest());
|
store.dispatch(LoadDocumentsRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadDocumentsSuccess(data));
|
store.dispatch(LoadDocumentsSuccess(data));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,7 @@ Middleware<AppState> _archiveExpense(ExpenseRepository repository) {
|
||||||
final action = dynamicAction as ArchiveExpenseRequest;
|
final action = dynamicAction as ArchiveExpenseRequest;
|
||||||
final origExpense = store.state.expenseState.map[action.expenseId];
|
final origExpense = store.state.expenseState.map[action.expenseId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origExpense, EntityAction.archive)
|
||||||
origExpense, EntityAction.archive)
|
|
||||||
.then((ExpenseEntity expense) {
|
.then((ExpenseEntity expense) {
|
||||||
store.dispatch(ArchiveExpenseSuccess(expense));
|
store.dispatch(ArchiveExpenseSuccess(expense));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -134,8 +133,7 @@ Middleware<AppState> _deleteExpense(ExpenseRepository repository) {
|
||||||
final action = dynamicAction as DeleteExpenseRequest;
|
final action = dynamicAction as DeleteExpenseRequest;
|
||||||
final origExpense = store.state.expenseState.map[action.expenseId];
|
final origExpense = store.state.expenseState.map[action.expenseId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origExpense, EntityAction.delete)
|
||||||
origExpense, EntityAction.delete)
|
|
||||||
.then((ExpenseEntity expense) {
|
.then((ExpenseEntity expense) {
|
||||||
store.dispatch(DeleteExpenseSuccess(expense));
|
store.dispatch(DeleteExpenseSuccess(expense));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -158,8 +156,7 @@ Middleware<AppState> _restoreExpense(ExpenseRepository repository) {
|
||||||
final action = dynamicAction as RestoreExpenseRequest;
|
final action = dynamicAction as RestoreExpenseRequest;
|
||||||
final origExpense = store.state.expenseState.map[action.expenseId];
|
final origExpense = store.state.expenseState.map[action.expenseId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origExpense, EntityAction.restore)
|
||||||
origExpense, EntityAction.restore)
|
|
||||||
.then((ExpenseEntity expense) {
|
.then((ExpenseEntity expense) {
|
||||||
store.dispatch(RestoreExpenseSuccess(expense));
|
store.dispatch(RestoreExpenseSuccess(expense));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -181,8 +178,7 @@ Middleware<AppState> _saveExpense(ExpenseRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as SaveExpenseRequest;
|
final action = dynamicAction as SaveExpenseRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.expense)
|
||||||
store.state.selectedCompany, store.state.authState, action.expense)
|
|
||||||
.then((ExpenseEntity expense) {
|
.then((ExpenseEntity expense) {
|
||||||
if (action.expense.isNew) {
|
if (action.expense.isNew) {
|
||||||
store.dispatch(AddExpenseSuccess(expense));
|
store.dispatch(AddExpenseSuccess(expense));
|
||||||
|
|
@ -212,7 +208,7 @@ Middleware<AppState> _loadExpense(ExpenseRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadExpenseRequest());
|
store.dispatch(LoadExpenseRequest());
|
||||||
repository
|
repository
|
||||||
.loadItem(state.selectedCompany, state.authState, action.expenseId)
|
.loadItem(store.state.credentials, action.expenseId)
|
||||||
.then((expense) {
|
.then((expense) {
|
||||||
store.dispatch(LoadExpenseSuccess(expense));
|
store.dispatch(LoadExpenseSuccess(expense));
|
||||||
|
|
||||||
|
|
@ -249,9 +245,7 @@ Middleware<AppState> _loadExpenses(ExpenseRepository repository) {
|
||||||
final int updatedAt = (state.expenseState.lastUpdated / 1000).round();
|
final int updatedAt = (state.expenseState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadExpensesRequest());
|
store.dispatch(LoadExpensesRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadExpensesSuccess(data));
|
store.dispatch(LoadExpensesSuccess(data));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
|
||||||
|
|
@ -135,8 +135,7 @@ Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
|
||||||
final action = dynamicAction as ArchiveInvoiceRequest;
|
final action = dynamicAction as ArchiveInvoiceRequest;
|
||||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origInvoice, EntityAction.archive)
|
||||||
origInvoice, EntityAction.archive)
|
|
||||||
.then((InvoiceEntity invoice) {
|
.then((InvoiceEntity invoice) {
|
||||||
store.dispatch(ArchiveInvoiceSuccess(invoice));
|
store.dispatch(ArchiveInvoiceSuccess(invoice));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -159,8 +158,7 @@ Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
|
||||||
final action = dynamicAction as DeleteInvoiceRequest;
|
final action = dynamicAction as DeleteInvoiceRequest;
|
||||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origInvoice, EntityAction.delete)
|
||||||
origInvoice, EntityAction.delete)
|
|
||||||
.then((InvoiceEntity invoice) {
|
.then((InvoiceEntity invoice) {
|
||||||
store.dispatch(DeleteInvoiceSuccess(invoice));
|
store.dispatch(DeleteInvoiceSuccess(invoice));
|
||||||
store.dispatch(LoadClient(clientId: invoice.clientId));
|
store.dispatch(LoadClient(clientId: invoice.clientId));
|
||||||
|
|
@ -184,8 +182,7 @@ Middleware<AppState> _restoreInvoice(InvoiceRepository repository) {
|
||||||
final action = dynamicAction as RestoreInvoiceRequest;
|
final action = dynamicAction as RestoreInvoiceRequest;
|
||||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origInvoice, EntityAction.restore)
|
||||||
origInvoice, EntityAction.restore)
|
|
||||||
.then((InvoiceEntity invoice) {
|
.then((InvoiceEntity invoice) {
|
||||||
store.dispatch(RestoreInvoiceSuccess(invoice));
|
store.dispatch(RestoreInvoiceSuccess(invoice));
|
||||||
store.dispatch(LoadClient(clientId: invoice.clientId));
|
store.dispatch(LoadClient(clientId: invoice.clientId));
|
||||||
|
|
@ -209,8 +206,7 @@ Middleware<AppState> _markSentInvoice(InvoiceRepository repository) {
|
||||||
final action = dynamicAction as MarkSentInvoiceRequest;
|
final action = dynamicAction as MarkSentInvoiceRequest;
|
||||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origInvoice, EntityAction.markSent)
|
||||||
origInvoice, EntityAction.markSent)
|
|
||||||
.then((InvoiceEntity invoice) {
|
.then((InvoiceEntity invoice) {
|
||||||
store.dispatch(MarkSentInvoiceSuccess(invoice));
|
store.dispatch(MarkSentInvoiceSuccess(invoice));
|
||||||
store.dispatch(LoadClient(clientId: invoice.clientId));
|
store.dispatch(LoadClient(clientId: invoice.clientId));
|
||||||
|
|
@ -234,8 +230,8 @@ Middleware<AppState> _emailInvoice(InvoiceRepository repository) {
|
||||||
final action = dynamicAction as EmailInvoiceRequest;
|
final action = dynamicAction as EmailInvoiceRequest;
|
||||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||||
repository
|
repository
|
||||||
.emailInvoice(store.state.selectedCompany, store.state.authState,
|
.emailInvoice(store.state.credentials, origInvoice, action.template,
|
||||||
origInvoice, action.template, action.subject, action.body)
|
action.subject, action.body)
|
||||||
.then((void _) {
|
.then((void _) {
|
||||||
store.dispatch(EmailInvoiceSuccess());
|
store.dispatch(EmailInvoiceSuccess());
|
||||||
store.dispatch(LoadClient(clientId: origInvoice.clientId));
|
store.dispatch(LoadClient(clientId: origInvoice.clientId));
|
||||||
|
|
@ -258,8 +254,7 @@ Middleware<AppState> _saveInvoice(InvoiceRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as SaveInvoiceRequest;
|
final action = dynamicAction as SaveInvoiceRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.invoice)
|
||||||
store.state.selectedCompany, store.state.authState, action.invoice)
|
|
||||||
.then((InvoiceEntity invoice) {
|
.then((InvoiceEntity invoice) {
|
||||||
if (action.invoice.isNew) {
|
if (action.invoice.isNew) {
|
||||||
store.dispatch(AddInvoiceSuccess(invoice));
|
store.dispatch(AddInvoiceSuccess(invoice));
|
||||||
|
|
@ -297,7 +292,7 @@ Middleware<AppState> _loadInvoice(InvoiceRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadInvoiceRequest());
|
store.dispatch(LoadInvoiceRequest());
|
||||||
repository
|
repository
|
||||||
.loadItem(state.selectedCompany, state.authState, action.invoiceId)
|
.loadItem(store.state.credentials, action.invoiceId)
|
||||||
.then((invoice) {
|
.then((invoice) {
|
||||||
store.dispatch(LoadInvoiceSuccess(invoice));
|
store.dispatch(LoadInvoiceSuccess(invoice));
|
||||||
store.dispatch(LoadClient(clientId: invoice.clientId));
|
store.dispatch(LoadClient(clientId: invoice.clientId));
|
||||||
|
|
@ -335,9 +330,7 @@ Middleware<AppState> _loadInvoices(InvoiceRepository repository) {
|
||||||
final int updatedAt = (state.invoiceState.lastUpdated / 1000).round();
|
final int updatedAt = (state.invoiceState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadInvoicesRequest());
|
store.dispatch(LoadInvoicesRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadInvoicesSuccess(data));
|
store.dispatch(LoadInvoicesSuccess(data));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,7 @@ Middleware<AppState> _archivePayment(PaymentRepository repository) {
|
||||||
final action = dynamicAction as ArchivePaymentRequest;
|
final action = dynamicAction as ArchivePaymentRequest;
|
||||||
final origPayment = store.state.paymentState.map[action.paymentId];
|
final origPayment = store.state.paymentState.map[action.paymentId];
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, origPayment,
|
||||||
store.state.selectedCompany, store.state.authState, origPayment,
|
|
||||||
action: EntityAction.archive)
|
action: EntityAction.archive)
|
||||||
.then((PaymentEntity payment) {
|
.then((PaymentEntity payment) {
|
||||||
store.dispatch(ArchivePaymentSuccess(payment));
|
store.dispatch(ArchivePaymentSuccess(payment));
|
||||||
|
|
@ -134,8 +133,7 @@ Middleware<AppState> _deletePayment(PaymentRepository repository) {
|
||||||
final action = dynamicAction as DeletePaymentRequest;
|
final action = dynamicAction as DeletePaymentRequest;
|
||||||
final origPayment = store.state.paymentState.map[action.paymentId];
|
final origPayment = store.state.paymentState.map[action.paymentId];
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, origPayment,
|
||||||
store.state.selectedCompany, store.state.authState, origPayment,
|
|
||||||
action: EntityAction.delete)
|
action: EntityAction.delete)
|
||||||
.then((PaymentEntity payment) {
|
.then((PaymentEntity payment) {
|
||||||
store.dispatch(DeletePaymentSuccess(payment));
|
store.dispatch(DeletePaymentSuccess(payment));
|
||||||
|
|
@ -160,8 +158,7 @@ Middleware<AppState> _restorePayment(PaymentRepository repository) {
|
||||||
final action = dynamicAction as RestorePaymentRequest;
|
final action = dynamicAction as RestorePaymentRequest;
|
||||||
final origPayment = store.state.paymentState.map[action.paymentId];
|
final origPayment = store.state.paymentState.map[action.paymentId];
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, origPayment,
|
||||||
store.state.selectedCompany, store.state.authState, origPayment,
|
|
||||||
action: EntityAction.restore)
|
action: EntityAction.restore)
|
||||||
.then((PaymentEntity payment) {
|
.then((PaymentEntity payment) {
|
||||||
store.dispatch(RestorePaymentSuccess(payment));
|
store.dispatch(RestorePaymentSuccess(payment));
|
||||||
|
|
@ -188,9 +185,7 @@ Middleware<AppState> _savePayment(PaymentRepository repository) {
|
||||||
final bool sendEmail =
|
final bool sendEmail =
|
||||||
payment.isNew ? store.state.uiState.emailPayment : false;
|
payment.isNew ? store.state.uiState.emailPayment : false;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.payment, sendEmail: sendEmail)
|
||||||
store.state.selectedCompany, store.state.authState, action.payment,
|
|
||||||
sendEmail: sendEmail)
|
|
||||||
.then((PaymentEntity payment) {
|
.then((PaymentEntity payment) {
|
||||||
if (action.payment.isNew) {
|
if (action.payment.isNew) {
|
||||||
store.dispatch(AddPaymentSuccess(payment));
|
store.dispatch(AddPaymentSuccess(payment));
|
||||||
|
|
@ -213,9 +208,7 @@ Middleware<AppState> _emailPayment(PaymentRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as EmailPaymentRequest;
|
final action = dynamicAction as EmailPaymentRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.payment, sendEmail: true)
|
||||||
store.state.selectedCompany, store.state.authState, action.payment,
|
|
||||||
sendEmail: true)
|
|
||||||
.then((PaymentEntity payment) {
|
.then((PaymentEntity payment) {
|
||||||
store.dispatch(SavePaymentSuccess(payment));
|
store.dispatch(SavePaymentSuccess(payment));
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
|
|
@ -241,7 +234,7 @@ Middleware<AppState> _loadPayment(PaymentRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadPaymentRequest());
|
store.dispatch(LoadPaymentRequest());
|
||||||
repository
|
repository
|
||||||
.loadItem(state.selectedCompany, state.authState, action.paymentId)
|
.loadItem(store.state.credentials, action.paymentId)
|
||||||
.then((payment) {
|
.then((payment) {
|
||||||
store.dispatch(LoadPaymentSuccess(payment));
|
store.dispatch(LoadPaymentSuccess(payment));
|
||||||
|
|
||||||
|
|
@ -279,9 +272,7 @@ Middleware<AppState> _loadPayments(PaymentRepository repository) {
|
||||||
final int updatedAt = (state.paymentState.lastUpdated / 1000).round();
|
final int updatedAt = (state.paymentState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadPaymentsRequest());
|
store.dispatch(LoadPaymentsRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadPaymentsSuccess(data));
|
store.dispatch(LoadPaymentsSuccess(data));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
|
||||||
|
|
@ -101,8 +101,7 @@ Middleware<AppState> _archiveProduct(ProductRepository repository) {
|
||||||
final action = dynamicAction as ArchiveProductRequest;
|
final action = dynamicAction as ArchiveProductRequest;
|
||||||
final origProduct = store.state.productState.map[action.productId];
|
final origProduct = store.state.productState.map[action.productId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origProduct, EntityAction.archive)
|
||||||
origProduct, EntityAction.archive)
|
|
||||||
.then((ProductEntity product) {
|
.then((ProductEntity product) {
|
||||||
store.dispatch(ArchiveProductSuccess(product));
|
store.dispatch(ArchiveProductSuccess(product));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -125,8 +124,7 @@ Middleware<AppState> _deleteProduct(ProductRepository repository) {
|
||||||
final action = dynamicAction as DeleteProductRequest;
|
final action = dynamicAction as DeleteProductRequest;
|
||||||
final origProduct = store.state.productState.map[action.productId];
|
final origProduct = store.state.productState.map[action.productId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origProduct, EntityAction.delete)
|
||||||
origProduct, EntityAction.delete)
|
|
||||||
.then((ProductEntity product) {
|
.then((ProductEntity product) {
|
||||||
store.dispatch(DeleteProductSuccess(product));
|
store.dispatch(DeleteProductSuccess(product));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -149,8 +147,7 @@ Middleware<AppState> _restoreProduct(ProductRepository repository) {
|
||||||
final action = dynamicAction as RestoreProductRequest;
|
final action = dynamicAction as RestoreProductRequest;
|
||||||
final origProduct = store.state.productState.map[action.productId];
|
final origProduct = store.state.productState.map[action.productId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origProduct, EntityAction.restore)
|
||||||
origProduct, EntityAction.restore)
|
|
||||||
.then((ProductEntity product) {
|
.then((ProductEntity product) {
|
||||||
store.dispatch(RestoreProductSuccess(product));
|
store.dispatch(RestoreProductSuccess(product));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -172,8 +169,7 @@ Middleware<AppState> _saveProduct(ProductRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as SaveProductRequest;
|
final action = dynamicAction as SaveProductRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.product)
|
||||||
store.state.selectedCompany, store.state.authState, action.product)
|
|
||||||
.then((ProductEntity product) {
|
.then((ProductEntity product) {
|
||||||
if (action.product.isNew) {
|
if (action.product.isNew) {
|
||||||
store.dispatch(AddProductSuccess(product));
|
store.dispatch(AddProductSuccess(product));
|
||||||
|
|
@ -209,9 +205,7 @@ Middleware<AppState> _loadProducts(ProductRepository repository) {
|
||||||
final int updatedAt = (state.productState.lastUpdated / 1000).round();
|
final int updatedAt = (state.productState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadProductsRequest());
|
store.dispatch(LoadProductsRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadProductsSuccess(data));
|
store.dispatch(LoadProductsSuccess(data));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,7 @@ Middleware<AppState> _archiveProject(ProjectRepository repository) {
|
||||||
final action = dynamicAction as ArchiveProjectRequest;
|
final action = dynamicAction as ArchiveProjectRequest;
|
||||||
final origProject = store.state.projectState.map[action.projectId];
|
final origProject = store.state.projectState.map[action.projectId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origProject, EntityAction.archive)
|
||||||
origProject, EntityAction.archive)
|
|
||||||
.then((ProjectEntity project) {
|
.then((ProjectEntity project) {
|
||||||
store.dispatch(ArchiveProjectSuccess(project));
|
store.dispatch(ArchiveProjectSuccess(project));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -134,8 +133,7 @@ Middleware<AppState> _deleteProject(ProjectRepository repository) {
|
||||||
final action = dynamicAction as DeleteProjectRequest;
|
final action = dynamicAction as DeleteProjectRequest;
|
||||||
final origProject = store.state.projectState.map[action.projectId];
|
final origProject = store.state.projectState.map[action.projectId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origProject, EntityAction.delete)
|
||||||
origProject, EntityAction.delete)
|
|
||||||
.then((ProjectEntity project) {
|
.then((ProjectEntity project) {
|
||||||
store.dispatch(DeleteProjectSuccess(project));
|
store.dispatch(DeleteProjectSuccess(project));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -158,8 +156,7 @@ Middleware<AppState> _restoreProject(ProjectRepository repository) {
|
||||||
final action = dynamicAction as RestoreProjectRequest;
|
final action = dynamicAction as RestoreProjectRequest;
|
||||||
final origProject = store.state.projectState.map[action.projectId];
|
final origProject = store.state.projectState.map[action.projectId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origProject, EntityAction.restore)
|
||||||
origProject, EntityAction.restore)
|
|
||||||
.then((ProjectEntity project) {
|
.then((ProjectEntity project) {
|
||||||
store.dispatch(RestoreProjectSuccess(project));
|
store.dispatch(RestoreProjectSuccess(project));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -181,8 +178,7 @@ Middleware<AppState> _saveProject(ProjectRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as SaveProjectRequest;
|
final action = dynamicAction as SaveProjectRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.project)
|
||||||
store.state.selectedCompany, store.state.authState, action.project)
|
|
||||||
.then((ProjectEntity project) {
|
.then((ProjectEntity project) {
|
||||||
if (action.project.isNew) {
|
if (action.project.isNew) {
|
||||||
store.dispatch(AddProjectSuccess(project));
|
store.dispatch(AddProjectSuccess(project));
|
||||||
|
|
@ -218,7 +214,7 @@ Middleware<AppState> _loadProject(ProjectRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadProjectRequest());
|
store.dispatch(LoadProjectRequest());
|
||||||
repository
|
repository
|
||||||
.loadItem(state.selectedCompany, state.authState, action.projectId)
|
.loadItem(store.state.credentials, action.projectId)
|
||||||
.then((project) {
|
.then((project) {
|
||||||
store.dispatch(LoadProjectSuccess(project));
|
store.dispatch(LoadProjectSuccess(project));
|
||||||
|
|
||||||
|
|
@ -258,9 +254,7 @@ Middleware<AppState> _loadProjects(ProjectRepository repository) {
|
||||||
final int updatedAt = (state.projectState.lastUpdated / 1000).round();
|
final int updatedAt = (state.projectState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadProjectsRequest());
|
store.dispatch(LoadProjectsRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadProjectsSuccess(data));
|
store.dispatch(LoadProjectsSuccess(data));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,7 @@ Middleware<AppState> _archiveQuote(QuoteRepository repository) {
|
||||||
final action = dynamicAction as ArchiveQuoteRequest;
|
final action = dynamicAction as ArchiveQuoteRequest;
|
||||||
final origQuote = store.state.quoteState.map[action.quoteId];
|
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState, origQuote,
|
.saveData(store.state.credentials, origQuote, EntityAction.archive)
|
||||||
EntityAction.archive)
|
|
||||||
.then((InvoiceEntity quote) {
|
.then((InvoiceEntity quote) {
|
||||||
store.dispatch(ArchiveQuoteSuccess(quote));
|
store.dispatch(ArchiveQuoteSuccess(quote));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -147,8 +146,7 @@ Middleware<AppState> _deleteQuote(QuoteRepository repository) {
|
||||||
final action = dynamicAction as DeleteQuoteRequest;
|
final action = dynamicAction as DeleteQuoteRequest;
|
||||||
final origQuote = store.state.quoteState.map[action.quoteId];
|
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState, origQuote,
|
.saveData(store.state.credentials, origQuote, EntityAction.delete)
|
||||||
EntityAction.delete)
|
|
||||||
.then((InvoiceEntity quote) {
|
.then((InvoiceEntity quote) {
|
||||||
store.dispatch(DeleteQuoteSuccess(quote));
|
store.dispatch(DeleteQuoteSuccess(quote));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -171,8 +169,7 @@ Middleware<AppState> _restoreQuote(QuoteRepository repository) {
|
||||||
final action = dynamicAction as RestoreQuoteRequest;
|
final action = dynamicAction as RestoreQuoteRequest;
|
||||||
final origQuote = store.state.quoteState.map[action.quoteId];
|
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState, origQuote,
|
.saveData(store.state.credentials, origQuote, EntityAction.restore)
|
||||||
EntityAction.restore)
|
|
||||||
.then((InvoiceEntity quote) {
|
.then((InvoiceEntity quote) {
|
||||||
store.dispatch(RestoreQuoteSuccess(quote));
|
store.dispatch(RestoreQuoteSuccess(quote));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -195,8 +192,7 @@ Middleware<AppState> _convertQuote(QuoteRepository repository) {
|
||||||
final action = dynamicAction as ConvertQuote;
|
final action = dynamicAction as ConvertQuote;
|
||||||
final quote = store.state.quoteState.map[action.quoteId];
|
final quote = store.state.quoteState.map[action.quoteId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState, quote,
|
.saveData(store.state.credentials, quote, EntityAction.convert)
|
||||||
EntityAction.convert)
|
|
||||||
.then((InvoiceEntity invoice) {
|
.then((InvoiceEntity invoice) {
|
||||||
store.dispatch(ConvertQuoteSuccess(quote: quote, invoice: invoice));
|
store.dispatch(ConvertQuoteSuccess(quote: quote, invoice: invoice));
|
||||||
action.completer.complete(invoice);
|
action.completer.complete(invoice);
|
||||||
|
|
@ -215,8 +211,7 @@ Middleware<AppState> _markSentQuote(QuoteRepository repository) {
|
||||||
final action = dynamicAction as MarkSentQuoteRequest;
|
final action = dynamicAction as MarkSentQuoteRequest;
|
||||||
final origQuote = store.state.quoteState.map[action.quoteId];
|
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState, origQuote,
|
.saveData(store.state.credentials, origQuote, EntityAction.markSent)
|
||||||
EntityAction.markSent)
|
|
||||||
.then((InvoiceEntity quote) {
|
.then((InvoiceEntity quote) {
|
||||||
store.dispatch(MarkSentQuoteSuccess(quote));
|
store.dispatch(MarkSentQuoteSuccess(quote));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -239,8 +234,8 @@ Middleware<AppState> _emailQuote(QuoteRepository repository) {
|
||||||
final action = dynamicAction as EmailQuoteRequest;
|
final action = dynamicAction as EmailQuoteRequest;
|
||||||
final origQuote = store.state.quoteState.map[action.quoteId];
|
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||||
repository
|
repository
|
||||||
.emailQuote(store.state.selectedCompany, store.state.authState,
|
.emailQuote(store.state.credentials, origQuote, action.template,
|
||||||
origQuote, action.template, action.subject, action.body)
|
action.subject, action.body)
|
||||||
.then((void _) {
|
.then((void _) {
|
||||||
store.dispatch(EmailQuoteSuccess());
|
store.dispatch(EmailQuoteSuccess());
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -262,8 +257,7 @@ Middleware<AppState> _saveQuote(QuoteRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as SaveQuoteRequest;
|
final action = dynamicAction as SaveQuoteRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.quote)
|
||||||
store.state.selectedCompany, store.state.authState, action.quote)
|
|
||||||
.then((InvoiceEntity quote) {
|
.then((InvoiceEntity quote) {
|
||||||
if (action.quote.isNew) {
|
if (action.quote.isNew) {
|
||||||
store.dispatch(AddQuoteSuccess(quote));
|
store.dispatch(AddQuoteSuccess(quote));
|
||||||
|
|
@ -292,9 +286,7 @@ Middleware<AppState> _loadQuote(QuoteRepository repository) {
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch(LoadQuoteRequest());
|
store.dispatch(LoadQuoteRequest());
|
||||||
repository
|
repository.loadItem(store.state.credentials, action.quoteId).then((quote) {
|
||||||
.loadItem(state.selectedCompany, state.authState, action.quoteId)
|
|
||||||
.then((quote) {
|
|
||||||
store.dispatch(LoadQuoteSuccess(quote));
|
store.dispatch(LoadQuoteSuccess(quote));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -333,9 +325,7 @@ Middleware<AppState> _loadQuotes(QuoteRepository repository) {
|
||||||
final int updatedAt = (state.quoteState.lastUpdated / 1000).round();
|
final int updatedAt = (state.quoteState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadQuotesRequest());
|
store.dispatch(LoadQuotesRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadQuotesSuccess(data));
|
store.dispatch(LoadQuotesSuccess(data));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,7 @@ Middleware<AppState> _archiveTask(TaskRepository repository) {
|
||||||
final action = dynamicAction as ArchiveTaskRequest;
|
final action = dynamicAction as ArchiveTaskRequest;
|
||||||
final origTask = store.state.taskState.map[action.taskId];
|
final origTask = store.state.taskState.map[action.taskId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState, origTask,
|
.saveData(store.state.credentials, origTask, EntityAction.archive)
|
||||||
EntityAction.archive)
|
|
||||||
.then((TaskEntity task) {
|
.then((TaskEntity task) {
|
||||||
store.dispatch(ArchiveTaskSuccess(task));
|
store.dispatch(ArchiveTaskSuccess(task));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -133,8 +132,7 @@ Middleware<AppState> _deleteTask(TaskRepository repository) {
|
||||||
final action = dynamicAction as DeleteTaskRequest;
|
final action = dynamicAction as DeleteTaskRequest;
|
||||||
final origTask = store.state.taskState.map[action.taskId];
|
final origTask = store.state.taskState.map[action.taskId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState, origTask,
|
.saveData(store.state.credentials, origTask, EntityAction.delete)
|
||||||
EntityAction.delete)
|
|
||||||
.then((TaskEntity task) {
|
.then((TaskEntity task) {
|
||||||
store.dispatch(DeleteTaskSuccess(task));
|
store.dispatch(DeleteTaskSuccess(task));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -157,8 +155,7 @@ Middleware<AppState> _restoreTask(TaskRepository repository) {
|
||||||
final action = dynamicAction as RestoreTaskRequest;
|
final action = dynamicAction as RestoreTaskRequest;
|
||||||
final origTask = store.state.taskState.map[action.taskId];
|
final origTask = store.state.taskState.map[action.taskId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState, origTask,
|
.saveData(store.state.credentials, origTask, EntityAction.restore)
|
||||||
EntityAction.restore)
|
|
||||||
.then((TaskEntity task) {
|
.then((TaskEntity task) {
|
||||||
store.dispatch(RestoreTaskSuccess(task));
|
store.dispatch(RestoreTaskSuccess(task));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -180,8 +177,7 @@ Middleware<AppState> _saveTask(TaskRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as SaveTaskRequest;
|
final action = dynamicAction as SaveTaskRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.task)
|
||||||
store.state.selectedCompany, store.state.authState, action.task)
|
|
||||||
.then((TaskEntity task) {
|
.then((TaskEntity task) {
|
||||||
if (action.task.isNew) {
|
if (action.task.isNew) {
|
||||||
store.dispatch(AddTaskSuccess(task));
|
store.dispatch(AddTaskSuccess(task));
|
||||||
|
|
@ -210,9 +206,7 @@ Middleware<AppState> _loadTask(TaskRepository repository) {
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch(LoadTaskRequest());
|
store.dispatch(LoadTaskRequest());
|
||||||
repository
|
repository.loadItem(state.credentials, action.taskId).then((task) {
|
||||||
.loadItem(state.selectedCompany, state.authState, action.taskId)
|
|
||||||
.then((task) {
|
|
||||||
store.dispatch(LoadTaskSuccess(task));
|
store.dispatch(LoadTaskSuccess(task));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -248,9 +242,7 @@ Middleware<AppState> _loadTasks(TaskRepository repository) {
|
||||||
final int updatedAt = (state.taskState.lastUpdated / 1000).round();
|
final int updatedAt = (state.taskState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadTasksRequest());
|
store.dispatch(LoadTasksRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadTasksSuccess(data));
|
store.dispatch(LoadTasksSuccess(data));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,7 @@ Middleware<AppState> _archiveVendor(VendorRepository repository) {
|
||||||
final action = dynamicAction as ArchiveVendorRequest;
|
final action = dynamicAction as ArchiveVendorRequest;
|
||||||
final origVendor = store.state.vendorState.map[action.vendorId];
|
final origVendor = store.state.vendorState.map[action.vendorId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origVendor, EntityAction.archive)
|
||||||
origVendor, EntityAction.archive)
|
|
||||||
.then((VendorEntity vendor) {
|
.then((VendorEntity vendor) {
|
||||||
store.dispatch(ArchiveVendorSuccess(vendor));
|
store.dispatch(ArchiveVendorSuccess(vendor));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -134,8 +133,7 @@ Middleware<AppState> _deleteVendor(VendorRepository repository) {
|
||||||
final action = dynamicAction as DeleteVendorRequest;
|
final action = dynamicAction as DeleteVendorRequest;
|
||||||
final origVendor = store.state.vendorState.map[action.vendorId];
|
final origVendor = store.state.vendorState.map[action.vendorId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origVendor, EntityAction.delete)
|
||||||
origVendor, EntityAction.delete)
|
|
||||||
.then((VendorEntity vendor) {
|
.then((VendorEntity vendor) {
|
||||||
store.dispatch(DeleteVendorSuccess(vendor));
|
store.dispatch(DeleteVendorSuccess(vendor));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -158,8 +156,7 @@ Middleware<AppState> _restoreVendor(VendorRepository repository) {
|
||||||
final action = dynamicAction as RestoreVendorRequest;
|
final action = dynamicAction as RestoreVendorRequest;
|
||||||
final origVendor = store.state.vendorState.map[action.vendorId];
|
final origVendor = store.state.vendorState.map[action.vendorId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials, origVendor, EntityAction.restore)
|
||||||
origVendor, EntityAction.restore)
|
|
||||||
.then((VendorEntity vendor) {
|
.then((VendorEntity vendor) {
|
||||||
store.dispatch(RestoreVendorSuccess(vendor));
|
store.dispatch(RestoreVendorSuccess(vendor));
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
@ -181,8 +178,7 @@ Middleware<AppState> _saveVendor(VendorRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final action = dynamicAction as SaveVendorRequest;
|
final action = dynamicAction as SaveVendorRequest;
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(store.state.credentials, action.vendor)
|
||||||
store.state.selectedCompany, store.state.authState, action.vendor)
|
|
||||||
.then((VendorEntity vendor) {
|
.then((VendorEntity vendor) {
|
||||||
if (action.vendor.isNew) {
|
if (action.vendor.isNew) {
|
||||||
store.dispatch(AddVendorSuccess(vendor));
|
store.dispatch(AddVendorSuccess(vendor));
|
||||||
|
|
@ -218,7 +214,7 @@ Middleware<AppState> _loadVendor(VendorRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadVendorRequest());
|
store.dispatch(LoadVendorRequest());
|
||||||
repository
|
repository
|
||||||
.loadItem(state.selectedCompany, state.authState, action.vendorId)
|
.loadItem(store.state.credentials, action.vendorId)
|
||||||
.then((vendor) {
|
.then((vendor) {
|
||||||
store.dispatch(LoadVendorSuccess(vendor));
|
store.dispatch(LoadVendorSuccess(vendor));
|
||||||
|
|
||||||
|
|
@ -261,9 +257,7 @@ Middleware<AppState> _loadVendors(VendorRepository repository) {
|
||||||
final int updatedAt = (state.vendorState.lastUpdated / 1000).round();
|
final int updatedAt = (state.vendorState.lastUpdated / 1000).round();
|
||||||
|
|
||||||
store.dispatch(LoadVendorsRequest());
|
store.dispatch(LoadVendorsRequest());
|
||||||
repository
|
repository.loadList(store.state.credentials, updatedAt).then((data) {
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
|
||||||
.then((data) {
|
|
||||||
store.dispatch(LoadVendorsSuccess(data));
|
store.dispatch(LoadVendorsSuccess(data));
|
||||||
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ class AppDrawer extends StatelessWidget {
|
||||||
//mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
//mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
// Hide options while refreshing data
|
// Hide options while refreshing data
|
||||||
company.token.isEmpty
|
state.credentials.token.isEmpty
|
||||||
? Container(
|
? Container(
|
||||||
padding: EdgeInsets.only(top: 40),
|
padding: EdgeInsets.only(top: 40),
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
|
|
@ -159,7 +159,7 @@ class AppDrawer extends StatelessWidget {
|
||||||
viewModel.companies.length > 1 && !viewModel.isLoading
|
viewModel.companies.length > 1 && !viewModel.isLoading
|
||||||
? _multipleCompanies
|
? _multipleCompanies
|
||||||
: _singleCompany),
|
: _singleCompany),
|
||||||
company.token.isEmpty
|
state.credentials.token.isEmpty
|
||||||
? SizedBox()
|
? SizedBox()
|
||||||
: Expanded(
|
: Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
|
|
|
||||||
|
|
@ -261,8 +261,8 @@ class DocumentPreview extends StatelessWidget {
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
key: ValueKey(document.preview),
|
key: ValueKey(document.preview),
|
||||||
imageUrl: document.previewUrl(state.authState.url),
|
imageUrl: document.previewUrl(state.credentials.url),
|
||||||
httpHeaders: {'X-Ninja-Token': state.selectedCompany.token},
|
httpHeaders: {'X-Ninja-Token': state.credentials.token},
|
||||||
placeholder: (context, url) => Container(
|
placeholder: (context, url) => Container(
|
||||||
height: height,
|
height: height,
|
||||||
child: Center(
|
child: Center(
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
||||||
|
|
||||||
final localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
final store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
final company = store.state.selectedCompany;
|
final state = store.state;
|
||||||
final webClient = WebClient();
|
final webClient = WebClient();
|
||||||
final data = {
|
final data = {
|
||||||
'order_id': purchase.purchaseID,
|
'order_id': purchase.purchaseID,
|
||||||
|
|
@ -61,7 +61,7 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final dynamic response = await webClient.post(
|
final dynamic response = await webClient.post(
|
||||||
'/api/v1/upgrade', company.token, json.encode(data));
|
'/api/v1/upgrade', state.credentials.token, json.encode(data));
|
||||||
final String message = response['message'];
|
final String message = response['message'];
|
||||||
|
|
||||||
if (message == 'success') {
|
if (message == 'success') {
|
||||||
|
|
@ -175,7 +175,6 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
||||||
return 'Enterprise - 20 Users';
|
return 'Enterprise - 20 Users';
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,13 +205,11 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text('Terms',
|
child: Text('Terms', style: TextStyle(fontSize: 12)),
|
||||||
style: TextStyle(fontSize: 12)),
|
|
||||||
onPressed: () => launch(kTermsOfServiceURL),
|
onPressed: () => launch(kTermsOfServiceURL),
|
||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text('Privacy',
|
child: Text('Privacy', style: TextStyle(fontSize: 12)),
|
||||||
style: TextStyle(fontSize: 12)),
|
|
||||||
onPressed: () => launch(kPrivacyPolicyURL),
|
onPressed: () => launch(kPrivacyPolicyURL),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -248,7 +245,8 @@ class _UpgradeDialogState extends State<UpgradeDialog> {
|
||||||
if (!_showPastPurchases)
|
if (!_showPastPurchases)
|
||||||
..._products
|
..._products
|
||||||
.map((productDetails) => ListTile(
|
.map((productDetails) => ListTile(
|
||||||
title: Text(productDetails.title ?? convertPlanToString(productDetails.id)),
|
title: Text(productDetails.title ??
|
||||||
|
convertPlanToString(productDetails.id)),
|
||||||
subtitle: Text(productDetails.description ?? ''),
|
subtitle: Text(productDetails.description ?? ''),
|
||||||
trailing: Text(productDetails.price ?? '',
|
trailing: Text(productDetails.price ?? '',
|
||||||
style: TextStyle(fontSize: 18)),
|
style: TextStyle(fontSize: 18)),
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ class StubRepository {
|
||||||
final WebClient webClient;
|
final WebClient webClient;
|
||||||
|
|
||||||
Future<StubEntity> loadItem(
|
Future<StubEntity> loadItem(
|
||||||
CompanyEntity company, AuthState auth, String entityId) async {
|
Credentials credentials, String entityId) async {
|
||||||
final dynamic response = await webClient.get(
|
final dynamic response = await webClient.get(
|
||||||
'${auth.url}/stubs/$entityId', company.token);
|
'${credentials.url}/stubs/$entityId', credentials.token);
|
||||||
|
|
||||||
final StubItemResponse stubResponse =
|
final StubItemResponse stubResponse =
|
||||||
serializers.deserializeWith(StubItemResponse.serializer, response);
|
serializers.deserializeWith(StubItemResponse.serializer, response);
|
||||||
|
|
@ -28,14 +28,14 @@ class StubRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BuiltList<StubEntity>> loadList(
|
Future<BuiltList<StubEntity>> loadList(
|
||||||
CompanyEntity company, AuthState auth, int updatedAt) async {
|
Credentials credentials, int updatedAt) async {
|
||||||
String url = auth.url + '/stubs?';
|
String url = credentials.url + '/stubs?';
|
||||||
|
|
||||||
if (updatedAt > 0) {
|
if (updatedAt > 0) {
|
||||||
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
url += '&updated_at=${updatedAt - kUpdatedAtBufferSeconds}';
|
||||||
}
|
}
|
||||||
|
|
||||||
final dynamic response = await webClient.get(url, company.token);
|
final dynamic response = await webClient.get(url, credentials.token);
|
||||||
|
|
||||||
final StubListResponse stubResponse =
|
final StubListResponse stubResponse =
|
||||||
serializers.deserializeWith(StubListResponse.serializer, response);
|
serializers.deserializeWith(StubListResponse.serializer, response);
|
||||||
|
|
@ -44,22 +44,22 @@ class StubRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<StubEntity> saveData(
|
Future<StubEntity> saveData(
|
||||||
CompanyEntity company, AuthState auth, StubEntity stub,
|
Credentials credentials, StubEntity stub,
|
||||||
[EntityAction action]) async {
|
[EntityAction action]) async {
|
||||||
final data = serializers.serializeWith(StubEntity.serializer, stub);
|
final data = serializers.serializeWith(StubEntity.serializer, stub);
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
|
||||||
if (stub.isNew) {
|
if (stub.isNew) {
|
||||||
response = await webClient.post(
|
response = await webClient.post(
|
||||||
auth.url + '/stubs',
|
credentials.url + '/stubs',
|
||||||
company.token,
|
credentials.token,
|
||||||
json.encode(data));
|
json.encode(data));
|
||||||
} else {
|
} else {
|
||||||
var url = auth.url + '/stubs/' + stub.id.toString();
|
var url = credentials.url + '/stubs/' + stub.id.toString();
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
url += '?action=' + action.toString();
|
url += '?action=' + action.toString();
|
||||||
}
|
}
|
||||||
response = await webClient.put(url, company.token, json.encode(data));
|
response = await webClient.put(url, credentials.token, json.encode(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
final StubItemResponse stubResponse =
|
final StubItemResponse stubResponse =
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ Middleware<AppState> _archiveStub(StubRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final origStub = store.state.stubState.map[action.stubId];
|
final origStub = store.state.stubState.map[action.stubId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials,
|
||||||
origStub, EntityAction.archive)
|
origStub, EntityAction.archive)
|
||||||
.then((StubEntity stub) {
|
.then((StubEntity stub) {
|
||||||
store.dispatch(ArchiveStubSuccess(stub));
|
store.dispatch(ArchiveStubSuccess(stub));
|
||||||
|
|
@ -107,7 +107,7 @@ Middleware<AppState> _deleteStub(StubRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final origStub = store.state.stubState.map[action.stubId];
|
final origStub = store.state.stubState.map[action.stubId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials,
|
||||||
origStub, EntityAction.delete)
|
origStub, EntityAction.delete)
|
||||||
.then((StubEntity stub) {
|
.then((StubEntity stub) {
|
||||||
store.dispatch(DeleteStubSuccess(stub));
|
store.dispatch(DeleteStubSuccess(stub));
|
||||||
|
|
@ -130,7 +130,7 @@ Middleware<AppState> _restoreStub(StubRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
final origStub = store.state.stubState.map[action.stubId];
|
final origStub = store.state.stubState.map[action.stubId];
|
||||||
repository
|
repository
|
||||||
.saveData(store.state.selectedCompany, store.state.authState,
|
.saveData(store.state.credentials,
|
||||||
origStub, EntityAction.restore)
|
origStub, EntityAction.restore)
|
||||||
.then((StubEntity stub) {
|
.then((StubEntity stub) {
|
||||||
store.dispatch(RestoreStubSuccess(stub));
|
store.dispatch(RestoreStubSuccess(stub));
|
||||||
|
|
@ -153,7 +153,7 @@ Middleware<AppState> _saveStub(StubRepository repository) {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
repository
|
repository
|
||||||
.saveData(
|
.saveData(
|
||||||
store.state.selectedCompany, store.state.authState, action.stub)
|
store.state.credentials, action.stub)
|
||||||
.then((StubEntity stub) {
|
.then((StubEntity stub) {
|
||||||
if (action.stub.isNew) {
|
if (action.stub.isNew) {
|
||||||
store.dispatch(AddStubSuccess(stub));
|
store.dispatch(AddStubSuccess(stub));
|
||||||
|
|
@ -182,7 +182,7 @@ Middleware<AppState> _loadStub(StubRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadStubRequest());
|
store.dispatch(LoadStubRequest());
|
||||||
repository
|
repository
|
||||||
.loadItem(state.selectedCompany, state.authState, action.stubId)
|
.loadItem(state.credentials, action.stubId)
|
||||||
.then((stub) {
|
.then((stub) {
|
||||||
store.dispatch(LoadStubSuccess(stub));
|
store.dispatch(LoadStubSuccess(stub));
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ Middleware<AppState> _loadStubs(StubRepository repository) {
|
||||||
|
|
||||||
store.dispatch(LoadStubsRequest());
|
store.dispatch(LoadStubsRequest());
|
||||||
repository
|
repository
|
||||||
.loadList(state.selectedCompany, state.authState, updatedAt)
|
.loadList(state.credentials, updatedAt)
|
||||||
.then((data) {
|
.then((data) {
|
||||||
store.dispatch(LoadStubsSuccess(data));
|
store.dispatch(LoadStubsSuccess(data));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue