@foxy.io/elements 1.24.1-beta.1 → 1.24.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/cdn/foxy-admin-subscription-card.js +1 -1
  2. package/dist/cdn/foxy-customer-portal.js +1 -1
  3. package/dist/cdn/foxy-customer.js +1 -1
  4. package/dist/cdn/foxy-subscription-card.js +1 -1
  5. package/dist/cdn/foxy-subscription-form.js +1 -1
  6. package/dist/cdn/foxy-subscriptions-table.js +1 -1
  7. package/dist/cdn/foxy-transaction.js +1 -1
  8. package/dist/cdn/shared-fa7539af.js +46 -0
  9. package/dist/cdn/translations/admin-subscription-card/en.json +1 -0
  10. package/dist/cdn/translations/cart-form/en.json +2 -0
  11. package/dist/cdn/translations/customer/en.json +2 -0
  12. package/dist/cdn/translations/customer-portal/en.json +2 -0
  13. package/dist/cdn/translations/item-form/en.json +2 -0
  14. package/dist/cdn/translations/shipment-card/en.json +2 -0
  15. package/dist/cdn/translations/subscription-card/en.json +1 -0
  16. package/dist/cdn/translations/subscription-form/en.json +1 -0
  17. package/dist/cdn/translations/subscriptions-table/en.json +1 -0
  18. package/dist/cdn/translations/transaction/en.json +4 -0
  19. package/dist/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.js +17 -6
  20. package/dist/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.js.map +1 -1
  21. package/dist/elements/public/SubscriptionCard/SubscriptionCard.js +24 -12
  22. package/dist/elements/public/SubscriptionCard/SubscriptionCard.js.map +1 -1
  23. package/dist/elements/public/SubscriptionForm/SubscriptionForm.js +11 -4
  24. package/dist/elements/public/SubscriptionForm/SubscriptionForm.js.map +1 -1
  25. package/dist/elements/public/SubscriptionsTable/SubscriptionsTable.js +22 -22
  26. package/dist/elements/public/SubscriptionsTable/SubscriptionsTable.js.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/cdn/shared-f29d410a.js +0 -46
@@ -249,11 +249,18 @@ export class AdminSubscriptionCard extends Base {
249
249
  return items.isApproximateCount ? 'summary_approximate' : 'summary';
250
250
  }
251
251
  get __statusOptions() {
252
- var _a, _b;
253
- const d = this.data;
254
- const date = (_b = (_a = d === null || d === void 0 ? void 0 : d.first_failed_transaction_date) !== null && _a !== void 0 ? _a : d === null || d === void 0 ? void 0 : d.end_date) !== null && _b !== void 0 ? _b : d === null || d === void 0 ? void 0 : d.next_transaction_date;
255
- if (date)
256
- return { date };
252
+ const data = this.data;
253
+ if (data === null)
254
+ return;
255
+ if (data.first_failed_transaction_date)
256
+ return { date: data.first_failed_transaction_date };
257
+ if (data.end_date)
258
+ return { date: data.end_date };
259
+ if (data.is_active === false)
260
+ return {};
261
+ if (new Date(data.start_date) > new Date())
262
+ return { date: data.start_date };
263
+ return { date: data.next_transaction_date };
257
264
  }
258
265
  get __currencyCode() {
259
266
  var _a, _b, _c;
@@ -299,7 +306,11 @@ export class AdminSubscriptionCard extends Base {
299
306
  const hasEnded = new Date(data.end_date).getTime() > Date.now();
300
307
  return hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';
301
308
  }
302
- return `subscription_${data.is_active ? 'active' : 'inactive'}`;
309
+ if (data.is_active === false)
310
+ return 'subscription_inactive';
311
+ if (new Date(data.start_date) > new Date())
312
+ return 'subscription_will_be_active';
313
+ return 'subscription_active';
303
314
  }
