Subscriptions

This commit is contained in:
Hillel Coren 2021-04-01 09:18:03 +03:00
parent 4ef924e0fa
commit c643b9c677
3 changed files with 20 additions and 43 deletions

View File

@ -65,7 +65,7 @@ abstract class SubscriptionEntity extends Object
createdUserId: '',
assignedUserId: '',
archivedAt: 0,
allowCancellation: true,
allowCancellation: false,
allowPlanChanges: false,
allowQueryOverrides: false,
autoBill: '',

View File

@ -52,7 +52,6 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
final _promoDiscountController = TextEditingController();
final _maxSeatsLimitController = TextEditingController();
final _returnUrlController = TextEditingController();
final _postPurchaseBodyController = TextEditingController();
final _postPurchaseHeadersController = TextEditingController();
final _postPurchaseRestMethodController = TextEditingController();
final _postPurchaseUrlController = TextEditingController();
@ -83,7 +82,6 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
_promoDiscountController,
_maxSeatsLimitController,
_returnUrlController,
_postPurchaseBodyController,
_postPurchaseHeadersController,
_postPurchaseRestMethodController,
_postPurchaseUrlController,
@ -101,7 +99,6 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
subscription.maxSeatsLimit.toDouble(), context,
formatNumberType: FormatNumberType.inputAmount);
_returnUrlController.text = webhookConfiguration.returnUrl;
_postPurchaseBodyController.text = webhookConfiguration.postPurchaseBody;
_postPurchaseHeadersController.text =
webhookConfiguration.postPurchaseHeaders.join(',');
_postPurchaseRestMethodController.text =
@ -131,8 +128,6 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
..promoDiscount = parseDouble(_promoDiscountController.text)
..maxSeatsLimit = parseInt(_maxSeatsLimitController.text)
..webhookConfiguration.returnUrl = _returnUrlController.text.trim()
..webhookConfiguration.postPurchaseBody =
_postPurchaseBodyController.text.trim()
..webhookConfiguration
.postPurchaseHeaders
.replace(_postPurchaseHeadersController.text.trim().split(','))
@ -153,7 +148,6 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
final state = viewModel.state;
final localization = AppLocalization.of(context);
final subscription = viewModel.subscription;
final origSubscription = state.subscriptionState.get(subscription.id);
final durations = [
DropdownMenuItem<int>(
@ -385,6 +379,11 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
),
FormCard(
children: [
DecoratedFormField(
label: localization.returnUrl,
controller: _returnUrlController,
keyboardType: TextInputType.url,
),
BoolDropdownButton(
label: localization.allowQueryOverrides,
value: subscription.allowQueryOverrides,
@ -400,8 +399,7 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
value: subscription.allowCancellation,
onChanged: (value) => viewModel.onChanged(subscription
.rebuild((b) => b..allowCancellation = value))),
if (subscription.allowCancellation ||
origSubscription.allowCancellation)
if (subscription.allowCancellation)
AppDropdownButton<int>(
showBlank: true,
blankValue: 0,
@ -416,8 +414,7 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
value: subscription.trialEnabled,
onChanged: (value) => viewModel.onChanged(
subscription.rebuild((b) => b.trialEnabled = value))),
if (subscription.trialEnabled ||
origSubscription.trialEnabled)
if (subscription.trialEnabled)
AppDropdownButton<int>(
showBlank: true,
blankValue: 0,
@ -433,8 +430,7 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
value: subscription.perSeatEnabled,
onChanged: (value) => viewModel.onChanged(subscription
.rebuild((b) => b.perSeatEnabled = value))),
if (subscription.perSeatEnabled ||
origSubscription.perSeatEnabled)
if (subscription.perSeatEnabled)
DecoratedFormField(
label: localization.maxSeatsLimit,
controller: _maxSeatsLimitController,
@ -451,28 +447,18 @@ class _SubscriptionEditState extends State<SubscriptionEdit>
FormCard(
children: [
DecoratedFormField(
label: localization.returnUrl,
controller: _returnUrlController,
keyboardType: TextInputType.url,
),
DecoratedFormField(
label: localization.postPurchaseUrl,
label: localization.webhookUrl,
controller: _postPurchaseUrlController,
keyboardType: TextInputType.url,
),
DecoratedFormField(
label: localization.postPurchaseRestMethod,
label: localization.restMethod,
controller: _postPurchaseRestMethodController,
),
DecoratedFormField(
label: localization.postPurchaseHeaders,
label: localization.headers,
controller: _postPurchaseHeadersController,
),
DecoratedFormField(
label: localization.postPurchaseBody,
controller: _postPurchaseBodyController,
maxLines: 6,
),
],
),
]),

View File

@ -16,10 +16,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
'en': {
// STARTER: lang key - do not remove comment
'return_url': 'Return URL',
'post_purchase_url': 'Post Purchase URL',
'post_purchase_rest_method': 'Post Purchase REST Method',
'post_purchase_headers': 'Post Purchase Headers',
'post_purchase_body': 'Post Purchase Body',
'rest_method': 'REST Method',
'headers': 'Headers',
'recurring_products': 'Recurring Products',
'promo_code': 'Promo Code',
'promo_discount': 'Promo Discount',
@ -56317,21 +56315,14 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['return_url'] ??
_localizedValues['en']['return_url'];
String get postPurchaseUrl =>
_localizedValues[localeCode]['post_purchase_url'] ??
_localizedValues['en']['post_purchase_url'];
String get restMethod =>
_localizedValues[localeCode]['rest_method'] ??
_localizedValues['en']['rest_method'];
String get postPurchaseRestMethod =>
_localizedValues[localeCode]['post_purchase_rest_method'] ??
_localizedValues['en']['post_purchase_rest_method'];
String get headers =>
_localizedValues[localeCode]['headers'] ??
_localizedValues['en']['headers'];
String get postPurchaseHeaders =>
_localizedValues[localeCode]['post_purchase_headers'] ??
_localizedValues['en']['post_purchase_headers'];
String get postPurchaseBody =>
_localizedValues[localeCode]['post_purchase_body'] ??
_localizedValues['en']['post_purchase_body'];
String lookup(String key) {
final lookupKey = toSnakeCase(key);