@manifoldco/manifold-subscription
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -9,2 +9,3 @@ import { Component, Element, Prop, State, Watch, h } from '@stencil/core'; | ||
import PlanSelector from './components/PlanSelector'; | ||
import { toFeatureMap } from '../../utils/plan'; | ||
export class ManifoldSubscriptionCreate { | ||
@@ -25,16 +26,3 @@ constructor() { | ||
this.data = response.data; | ||
const normalizeValue = (node) => { | ||
if (node.stringValue !== undefined) { | ||
return node.stringValue; | ||
} | ||
if (node.numberValue !== undefined) { | ||
return node.numberValue; | ||
} | ||
if (node.booleanValue !== undefined) { | ||
return node.booleanValue; | ||
} | ||
return undefined; | ||
}; | ||
const featureMap = response.data.subscription.configuredFeatures.edges.reduce((features, { node }) => (Object.assign(Object.assign({}, features), { [node.label]: normalizeValue(node) })), {}); | ||
state.configuredFeatures = featureMap; | ||
state.configuredFeatures = toFeatureMap(response.data.subscription.configuredFeatures); | ||
} | ||
@@ -62,3 +50,3 @@ } | ||
} | ||
const { plan, status } = this.data.subscription; | ||
const { plan, status, configuredFeatures } = this.data.subscription; | ||
return (h("div", { class: "ManifoldSubscriptionCreate__Details" }, | ||
@@ -77,3 +65,3 @@ this.heading && h("h1", { class: "ManifoldSubscription__Heading" }, this.heading), | ||
// TODO format configured feature so it displays as fixed | ||
h(ConfigurableFeature, { setConfiguredFeature: () => null, configurableFeature: configurableFeature })))), | ||
h(ConfigurableFeature, { readOnly: true, setConfiguredFeature: () => null, configurableFeature: configurableFeature, value: toFeatureMap(configuredFeatures)[configurableFeature.node.label] })))), | ||
h("footer", { class: "ManifoldSubscriptionCreate__PlanSelector__Footer" }, | ||
@@ -80,0 +68,0 @@ h("div", null, |
@@ -0,4 +1,15 @@ | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
import { $ } from './currency'; | ||
import { pluralize } from './string'; | ||
import { PlanFeatureType } from '../types/graphql'; | ||
import { PlanFeatureType, } from '../types/graphql'; | ||
// numeric details constants | ||
@@ -94,2 +105,11 @@ export const NUMBER_FEATURE_COIN = 10000000; // Numeric features are a ten-millionth of a cent, because floats stink | ||
} | ||
export const toFeatureMap = (configuredFeatures) => { | ||
const featureMap = configuredFeatures.edges.reduce((result, { node }) => { | ||
// The only field left will be the value field. We don't care what it's called. | ||
const { label } = node, rest = __rest(node, ["label"]); | ||
const value = Object.values(rest)[0]; | ||
return Object.assign(Object.assign({}, result), { [label]: value }); | ||
}, {}); | ||
return featureMap; | ||
}; | ||
/** | ||
@@ -96,0 +116,0 @@ * Get default feature map for configurableFeatures |
@@ -1,1 +0,1 @@ | ||
import{p as i,b as a}from"./p-a98c757b.js";i().then(i=>a([["p-ee3713b4",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],heading:[1],isEditing:[4,"is-editing"],data:[32]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],i)); | ||
import{p as i,b as a}from"./p-a98c757b.js";i().then(i=>a([["p-398b2de2",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],heading:[1],isEditing:[4,"is-editing"],data:[32]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],i)); |
@@ -1,1 +0,1 @@ | ||
System.register(["./p-a956fdd1.system.js"],(function(){"use strict";var e,t;return{setters:[function(i){e=i.p;t=i.b}],execute:function(){e().then((function(e){return t([["p-943b16eb.system",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],heading:[1],isEditing:[4,"is-editing"],data:[32]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],e)}))}}})); | ||
System.register(["./p-a956fdd1.system.js"],(function(){"use strict";var e,t;return{setters:[function(i){e=i.p;t=i.b}],execute:function(){e().then((function(e){return t([["p-60af6a37.system",[[0,"manifold-configured-feature",{label:[1],value:[8]}],[0,"manifold-subscription-create",{loading:[1028],isLoadingPlanSelector:[1028,"is-loading-plan-selector"],errors:[1040],data:[1040],planListData:[1040],setupIntentStatus:[1025,"setup-intent-status"],setupIntentError:[1025,"setup-intent-error"],subscribing:[1028],configuredFeatures:[1040],calculatedCost:[1026,"calculated-cost"],isEditing:[1028,"is-editing"],heading:[1],planId:[1025,"plan-id"],ownerId:[1,"owner-id"],stripePublishableKey:[1,"stripe-publishable-key"],displayName:[1,"display-name"],label:[1],card:[32],cardStatus:[32]},[[0,"manifold-configured-feature-change","updateConfiguredFeature"]]],[0,"manifold-subscription-details",{subscriptionId:[1,"subscription-id"],heading:[1],isEditing:[4,"is-editing"],data:[32]}],[0,"manifold-subscription-list",{connection:[1040],loading:[1028],errors:[1040],data:[1040],subLinkFormat:[1025,"sub-link-format"],heading:[1],owner:[1]}]]]],e)}))}}})); |
@@ -1325,2 +1325,6 @@ export declare type Maybe<T> = T; | ||
node: ({ | ||
__typename?: 'StringConfiguredFeature'; | ||
} & Pick<StringConfiguredFeature, 'label'> & { | ||
stringValue: StringConfiguredFeature['value']; | ||
}) | ({ | ||
__typename?: 'NumberConfiguredFeature'; | ||
@@ -1330,6 +1334,2 @@ } & Pick<NumberConfiguredFeature, 'label'> & { | ||
}) | ({ | ||
__typename?: 'StringConfiguredFeature'; | ||
} & Pick<StringConfiguredFeature, 'label'> & { | ||
stringValue: StringConfiguredFeature['value']; | ||
}) | ({ | ||
__typename?: 'BooleanConfiguredFeature'; | ||
@@ -1336,0 +1336,0 @@ } & Pick<BooleanConfiguredFeature, 'label'> & { |
@@ -1,2 +0,2 @@ | ||
import { PlanMeteredFeatureNumericDetails, PlanEdge } from '../types/graphql'; | ||
import { PlanMeteredFeatureNumericDetails, PlanEdge, BooleanConfiguredFeature, NumberConfiguredFeature, StringConfiguredFeature } from '../types/graphql'; | ||
export interface PricingTier { | ||
@@ -34,2 +34,14 @@ cost: number; | ||
} | ||
declare type ToFeatureMapConfiguredFeatures = { | ||
edges: Array<{ | ||
node: (Pick<BooleanConfiguredFeature, 'label'> & { | ||
booleanValue: BooleanConfiguredFeature['value']; | ||
}) | (Pick<NumberConfiguredFeature, 'label'> & { | ||
numberValue: NumberConfiguredFeature['value']; | ||
}) | (Pick<StringConfiguredFeature, 'label'> & { | ||
stringValue: StringConfiguredFeature['value']; | ||
}); | ||
}>; | ||
}; | ||
export declare const toFeatureMap: (configuredFeatures: ToFeatureMapConfiguredFeatures) => FeatureMap; | ||
/** | ||
@@ -36,0 +48,0 @@ * Get default feature map for configurableFeatures |
{ | ||
"name": "@manifoldco/manifold-subscription", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Manifold Subscription Web Components", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1176648
16635