304
315
  get __priceKey() {
305
316
  var _a;
@@ -1 +1 @@
1
- {"version":3,"file":"AdminSubscriptionCard.js","sourceRoot":"","sources":["../../../../src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAChE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,E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AC1B,IAAI,IAAI,CAAC,6BAA6B;YAAE,OAAO,qBAAqB,CAAC;QACrE,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAChE,OAAO,QAAQ,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,wBAAwB,CAAC;SAC/E;QAED,OAAO,gBAAgB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IAClE,CAAC;IAED,IAAY,UAAU;;QACpB,MAAM,SAAS,SAAG,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC;QACvC,IAAI,SAAS;YAAE,OAAO,SAAS,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACvF,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'admin-subscription-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Card element representing a subscription (`fx:subscription`).\n * Admin-only.\n *\n * @element foxy-admin-subscription-card\n * @since 1.21.0\n */\nexport class AdminSubscriptionCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n localeCodes: { attribute: 'locale-codes' },\n };\n }\n\n /**\n * URL of the `fx:locale_codes` property helper.\n * This will be used to determine the currency code for subscriptions that link to a\n * transaction template without the code.\n */\n localeCodes: string | null = null;\n\n private readonly __transactionTemplateLoaderId = 'transactionTemplateLoader';\n\n private readonly __defaultTemplateSetLoaderId = 'defaultTemplateSetLoader';\n\n private readonly __localeCodesHelperLoaderId = 'localeCodesLoader';\n\n private readonly __templateSetLoaderId = 'templateSetLoader';\n\n private readonly __itemsLoaderId = 'itemsLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n renderBody(): TemplateResult {\n const isFailed = !!this.data?.first_failed_transaction_date;\n const cart = this.__transactionTemplate;\n\n const priceKey = this.__priceKey;\n const priceOptions = this.__priceOptions;\n const summaryOptions = this.__summaryOptions;\n const summaryKey = this.__summaryKey;\n const statusKey = this.__statusKey;\n const statusOptions = this.__statusOptions;\n\n return html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionTemplateHref)}\n id=${this.__transactionTemplateLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__defaultTemplateSetHref)}\n id=${this.__defaultTemplateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__localeCodesHelperHref)}\n id=${this.__localeCodesHelperLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__templateSetHref)}\n id=${this.__templateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__itemsHref)}\n id=${this.__itemsLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__storeHref)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div class=\"text-left leading-s text-tertiary\">\n <div class=\"flex items-center space-x-s\">\n <span class=\"block flex-1 font-medium text-body truncate\">\n ${summaryOptions && summaryKey\n ? html`<foxy-i18n infer=\"\" key=${summaryKey} .options=${summaryOptions}></foxy-i18n>`\n : html`&ZeroWidthSpace;`}\n </span>\n <span class=\"text-s\">\n ${priceOptions && priceKey\n ? html`<foxy-i18n infer=\"\" key=${priceKey} .options=${priceOptions}></foxy-i18n>`\n : html`&ZeroWidthSpace;`}\n </span>\n </div>\n\n <div class=\"truncate text-s ${isFailed ? 'text-error' : 'text-secondary'}\">\n ${statusOptions && statusKey\n ? html`<foxy-i18n infer=\"\" key=${statusKey} .options=${statusOptions}></foxy-i18n>`\n : html`&ZeroWidthSpace;`}\n </div>\n\n <div class=\"text-tertiary truncate text-s\">${cart?.customer_email}&ZeroWidthSpace;</div>\n </div>\n `;\n }\n\n get isBodyReady(): boolean {\n const isLoaded = !!this.__items && !!this.__currencyCode && !!this.__currencyDisplay;\n return super.isBodyReady && isLoaded;\n }\n\n private get __transactionTemplateHref() {\n const data = this.data;\n\n if (!data) return;\n if ('_embedded' in data && 'fx:transaction_template' in data._embedded) return;\n\n const url = new URL(this.data?._links['fx:transaction_template'].href ?? '');\n url.searchParams.set('zoom', 'items');\n return url.toString();\n }\n\n private get __defaultTemplateSetHref() {\n const templateSetUri = this.__transactionTemplate?.template_set_uri;\n\n if (templateSetUri === '') {\n try {\n const url = new URL(this.__store?._links['fx:template_sets'].href ?? '');\n url.searchParams.set('code', 'DEFAULT');\n return url.toString();\n } catch {\n //\n }\n }\n }\n\n private get __localeCodesHelperHref() {\n if (this.__defaultTemplateSetHref || this.__templateSetHref) {\n return this.localeCodes ?? void 0;\n }\n }\n\n private get __templateSetHref() {\n const cart = this.__transactionTemplate;\n if (!cart?.currency_code) return cart?.template_set_uri || void 0;\n }\n\n private get __itemsHref() {\n const cart = this.__transactionTemplate;\n\n if (!cart) return;\n if ('_embedded' in cart && 'fx:items' in cart._embedded) return;\n\n const url = new URL(cart._links['fx:items'].href);\n url.searchParams.set('limit', '1');\n return url.toString();\n }\n\n private get __storeHref() {\n return this.data?._links['fx:store']?.href;\n }\n\n private get __transactionTemplate() {\n const data = this.data;\n\n if (data && '_embedded' in data && 'fx:transaction_template' in data._embedded) {\n type Cart = Resource<Rels.TransactionTemplate>;\n type CartWithItems = Resource<Rels.TransactionTemplate, { zoom: 'items' }>;\n return data._embedded['fx:transaction_template'] as Cart | CartWithItems;\n } else {\n type Loader = NucleonElement<Resource<Rels.TransactionTemplate, { zoom: 'items' }>>;\n const selector = `#${this.__transactionTemplateLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n }\n\n private get __defaultTemplateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSets>>;\n const selector = `#${this.__defaultTemplateSetLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:template_sets'][0] ?? null;\n }\n\n private get __localeCodesHelper() {\n type Loader = NucleonElement<Resource<Rels.LocaleCodes>>;\n const selector = `#${this.__localeCodesHelperLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __templateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSet>>;\n const selector = `#${this.__templateSetLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __items() {\n type Cart = Resource<Rels.TransactionTemplate>;\n type CartWithItems = Resource<Rels.TransactionTemplate, { zoom: 'items' }>;\n\n const cart = this.__transactionTemplate as Cart | CartWithItems | null;\n\n if (cart && '_embedded' in cart && 'fx:items' in cart._embedded) {\n const items = cart._embedded['fx:items'];\n\n return {\n array: items,\n count: items.length,\n isApproximateCount: items.length === 20,\n };\n }\n\n type Loader = NucleonElement<Resource<Rels.Items>>;\n const loader = this.renderRoot.querySelector<Loader>(`#${this.__itemsLoaderId}`);\n if (!loader?.data) return null;\n\n return {\n array: loader.data._embedded['fx:items'],\n count: loader.data.total_items,\n isApproximateCount: false,\n };\n }\n\n private get __store() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n const selector = `#${this.__storeLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __currencyDisplay() {\n const useCode = this.__store?.use_international_currency_symbol;\n\n if (useCode === true) return 'code';\n if (useCode === false) return 'symbol';\n }\n\n private get __summaryOptions() {\n const { array, count } = this.__items ?? {};\n if (array && count) return { firstItem: array[0], count, countMinus1: count - 1 };\n }\n\n private get __summaryKey() {\n const items = this.__items;\n if (items) return items.isApproximateCount ? 'summary_approximate' : 'summary';\n }\n\n private get __statusOptions() {\n const d = this.data;\n const date = d?.first_failed_transaction_date ?? d?.end_date ?? d?.next_transaction_date;\n if (date) return { date };\n }\n\n private get __currencyCode() {\n const cart = this.__transactionTemplate;\n\n if (cart?.currency_code) {\n return cart.currency_code as string;\n } else {\n const allLocaleCodes = this.__localeCodesHelper;\n const localeCode = (this.__templateSet ?? this.__defaultTemplateSet)?.locale_code;\n const localeInfo = localeCode ? allLocaleCodes?.values[localeCode] : void 0;\n\n if (localeInfo) return /Currency: ([A-Z]{3})/g.exec(localeInfo)?.[1];\n }\n }\n\n private get __priceOptions() {\n const currencyDisplay = this.__currencyDisplay;\n if (currencyDisplay === undefined) return;\n\n const currencyCode = this.__currencyCode;\n if (currencyCode === undefined) return;\n\n const totalOrder = this.__transactionTemplate?.total_order;\n if (totalOrder === undefined) return;\n\n const frequency = this.data?.frequency;\n if (frequency === undefined) return;\n\n return {\n ...parseFrequency(frequency),\n amount: `${totalOrder} ${currencyCode}`,\n currencyDisplay,\n };\n }\n\n private get __statusKey() {\n const data = this.data;\n\n if (data === null) return;\n if (data.first_failed_transaction_date) return 'subscription_failed';\n if (data.end_date) {\n const hasEnded = new Date(data.end_date).getTime() > Date.now();\n return hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';\n }\n\n return `subscription_${data.is_active ? 'active' : 'inactive'}`;\n }\n\n private get __priceKey() {\n const frequency = this.data?.frequency;\n if (frequency) return `price_${frequency === '.5m' ? 'twice_a_month' : 'recurring'}`;\n }\n}\n"]}
1
+ {"version":3,"file":"AdminSubscriptionCard.js","sourceRoot":"","sources":["../../../../src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAChE,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,EAAE,GAAG,yBAAyB,CAAC;AACrC,MAAM,IAAI,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,OAAO,qBAAsB,SAAQ,IAAU;IAArD;;QAQE;;;;WAIG;QACH,gBAAW,GAAkB,IAAI,CAAC;QAEjB,kCAA6B,GAAG,2BAA2B,CAAC;QAE5D,iCAA4B,GAAG,0BAA0B,CAAC;QAE1D,gCAA2B,GAAG,mBAAmB,CAAC;QAElD,0BAAqB,GAAG,mBAAmB,CAAC;QAE5C,oBAAe,GAAG,aAAa,CAAC;QAEhC,oBAAe,GAAG,aAAa,CAAC;IA0SnD,CAAC;IAlUC,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,KAAK,CAAC,UAAU;YACnB,WAAW,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE;SAC3C,CAAC;IACJ,CAAC;IAqBD,UAAU;;QACR,MAAM,QAAQ,GAAG,CAAC,QAAC,IAAI,CAAC,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AAC,GAAG,IAAI,IAAI,EAAE;YAAE,OAAO,6BAA6B,CAAC;QAEjF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,IAAY,UAAU;;QACpB,MAAM,SAAS,SAAG,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAC;QACvC,IAAI,SAAS;YAAE,OAAO,SAAS,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACvF,CAAC;CACF","sourcesContent":["import type { PropertyDeclarations } from 'lit-element';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { Resource } from '@foxy.io/sdk/core';\nimport type { Rels } from '@foxy.io/sdk/backend';\nimport type { Data } from './types';\n\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { InternalCard } from '../../internal/InternalCard/InternalCard';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { html } from 'lit-html';\n\nconst NS = 'admin-subscription-card';\nconst Base = ConfigurableMixin(TranslatableMixin(InternalCard, NS));\n\n/**\n * Card element representing a subscription (`fx:subscription`).\n * Admin-only.\n *\n * @element foxy-admin-subscription-card\n * @since 1.21.0\n */\nexport class AdminSubscriptionCard extends Base<Data> {\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n localeCodes: { attribute: 'locale-codes' },\n };\n }\n\n /**\n * URL of the `fx:locale_codes` property helper.\n * This will be used to determine the currency code for subscriptions that link to a\n * transaction template without the code.\n */\n localeCodes: string | null = null;\n\n private readonly __transactionTemplateLoaderId = 'transactionTemplateLoader';\n\n private readonly __defaultTemplateSetLoaderId = 'defaultTemplateSetLoader';\n\n private readonly __localeCodesHelperLoaderId = 'localeCodesLoader';\n\n private readonly __templateSetLoaderId = 'templateSetLoader';\n\n private readonly __itemsLoaderId = 'itemsLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n renderBody(): TemplateResult {\n const isFailed = !!this.data?.first_failed_transaction_date;\n const cart = this.__transactionTemplate;\n\n const priceKey = this.__priceKey;\n const priceOptions = this.__priceOptions;\n const summaryOptions = this.__summaryOptions;\n const summaryKey = this.__summaryKey;\n const statusKey = this.__statusKey;\n const statusOptions = this.__statusOptions;\n\n return html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionTemplateHref)}\n id=${this.__transactionTemplateLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__defaultTemplateSetHref)}\n id=${this.__defaultTemplateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__localeCodesHelperHref)}\n id=${this.__localeCodesHelperLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__templateSetHref)}\n id=${this.__templateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__itemsHref)}\n id=${this.__itemsLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__storeHref)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div class=\"text-left leading-s text-tertiary\">\n <div class=\"flex items-center space-x-s\">\n <span class=\"block flex-1 font-medium text-body truncate\">\n ${summaryOptions && summaryKey\n ? html`<foxy-i18n infer=\"\" key=${summaryKey} .options=${summaryOptions}></foxy-i18n>`\n : html`&ZeroWidthSpace;`}\n </span>\n <span class=\"text-s\">\n ${priceOptions && priceKey\n ? html`<foxy-i18n infer=\"\" key=${priceKey} .options=${priceOptions}></foxy-i18n>`\n : html`&ZeroWidthSpace;`}\n </span>\n </div>\n\n <div class=\"truncate text-s ${isFailed ? 'text-error' : 'text-secondary'}\">\n ${statusOptions && statusKey\n ? html`<foxy-i18n infer=\"\" key=${statusKey} .options=${statusOptions}></foxy-i18n>`\n : html`&ZeroWidthSpace;`}\n </div>\n\n <div class=\"text-tertiary truncate text-s\">${cart?.customer_email}&ZeroWidthSpace;</div>\n </div>\n `;\n }\n\n get isBodyReady(): boolean {\n const isLoaded = !!this.__items && !!this.__currencyCode && !!this.__currencyDisplay;\n return super.isBodyReady && isLoaded;\n }\n\n private get __transactionTemplateHref() {\n const data = this.data;\n\n if (!data) return;\n if ('_embedded' in data && 'fx:transaction_template' in data._embedded) return;\n\n const url = new URL(this.data?._links['fx:transaction_template'].href ?? '');\n url.searchParams.set('zoom', 'items');\n return url.toString();\n }\n\n private get __defaultTemplateSetHref() {\n const templateSetUri = this.__transactionTemplate?.template_set_uri;\n\n if (templateSetUri === '') {\n try {\n const url = new URL(this.__store?._links['fx:template_sets'].href ?? '');\n url.searchParams.set('code', 'DEFAULT');\n return url.toString();\n } catch {\n //\n }\n }\n }\n\n private get __localeCodesHelperHref() {\n if (this.__defaultTemplateSetHref || this.__templateSetHref) {\n return this.localeCodes ?? void 0;\n }\n }\n\n private get __templateSetHref() {\n const cart = this.__transactionTemplate;\n if (!cart?.currency_code) return cart?.template_set_uri || void 0;\n }\n\n private get __itemsHref() {\n const cart = this.__transactionTemplate;\n\n if (!cart) return;\n if ('_embedded' in cart && 'fx:items' in cart._embedded) return;\n\n const url = new URL(cart._links['fx:items'].href);\n url.searchParams.set('limit', '1');\n return url.toString();\n }\n\n private get __storeHref() {\n return this.data?._links['fx:store']?.href;\n }\n\n private get __transactionTemplate() {\n const data = this.data;\n\n if (data && '_embedded' in data && 'fx:transaction_template' in data._embedded) {\n type Cart = Resource<Rels.TransactionTemplate>;\n type CartWithItems = Resource<Rels.TransactionTemplate, { zoom: 'items' }>;\n return data._embedded['fx:transaction_template'] as Cart | CartWithItems;\n } else {\n type Loader = NucleonElement<Resource<Rels.TransactionTemplate, { zoom: 'items' }>>;\n const selector = `#${this.__transactionTemplateLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n }\n\n private get __defaultTemplateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSets>>;\n const selector = `#${this.__defaultTemplateSetLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:template_sets'][0] ?? null;\n }\n\n private get __localeCodesHelper() {\n type Loader = NucleonElement<Resource<Rels.LocaleCodes>>;\n const selector = `#${this.__localeCodesHelperLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __templateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSet>>;\n const selector = `#${this.__templateSetLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __items() {\n type Cart = Resource<Rels.TransactionTemplate>;\n type CartWithItems = Resource<Rels.TransactionTemplate, { zoom: 'items' }>;\n\n const cart = this.__transactionTemplate as Cart | CartWithItems | null;\n\n if (cart && '_embedded' in cart && 'fx:items' in cart._embedded) {\n const items = cart._embedded['fx:items'];\n\n return {\n array: items,\n count: items.length,\n isApproximateCount: items.length === 20,\n };\n }\n\n type Loader = NucleonElement<Resource<Rels.Items>>;\n const loader = this.renderRoot.querySelector<Loader>(`#${this.__itemsLoaderId}`);\n if (!loader?.data) return null;\n\n return {\n array: loader.data._embedded['fx:items'],\n count: loader.data.total_items,\n isApproximateCount: false,\n };\n }\n\n private get __store() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n const selector = `#${this.__storeLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __currencyDisplay() {\n const useCode = this.__store?.use_international_currency_symbol;\n\n if (useCode === true) return 'code';\n if (useCode === false) return 'symbol';\n }\n\n private get __summaryOptions() {\n const { array, count } = this.__items ?? {};\n if (array && count) return { firstItem: array[0], count, countMinus1: count - 1 };\n }\n\n private get __summaryKey() {\n const items = this.__items;\n if (items) return items.isApproximateCount ? 'summary_approximate' : 'summary';\n }\n\n private get __statusOptions() {\n const data = this.data;\n\n if (data === null) return;\n if (data.first_failed_transaction_date) return { date: data.first_failed_transaction_date };\n if (data.end_date) return { date: data.end_date };\n if (data.is_active === false) return {};\n if (new Date(data.start_date) > new Date()) return { date: data.start_date };\n\n return { date: data.next_transaction_date };\n }\n\n private get __currencyCode() {\n const cart = this.__transactionTemplate;\n\n if (cart?.currency_code) {\n return cart.currency_code as string;\n } else {\n const allLocaleCodes = this.__localeCodesHelper;\n const localeCode = (this.__templateSet ?? this.__defaultTemplateSet)?.locale_code;\n const localeInfo = localeCode ? allLocaleCodes?.values[localeCode] : void 0;\n\n if (localeInfo) return /Currency: ([A-Z]{3})/g.exec(localeInfo)?.[1];\n }\n }\n\n private get __priceOptions() {\n const currencyDisplay = this.__currencyDisplay;\n if (currencyDisplay === undefined) return;\n\n const currencyCode = this.__currencyCode;\n if (currencyCode === undefined) return;\n\n const totalOrder = this.__transactionTemplate?.total_order;\n if (totalOrder === undefined) return;\n\n const frequency = this.data?.frequency;\n if (frequency === undefined) return;\n\n return {\n ...parseFrequency(frequency),\n amount: `${totalOrder} ${currencyCode}`,\n currencyDisplay,\n };\n }\n\n private get __statusKey() {\n const data = this.data;\n\n if (data === null) return;\n if (data.first_failed_transaction_date) return 'subscription_failed';\n if (data.end_date) {\n const hasEnded = new Date(data.end_date).getTime() > Date.now();\n return hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';\n }\n\n if (data.is_active === false) return 'subscription_inactive';\n if (new Date(data.start_date) > new Date()) return 'subscription_will_be_active';\n\n return 'subscription_active';\n }\n\n private get __priceKey() {\n const frequency = this.data?.frequency;\n if (frequency) return `price_${frequency === '.5m' ? 'twice_a_month' : 'recurring'}`;\n }\n}\n"]}
@@ -113,7 +113,7 @@ export class SubscriptionCard extends Base {
113
113
  `;
114
114
  }
115
115
  __getSummaryOptions() {
116
- if (!this.in({ idle: 'snapshot' }))
116
+ if (this.data === null)
117
117
  return {};
118
118
  const items = this.data._embedded['fx:transaction_template']._embedded['fx:items'];
119
119
  return {
@@ -123,29 +123,41 @@ export class SubscriptionCard extends Base {
123
123
  };
124
124
  }
125
125
  __getStatusOptions() {
126
- var _a, _b;
127
- if (!this.in({ idle: 'snapshot' }))
126
+ const data = this.data;
127
+ if (data === null)
128
128
  return {};
129
- return {
130
- date: (_b = (_a = this.data.first_failed_transaction_date) !== null && _a !== void 0 ? _a : this.data.end_date) !== null && _b !== void 0 ? _b : this.data.next_transaction_date,
131
- };
129
+ if (data.first_failed_transaction_date)
130
+ return { date: data.first_failed_transaction_date };
131
+ if (data.end_date)
132
+ return { date: data.end_date };
133
+ if (data.is_active === false)
134
+ return {};
135
+ if (new Date(data.start_date) > new Date())
136
+ return { date: data.start_date };
137
+ return { date: data.next_transaction_date };
132
138
  }
133
139
  __getPriceOptions() {
134
- if (!this.in({ idle: 'snapshot' }))
140
+ if (this.data === null)
135
141
  return {};
136
142
  const transaction = this.data._embedded['fx:last_transaction'];
137
143
  const amount = `${transaction.total_order} ${transaction.currency_code}`;
138
144
  return { ...parseFrequency(this.data.frequency), amount };
139
145
  }
140
146
  __getStatusKey() {
141
- var _a, _b, _c;
142
- if ((_a = this.data) === null || _a === void 0 ? void 0 : _a.first_failed_transaction_date)
147
+ const data = this.data;
148
+ if (data === null)
149
+ return;
150
+ if (data.first_failed_transaction_date)
143
151
  return 'subscription_failed';
144
- if ((_b = this.data) === null || _b === void 0 ? void 0 : _b.end_date) {
145
- const hasEnded = new Date(this.data.end_date).getTime() > Date.now();
152
+ if (data.end_date) {
153
+ const hasEnded = new Date(data.end_date).getTime() > Date.now();
146
154
  return hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';
147
155
  }
148
- return `subscription_${((_c = this.data) === null || _c === void 0 ? void 0 : _c.is_active) ? 'active' : 'inactive'}`;
156
+ if (data.is_active === false)
157
+ return 'subscription_inactive';
158
+ if (new Date(data.start_date) > new Date())
159
+ return 'subscription_will_be_active';
160
+ return 'subscription_active';
149
161
  }
150
162
  }
151
163
  //# sourceMappingURL=SubscriptionCard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionCard.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionCard/SubscriptionCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAClE,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,qCAAkC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAEhE,MAAM,EAAE,GAAG,mBAAmB,CAAC;AAC/B,MAAM,IAAI,GAAG,iBAAiB,CAC5B,eAAe,CAAC,cAAc,CAAC,iBAAiB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CACvE,CAAC;AAEF;;;;;GAKG;AACH,MAAM,OAAO,gBAAiB,SAAQ,IAAU;IAC9C,MAAM;;QACJ,MAAM,QAAQ,GAAG,CAAC,QAAC,IAAI,CAAC,IAAI,0CAAE,SAAS,CAAA,CAAC;QACxC,MAAM,QAAQ,GAAG,CAAC,QAAC,IAAI,CAAC,IAAI,0CAAE,6BAA6B,CAAA,CAAC;QAE5D,OAAO,IAAI,CAAA;;;kBAGG,QAAQ,CAAC;YACf,gFAAgF,EAAE,IAAI;YACtF,WAAW,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;SAC5C,CAAC;;;o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AAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAG,GAAG,WAAW,CAAC,WAAW,IAAI,WAAW,CAAC,aAAa,EAAE,CAAC;QACzE,OAAO,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5D,CAAC;IAEO,cAAc;;QACpB,UAAI,IAAI,CAAC,IAAI,0CAAE,6BAA6B;YAAE,OAAO,qBAAqB,CAAC;QAE3E,UAAI,IAAI,CAAC,IAAI,0CAAE,QAAQ,EAAE;YACvB,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACrE,OAAO,QAAQ,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,wBAAwB,CAAC;SAC/E;QAED,OAAO,gBAAgB,OAAA,IAAI,CAAC,IAAI,0CAAE,SAAS,EAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IACxE,CAAC;CACF","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { Data } from './types';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { parseFrequency } from '../../../utils/parse-frequency';\n\nconst NS = 'subscription-card';\nconst Base = ConfigurableMixin(\n ResponsiveMixin(ThemeableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Card element displaying subscription summary.\n *\n * @element foxy-subscription-card\n * @since 1.4.0\n */\nexport class SubscriptionCard extends Base<Data> {\n render(): TemplateResult {\n const isActive = !!this.data?.is_active;\n const isFailed = !!this.data?.first_failed_transaction_date;\n\n return html`\n <div class=\"relative text-left\">\n <div\n class=${classMap({\n 'flex items-start sm-items-center space-x-m transition duration-150 ease-in-out': true,\n 'opacity-0': !this.in({ idle: 'snapshot' }),\n })}\n >\n <div\n class=${classMap({\n 'min-w-0 flex-shrink-0 rounded-full relative flex p-s': true,\n 'text-success bg-success-10': isActive && !isFailed,\n 'text-body bg-contrast-5': !isActive && !isFailed,\n 'text-error bg-error-10': isFailed,\n })}\n >\n <iron-icon\n class=\"m-auto\"\n icon=${isFailed ? 'error-outline' : isActive ? 'done' : 'done-all'}\n >\n </iron-icon>\n </div>\n\n <div class=\"flex-1 min-w-0 leading-xs flex flex-col sm-flex-row sm-items-center\">\n <div class=\"order-1 sm-order-0\">\n <div class=\"text-body font-medium origin-top-left text-m\">\n <foxy-i18n\n data-testid=\"summary\"\n options=${JSON.stringify(this.__getSummaryOptions())}\n lang=${this.lang}\n key=\"transaction_summary\"\n ns=${this.ns}\n >\n </foxy-i18n>\n &#8203;\n </div>\n\n <div\n class=${classMap({\n 'text-m': true,\n 'text-tertiary': !isActive && !isFailed,\n 'text-success': isActive && !isFailed,\n 'text-error': isFailed,\n })}\n >\n <foxy-i18n\n data-testid=\"status\"\n options=${JSON.stringify(this.__getStatusOptions())}\n lang=${this.lang}\n key=${this.__getStatusKey()}\n ns=${this.ns}\n >\n </foxy-i18n>\n &#8203;\n </div>\n </div>\n\n <div\n class=\"flex-1 font-medium leading-xs mb-xs sm-mb-0 sm-text-right text-xxs sm-text-l tracking-wide sm-tracking-normal uppercase sm-normal-case order-0 sm-order-1 font-tnum text-secondary sm-text-body\"\n >\n <foxy-i18n\n data-testid=\"price\"\n options=${JSON.stringify(this.__getPriceOptions())}\n lang=${this.lang}\n key=\"price_${this.data?.frequency === '.5m' ? 'twice_a_month' : 'recurring'}\"\n ns=${this.ns}\n >\n </foxy-i18n>\n &#8203;\n </div>\n </div>\n </div>\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'pointer-events-none absolute inset-0 flex transition ease-in-out duration-150': true,\n 'opacity-0': this.in({ idle: 'snapshot' }),\n })}\n >\n <foxy-spinner\n state=${this.in('fail') ? 'error' : this.in({ idle: 'template' }) ? 'empty' : 'busy'}\n class=\"m-auto\"\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n\n ${this.renderTemplateOrSlot()}\n `;\n }\n\n private __getSummaryOptions() {\n if (!this.in({ idle: 'snapshot' })) return {};\n const items = this.data._embedded['fx:transaction_template']._embedded['fx:items'];\n\n return {\n most_expensive_item: [...items].sort((a, b) => a.price - b.price)[0],\n count_minus_one: items.length - 1,\n count: items.length,\n };\n }\n\n private __getStatusOptions() {\n if (!this.in({ idle: 'snapshot' })) return {};\n return {\n date:\n this.data.first_failed_transaction_date ??\n this.data.end_date ??\n this.data.next_transaction_date,\n };\n }\n\n private __getPriceOptions() {\n if (!this.in({ idle: 'snapshot' })) return {};\n\n const transaction = this.data._embedded['fx:last_transaction'];\n const amount = `${transaction.total_order} ${transaction.currency_code}`;\n return { ...parseFrequency(this.data.frequency), amount };\n }\n\n private __getStatusKey() {\n if (this.data?.first_failed_transaction_date) return 'subscription_failed';\n\n if (this.data?.end_date) {\n const hasEnded = new Date(this.data.end_date).getTime() > Date.now();\n return hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';\n }\n\n return `subscription_${this.data?.is_active ? 'active' : 'inactive'}`;\n }\n}\n"]}
1
+ {"version":3,"file":"SubscriptionCard.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionCard/SubscriptionCard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AAEjE,OAAO,EAAE,cAAc,EAAE,4CAAyC;AAClE,OAAO,EAAE,eAAe,EAAE,sCAAm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;IAEO,cAAc;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO;QAC1B,IAAI,IAAI,CAAC,6BAA6B;YAAE,OAAO,qBAAqB,CAAC;QACrE,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAChE,OAAO,QAAQ,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,wBAAwB,CAAC;SAC/E;QAED,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK;YAAE,OAAO,uBAAuB,CAAC;QAC7D,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,IAAI,IAAI,EAAE;YAAE,OAAO,6BAA6B,CAAC;QAEjF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;CACF","sourcesContent":["import { TemplateResult, html } from 'lit-html';\n\nimport { ConfigurableMixin } from '../../../mixins/configurable';\nimport { Data } from './types';\nimport { NucleonElement } from '../NucleonElement/NucleonElement';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { ThemeableMixin } from '../../../mixins/themeable';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { classMap } from '../../../utils/class-map';\nimport { parseFrequency } from '../../../utils/parse-frequency';\n\nconst NS = 'subscription-card';\nconst Base = ConfigurableMixin(\n ResponsiveMixin(ThemeableMixin(TranslatableMixin(NucleonElement, NS)))\n);\n\n/**\n * Card element displaying subscription summary.\n *\n * @element foxy-subscription-card\n * @since 1.4.0\n */\nexport class SubscriptionCard extends Base<Data> {\n render(): TemplateResult {\n const isActive = !!this.data?.is_active;\n const isFailed = !!this.data?.first_failed_transaction_date;\n\n return html`\n <div class=\"relative text-left\">\n <div\n class=${classMap({\n 'flex items-start sm-items-center space-x-m transition duration-150 ease-in-out': true,\n 'opacity-0': !this.in({ idle: 'snapshot' }),\n })}\n >\n <div\n class=${classMap({\n 'min-w-0 flex-shrink-0 rounded-full relative flex p-s': true,\n 'text-success bg-success-10': isActive && !isFailed,\n 'text-body bg-contrast-5': !isActive && !isFailed,\n 'text-error bg-error-10': isFailed,\n })}\n >\n <iron-icon\n class=\"m-auto\"\n icon=${isFailed ? 'error-outline' : isActive ? 'done' : 'done-all'}\n >\n </iron-icon>\n </div>\n\n <div class=\"flex-1 min-w-0 leading-xs flex flex-col sm-flex-row sm-items-center\">\n <div class=\"order-1 sm-order-0\">\n <div class=\"text-body font-medium origin-top-left text-m\">\n <foxy-i18n\n data-testid=\"summary\"\n options=${JSON.stringify(this.__getSummaryOptions())}\n lang=${this.lang}\n key=\"transaction_summary\"\n ns=${this.ns}\n >\n </foxy-i18n>\n &#8203;\n </div>\n\n <div\n class=${classMap({\n 'text-m': true,\n 'text-tertiary': !isActive && !isFailed,\n 'text-success': isActive && !isFailed,\n 'text-error': isFailed,\n })}\n >\n <foxy-i18n\n data-testid=\"status\"\n options=${JSON.stringify(this.__getStatusOptions())}\n lang=${this.lang}\n key=${this.__getStatusKey()}\n ns=${this.ns}\n >\n </foxy-i18n>\n &#8203;\n </div>\n </div>\n\n <div\n class=\"flex-1 font-medium leading-xs mb-xs sm-mb-0 sm-text-right text-xxs sm-text-l tracking-wide sm-tracking-normal uppercase sm-normal-case order-0 sm-order-1 font-tnum text-secondary sm-text-body\"\n >\n <foxy-i18n\n data-testid=\"price\"\n options=${JSON.stringify(this.__getPriceOptions())}\n lang=${this.lang}\n key=\"price_${this.data?.frequency === '.5m' ? 'twice_a_month' : 'recurring'}\"\n ns=${this.ns}\n >\n </foxy-i18n>\n &#8203;\n </div>\n </div>\n </div>\n\n <div\n data-testid=\"spinner\"\n class=${classMap({\n 'pointer-events-none absolute inset-0 flex transition ease-in-out duration-150': true,\n 'opacity-0': this.in({ idle: 'snapshot' }),\n })}\n >\n <foxy-spinner\n state=${this.in('fail') ? 'error' : this.in({ idle: 'template' }) ? 'empty' : 'busy'}\n class=\"m-auto\"\n lang=${this.lang}\n ns=\"${this.ns} ${customElements.get('foxy-spinner')?.defaultNS ?? ''}\"\n >\n </foxy-spinner>\n </div>\n </div>\n\n ${this.renderTemplateOrSlot()}\n `;\n }\n\n private __getSummaryOptions() {\n if (this.data === null) return {};\n const items = this.data._embedded['fx:transaction_template']._embedded['fx:items'];\n\n return {\n most_expensive_item: [...items].sort((a, b) => a.price - b.price)[0],\n count_minus_one: items.length - 1,\n count: items.length,\n };\n }\n\n private __getStatusOptions() {\n const data = this.data;\n\n if (data === null) return {};\n if (data.first_failed_transaction_date) return { date: data.first_failed_transaction_date };\n if (data.end_date) return { date: data.end_date };\n if (data.is_active === false) return {};\n if (new Date(data.start_date) > new Date()) return { date: data.start_date };\n\n return { date: data.next_transaction_date };\n }\n\n private __getPriceOptions() {\n if (this.data === null) return {};\n\n const transaction = this.data._embedded['fx:last_transaction'];\n const amount = `${transaction.total_order} ${transaction.currency_code}`;\n return { ...parseFrequency(this.data.frequency), amount };\n }\n\n private __getStatusKey() {\n const data = this.data;\n\n if (data === null) return;\n if (data.first_failed_transaction_date) return 'subscription_failed';\n if (data.end_date) {\n const hasEnded = new Date(data.end_date).getTime() > Date.now();\n return hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';\n }\n\n if (data.is_active === false) return 'subscription_inactive';\n if (new Date(data.start_date) > new Date()) return 'subscription_will_be_active';\n\n return 'subscription_active';\n }\n}\n"]}
@@ -69,7 +69,6 @@ export class SubscriptionForm extends Base {
69
69
  this.__templateSetLoaderId = 'templateSetLoader';
70
70
  this.__storeLoaderId = 'storeLoader';
71
71
  this.__renderHeaderSubtitle = () => {
72
- var _a;
73
72
  const { data, lang, ns } = this;
74
73
  if (data) {
75
74
  let color = 'text-secondary';
@@ -82,12 +81,20 @@ export class SubscriptionForm extends Base {
82
81
  }
83
82
  else if (data.end_date) {
84
83
  date = data.end_date;
85
- const hasEnded = new Date(date).getTime() > Date.now();
84
+ const hasEnded = new Date(data.end_date).getTime() > Date.now();
86
85
  key = hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';
87
86
  }
87
+ else if (!data.is_active) {
88
+ date = '';
89
+ key = 'subscription_inactive';
90
+ }
91
+ else if (new Date(data.start_date) > new Date()) {
92
+ date = data.start_date;
93
+ key = 'subscription_will_be_active';
94
+ }
88
95
  else {
89
- date = (_a = data.next_transaction_date) !== null && _a !== void 0 ? _a : new Date().toISOString();
90
- key = `subscription_${data.is_active ? 'active' : 'inactive'}`;
96
+ date = data.next_transaction_date;
97
+ key = 'subscription_active';
91
98
  }
92
99
  const text = html `
93
100
  <foxy-i18n
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionForm.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionForm/SubscriptionForm.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,+BAA4B;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,wCAAqC;AACjE,OAAO,EAAE,eAAe,EAAY,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,sCAAmC;AAC7D,OAAO,EAAE,cAAc,EAAE,0CAAuC;AAChE,OAAO,EAAE,aAAa,EAAE,yCAAsC;AAC9D,OAAO,EAAE,YAAY,EAAE,oDAAiD;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EACL,iCAAiC,EACjC,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,EAAE,GAAG,mBAAmB,CAAC;AAC/B,MAAM,IAAI,GAAG,mBAAmB,CAAC,eAAe,CAAC,iBA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qBAAqB,CAAC;YAC/C,YAAY,EAAE,IAAI,CAAC,IAAI;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import type { CustomerPageGetter, Data, Settings, Templates, TransactionPageGetter } from './types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport type { InternalCalendar } from '../../internal/InternalCalendar';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { ButtonElement } from '@vaadin/vaadin-button';\nimport type { FormDialog } from '../FormDialog';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { Choice, Group, Skeleton } from '../../private/index';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector, Resource } from '@foxy.io/sdk/core';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { serializeDate } from '../../../utils/serialize-date';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nimport {\n getNextTransactionDateConstraints,\n getAllowedFrequencies,\n isNextTransactionDate,\n} from '@foxy.io/sdk/customer';\n\nconst NS = 'subscription-form';\nconst Base = ScopedElementsMixin(ResponsiveMixin(TranslatableMixin(InternalForm, NS)));\n\n/**\n * Form element for creating or editing subscriptions.\n *\n * @slot header:before - **new in v1.4.0**\n * @slot header:after - **new in v1.4.0**\n *\n * @slot items:before - **new in v1.4.0**\n * @slot items:after - **new in v1.4.0**\n * @slot items:actions:before - **new in v1.4.0**\n * @slot items:actions:after - **new in v1.4.0**\n *\n * @slot end-date:before - **new in v1.4.0**\n * @slot end-date:after - **new in v1.4.0**\n *\n * @slot next-transaction-date:before - **new in v1.4.0**\n * @slot next-transaction-date:after - **new in v1.4.0**\n *\n * @slot frequency:before - **new in v1.4.0**\n * @slot frequency:after - **new in v1.4.0**\n *\n * @slot transactions:before - **new in v1.4.0**\n * @slot transactions:after - **new in v1.4.0**\n *\n * @slot attributes:before - **new in v1.20.0**\n * @slot attributes:after - **new in v1.20.0**\n *\n * @slot timestamps:before - **new in v1.20.0**\n * @slot timestamps:after - **new in v1.20.0**\n *\n * @slot past-due-amount:before - **new in v1.20.0**\n * @slot past-due-amount:after - **new in v1.20.0**\n *\n * @slot start-date:before - **new in v1.20.0**\n * @slot start-date:after - **new in v1.20.0**\n *\n * @element foxy-subscription-form\n * @since 1.2.0\n */\nexport class SubscriptionForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-timestamps-control': customElements.get('foxy-internal-timestamps-control'),\n 'foxy-internal-async-list-control': customElements.get('foxy-internal-async-list-control'),\n 'foxy-internal-number-control': customElements.get('foxy-internal-number-control'),\n 'foxy-internal-calendar': customElements.get('foxy-internal-calendar'),\n 'foxy-collection-pages': customElements.get('foxy-collection-pages'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-customer-card': customElements.get('foxy-customer-card'),\n 'vaadin-combo-box': customElements.get('vaadin-combo-box'),\n 'foxy-form-dialog': customElements.get('foxy-form-dialog'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-nucleon': customElements.get('foxy-nucleon'),\n 'vcf-tooltip': customElements.get('vcf-tooltip'),\n 'foxy-table': customElements.get('foxy-table'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'iron-icon': customElements.get('iron-icon'),\n 'x-skeleton': Skeleton,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getTransactionPageHref: { attribute: false },\n getCustomerPageHref: { attribute: false },\n customerAddresses: { attribute: 'customer-addresses' },\n itemCategories: { attribute: 'item-categories' },\n localeCodes: { attribute: 'locale-codes' },\n settings: { type: Object },\n coupons: {},\n };\n }\n\n getTransactionPageHref: TransactionPageGetter = (_, data: any) => {\n return data?._links['fx:receipt'].href;\n };\n\n getCustomerPageHref: CustomerPageGetter | null = null;\n\n customerAddresses: string | null = null;\n\n itemCategories: string | null = null;\n\n localeCodes: string | null = null;\n\n templates: Templates = {};\n\n settings: Settings | null = null;\n\n coupons: string | null = null;\n\n private readonly __transactionTemplateLoaderId = 'transactionTemplateLoader';\n\n private readonly __defaultTemplateSetLoaderId = 'defaultTemplateSetLoader';\n\n private readonly __localeCodesHelperLoaderId = 'localeCodesLoader';\n\n private readonly __templateSetLoaderId = 'templateSetLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __renderHeaderSubtitle = () => {\n const { data, lang, ns } = this;\n\n if (data) {\n let color = 'text-secondary';\n let date: string;\n let key: string;\n\n if (data.first_failed_transaction_date) {\n color = 'text-error';\n date = data.first_failed_transaction_date;\n key = 'subscription_failed';\n } else if (data.end_date) {\n date = data.end_date;\n const hasEnded = new Date(date).getTime() > Date.now();\n key = hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';\n } else {\n date = data.next_transaction_date ?? new Date().toISOString();\n key = `subscription_${data.is_active ? 'active' : 'inactive'}`;\n }\n\n const text = html`\n <foxy-i18n\n data-testid=\"header-subtitle\"\n options=${JSON.stringify({ date })}\n class=${color}\n lang=${lang}\n key=${key}\n ns=${ns}\n >\n </foxy-i18n>\n `;\n\n if (data.first_failed_transaction_date) {\n return html`\n <span id=\"status\" class=\"flex items-center space-x-xs ${color}\">\n ${text}<iron-icon icon=\"icons:info-outline\" class=\"icon-inline\"></iron-icon>\n </span>\n <vcf-tooltip for=\"status\" position=\"bottom\">\n <span class=\"text-s\">${data.error_message}</span>\n </vcf-tooltip>\n `;\n }\n\n return text;\n }\n\n return html`<x-skeleton class=\"w-full\" variant=\"static\">&nbsp;</x-skeleton>`;\n };\n\n private readonly __renderHeaderTitle = (\n currency: string | undefined,\n currencyDisplay: string | undefined\n ) => {\n const { data, lang, ns } = this;\n\n if (data) {\n const frequency = parseFrequency(data.frequency);\n const transactionTemplate = this.__transactionTemplate;\n const total = transactionTemplate?.total_order;\n\n if (typeof currency !== 'string') return html`--`;\n\n return html`\n <foxy-i18n\n data-testid=\"header-title\"\n options=${JSON.stringify({\n ...frequency,\n amount: `${total} ${currency}`,\n currencyDisplay,\n })}\n lang=${lang}\n key=\"price_${data.frequency === '.5m' ? 'twice_a_month' : 'recurring'}\"\n ns=${ns}\n >\n </foxy-i18n>\n `;\n }\n\n return html`<x-skeleton class=\"w-full\" variant=\"static\">&nbsp;</x-skeleton>`;\n };\n\n private readonly __renderHeader = (\n currencyCode: string | undefined,\n currencyDisplay: string | undefined\n ) => {\n return html`\n <div data-testid=\"header\" class=\"sm-col-span-2\">\n ${this.renderTemplateOrSlot('header:before')}\n <div class=\"leading-xs text-xxl font-medium truncate\">\n ${this.__renderHeaderTitle(currencyCode, currencyDisplay)}\n </div>\n <div class=\"leading-xs text-l\">${this.__renderHeaderSubtitle()}</div>\n ${this.renderTemplateOrSlot('header:after')}\n </div>\n `;\n };\n\n private readonly __renderItemsActions = () => {\n return html`\n <div class=\"flex\" data-testid=\"items:actions\">\n ${this.renderTemplateOrSlot('items:actions:before')}\n\n <foxy-i18n\n data-testid=\"items:actions-label\"\n class=\"flex-1 text-s font-medium text-secondary\"\n lang=${this.lang}\n key=\"item_plural\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n ${this.renderTemplateOrSlot('items:actions:after')}\n </div>\n `;\n };\n\n private readonly __renderItems = () => {\n let itemsHref: string | undefined;\n\n try {\n const cart = this.__transactionTemplate;\n const url = new URL(cart?._links['fx:items'].href ?? '');\n url.searchParams.set('zoom', 'item_options');\n itemsHref = url.toString();\n } catch {\n itemsHref = undefined;\n }\n\n return html`\n <div data-testid=\"items\" class=\"space-y-xs sm-col-span-2\">\n ${this.hiddenSelector.matches('items:actions', true) ? '' : this.__renderItemsActions()}\n\n <foxy-internal-async-list-control\n first=${ifDefined(itemsHref)}\n limit=\"5\"\n infer=\"items\"\n item=\"foxy-item-card\"\n >\n </foxy-internal-async-list-control>\n </div>\n `;\n };\n\n private readonly __renderEndDate = () => {\n const { disabledSelector, lang, ns } = this;\n const formHiddenSelector = this.hiddenSelector.zoom('end-date:form').toString();\n\n return html`\n <div class=\"sm-col-span-2\">\n ${this.renderTemplateOrSlot('end-date:before')}\n\n <foxy-form-dialog\n readonlycontrols=${this.readonlySelector.zoom('end-date:form').toString()}\n disabledcontrols=${disabledSelector.zoom('end-date:form').toString()}\n hiddencontrols=\"save-button ${formHiddenSelector}\"\n data-testid=\"cancellation-form\"\n parent=${this.parent}\n header=\"end_subscription\"\n alert\n form=\"foxy-cancellation-form\"\n href=${this.href}\n lang=${lang}\n id=\"end-date-form\"\n ns=${ns}\n .templates=${this.getNestedTemplates('end-date:form')}\n >\n </foxy-form-dialog>\n\n <vaadin-button\n data-testid=\"end-date\"\n theme=\"error\"\n class=\"w-full\"\n ?disabled=${!this.data || disabledSelector.matches('end-date', true)}\n @click=${(evt: Event) => {\n const form = this.renderRoot.querySelector('#end-date-form') as FormDialog;\n form.show(evt.currentTarget as ButtonElement);\n }}\n >\n <foxy-i18n key=\"end_subscription\" ns=${ns} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('end-date:after')}\n </div>\n `;\n };\n\n private readonly __checkNextTransactionDateAvailability = (date: Date) => {\n const { settings, data: subscription } = this;\n\n if (settings && subscription) {\n const value = serializeDate(date);\n return isNextTransactionDate({ value, settings, subscription });\n }\n\n return date.getTime() >= Date.now();\n };\n\n private readonly __checkStartDateAvailability = (date: Date) => {\n return date.getTime() >= Date.now();\n };\n\n private readonly __renderStartDate = () => {\n const { data, lang, ns } = this;\n\n return html`\n <div data-testid=\"start-date\">\n ${this.renderTemplateOrSlot('start-date:before')}\n\n <x-group frame>\n <foxy-i18n key=\"start_date\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n <foxy-internal-calendar\n start=${ifDefined(data?.start_date.substr(0, 10))}\n value=${ifDefined(data?.start_date)}\n lang=${lang}\n ?readonly=${!this.__isStartDateEditable}\n ?disabled=${this.disabledSelector.matches('start-date', true)}\n .checkAvailability=${this.__checkStartDateAvailability}\n @change=${(evt: Event) => {\n const target = evt.target as InternalCalendar;\n this.edit({ start_date: target.value });\n }}\n >\n </foxy-internal-calendar>\n </x-group>\n\n ${this.renderTemplateOrSlot('start-date:after')}\n </div>\n `;\n };\n\n private readonly __renderNextTransactionDate = () => {\n const { data, lang, ns } = this;\n const isActive = !!data?.is_active;\n\n return html`\n <div data-testid=\"next-transaction-date\">\n ${this.renderTemplateOrSlot('next-transaction-date:before')}\n\n <x-group frame>\n <foxy-i18n key=\"next_transaction_date\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n <foxy-internal-calendar\n start=${ifDefined(data?.next_transaction_date.substr(0, 10))}\n value=${ifDefined(data?.next_transaction_date)}\n lang=${lang}\n ?readonly=${!isActive || this.readonlySelector.matches('next-transaction-date', true)}\n ?disabled=${!data || this.disabledSelector.matches('next-transaction-date', true)}\n .checkAvailability=${this.__checkNextTransactionDateAvailability}\n @change=${(evt: Event) => {\n const target = evt.target as InternalCalendar;\n this.edit({ next_transaction_date: target.value });\n }}\n >\n </foxy-internal-calendar>\n </x-group>\n\n ${this.renderTemplateOrSlot('next-transaction-date:after')}\n </div>\n `;\n };\n\n private readonly __renderFrequencyAsDropdown = () => {\n const { data } = this;\n const active = !!data?.is_active;\n const items = this.__frequencies.map(v => ({\n label: this.t(v === '.5m' ? 'twice_a_month' : 'frequency', parseFrequency(v)),\n value: v,\n }));\n\n return html`\n <vaadin-combo-box\n item-value-path=\"value\"\n item-label-path=\"label\"\n data-testid=\"frequency\"\n ?disabled=${!data || this.disabledSelector.matches('frequency', true)}\n ?readonly=${data && (!active || this.readonlySelector.matches('frequency', true))}\n class=\"w-full\"\n label=${this.t('frequency_label').toString()}\n value=${ifDefined(this.form.frequency)}\n .items=${items}\n @change=${(evt: Event) => {\n this.edit({ frequency: (evt.target as HTMLInputElement).value });\n }}\n >\n </vaadin-combo-box>\n `;\n };\n\n private readonly __renderFrequencyAsRadioList = () => {\n const { data, lang, ns } = this;\n\n return html`\n <x-group frame>\n <foxy-i18n key=\"frequency_label\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n\n <x-choice\n default-custom-value=\"1d\"\n data-testid=\"frequency\"\n type=\"frequency\"\n ns=${ns}\n ?custom=${this.settings === null}\n .items=${this.__frequencies}\n .value=${this.form.frequency ?? null}\n ?disabled=${!data || this.disabledSelector.matches('frequency', true)}\n ?readonly=${data && (!data.is_active || this.readonlySelector.matches('frequency', true))}\n @change=${(evt: Event) => {\n this.edit({ frequency: (evt.target as HTMLInputElement).value });\n }}\n >\n ${this.__frequencies.map(\n frequency => html`\n <foxy-i18n\n options=${JSON.stringify(parseFrequency(frequency))}\n slot=\"${frequency}-label\"\n lang=${lang}\n key=${frequency === '.5m' ? 'twice_a_month' : 'frequency'}\n ns=${ns}\n >\n </foxy-i18n>\n `\n )}\n </x-choice>\n </x-group>\n `;\n };\n\n private readonly __renderFrequency = () => {\n return html`\n <div class=\"sm-col-span-2\">\n ${this.renderTemplateOrSlot('frequency:before')}\n ${this.settings && this.__frequencies.length > 4\n ? this.__renderFrequencyAsDropdown()\n : this.__renderFrequencyAsRadioList()}\n ${this.renderTemplateOrSlot('frequency:after')}\n </div>\n `;\n };\n\n private readonly __renderCustomer = () => {\n const customerHref = this.data?._links['fx:customer'].href;\n const customerPageHref = customerHref ? this.getCustomerPageHref?.(customerHref) : void 0;\n\n return html`\n <div data-testid=\"customer\" class=\"sm-col-span-2\">\n ${this.renderTemplateOrSlot('customer:before')}\n\n <foxy-i18n infer=\"customer\" class=\"block text-s font-medium leading-xs mb-xs\" key=\"label\">\n </foxy-i18n>\n\n <a\n class=${classMap({\n 'block rounded transition-colors': true,\n 'ring-1 ring-contrast-10': !customerPageHref,\n 'cursor-pointer bg-contrast-5 hover-bg-contrast-10': !!customerPageHref,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': !!customerPageHref,\n })}\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n href=${ifDefined(customerPageHref)}\n >\n <foxy-customer-card infer=\"customer\" href=${ifDefined(customerHref)}></foxy-customer-card>\n </a>\n\n ${this.renderTemplateOrSlot('customer:after')}\n </div>\n `;\n };\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`items:pagination:card:autorenew-icon ${super.hiddenSelector}`);\n }\n\n renderBody(): TemplateResult {\n let transactionsHref: string | undefined;\n\n try {\n const url = new URL(this.data?._links['fx:transactions'].href ?? '');\n url.searchParams.set('order', 'transaction_date desc');\n url.searchParams.set('zoom', 'items');\n transactionsHref = url.toString();\n } catch {\n transactionsHref = undefined;\n }\n\n const currencyDisplay = this.__store?.use_international_currency_symbol ? 'code' : 'symbol';\n const cart = this.__transactionTemplate;\n\n let currencyCode: string | null = null;\n\n if (cart?.currency_code) {\n currencyCode = cart.currency_code;\n } else {\n const allLocaleCodes = this.__localeCodesHelper;\n const localeCode = (this.__templateSet ?? this.__defaultTemplateSet)?.locale_code;\n const localeInfo = localeCode ? allLocaleCodes?.values[localeCode] : void 0;\n\n if (localeInfo) currencyCode = /Currency: ([A-Z]{3})/g.exec(localeInfo)?.[1] ?? null;\n }\n\n return html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionTemplateHref)}\n id=${this.__transactionTemplateLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__defaultTemplateSetHref)}\n id=${this.__defaultTemplateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__localeCodesHelperHref)}\n id=${this.__localeCodesHelperLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__templateSetHref)}\n id=${this.__templateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__storeHref)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div class=\"relative grid grid-cols-1 sm-grid-cols-2 gap-l\">\n ${this.hiddenSelector.matches('header', true)\n ? ''\n : this.__renderHeader(currencyCode ?? void 0, currencyDisplay)}\n ${this.hiddenSelector.matches('customer', true) ? '' : this.__renderCustomer()}\n ${this.hiddenSelector.matches('items', true) ? '' : this.__renderItems()}\n ${this.__isFrequencyVisible ? this.__renderFrequency() : ''}\n ${this.__isStartDateVisible ? this.__renderStartDate() : ''}\n ${this.__isNextTransactionDateVisible ? this.__renderNextTransactionDate() : ''}\n\n <foxy-internal-number-control\n suffix=${ifDefined(currencyCode ?? void 0)}\n infer=\"past-due-amount\"\n class=\"sm-col-span-2\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n\n <foxy-internal-async-list-control\n first=${ifDefined(this.data?._links['fx:attributes']?.href)}\n class=\"sm-col-span-2\"\n infer=\"attributes\"\n limit=\"5\"\n form=\"foxy-attribute-form\"\n item=\"foxy-attribute-card\"\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n first=${ifDefined(transactionsHref)}\n class=\"sm-col-span-2\"\n infer=\"transactions\"\n limit=\"5\"\n item=\"foxy-transaction-card\"\n hide-delete-button\n .getPageHref=${this.getTransactionPageHref}\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-timestamps-control infer=\"timestamps\" class=\"sm-col-span-2\">\n </foxy-internal-timestamps-control>\n\n ${this.hiddenSelector.matches('end-date', true) ? '' : this.__renderEndDate()}\n </div>\n `;\n }\n\n private get __transactionTemplateHref() {\n type DataWithEmbeds = Resource<Rels.Subscription, { zoom: 'transaction_template' }>;\n type Embed = Resource<Rels.TransactionTemplate>;\n\n const data = this.data as DataWithEmbeds | null;\n const embed = data?._embedded?.['fx:transaction_template'] as Embed | undefined;\n\n return embed ? void 0 : data?._links['fx:transaction_template'].href;\n }\n\n private get __defaultTemplateSetHref() {\n const templateSetUri = this.__transactionTemplate?.template_set_uri;\n\n if (templateSetUri === '') {\n try {\n const url = new URL(this.__store?._links['fx:template_sets'].href ?? '');\n url.searchParams.set('code', 'DEFAULT');\n return url.toString();\n } catch {\n //\n }\n }\n }\n\n private get __localeCodesHelperHref() {\n if (this.__defaultTemplateSetHref || this.__templateSetHref) {\n return this.localeCodes ?? void 0;\n }\n }\n\n private get __templateSetHref() {\n const cart = this.__transactionTemplate;\n if (!cart?.currency_code) return cart?.template_set_uri || void 0;\n }\n\n private get __storeHref() {\n return this.data?._links['fx:store']?.href;\n }\n\n private get __transactionTemplate() {\n type DataWithEmbeds = Resource<Rels.Subscription, { zoom: 'transaction_template' }>;\n type Loader = NucleonElement<Resource<Rels.TransactionTemplate>>;\n type Embed = Resource<Rels.TransactionTemplate>;\n\n const data = this.data as DataWithEmbeds | null;\n const embed = data?._embedded?.['fx:transaction_template'] as Embed | undefined;\n const selector = `#${this.__transactionTemplateLoaderId}`;\n\n return embed ?? this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __defaultTemplateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSets>>;\n const selector = `#${this.__defaultTemplateSetLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:template_sets'][0] ?? null;\n }\n\n private get __localeCodesHelper() {\n type Loader = NucleonElement<Resource<Rels.LocaleCodes>>;\n const selector = `#${this.__localeCodesHelperLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __templateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSet>>;\n const selector = `#${this.__templateSetLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __store() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n const selector = `#${this.__storeLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __isNextTransactionDateVisible() {\n if (this.hiddenSelector.matches('next-transaction-date', true)) return false;\n if (this.data === null) return false;\n if (this.data.end_date && new Date(this.data.end_date).getTime() <= Date.now()) return false;\n if (this.data.is_active === false) return false;\n if (this.settings === null) return true;\n\n const rules = this.settings.subscriptions.allow_next_date_modification;\n return !!getNextTransactionDateConstraints(this.data, rules);\n }\n\n private get __isStartDateVisible() {\n if (this.hiddenSelector.matches('start-date', true)) return false;\n return this.__isNextTransactionDateVisible;\n }\n\n private get __isStartDateEditable() {\n if (this.readonlySelector.matches('start-date', true)) return false;\n if (this.data === null) return false;\n if (this.data.end_date && new Date(this.data.end_date) <= new Date()) return false;\n if (this.data.is_active === false) return false;\n if (this.data.start_date && new Date(this.data.start_date) <= new Date()) return false;\n\n return this.settings === null;\n }\n\n private get __isFrequencyVisible() {\n if (this.hiddenSelector.matches('frequency', true)) return false;\n if (this.data === null) return false;\n if (this.data.end_date && new Date(this.data.end_date).getTime() <= Date.now()) return false;\n if (this.data.is_active === false) return false;\n if (this.settings === null) return true;\n\n const allowedFrequencies = getAllowedFrequencies({\n subscription: this.data,\n settings: this.settings,\n });\n\n return !allowedFrequencies.next().done;\n }\n\n private get __frequencies() {\n if (!this.settings || !this.data) return ['.5m', '1m', '1y'];\n\n const allowedFrequencies = getAllowedFrequencies({\n subscription: this.data,\n settings: this.settings,\n });\n\n return Array.from(allowedFrequencies);\n }\n}\n"]}
1
+ {"version":3,"file":"SubscriptionForm.js","sourceRoot":"","sources":["../../../../src/elements/public/SubscriptionForm/SubscriptionForm.ts"],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Y,oBAAoB;QAC9B,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QACjE,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QACrC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE;YAAE,OAAO,KAAK,CAAC;QAC7F,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC;QAChD,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAExC,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;YAC/C,YAAY,EAAE,IAAI,CAAC,IAAI;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QAEH,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;IACzC,CAAC;IAED,IAAY,aAAa;QACvB,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAE7D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;YAC/C,YAAY,EAAE,IAAI,CAAC,IAAI;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["import type { CustomerPageGetter, Data, Settings, Templates, TransactionPageGetter } from './types';\nimport type { PropertyDeclarations } from 'lit-element';\nimport type { ScopedElementsMap } from '@open-wc/scoped-elements';\nimport type { InternalCalendar } from '../../internal/InternalCalendar';\nimport type { TemplateResult } from 'lit-html';\nimport type { NucleonElement } from '../NucleonElement/NucleonElement';\nimport type { ButtonElement } from '@vaadin/vaadin-button';\nimport type { FormDialog } from '../FormDialog';\nimport type { Rels } from '@foxy.io/sdk/backend';\n\nimport { Choice, Group, Skeleton } from '../../private/index';\nimport { ScopedElementsMixin } from '@open-wc/scoped-elements';\nimport { TranslatableMixin } from '../../../mixins/translatable';\nimport { BooleanSelector, Resource } from '@foxy.io/sdk/core';\nimport { ResponsiveMixin } from '../../../mixins/responsive';\nimport { parseFrequency } from '../../../utils/parse-frequency';\nimport { serializeDate } from '../../../utils/serialize-date';\nimport { InternalForm } from '../../internal/InternalForm/InternalForm';\nimport { ifDefined } from 'lit-html/directives/if-defined';\nimport { classMap } from '../../../utils/class-map';\nimport { html } from 'lit-html';\n\nimport {\n getNextTransactionDateConstraints,\n getAllowedFrequencies,\n isNextTransactionDate,\n} from '@foxy.io/sdk/customer';\n\nconst NS = 'subscription-form';\nconst Base = ScopedElementsMixin(ResponsiveMixin(TranslatableMixin(InternalForm, NS)));\n\n/**\n * Form element for creating or editing subscriptions.\n *\n * @slot header:before - **new in v1.4.0**\n * @slot header:after - **new in v1.4.0**\n *\n * @slot items:before - **new in v1.4.0**\n * @slot items:after - **new in v1.4.0**\n * @slot items:actions:before - **new in v1.4.0**\n * @slot items:actions:after - **new in v1.4.0**\n *\n * @slot end-date:before - **new in v1.4.0**\n * @slot end-date:after - **new in v1.4.0**\n *\n * @slot next-transaction-date:before - **new in v1.4.0**\n * @slot next-transaction-date:after - **new in v1.4.0**\n *\n * @slot frequency:before - **new in v1.4.0**\n * @slot frequency:after - **new in v1.4.0**\n *\n * @slot transactions:before - **new in v1.4.0**\n * @slot transactions:after - **new in v1.4.0**\n *\n * @slot attributes:before - **new in v1.20.0**\n * @slot attributes:after - **new in v1.20.0**\n *\n * @slot timestamps:before - **new in v1.20.0**\n * @slot timestamps:after - **new in v1.20.0**\n *\n * @slot past-due-amount:before - **new in v1.20.0**\n * @slot past-due-amount:after - **new in v1.20.0**\n *\n * @slot start-date:before - **new in v1.20.0**\n * @slot start-date:after - **new in v1.20.0**\n *\n * @element foxy-subscription-form\n * @since 1.2.0\n */\nexport class SubscriptionForm extends Base<Data> {\n static get scopedElements(): ScopedElementsMap {\n return {\n 'foxy-internal-timestamps-control': customElements.get('foxy-internal-timestamps-control'),\n 'foxy-internal-async-list-control': customElements.get('foxy-internal-async-list-control'),\n 'foxy-internal-number-control': customElements.get('foxy-internal-number-control'),\n 'foxy-internal-calendar': customElements.get('foxy-internal-calendar'),\n 'foxy-collection-pages': customElements.get('foxy-collection-pages'),\n 'foxy-internal-sandbox': customElements.get('foxy-internal-sandbox'),\n 'foxy-customer-card': customElements.get('foxy-customer-card'),\n 'vaadin-combo-box': customElements.get('vaadin-combo-box'),\n 'foxy-form-dialog': customElements.get('foxy-form-dialog'),\n 'vaadin-button': customElements.get('vaadin-button'),\n 'foxy-spinner': customElements.get('foxy-spinner'),\n 'foxy-nucleon': customElements.get('foxy-nucleon'),\n 'vcf-tooltip': customElements.get('vcf-tooltip'),\n 'foxy-table': customElements.get('foxy-table'),\n 'foxy-i18n': customElements.get('foxy-i18n'),\n 'iron-icon': customElements.get('iron-icon'),\n 'x-skeleton': Skeleton,\n 'x-choice': Choice,\n 'x-group': Group,\n };\n }\n\n static get properties(): PropertyDeclarations {\n return {\n ...super.properties,\n getTransactionPageHref: { attribute: false },\n getCustomerPageHref: { attribute: false },\n customerAddresses: { attribute: 'customer-addresses' },\n itemCategories: { attribute: 'item-categories' },\n localeCodes: { attribute: 'locale-codes' },\n settings: { type: Object },\n coupons: {},\n };\n }\n\n getTransactionPageHref: TransactionPageGetter = (_, data: any) => {\n return data?._links['fx:receipt'].href;\n };\n\n getCustomerPageHref: CustomerPageGetter | null = null;\n\n customerAddresses: string | null = null;\n\n itemCategories: string | null = null;\n\n localeCodes: string | null = null;\n\n templates: Templates = {};\n\n settings: Settings | null = null;\n\n coupons: string | null = null;\n\n private readonly __transactionTemplateLoaderId = 'transactionTemplateLoader';\n\n private readonly __defaultTemplateSetLoaderId = 'defaultTemplateSetLoader';\n\n private readonly __localeCodesHelperLoaderId = 'localeCodesLoader';\n\n private readonly __templateSetLoaderId = 'templateSetLoader';\n\n private readonly __storeLoaderId = 'storeLoader';\n\n private readonly __renderHeaderSubtitle = () => {\n const { data, lang, ns } = this;\n\n if (data) {\n let color = 'text-secondary';\n let date: string;\n let key: string;\n\n if (data.first_failed_transaction_date) {\n color = 'text-error';\n date = data.first_failed_transaction_date;\n key = 'subscription_failed';\n } else if (data.end_date) {\n date = data.end_date;\n const hasEnded = new Date(data.end_date).getTime() > Date.now();\n key = hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';\n } else if (!data.is_active) {\n date = '';\n key = 'subscription_inactive';\n } else if (new Date(data.start_date) > new Date()) {\n date = data.start_date;\n key = 'subscription_will_be_active';\n } else {\n date = data.next_transaction_date;\n key = 'subscription_active';\n }\n\n const text = html`\n <foxy-i18n\n data-testid=\"header-subtitle\"\n options=${JSON.stringify({ date })}\n class=${color}\n lang=${lang}\n key=${key}\n ns=${ns}\n >\n </foxy-i18n>\n `;\n\n if (data.first_failed_transaction_date) {\n return html`\n <span id=\"status\" class=\"flex items-center space-x-xs ${color}\">\n ${text}<iron-icon icon=\"icons:info-outline\" class=\"icon-inline\"></iron-icon>\n </span>\n <vcf-tooltip for=\"status\" position=\"bottom\">\n <span class=\"text-s\">${data.error_message}</span>\n </vcf-tooltip>\n `;\n }\n\n return text;\n }\n\n return html`<x-skeleton class=\"w-full\" variant=\"static\">&nbsp;</x-skeleton>`;\n };\n\n private readonly __renderHeaderTitle = (\n currency: string | undefined,\n currencyDisplay: string | undefined\n ) => {\n const { data, lang, ns } = this;\n\n if (data) {\n const frequency = parseFrequency(data.frequency);\n const transactionTemplate = this.__transactionTemplate;\n const total = transactionTemplate?.total_order;\n\n if (typeof currency !== 'string') return html`--`;\n\n return html`\n <foxy-i18n\n data-testid=\"header-title\"\n options=${JSON.stringify({\n ...frequency,\n amount: `${total} ${currency}`,\n currencyDisplay,\n })}\n lang=${lang}\n key=\"price_${data.frequency === '.5m' ? 'twice_a_month' : 'recurring'}\"\n ns=${ns}\n >\n </foxy-i18n>\n `;\n }\n\n return html`<x-skeleton class=\"w-full\" variant=\"static\">&nbsp;</x-skeleton>`;\n };\n\n private readonly __renderHeader = (\n currencyCode: string | undefined,\n currencyDisplay: string | undefined\n ) => {\n return html`\n <div data-testid=\"header\" class=\"sm-col-span-2\">\n ${this.renderTemplateOrSlot('header:before')}\n <div class=\"leading-xs text-xxl font-medium truncate\">\n ${this.__renderHeaderTitle(currencyCode, currencyDisplay)}\n </div>\n <div class=\"leading-xs text-l\">${this.__renderHeaderSubtitle()}</div>\n ${this.renderTemplateOrSlot('header:after')}\n </div>\n `;\n };\n\n private readonly __renderItemsActions = () => {\n return html`\n <div class=\"flex\" data-testid=\"items:actions\">\n ${this.renderTemplateOrSlot('items:actions:before')}\n\n <foxy-i18n\n data-testid=\"items:actions-label\"\n class=\"flex-1 text-s font-medium text-secondary\"\n lang=${this.lang}\n key=\"item_plural\"\n ns=${this.ns}\n >\n </foxy-i18n>\n\n ${this.renderTemplateOrSlot('items:actions:after')}\n </div>\n `;\n };\n\n private readonly __renderItems = () => {\n let itemsHref: string | undefined;\n\n try {\n const cart = this.__transactionTemplate;\n const url = new URL(cart?._links['fx:items'].href ?? '');\n url.searchParams.set('zoom', 'item_options');\n itemsHref = url.toString();\n } catch {\n itemsHref = undefined;\n }\n\n return html`\n <div data-testid=\"items\" class=\"space-y-xs sm-col-span-2\">\n ${this.hiddenSelector.matches('items:actions', true) ? '' : this.__renderItemsActions()}\n\n <foxy-internal-async-list-control\n first=${ifDefined(itemsHref)}\n limit=\"5\"\n infer=\"items\"\n item=\"foxy-item-card\"\n >\n </foxy-internal-async-list-control>\n </div>\n `;\n };\n\n private readonly __renderEndDate = () => {\n const { disabledSelector, lang, ns } = this;\n const formHiddenSelector = this.hiddenSelector.zoom('end-date:form').toString();\n\n return html`\n <div class=\"sm-col-span-2\">\n ${this.renderTemplateOrSlot('end-date:before')}\n\n <foxy-form-dialog\n readonlycontrols=${this.readonlySelector.zoom('end-date:form').toString()}\n disabledcontrols=${disabledSelector.zoom('end-date:form').toString()}\n hiddencontrols=\"save-button ${formHiddenSelector}\"\n data-testid=\"cancellation-form\"\n parent=${this.parent}\n header=\"end_subscription\"\n alert\n form=\"foxy-cancellation-form\"\n href=${this.href}\n lang=${lang}\n id=\"end-date-form\"\n ns=${ns}\n .templates=${this.getNestedTemplates('end-date:form')}\n >\n </foxy-form-dialog>\n\n <vaadin-button\n data-testid=\"end-date\"\n theme=\"error\"\n class=\"w-full\"\n ?disabled=${!this.data || disabledSelector.matches('end-date', true)}\n @click=${(evt: Event) => {\n const form = this.renderRoot.querySelector('#end-date-form') as FormDialog;\n form.show(evt.currentTarget as ButtonElement);\n }}\n >\n <foxy-i18n key=\"end_subscription\" ns=${ns} lang=${lang}></foxy-i18n>\n </vaadin-button>\n\n ${this.renderTemplateOrSlot('end-date:after')}\n </div>\n `;\n };\n\n private readonly __checkNextTransactionDateAvailability = (date: Date) => {\n const { settings, data: subscription } = this;\n\n if (settings && subscription) {\n const value = serializeDate(date);\n return isNextTransactionDate({ value, settings, subscription });\n }\n\n return date.getTime() >= Date.now();\n };\n\n private readonly __checkStartDateAvailability = (date: Date) => {\n return date.getTime() >= Date.now();\n };\n\n private readonly __renderStartDate = () => {\n const { data, lang, ns } = this;\n\n return html`\n <div data-testid=\"start-date\">\n ${this.renderTemplateOrSlot('start-date:before')}\n\n <x-group frame>\n <foxy-i18n key=\"start_date\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n <foxy-internal-calendar\n start=${ifDefined(data?.start_date.substr(0, 10))}\n value=${ifDefined(data?.start_date)}\n lang=${lang}\n ?readonly=${!this.__isStartDateEditable}\n ?disabled=${this.disabledSelector.matches('start-date', true)}\n .checkAvailability=${this.__checkStartDateAvailability}\n @change=${(evt: Event) => {\n const target = evt.target as InternalCalendar;\n this.edit({ start_date: target.value });\n }}\n >\n </foxy-internal-calendar>\n </x-group>\n\n ${this.renderTemplateOrSlot('start-date:after')}\n </div>\n `;\n };\n\n private readonly __renderNextTransactionDate = () => {\n const { data, lang, ns } = this;\n const isActive = !!data?.is_active;\n\n return html`\n <div data-testid=\"next-transaction-date\">\n ${this.renderTemplateOrSlot('next-transaction-date:before')}\n\n <x-group frame>\n <foxy-i18n key=\"next_transaction_date\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n <foxy-internal-calendar\n start=${ifDefined(data?.next_transaction_date.substr(0, 10))}\n value=${ifDefined(data?.next_transaction_date)}\n lang=${lang}\n ?readonly=${!isActive || this.readonlySelector.matches('next-transaction-date', true)}\n ?disabled=${!data || this.disabledSelector.matches('next-transaction-date', true)}\n .checkAvailability=${this.__checkNextTransactionDateAvailability}\n @change=${(evt: Event) => {\n const target = evt.target as InternalCalendar;\n this.edit({ next_transaction_date: target.value });\n }}\n >\n </foxy-internal-calendar>\n </x-group>\n\n ${this.renderTemplateOrSlot('next-transaction-date:after')}\n </div>\n `;\n };\n\n private readonly __renderFrequencyAsDropdown = () => {\n const { data } = this;\n const active = !!data?.is_active;\n const items = this.__frequencies.map(v => ({\n label: this.t(v === '.5m' ? 'twice_a_month' : 'frequency', parseFrequency(v)),\n value: v,\n }));\n\n return html`\n <vaadin-combo-box\n item-value-path=\"value\"\n item-label-path=\"label\"\n data-testid=\"frequency\"\n ?disabled=${!data || this.disabledSelector.matches('frequency', true)}\n ?readonly=${data && (!active || this.readonlySelector.matches('frequency', true))}\n class=\"w-full\"\n label=${this.t('frequency_label').toString()}\n value=${ifDefined(this.form.frequency)}\n .items=${items}\n @change=${(evt: Event) => {\n this.edit({ frequency: (evt.target as HTMLInputElement).value });\n }}\n >\n </vaadin-combo-box>\n `;\n };\n\n private readonly __renderFrequencyAsRadioList = () => {\n const { data, lang, ns } = this;\n\n return html`\n <x-group frame>\n <foxy-i18n key=\"frequency_label\" ns=${ns} lang=${lang} slot=\"header\"></foxy-i18n>\n\n <x-choice\n default-custom-value=\"1d\"\n data-testid=\"frequency\"\n type=\"frequency\"\n ns=${ns}\n ?custom=${this.settings === null}\n .items=${this.__frequencies}\n .value=${this.form.frequency ?? null}\n ?disabled=${!data || this.disabledSelector.matches('frequency', true)}\n ?readonly=${data && (!data.is_active || this.readonlySelector.matches('frequency', true))}\n @change=${(evt: Event) => {\n this.edit({ frequency: (evt.target as HTMLInputElement).value });\n }}\n >\n ${this.__frequencies.map(\n frequency => html`\n <foxy-i18n\n options=${JSON.stringify(parseFrequency(frequency))}\n slot=\"${frequency}-label\"\n lang=${lang}\n key=${frequency === '.5m' ? 'twice_a_month' : 'frequency'}\n ns=${ns}\n >\n </foxy-i18n>\n `\n )}\n </x-choice>\n </x-group>\n `;\n };\n\n private readonly __renderFrequency = () => {\n return html`\n <div class=\"sm-col-span-2\">\n ${this.renderTemplateOrSlot('frequency:before')}\n ${this.settings && this.__frequencies.length > 4\n ? this.__renderFrequencyAsDropdown()\n : this.__renderFrequencyAsRadioList()}\n ${this.renderTemplateOrSlot('frequency:after')}\n </div>\n `;\n };\n\n private readonly __renderCustomer = () => {\n const customerHref = this.data?._links['fx:customer'].href;\n const customerPageHref = customerHref ? this.getCustomerPageHref?.(customerHref) : void 0;\n\n return html`\n <div data-testid=\"customer\" class=\"sm-col-span-2\">\n ${this.renderTemplateOrSlot('customer:before')}\n\n <foxy-i18n infer=\"customer\" class=\"block text-s font-medium leading-xs mb-xs\" key=\"label\">\n </foxy-i18n>\n\n <a\n class=${classMap({\n 'block rounded transition-colors': true,\n 'ring-1 ring-contrast-10': !customerPageHref,\n 'cursor-pointer bg-contrast-5 hover-bg-contrast-10': !!customerPageHref,\n 'focus-outline-none focus-ring-2 focus-ring-primary-50': !!customerPageHref,\n })}\n style=\"padding: calc(0.625em + (var(--lumo-border-radius) / 4) - 1px)\"\n href=${ifDefined(customerPageHref)}\n >\n <foxy-customer-card infer=\"customer\" href=${ifDefined(customerHref)}></foxy-customer-card>\n </a>\n\n ${this.renderTemplateOrSlot('customer:after')}\n </div>\n `;\n };\n\n get hiddenSelector(): BooleanSelector {\n return new BooleanSelector(`items:pagination:card:autorenew-icon ${super.hiddenSelector}`);\n }\n\n renderBody(): TemplateResult {\n let transactionsHref: string | undefined;\n\n try {\n const url = new URL(this.data?._links['fx:transactions'].href ?? '');\n url.searchParams.set('order', 'transaction_date desc');\n url.searchParams.set('zoom', 'items');\n transactionsHref = url.toString();\n } catch {\n transactionsHref = undefined;\n }\n\n const currencyDisplay = this.__store?.use_international_currency_symbol ? 'code' : 'symbol';\n const cart = this.__transactionTemplate;\n\n let currencyCode: string | null = null;\n\n if (cart?.currency_code) {\n currencyCode = cart.currency_code;\n } else {\n const allLocaleCodes = this.__localeCodesHelper;\n const localeCode = (this.__templateSet ?? this.__defaultTemplateSet)?.locale_code;\n const localeInfo = localeCode ? allLocaleCodes?.values[localeCode] : void 0;\n\n if (localeInfo) currencyCode = /Currency: ([A-Z]{3})/g.exec(localeInfo)?.[1] ?? null;\n }\n\n return html`\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__transactionTemplateHref)}\n id=${this.__transactionTemplateLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__defaultTemplateSetHref)}\n id=${this.__defaultTemplateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__localeCodesHelperHref)}\n id=${this.__localeCodesHelperLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__templateSetHref)}\n id=${this.__templateSetLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <foxy-nucleon\n class=\"hidden\"\n infer=\"\"\n href=${ifDefined(this.__storeHref)}\n id=${this.__storeLoaderId}\n @update=${() => this.requestUpdate()}\n >\n </foxy-nucleon>\n\n <div class=\"relative grid grid-cols-1 sm-grid-cols-2 gap-l\">\n ${this.hiddenSelector.matches('header', true)\n ? ''\n : this.__renderHeader(currencyCode ?? void 0, currencyDisplay)}\n ${this.hiddenSelector.matches('customer', true) ? '' : this.__renderCustomer()}\n ${this.hiddenSelector.matches('items', true) ? '' : this.__renderItems()}\n ${this.__isFrequencyVisible ? this.__renderFrequency() : ''}\n ${this.__isStartDateVisible ? this.__renderStartDate() : ''}\n ${this.__isNextTransactionDateVisible ? this.__renderNextTransactionDate() : ''}\n\n <foxy-internal-number-control\n suffix=${ifDefined(currencyCode ?? void 0)}\n infer=\"past-due-amount\"\n class=\"sm-col-span-2\"\n min=\"0\"\n >\n </foxy-internal-number-control>\n\n <foxy-internal-async-list-control\n first=${ifDefined(this.data?._links['fx:attributes']?.href)}\n class=\"sm-col-span-2\"\n infer=\"attributes\"\n limit=\"5\"\n form=\"foxy-attribute-form\"\n item=\"foxy-attribute-card\"\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-async-list-control\n first=${ifDefined(transactionsHref)}\n class=\"sm-col-span-2\"\n infer=\"transactions\"\n limit=\"5\"\n item=\"foxy-transaction-card\"\n hide-delete-button\n .getPageHref=${this.getTransactionPageHref}\n >\n </foxy-internal-async-list-control>\n\n <foxy-internal-timestamps-control infer=\"timestamps\" class=\"sm-col-span-2\">\n </foxy-internal-timestamps-control>\n\n ${this.hiddenSelector.matches('end-date', true) ? '' : this.__renderEndDate()}\n </div>\n `;\n }\n\n private get __transactionTemplateHref() {\n type DataWithEmbeds = Resource<Rels.Subscription, { zoom: 'transaction_template' }>;\n type Embed = Resource<Rels.TransactionTemplate>;\n\n const data = this.data as DataWithEmbeds | null;\n const embed = data?._embedded?.['fx:transaction_template'] as Embed | undefined;\n\n return embed ? void 0 : data?._links['fx:transaction_template'].href;\n }\n\n private get __defaultTemplateSetHref() {\n const templateSetUri = this.__transactionTemplate?.template_set_uri;\n\n if (templateSetUri === '') {\n try {\n const url = new URL(this.__store?._links['fx:template_sets'].href ?? '');\n url.searchParams.set('code', 'DEFAULT');\n return url.toString();\n } catch {\n //\n }\n }\n }\n\n private get __localeCodesHelperHref() {\n if (this.__defaultTemplateSetHref || this.__templateSetHref) {\n return this.localeCodes ?? void 0;\n }\n }\n\n private get __templateSetHref() {\n const cart = this.__transactionTemplate;\n if (!cart?.currency_code) return cart?.template_set_uri || void 0;\n }\n\n private get __storeHref() {\n return this.data?._links['fx:store']?.href;\n }\n\n private get __transactionTemplate() {\n type DataWithEmbeds = Resource<Rels.Subscription, { zoom: 'transaction_template' }>;\n type Loader = NucleonElement<Resource<Rels.TransactionTemplate>>;\n type Embed = Resource<Rels.TransactionTemplate>;\n\n const data = this.data as DataWithEmbeds | null;\n const embed = data?._embedded?.['fx:transaction_template'] as Embed | undefined;\n const selector = `#${this.__transactionTemplateLoaderId}`;\n\n return embed ?? this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __defaultTemplateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSets>>;\n const selector = `#${this.__defaultTemplateSetLoaderId}`;\n const loader = this.renderRoot.querySelector<Loader>(selector);\n return loader?.data?._embedded['fx:template_sets'][0] ?? null;\n }\n\n private get __localeCodesHelper() {\n type Loader = NucleonElement<Resource<Rels.LocaleCodes>>;\n const selector = `#${this.__localeCodesHelperLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __templateSet() {\n type Loader = NucleonElement<Resource<Rels.TemplateSet>>;\n const selector = `#${this.__templateSetLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __store() {\n type Loader = NucleonElement<Resource<Rels.Store>>;\n const selector = `#${this.__storeLoaderId}`;\n return this.renderRoot.querySelector<Loader>(selector)?.data ?? null;\n }\n\n private get __isNextTransactionDateVisible() {\n if (this.hiddenSelector.matches('next-transaction-date', true)) return false;\n if (this.data === null) return false;\n if (this.data.end_date && new Date(this.data.end_date).getTime() <= Date.now()) return false;\n if (this.data.is_active === false) return false;\n if (this.settings === null) return true;\n\n const rules = this.settings.subscriptions.allow_next_date_modification;\n return !!getNextTransactionDateConstraints(this.data, rules);\n }\n\n private get __isStartDateVisible() {\n if (this.hiddenSelector.matches('start-date', true)) return false;\n return this.__isNextTransactionDateVisible;\n }\n\n private get __isStartDateEditable() {\n if (this.readonlySelector.matches('start-date', true)) return false;\n if (this.data === null) return false;\n if (this.data.end_date && new Date(this.data.end_date) <= new Date()) return false;\n if (this.data.is_active === false) return false;\n if (this.data.start_date && new Date(this.data.start_date) <= new Date()) return false;\n\n return this.settings === null;\n }\n\n private get __isFrequencyVisible() {\n if (this.hiddenSelector.matches('frequency', true)) return false;\n if (this.data === null) return false;\n if (this.data.end_date && new Date(this.data.end_date).getTime() <= Date.now()) return false;\n if (this.data.is_active === false) return false;\n if (this.settings === null) return true;\n\n const allowedFrequencies = getAllowedFrequencies({\n subscription: this.data,\n settings: this.settings,\n });\n\n return !allowedFrequencies.next().done;\n }\n\n private get __frequencies() {\n if (!this.settings || !this.data) return ['.5m', '1m', '1y'];\n\n const allowedFrequencies = getAllowedFrequencies({\n subscription: this.data,\n settings: this.settings,\n });\n\n return Array.from(allowedFrequencies);\n }\n}\n"]}
@@ -52,40 +52,40 @@ SubscriptionsTable.summaryColumn = {
52
52
  };
53
53
  SubscriptionsTable.statusColumn = {
54
54
  hideBelow: 'sm',
55
- cell: ctx => {
56
- let color;
55
+ cell: ({ ns, lang, data, html }) => {
56
+ let color = 'bg-contrast-5 text-secondary';
57
57
  let date;
58
58
  let key;
59
- if (ctx.data.first_failed_transaction_date) {
60
- date = ctx.data.first_failed_transaction_date;
61
- key = 'subscription_failed';
59
+ if (data.first_failed_transaction_date) {
62
60
  color = 'bg-error-10 text-error';
61
+ date = data.first_failed_transaction_date;
62
+ key = 'subscription_failed';
63
63
  }
64
- else if (ctx.data.end_date) {
65
- date = ctx.data.end_date;
66
- const dateAsObject = new Date(date);
67
- const hasEnded = dateAsObject.getTime() > Date.now();
64
+ else if (data.end_date) {
65
+ date = data.end_date;
66
+ const hasEnded = new Date(data.end_date).getTime() > Date.now();
68
67
  key = hasEnded ? 'subscription_will_be_cancelled' : 'subscription_cancelled';
69
- color = hasEnded ? 'bg-success-10 text-success' : 'bg-contrast-5 text-tertiary';
68
+ }
69
+ else if (!data.is_active) {
70
+ date = '';
71
+ key = 'subscription_inactive';
72
+ }
73
+ else if (new Date(data.start_date) > new Date()) {
74
+ date = data.start_date;
75
+ key = 'subscription_will_be_active';
70
76
  }
71
77
  else {
72
- date = ctx.data.next_transaction_date;
73
- if (ctx.data.is_active) {
74
- key = 'subscription_active';
75
- color = 'bg-success-10 text-success';
76
- }
77
- else {
78
- key = 'subscription_inactive';
79
- color = 'bg-contrast-5 text-tertiary';
80
- }
78
+ color = 'bg-success-10 text-success';
79
+ date = data.next_transaction_date;
80
+ key = 'subscription_active';
81
81
  }
82
- return ctx.html `
82
+ return html `
83
83
  <foxy-i18n
84
84
  data-testclass="i18n statuses"
85
85
  class="px-s py-xs text-m font-medium block whitespace-normal rounded ${color}"
86
- lang=${ctx.lang}
86
+ lang=${lang}
87
87
  key=${key}
88
- ns=${ctx.ns}
88
+ ns=${ns}
89
89
  .options=${{ date }}
90
90
  >
91
91
  </foxy-i18n>