{"version":3,"file":"teamSeatsOptions-CQWRn9lZ.js","sources":["../../../app/javascript/shared/utils/teamSubscriptionTiers.js","../../../app/javascript/shared/utils/calculateTeamInvoiceTotal.js","../../../app/javascript/modules/growthmentor/team/composables/useStripeTeamSubscription.ts","../../../app/javascript/modules/growthmentor/team/composables/useTeamCoupon.ts","../../../app/javascript/shared/data/teamSeatsOptions.ts"],"sourcesContent":["// input: [{id: 1, unitAmount: 1000, upTo: 5 }, {id: 2, unitAmount: 800, upTo: 10}]\n// output: [{id: 1, minSeats: 2, maxSeats: 5, amountInDollars: 10}, {id: 2, minSeats: 6, maxSeats: -1, amountInDollars: 8}]\nconst getPricingTable = (tiers) => {\n return tiers.map((tier, index, tiers) => {\n const isFirst = index === 0\n const isLast = index === tiers.length - 1\n const { id, unitAmount, upTo } = tier\n const amountInDollars = unitAmount\n const lastTier = tiers[index - 1]\n if (isFirst) {\n return {\n id,\n minSeats: 2,\n maxSeats: upTo,\n amountInDollars,\n }\n }\n if (isLast) {\n return {\n id,\n minSeats: lastTier.upTo + 1,\n // -1 means that there is no upper limit\n maxSeats: -1,\n amountInDollars,\n }\n }\n return {\n id,\n minSeats: lastTier.upTo + 1,\n maxSeats: upTo,\n amountInDollars,\n }\n })\n}\n\nexport { getPricingTable }\n","import { getPricingTable } from '@/shared/utils/teamSubscriptionTiers.js'\n\nconst calculateTeamInvoiceTotal = (seats, planTiers) => {\n const pricingTable = getPricingTable(planTiers)\n\n const lastTier = pricingTable[pricingTable.length - 1]\n if (seats >= lastTier.minSeats) return lastTier.amountInDollars * seats\n\n const tier = pricingTable.find(({ minSeats, maxSeats }) => {\n return seats >= minSeats && seats <= maxSeats\n })\n return tier ? tier.amountInDollars * seats : null\n}\n\nexport { calculateTeamInvoiceTotal }\n","import { ref } from 'vue'\nimport axios from 'axios'\nimport { usePage } from '@inertiajs/vue3'\n\ninterface StartSubscriptionParams {\n planId: string\n seats: number\n couponCode: string\n}\n\nexport const useStripeTeamSubscription = () => {\n const page = usePage()\n const errors = ref(null)\n const isLoading = ref(false)\n\n const startSubscription = async ({\n planId,\n seats,\n couponCode,\n }: StartSubscriptionParams) => {\n errors.value = null\n isLoading.value = true\n try {\n const {\n data: { checkout_session_stripe_id },\n } = await axios.post('/stripe/open_team_checkout_session', {\n plan_id: planId,\n seats,\n success_path: '/thank-you-for-subscribing-teams',\n coupon_code: couponCode,\n metadata: {\n action: 'start',\n },\n })\n\n // eslint-disable-next-line no-undef\n const stripe = Stripe(page.props.stripePublicKey)\n stripe.redirectToCheckout({ sessionId: checkout_session_stripe_id })\n } catch ({ message }) {\n errors.value = message\n } finally {\n isLoading.value = false\n }\n }\n\n return {\n startSubscription,\n errors,\n isLoading,\n }\n}\n","import { computed, onBeforeMount, ref } from 'vue'\nimport { usePage } from '@inertiajs/vue3'\n\nexport const useTeamCoupon = () => {\n const page = usePage<{ isCouponValid: boolean; team?: any }>()\n\n const couponCode = ref('')\n const isCouponValid = computed(() => page.props.isCouponValid)\n\n onBeforeMount(() => {\n // Coupon code is valid if loaded from team object (like on billing page)\n if (page.props?.team?.coupon) {\n return (couponCode.value = page.props.team.coupon.code)\n }\n })\n\n return {\n couponCode,\n isCouponValid,\n }\n}\n","export const TEAM_SEATS_OPTIONS = [\n { label: '2 seats', value: 2 },\n { label: '3 seats', value: 3 },\n { label: '4 seats', value: 4 },\n { label: '5 seats', value: 5 },\n { label: '6 seats', value: 6 },\n { label: '7 seats', value: 7 },\n { label: '8 seats', value: 8 },\n { label: '9 seats', value: 9 },\n { label: '10 seats', value: 10 },\n { label: '11 seats', value: 11 },\n { label: '12 seats', value: 12 },\n { label: '13 seats', value: 13 },\n { label: '14 seats', value: 14 },\n { label: '15 seats', value: 15 },\n { label: '16 seats', value: 16 },\n { label: '17 seats', value: 17 },\n { label: '18 seats', value: 18 },\n { label: '19 seats', value: 19 },\n { label: '20 seats', value: 20 },\n]\n\nexport const TEAM_SEATS_OPTIONS_VALUES = TEAM_SEATS_OPTIONS.map(\n (option) => option.value,\n)\n"],"names":["getPricingTable","tiers","tier","index","isFirst","isLast","id","unitAmount","upTo","amountInDollars","lastTier","calculateTeamInvoiceTotal","seats","planTiers","pricingTable","minSeats","maxSeats","useStripeTeamSubscription","page","usePage","errors","ref","isLoading","planId","couponCode","checkout_session_stripe_id","axios","message","useTeamCoupon","isCouponValid","computed","onBeforeMount","_b","_a","TEAM_SEATS_OPTIONS","TEAM_SEATS_OPTIONS_VALUES","option"],"mappings":"2EAEK,MAACA,EAAmBC,GAChBA,EAAM,IAAI,CAACC,EAAMC,EAAOF,IAAU,CACvC,MAAMG,EAAUD,IAAU,EACpBE,EAASF,IAAUF,EAAM,OAAS,EAClC,CAAE,GAAAK,EAAI,WAAAC,EAAY,KAAAC,CAAM,EAAGN,EAC3BO,EAAkBF,EAClBG,EAAWT,EAAME,EAAQ,CAAC,EAChC,OAAIC,EACK,CACL,GAAAE,EACA,SAAU,EACV,SAAUE,EACV,gBAAAC,CACD,EAECJ,EACK,CACL,GAAAC,EACA,SAAUI,EAAS,KAAO,EAE1B,SAAU,GACV,gBAAAD,CACD,EAEI,CACL,GAAAH,EACA,SAAUI,EAAS,KAAO,EAC1B,SAAUF,EACV,gBAAAC,CACD,CACL,CAAG,EC9BGE,EAA4B,CAACC,EAAOC,IAAc,CACtD,MAAMC,EAAed,EAAgBa,CAAS,EAExCH,EAAWI,EAAaA,EAAa,OAAS,CAAC,EACrD,GAAIF,GAASF,EAAS,SAAU,OAAOA,EAAS,gBAAkBE,EAElE,MAAMV,EAAOY,EAAa,KAAK,CAAC,CAAE,SAAAC,EAAU,SAAAC,KACnCJ,GAASG,GAAYH,GAASI,CACtC,EACD,OAAOd,EAAOA,EAAK,gBAAkBU,EAAQ,IAC/C,ECFaK,EAA4B,IAAM,CAC7C,MAAMC,EAAOC,IACPC,EAASC,EAAI,IAAI,EACjBC,EAAYD,EAAI,EAAK,EAgCpB,MAAA,CACL,kBA/BwB,MAAO,CAC/B,OAAAE,EACA,MAAAX,EACA,WAAAY,CAAA,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