@bunnyapp/components 1.0.14 → 1.0.16

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 (46) hide show
  1. package/dist/cjs/index.js +649 -814
  2. package/dist/cjs/src/components/BillingDetails/BillingDetails.d.ts +7 -2
  3. package/dist/cjs/src/components/PaymentForm/CheckoutFooter.d.ts +3 -4
  4. package/dist/cjs/src/components/PaymentForm/DemoPay/hooks/usePay.d.ts +5 -6
  5. package/dist/cjs/src/components/PaymentForm/PaymentForm.d.ts +4 -4
  6. package/dist/cjs/src/components/PaymentForm/PaymentFormTypes.d.ts +3 -28
  7. package/dist/cjs/src/components/PaymentForm/PaymentMethodDetails.d.ts +1 -2
  8. package/dist/cjs/src/components/PaymentForm/PaymentMethodSelector.d.ts +3 -3
  9. package/dist/cjs/src/components/PaymentForm/Stripe/StripeForm.d.ts +1 -1
  10. package/dist/cjs/src/components/PaymentForm/Stripe/hooks/usePay.d.ts +5 -5
  11. package/dist/cjs/src/components/Signup/PaymentForms.d.ts +4 -4
  12. package/dist/cjs/src/components/Signup/Signup.d.ts +1 -3
  13. package/dist/cjs/src/contexts/PaymentContext.d.ts +3 -0
  14. package/dist/cjs/src/hooks/usePaymentMethod.d.ts +1 -1
  15. package/dist/cjs/src/hooks/useToken.d.ts +2 -0
  16. package/dist/esm/index.js +652 -817
  17. package/dist/esm/src/components/BillingDetails/BillingDetails.d.ts +7 -2
  18. package/dist/esm/src/components/PaymentForm/CheckoutFooter.d.ts +3 -4
  19. package/dist/esm/src/components/PaymentForm/DemoPay/hooks/usePay.d.ts +5 -6
  20. package/dist/esm/src/components/PaymentForm/PaymentForm.d.ts +4 -4
  21. package/dist/esm/src/components/PaymentForm/PaymentFormTypes.d.ts +3 -28
  22. package/dist/esm/src/components/PaymentForm/PaymentMethodDetails.d.ts +1 -2
  23. package/dist/esm/src/components/PaymentForm/PaymentMethodSelector.d.ts +3 -3
  24. package/dist/esm/src/components/PaymentForm/Stripe/StripeForm.d.ts +1 -1
  25. package/dist/esm/src/components/PaymentForm/Stripe/hooks/usePay.d.ts +5 -5
  26. package/dist/esm/src/components/Signup/PaymentForms.d.ts +4 -4
  27. package/dist/esm/src/components/Signup/Signup.d.ts +1 -3
  28. package/dist/esm/src/contexts/PaymentContext.d.ts +3 -0
  29. package/dist/esm/src/hooks/usePaymentMethod.d.ts +1 -1
  30. package/dist/esm/src/hooks/useToken.d.ts +2 -0
  31. package/dist/index.d.ts +10 -9
  32. package/package.json +4 -3
  33. package/dist/cjs/src/components/Checkout/InvoiceCheckout.d.ts +0 -8
  34. package/dist/cjs/src/components/Transactions/DocumentNameEnum.d.ts +0 -4
  35. package/dist/cjs/src/components/icons/BunnyFooterIcon.d.ts +0 -4
  36. package/dist/cjs/src/consts/paymentConsts.d.ts +0 -16
  37. package/dist/cjs/src/graphql/mutations/quoteCreate.d.ts +0 -9
  38. package/dist/cjs/src/graphql/queries/getInvoice.d.ts +0 -7
  39. package/dist/cjs/src/graphql/queries/getSubscription.d.ts +0 -12
  40. package/dist/esm/src/components/Checkout/InvoiceCheckout.d.ts +0 -8
  41. package/dist/esm/src/components/Transactions/DocumentNameEnum.d.ts +0 -4
  42. package/dist/esm/src/components/icons/BunnyFooterIcon.d.ts +0 -4
  43. package/dist/esm/src/consts/paymentConsts.d.ts +0 -16
  44. package/dist/esm/src/graphql/mutations/quoteCreate.d.ts +0 -9
  45. package/dist/esm/src/graphql/queries/getInvoice.d.ts +0 -7
  46. package/dist/esm/src/graphql/queries/getSubscription.d.ts +0 -12
package/dist/esm/index.js CHANGED
@@ -4,13 +4,13 @@ import React__default, { createContext as createContext$1, useContext as useCont
4
4
  import { Markup } from 'interweave';
5
5
  import { ConfigProvider, Button as Button$1, Typography, Tag, Divider, Popconfirm, Input, Checkbox, Collapse, Modal, Form, Drawer, Card as Card$1, Select, Image, Dropdown, Skeleton } from 'antd';
6
6
  import styled from 'styled-components';
7
- import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, invokePlugin, useErrorNotification, formatCurrency, GRAY_500, GRAY_200, useSuccessNotification, useAllErrorFormats, getFormattedInvoice, PAYABLE_INVOICE_STATES, DOCUMENT_NAME as DOCUMENT_NAME$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getAccount as getAccount$1, DEFAULT_CONFIG, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, SLATE_500, StringUtils, DataInterval, TAG_COLORS, ChargeType } from '@bunnyapp/common';
8
- import { QueryClient, QueryClientProvider, useQuery, useQueryClient, useMutation, keepPreviousData, onlineManager } from '@tanstack/react-query';
7
+ import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, QueryKeyFactory, useIsMobile, isColorTooDark, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, getPlugins, DEFAULT_CONFIG, useErrorNotification, formatCurrency, invokePlugin, GRAY_500, GRAY_200, useSuccessNotification, BreakpointNumbers, useAllErrorFormats, getFormattedInvoice, PAYABLE_INVOICE_STATES, DOCUMENT_NAME as DOCUMENT_NAME$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getAccount as getAccount$1, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, SLATE_500, StringUtils, DataInterval, TAG_COLORS, ChargeType } from '@bunnyapp/common';
8
+ import { QueryClient, QueryClientProvider, useQuery, useQueryClient, keepPreviousData, useMutation, onlineManager } from '@tanstack/react-query';
9
9
  import theme from 'antd/lib/theme';
10
10
  import { RecoilRoot } from 'recoil';
11
11
  import request, { GraphQLClient } from 'graphql-request';
12
12
  import { HelmetProvider, Helmet } from 'react-helmet-async';
13
- import { useElements, useStripe, Elements, PaymentElement } from '@stripe/react-stripe-js';
13
+ import { useElements, useStripe, PaymentElement, Elements } from '@stripe/react-stripe-js';
14
14
  import { loadStripe } from '@stripe/stripe-js/pure';
15
15
  import { capitalize, startCase, cloneDeep, omit } from 'lodash';
16
16
  import { BarChart, ResponsiveContainer, XAxis, Tooltip, Bar, Rectangle } from 'recharts';
@@ -42,7 +42,7 @@ function styleInject(css, ref) {
42
42
  }
43
43
  }
44
44
 
45
- var css_248z = ".ant-collapse-header {\n cursor: default !important;\n padding: 0 !important;\n}\n.ant-tag {\n border: none;\n border-radius: 14px;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n font-weight: 500;\n white-space: nowrap;\n margin: 0;\n}\n.ant-tag-blue {\n color: #3b82f6 !important;\n background: #bfdbfe !important;\n}\n.ant-tag-green {\n color: #059669 !important;\n background: #a7f3d0 !important;\n}\n.ant-tag-red {\n color: #ef4444 !important;\n background: #fecaca !important;\n}\n.ant-tag-orange {\n color: #f97316 !important;\n background: #fed7aa !important;\n}\n.ant-tag-yellow {\n color: #f59e0b !important;\n background: #fde68a !important;\n}\n.ant-tag-purple {\n color: #8b5cf6 !important;\n background: #ddd6fe !important;\n}\n.ant-tag-black {\n color: white !important;\n background: black !important;\n}\n.ant-popover {\n z-index: 1050;\n}\n.ant-popover-inner-content {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n max-width: 300px;\n}\n.ant-popover-message-title {\n padding: 0;\n text-align: center;\n font-size: 1rem;\n}\n.ant-popover-buttons {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.ant-btn-link:disabled {\n color: #717d94 !important;\n}\n.ant-btn-link:disabled:hover {\n background-color: transparent !important;\n}\n.ant-input-affix-wrapper .ant-input-prefix {\n transition: color 0.3s;\n}\n.ant-form-item-label {\n text-transform: none !important;\n font-size: 0.75rem;\n padding-bottom: 2px !important;\n}\n.ant-form-item-label > label {\n width: 100%;\n color: #4b5563 !important;\n}\n.ant-form-item-explain-error {\n font-size: 11px;\n min-height: 11px;\n line-height: 11px;\n padding-top: 2px;\n}\n.ant-form-item {\n margin-bottom: 0;\n}\n.ant-notification {\n width: min-content;\n}\n.ant-notification-topRight {\n right: 0 !important;\n left: 0 !important;\n margin-left: auto !important;\n margin-right: auto !important;\n}\n.ant-notification-notice-wrapper {\n width: 350px !important;\n overflow: hidden !important;\n}\n.ant-notification-notice {\n padding: 16px !important;\n width: 350px !important;\n display: flex !important;\n box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.08), 0px 1px 18px rgba(0, 0, 0, 0.08), 0px 3px 5px rgba(0, 0, 0, 0.16) !important;\n}\n.ant-notification-notice-description {\n padding: 0 14px 0 0 !important;\n color: #232323 !important;\n font-size: 14px !important;\n word-break: break-all !important;\n overflow-wrap: break-word !important;\n}\n.ant-notification-notice-success {\n background-color: #edfffa !important;\n}\n.ant-notification-notice-error {\n background-color: #fff8f4 !important;\n}\n.ant-notification-notice-error .ant-notification-notice-message {\n color: #ff6e1c !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-error .ant-notification-notice-icon {\n color: #ff6e1c;\n}\n.ant-notification-notice-success .ant-notification-notice-message {\n color: #00b76a !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-success .ant-notification-notice-icon {\n color: #00b76a !important;\n}\n.ant-notification-notice-message {\n margin-bottom: 0 !important;\n}\n.ant-notification-notice-close {\n top: 16px !important;\n right: 16px !important;\n}\n.ant-menu-submenu-popup > .ant-menu .ant-menu-item {\n display: flex !important;\n align-items: center !important;\n}\n.ant-menu-submenu::after {\n display: none !important;\n}\n.ant-drawer-title {\n font-weight: 400 !important;\n}\n.ant-drawer-header-title {\n flex-direction: row-reverse !important;\n align-items: start !important ;\n}\n.ant-drawer-close {\n margin-inline-end: 0 !important;\n}\n@media (min-width: 768px) {\n .ant-input,\n .ant-picker,\n .ant-select,\n .ant-input-affix-wrapper {\n font-size: 1rem !important;\n }\n .ant-drawer-header {\n padding-right: 1.5rem !important;\n padding-left: 1.5rem !important;\n }\n}\n:root {\n --row-background: #ffffff;\n --row-background-alternate: rgba(100, 116, 139, 0.04);\n --row-background-dark: #121212;\n --row-background-alternate-dark: #1e1e1e;\n}\n.plan-step-line {\n height: 1px;\n min-width: 128px;\n background: #717d94;\n}\n.plan-step-number {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n border: 1px solid #717d94;\n background: white;\n width: 24px;\n height: 24px;\n color: #717d94;\n}\n.plan-step-number.active {\n border: none;\n color: white;\n background: #ff6e1c;\n}\n.hidden {\n display: none;\n}\n.cardElement {\n padding: 8px 11px;\n border: 1px solid #e5e7eb;\n background-color: white;\n font-family: Inter !important;\n}\n.tooltip {\n visibility: hidden;\n position: absolute !important;\n}\n.has-tooltip:hover .tooltip {\n visibility: visible;\n z-index: 100;\n}\n.show-on-hover {\n opacity: 0;\n}\n.show-on-hover-container:hover .show-on-hover {\n opacity: 1;\n}\n.pdf-only {\n display: none !important;\n}\n.notes p {\n margin: 0;\n padding: 0;\n padding-bottom: 0.25rem;\n}\n#form-element #finix-form-container .field-holder label {\n color: #717d94 !important;\n font-size: 12px !important;\n}\n#form-element #finix-form-container > *:first-child,\n#form-element #finix-form-container > *:last-child {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container > *:not(:first-child):not(:last-child) {\n margin-top: 12px !important;\n}\n#form-element #finix-form-container .field-array > * {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container .field-holder .field,\n#form-element #finix-form-container iframe {\n height: 34px !important;\n}\n#form-element #finix-form-container .field {\n margin-top: 0 !important;\n padding-top: 2px !important;\n}\n#form-element #finix-form-container .field-holder .validation {\n font-size: 11px !important;\n color: #ff4d4f !important;\n}\n.icon-path {\n transition: fill 0.3s;\n}\n.shadow-padding-x {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.shadow-padding-xb {\n padding-right: 1rem;\n padding-left: 1rem;\n padding-bottom: 0.5rem;\n}\n.content-container {\n width: 100%;\n margin: 0 auto;\n}\n@media (min-width: 1220px) {\n .content-container {\n width: 1220px !important;\n margin: 0 auto;\n }\n}\n@media (min-width: 768px) {\n .shadow-padding-x {\n padding-right: 2rem;\n padding-left: 2rem;\n }\n .shadow-padding-xb {\n padding-right: 2rem;\n padding-left: 2rem;\n padding-bottom: 0.5rem;\n }\n .sm\\:flex {\n display: flex !important;\n }\n .sm\\:hidden {\n display: none !important;\n }\n}\n.rotate-45,\n.transform {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n}\n.shadow,\n.shadow-lg,\n.shadow-md,\n.shadow-none,\n.shadow-sm,\n.shadow-xl {\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 768px) {\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n .container {\n max-width: 1536px;\n }\n}\n.visible {\n visibility: visible;\n}\n.fixed {\n position: fixed;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.left-0 {\n left: 0px;\n}\n.right-0 {\n right: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-50 {\n z-index: 50;\n}\n.col-span-2 {\n grid-column: span 2 / span 2;\n}\n.col-span-3 {\n grid-column: span 3 / span 3;\n}\n.m-0 {\n margin: 0px;\n}\n.mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.my-12 {\n margin-top: 3rem;\n margin-bottom: 3rem;\n}\n.my-2 {\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n}\n.my-4 {\n margin-top: 1rem;\n margin-bottom: 1rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.ml-2 {\n margin-left: 0.5rem;\n}\n.mr-8 {\n margin-right: 2rem;\n}\n.mt-1 {\n margin-top: 0.25rem;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.mt-4 {\n margin-top: 1rem;\n}\n.mt-6 {\n margin-top: 1.5rem;\n}\n.mt-8 {\n margin-top: 2rem;\n}\n.block {\n display: block;\n}\n.flex {\n display: flex;\n}\n.table {\n display: table;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.hidden {\n display: none;\n}\n.h-4 {\n height: 1rem;\n}\n.h-5 {\n height: 1.25rem;\n}\n.h-8 {\n height: 2rem;\n}\n.h-full {\n height: 100%;\n}\n.w-1\\/2 {\n width: 50%;\n}\n.w-1\\/3 {\n width: 33.333333%;\n}\n.w-2\\/3 {\n width: 66.666667%;\n}\n.w-4 {\n width: 1rem;\n}\n.w-full {\n width: 100%;\n}\n.max-w-32 {\n max-width: 8rem;\n}\n.flex-1 {\n flex: 1 1 0%;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.grow {\n flex-grow: 1;\n}\n.border-collapse {\n border-collapse: collapse;\n}\n.rotate-45 {\n --tw-rotate: 45deg;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.grid-cols-3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n}\n.flex-row {\n flex-direction: row;\n}\n.flex-col {\n flex-direction: column;\n}\n.items-end {\n align-items: flex-end;\n}\n.items-center {\n align-items: center;\n}\n.justify-start {\n justify-content: flex-start;\n}\n.justify-end {\n justify-content: flex-end;\n}\n.justify-center {\n justify-content: center;\n}\n.justify-between {\n justify-content: space-between;\n}\n.gap-0 {\n gap: 0px;\n}\n.gap-1 {\n gap: 0.25rem;\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-4 {\n gap: 1rem;\n}\n.gap-6 {\n gap: 1.5rem;\n}\n.space-y-2 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));\n}\n.space-y-4 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(1rem * var(--tw-space-y-reverse));\n}\n.space-y-8 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(2rem * var(--tw-space-y-reverse));\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.overflow-visible {\n overflow: visible;\n}\n.whitespace-nowrap {\n white-space: nowrap;\n}\n.text-nowrap {\n text-wrap: nowrap;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.rounded-full {\n border-radius: 9999px;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.border {\n border-width: 1px;\n}\n.border-solid {\n border-style: solid;\n}\n.border-gray-400 {\n --tw-border-opacity: 1;\n border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));\n}\n.border-gray-500 {\n --tw-border-opacity: 1;\n border-color: rgb(107 114 128 / var(--tw-border-opacity, 1));\n}\n.border-slate-200 {\n --tw-border-opacity: 1;\n border-color: rgb(226 232 240 / var(--tw-border-opacity, 1));\n}\n.border-slate-300 {\n --tw-border-opacity: 1;\n border-color: rgb(203 213 225 / var(--tw-border-opacity, 1));\n}\n.border-slate-700 {\n --tw-border-opacity: 1;\n border-color: rgb(51 65 85 / var(--tw-border-opacity, 1));\n}\n.bg-black {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));\n}\n.bg-emerald-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(167 243 208 / var(--tw-bg-opacity, 1));\n}\n.bg-green-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(187 247 208 / var(--tw-bg-opacity, 1));\n}\n.bg-orange-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 215 170 / var(--tw-bg-opacity, 1));\n}\n.bg-red-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 202 202 / var(--tw-bg-opacity, 1));\n}\n.bg-red-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));\n}\n.bg-slate-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(248 250 252 / var(--tw-bg-opacity, 1));\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));\n}\n.bg-yellow-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 240 138 / var(--tw-bg-opacity, 1));\n}\n.p-0 {\n padding: 0px;\n}\n.p-1 {\n padding: 0.25rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-8 {\n padding: 2rem;\n}\n.px-0 {\n padding-left: 0px;\n padding-right: 0px;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-4 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n.px-6 {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n}\n.py-1 {\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n}\n.py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n.py-4 {\n padding-top: 1rem;\n padding-bottom: 1rem;\n}\n.py-6 {\n padding-top: 1.5rem;\n padding-bottom: 1.5rem;\n}\n.px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pb-6 {\n padding-bottom: 1.5rem;\n}\n.pb-8 {\n padding-bottom: 2rem;\n}\n.pl-0 {\n padding-left: 0px;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pl-4 {\n padding-left: 1rem;\n}\n.pt-1 {\n padding-top: 0.25rem;\n}\n.pt-12 {\n padding-top: 3rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pt-4 {\n padding-top: 1rem;\n}\n.pt-5 {\n padding-top: 1.25rem;\n}\n.pt-6 {\n padding-top: 1.5rem;\n}\n.pt-8 {\n padding-top: 2rem;\n}\n.text-left {\n text-align: left;\n}\n.text-center {\n text-align: center;\n}\n.text-right {\n text-align: right;\n}\n.align-middle {\n vertical-align: middle;\n}\n.text-2xl {\n font-size: 1.5rem;\n line-height: 2rem;\n}\n.text-base {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n.text-lg {\n font-size: 1.125rem;\n line-height: 1.75rem;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xl {\n font-size: 1.25rem;\n line-height: 1.75rem;\n}\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.font-bold {\n font-weight: 700;\n}\n.font-medium {\n font-weight: 500;\n}\n.font-normal {\n font-weight: 400;\n}\n.capitalize {\n text-transform: capitalize;\n}\n.text-emerald-600 {\n --tw-text-opacity: 1;\n color: rgb(5 150 105 / var(--tw-text-opacity, 1));\n}\n.text-emerald-700 {\n --tw-text-opacity: 1;\n color: rgb(4 120 87 / var(--tw-text-opacity, 1));\n}\n.text-gray-600 {\n --tw-text-opacity: 1;\n color: rgb(75 85 99 / var(--tw-text-opacity, 1));\n}\n.text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(17 24 39 / var(--tw-text-opacity, 1));\n}\n.text-green-600 {\n --tw-text-opacity: 1;\n color: rgb(22 163 74 / var(--tw-text-opacity, 1));\n}\n.text-orange-500 {\n --tw-text-opacity: 1;\n color: rgb(249 115 22 / var(--tw-text-opacity, 1));\n}\n.text-red-500 {\n --tw-text-opacity: 1;\n color: rgb(239 68 68 / var(--tw-text-opacity, 1));\n}\n.text-slate-400 {\n --tw-text-opacity: 1;\n color: rgb(148 163 184 / var(--tw-text-opacity, 1));\n}\n.text-slate-500 {\n --tw-text-opacity: 1;\n color: rgb(100 116 139 / var(--tw-text-opacity, 1));\n}\n.text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\n}\n.text-yellow-500 {\n --tw-text-opacity: 1;\n color: rgb(234 179 8 / var(--tw-text-opacity, 1));\n}\n.underline {\n text-decoration-line: underline;\n}\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-md {\n --tw-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-none {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-sm {\n --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-xl {\n --tw-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.font-light {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-medium {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-bold {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex;\n }\n .sm\\:hidden {\n display: none;\n }\n}\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n line-height: 1.15;\n}\nbody {\n color: #232323;\n background-color: #f8fafc;\n}\nth {\n font-weight: normal;\n}\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\", monospace;\n}\n@media only screen and (max-width: 768px) {\n select,\n textarea,\n input[type=\"text\"],\n input[type=\"password\"],\n input[type=\"datetime\"],\n input[type=\"datetime-local\"],\n input[type=\"date\"],\n input[type=\"month\"],\n input[type=\"time\"],\n input[type=\"week\"],\n input[type=\"number\"],\n input[type=\"email\"],\n input[type=\"url\"],\n input[type=\"search\"],\n input[type=\"tel\"],\n input[type=\"color\"] {\n font-size: 16px !important;\n }\n}\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n";
45
+ var css_248z = ".ant-divider-horizontal {\n margin: 0;\n}\n.ant-tag {\n border: none;\n border-radius: 14px;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n font-weight: 500;\n white-space: nowrap;\n margin: 0;\n}\n.ant-tag-blue {\n color: #3b82f6 !important;\n background: #bfdbfe !important;\n}\n.ant-tag-green {\n color: #059669 !important;\n background: #a7f3d0 !important;\n}\n.ant-tag-red {\n color: #ef4444 !important;\n background: #fecaca !important;\n}\n.ant-tag-orange {\n color: #f97316 !important;\n background: #fed7aa !important;\n}\n.ant-tag-yellow {\n color: #f59e0b !important;\n background: #fde68a !important;\n}\n.ant-tag-purple {\n color: #8b5cf6 !important;\n background: #ddd6fe !important;\n}\n.ant-tag-black {\n color: white !important;\n background: black !important;\n}\n.ant-popover {\n z-index: 1050;\n}\n.ant-popover-inner-content {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n max-width: 300px;\n}\n.ant-popover-message-title {\n padding: 0;\n text-align: center;\n font-size: 1rem;\n}\n.ant-popover-buttons {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.ant-btn-link:disabled {\n color: #717d94 !important;\n}\n.ant-btn-link:disabled:hover {\n background-color: transparent !important;\n}\n.ant-notification {\n width: min-content;\n}\n.ant-notification-topRight {\n right: 0 !important;\n left: 0 !important;\n margin-left: auto !important;\n margin-right: auto !important;\n}\n.ant-notification-notice-wrapper {\n width: 350px !important;\n overflow: hidden !important;\n}\n.ant-notification-notice {\n padding: 16px !important;\n width: 350px !important;\n display: flex !important;\n box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.08), 0px 1px 18px rgba(0, 0, 0, 0.08), 0px 3px 5px rgba(0, 0, 0, 0.16) !important;\n}\n.ant-notification-notice-description {\n padding: 0 14px 0 0 !important;\n color: #232323 !important;\n font-size: 14px !important;\n word-break: break-all !important;\n overflow-wrap: break-word !important;\n}\n.ant-notification-notice-success {\n background-color: #edfffa !important;\n}\n.ant-notification-notice-error {\n background-color: #fff8f4 !important;\n}\n.ant-notification-notice-error .ant-notification-notice-message {\n color: #ff6e1c !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-error .ant-notification-notice-icon {\n color: #ff6e1c;\n}\n.ant-notification-notice-success .ant-notification-notice-message {\n color: #00b76a !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji !important;\n font-weight: 500;\n}\n.ant-notification-notice-success .ant-notification-notice-icon {\n color: #00b76a !important;\n}\n.ant-notification-notice-message {\n margin-bottom: 0 !important;\n}\n.ant-notification-notice-close {\n top: 16px !important;\n right: 16px !important;\n}\n.ant-menu-submenu-popup > .ant-menu .ant-menu-item {\n display: flex !important;\n align-items: center !important;\n}\n.ant-menu-submenu::after {\n display: none !important;\n}\n:root {\n --row-background: #ffffff;\n --row-background-alternate: rgba(100, 116, 139, 0.04);\n --row-background-dark: #121212;\n --row-background-alternate-dark: #1e1e1e;\n}\n.plan-step-line {\n height: 1px;\n min-width: 128px;\n background: #717d94;\n}\n.plan-step-number {\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 9999px;\n border: 1px solid #717d94;\n background: white;\n width: 24px;\n height: 24px;\n color: #717d94;\n}\n.plan-step-number.active {\n border: none;\n color: white;\n background: #ff6e1c;\n}\n.hidden {\n display: none;\n}\n.cardElement {\n padding: 8px 11px;\n border: 1px solid #e5e7eb;\n background-color: white;\n font-family: Inter !important;\n}\n.tooltip {\n visibility: hidden;\n position: absolute !important;\n}\n.has-tooltip:hover .tooltip {\n visibility: visible;\n z-index: 100;\n}\n.show-on-hover {\n opacity: 0;\n}\n.show-on-hover-container:hover .show-on-hover {\n opacity: 1;\n}\n.pdf-only {\n display: none !important;\n}\n.notes p {\n margin: 0;\n padding: 0;\n padding-bottom: 0.25rem;\n}\n#form-element #finix-form-container .field-holder label {\n color: #717d94 !important;\n font-size: 12px !important;\n}\n#form-element #finix-form-container > *:first-child,\n#form-element #finix-form-container > *:last-child {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container > *:not(:first-child):not(:last-child) {\n margin-top: 12px !important;\n}\n#form-element #finix-form-container .field-array > * {\n margin-top: 0 !important;\n}\n#form-element #finix-form-container .field-holder .field,\n#form-element #finix-form-container iframe {\n height: 34px !important;\n}\n#form-element #finix-form-container .field {\n margin-top: 0 !important;\n padding-top: 2px !important;\n}\n#form-element #finix-form-container .field-holder .validation {\n font-size: 11px !important;\n color: #ff4d4f !important;\n}\n.icon-path {\n transition: fill 0.3s;\n}\n.shadow-padding-x {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.shadow-padding-xb {\n padding-right: 1rem;\n padding-left: 1rem;\n padding-bottom: 0.5rem;\n}\n.content-container {\n width: 100%;\n margin: 0 auto;\n}\n@media (min-width: 1220px) {\n .content-container {\n width: 1220px !important;\n margin: 0 auto;\n }\n}\n@media (min-width: 768px) {\n .shadow-padding-x {\n padding-right: 2rem;\n padding-left: 2rem;\n }\n .shadow-padding-xb {\n padding-right: 2rem;\n padding-left: 2rem;\n padding-bottom: 0.5rem;\n }\n .sm\\:flex {\n display: flex !important;\n }\n .sm\\:hidden {\n display: none !important;\n }\n}\n.rotate-45,\n.transform {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n}\n.shadow,\n.shadow-lg,\n.shadow-md,\n.shadow-none,\n.shadow-sm,\n.shadow-xl {\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 768px) {\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n .container {\n max-width: 1536px;\n }\n}\n.visible {\n visibility: visible;\n}\n.fixed {\n position: fixed;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.bottom-0 {\n bottom: 0px;\n}\n.left-0 {\n left: 0px;\n}\n.right-0 {\n right: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-50 {\n z-index: 50;\n}\n.col-span-2 {\n grid-column: span 2 / span 2;\n}\n.col-span-3 {\n grid-column: span 3 / span 3;\n}\n.m-0 {\n margin: 0px;\n}\n.mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.my-12 {\n margin-top: 3rem;\n margin-bottom: 3rem;\n}\n.my-2 {\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n}\n.my-4 {\n margin-top: 1rem;\n margin-bottom: 1rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.ml-2 {\n margin-left: 0.5rem;\n}\n.mr-8 {\n margin-right: 2rem;\n}\n.mt-1 {\n margin-top: 0.25rem;\n}\n.mt-2 {\n margin-top: 0.5rem;\n}\n.mt-4 {\n margin-top: 1rem;\n}\n.mt-6 {\n margin-top: 1.5rem;\n}\n.mt-8 {\n margin-top: 2rem;\n}\n.block {\n display: block;\n}\n.flex {\n display: flex;\n}\n.table {\n display: table;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.hidden {\n display: none;\n}\n.h-4 {\n height: 1rem;\n}\n.h-5 {\n height: 1.25rem;\n}\n.h-8 {\n height: 2rem;\n}\n.h-full {\n height: 100%;\n}\n.w-1\\/2 {\n width: 50%;\n}\n.w-1\\/3 {\n width: 33.333333%;\n}\n.w-2\\/3 {\n width: 66.666667%;\n}\n.w-4 {\n width: 1rem;\n}\n.w-full {\n width: 100%;\n}\n.max-w-32 {\n max-width: 8rem;\n}\n.flex-1 {\n flex: 1 1 0%;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.grow {\n flex-grow: 1;\n}\n.border-collapse {\n border-collapse: collapse;\n}\n.rotate-45 {\n --tw-rotate: 45deg;\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n}\n.grid-cols-3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n}\n.flex-row {\n flex-direction: row;\n}\n.flex-col {\n flex-direction: column;\n}\n.items-end {\n align-items: flex-end;\n}\n.items-center {\n align-items: center;\n}\n.justify-start {\n justify-content: flex-start;\n}\n.justify-end {\n justify-content: flex-end;\n}\n.justify-center {\n justify-content: center;\n}\n.justify-between {\n justify-content: space-between;\n}\n.gap-0 {\n gap: 0px;\n}\n.gap-1 {\n gap: 0.25rem;\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-4 {\n gap: 1rem;\n}\n.gap-6 {\n gap: 1.5rem;\n}\n.space-y-2 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.5rem * var(--tw-space-y-reverse));\n}\n.space-y-4 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(1rem * var(--tw-space-y-reverse));\n}\n.space-y-8 > :not([hidden]) ~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(2rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(2rem * var(--tw-space-y-reverse));\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.overflow-visible {\n overflow: visible;\n}\n.whitespace-nowrap {\n white-space: nowrap;\n}\n.text-nowrap {\n text-wrap: nowrap;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.rounded-full {\n border-radius: 9999px;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.border {\n border-width: 1px;\n}\n.border-solid {\n border-style: solid;\n}\n.border-gray-400 {\n --tw-border-opacity: 1;\n border-color: rgb(156 163 175 / var(--tw-border-opacity, 1));\n}\n.border-gray-500 {\n --tw-border-opacity: 1;\n border-color: rgb(107 114 128 / var(--tw-border-opacity, 1));\n}\n.border-slate-200 {\n --tw-border-opacity: 1;\n border-color: rgb(226 232 240 / var(--tw-border-opacity, 1));\n}\n.border-slate-300 {\n --tw-border-opacity: 1;\n border-color: rgb(203 213 225 / var(--tw-border-opacity, 1));\n}\n.border-slate-700 {\n --tw-border-opacity: 1;\n border-color: rgb(51 65 85 / var(--tw-border-opacity, 1));\n}\n.bg-black {\n --tw-bg-opacity: 1;\n background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));\n}\n.bg-emerald-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(167 243 208 / var(--tw-bg-opacity, 1));\n}\n.bg-green-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(187 247 208 / var(--tw-bg-opacity, 1));\n}\n.bg-orange-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 215 170 / var(--tw-bg-opacity, 1));\n}\n.bg-red-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 202 202 / var(--tw-bg-opacity, 1));\n}\n.bg-red-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));\n}\n.bg-slate-50 {\n --tw-bg-opacity: 1;\n background-color: rgb(248 250 252 / var(--tw-bg-opacity, 1));\n}\n.bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));\n}\n.bg-yellow-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(254 240 138 / var(--tw-bg-opacity, 1));\n}\n.p-0 {\n padding: 0px;\n}\n.p-1 {\n padding: 0.25rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-8 {\n padding: 2rem;\n}\n.px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n.px-4 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n.px-6 {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n}\n.py-1 {\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n}\n.py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n.py-4 {\n padding-top: 1rem;\n padding-bottom: 1rem;\n}\n.py-6 {\n padding-top: 1.5rem;\n padding-bottom: 1.5rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pb-6 {\n padding-bottom: 1.5rem;\n}\n.pb-8 {\n padding-bottom: 2rem;\n}\n.pl-0 {\n padding-left: 0px;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pl-4 {\n padding-left: 1rem;\n}\n.pt-1 {\n padding-top: 0.25rem;\n}\n.pt-12 {\n padding-top: 3rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pt-4 {\n padding-top: 1rem;\n}\n.pt-5 {\n padding-top: 1.25rem;\n}\n.pt-6 {\n padding-top: 1.5rem;\n}\n.pt-8 {\n padding-top: 2rem;\n}\n.text-left {\n text-align: left;\n}\n.text-center {\n text-align: center;\n}\n.text-right {\n text-align: right;\n}\n.align-middle {\n vertical-align: middle;\n}\n.text-2xl {\n font-size: 1.5rem;\n line-height: 2rem;\n}\n.text-base {\n font-size: 1rem;\n line-height: 1.5rem;\n}\n.text-lg {\n font-size: 1.125rem;\n line-height: 1.75rem;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xl {\n font-size: 1.25rem;\n line-height: 1.75rem;\n}\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.font-bold {\n font-weight: 700;\n}\n.font-medium {\n font-weight: 500;\n}\n.font-normal {\n font-weight: 400;\n}\n.capitalize {\n text-transform: capitalize;\n}\n.text-emerald-600 {\n --tw-text-opacity: 1;\n color: rgb(5 150 105 / var(--tw-text-opacity, 1));\n}\n.text-emerald-700 {\n --tw-text-opacity: 1;\n color: rgb(4 120 87 / var(--tw-text-opacity, 1));\n}\n.text-gray-600 {\n --tw-text-opacity: 1;\n color: rgb(75 85 99 / var(--tw-text-opacity, 1));\n}\n.text-gray-900 {\n --tw-text-opacity: 1;\n color: rgb(17 24 39 / var(--tw-text-opacity, 1));\n}\n.text-green-600 {\n --tw-text-opacity: 1;\n color: rgb(22 163 74 / var(--tw-text-opacity, 1));\n}\n.text-orange-500 {\n --tw-text-opacity: 1;\n color: rgb(249 115 22 / var(--tw-text-opacity, 1));\n}\n.text-red-500 {\n --tw-text-opacity: 1;\n color: rgb(239 68 68 / var(--tw-text-opacity, 1));\n}\n.text-slate-400 {\n --tw-text-opacity: 1;\n color: rgb(148 163 184 / var(--tw-text-opacity, 1));\n}\n.text-slate-500 {\n --tw-text-opacity: 1;\n color: rgb(100 116 139 / var(--tw-text-opacity, 1));\n}\n.text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\n}\n.text-yellow-500 {\n --tw-text-opacity: 1;\n color: rgb(234 179 8 / var(--tw-text-opacity, 1));\n}\n.underline {\n text-decoration-line: underline;\n}\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-md {\n --tw-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-none {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-sm {\n --tw-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n --tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-xl {\n --tw-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n --tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.transition {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.font-light {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-medium {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n.font-bold {\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex;\n }\n .sm\\:hidden {\n display: none;\n }\n}\n* {\n margin: 0;\n padding: 0;\n box-sizing: border-box !important;\n font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;\n line-height: 1.15;\n}\nbody {\n color: #232323;\n background-color: #f8fafc;\n}\nth {\n font-weight: normal;\n}\ncode {\n font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\", monospace;\n}\n@media only screen and (max-width: 768px) {\n select,\n textarea,\n input[type=\"text\"],\n input[type=\"password\"],\n input[type=\"datetime\"],\n input[type=\"datetime-local\"],\n input[type=\"date\"],\n input[type=\"month\"],\n input[type=\"time\"],\n input[type=\"week\"],\n input[type=\"number\"],\n input[type=\"email\"],\n input[type=\"url\"],\n input[type=\"search\"],\n input[type=\"tel\"],\n input[type=\"color\"] {\n font-size: 16px !important;\n }\n}\n@keyframes App-logo-spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n}\n";
46
46
  styleInject(css_248z);
47
47
 
48
48
  /******************************************************************************
@@ -1681,6 +1681,19 @@ function ContextualWrapper(_a) {
1681
1681
  colorSplit: darkMode ? SLATE_400 : SLATE_200,
1682
1682
  verticalMarginInline: 0,
1683
1683
  },
1684
+ Form: {
1685
+ itemMarginBottom: 0,
1686
+ verticalLabelPadding: "4px",
1687
+ },
1688
+ Input: {
1689
+ fontSize: 16,
1690
+ },
1691
+ Select: {
1692
+ fontSize: 16,
1693
+ },
1694
+ DatePicker: {
1695
+ fontSize: 16,
1696
+ },
1684
1697
  } }, configProviderProps) }, { children: children })) })) }));
1685
1698
  }
1686
1699
 
@@ -1748,13 +1761,24 @@ var useDownloadFile = function (id, onError) {
1748
1761
 
1749
1762
  var InvoiceQuoteContext = createContext$1({});
1750
1763
 
1764
+ var PaymentContext = createContext$1({});
1765
+
1766
+ // Use this hook instead of getting the token from BunnyContext directly
1767
+ // Because we have overrideToken as an option, this token ensures the correct token is used
1768
+ function useToken() {
1769
+ var tokenFromContext = useContext$1(BunnyContext).token;
1770
+ var overrideToken = useContext$1(PaymentContext).overrideToken;
1771
+ return overrideToken || tokenFromContext;
1772
+ }
1773
+
1751
1774
  var MarkupContainer = styled.div(templateObject_1$8 || (templateObject_1$8 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
1752
1775
  var InvoiceQuoteView = function (_a) {
1753
1776
  var children = _a.children, formattedInvoice = _a.formattedInvoice, html = _a.html, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onDownloadError = _a.onDownloadError;
1754
1777
  var downloadFile = useDownloadFile(formattedInvoice === null || formattedInvoice === void 0 ? void 0 : formattedInvoice.id, onDownloadError);
1755
1778
  var secondaryColor = useContext$1(BrandContext).secondaryColor;
1756
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost;
1757
- var _c = useContext$1(InvoiceQuoteContext), shadow = _c.shadow, hideDownloadButton = _c.hideDownloadButton;
1779
+ var apiHost = useContext$1(BunnyContext).apiHost;
1780
+ var token = useToken();
1781
+ var _b = useContext$1(InvoiceQuoteContext), shadow = _b.shadow, hideDownloadButton = _b.hideDownloadButton;
1758
1782
  var isMobile = useIsMobile();
1759
1783
  var buttonsVisible = formattedInvoice && (!hideDownloadButton || onBackButtonClick);
1760
1784
  return (jsxs("div", __assign({ className: "flex flex-col w-full grow ".concat(isMobile ? "overflow-hidden" : "") }, { children: [buttonsVisible ? (jsxs("div", __assign({ className: "flex justify-between items-center pb-4 ".concat(isMobile ? "shadow-padding-x" : ""), id: "acceptance" }, { children: [jsx("div", { children: onBackButtonClick ? (jsx(Button$1, __assign({ className: "text-xs pl-0", onClick: onBackButtonClick, style: {
@@ -1775,17 +1799,57 @@ var quoteMetaTitle = function (_a) {
1775
1799
  return vendorName + " " + documentName;
1776
1800
  };
1777
1801
 
1778
- var PaymentContext = createContext$1({});
1802
+ var fetchPDF = function (apiEndpoint, invoiceUuid) { return __awaiter(void 0, void 0, void 0, function () {
1803
+ var response;
1804
+ return __generator(this, function (_a) {
1805
+ switch (_a.label) {
1806
+ case 0:
1807
+ if (!invoiceUuid) {
1808
+ throw new Error("Invoice ID is required to fetch PDF");
1809
+ }
1810
+ return [4 /*yield*/, fetch("".concat(apiEndpoint, "/api/legacy_invoices/").concat(invoiceUuid))];
1811
+ case 1:
1812
+ response = _a.sent();
1813
+ if (!response.ok)
1814
+ throw new Error("Failed to fetch PDF");
1815
+ return [2 /*return*/, response.blob()]; // Return the PDF as a blob
1816
+ }
1817
+ });
1818
+ }); };
1819
+ function InvoicePDF(_a) {
1820
+ var invoiceUuid = _a.invoiceUuid, apiHost = _a.apiHost;
1821
+ var _b = useState(undefined), pdfUrl = _b[0], setPdfUrl = _b[1];
1822
+ var _c = useQuery({
1823
+ queryKey: ["invoicePDF", invoiceUuid],
1824
+ queryFn: function () { return fetchPDF(apiHost || "", invoiceUuid); },
1825
+ enabled: Boolean(invoiceUuid),
1826
+ }), pdfBlob = _c.data, isLoading = _c.isLoading;
1827
+ useEffect(function () {
1828
+ if (pdfBlob) {
1829
+ var url_1 = URL.createObjectURL(pdfBlob);
1830
+ setPdfUrl(url_1);
1831
+ return function () { return URL.revokeObjectURL(url_1); };
1832
+ }
1833
+ }, [pdfBlob]);
1834
+ if (isLoading || !pdfUrl)
1835
+ return jsx(Fragment, {});
1836
+ return (jsx("iframe", { src: pdfUrl, style: {
1837
+ border: "none",
1838
+ gridColumn: "1/-1",
1839
+ minHeight: "1000px",
1840
+ minWidth: "780px",
1841
+ }, title: "Invoice PDF", width: "100%" }));
1842
+ }
1779
1843
 
1780
1844
  var paymentMethodsQuery = "query paymentMethods ($filter: String, $first: Int, $sort: String) {\n paymentMethods (filter: $filter, first: $first, sort: $sort) {\n nodes {\n id\n disabled\n pluginId\n accountId\n expirationDate\n plugin {\n guid\n id\n }\n state\n metadata {\n issuer\n identifier\n kind\n description\n icon\n }\n }\n }\n}";
1781
- var usePaymentMethod = function (graphQLClient, accountId) {
1845
+ var usePaymentMethod = function (graphQLClient) {
1782
1846
  var result = useQuery({
1783
1847
  queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
1784
1848
  queryFn: function () {
1785
1849
  return graphQLClient
1786
1850
  .request(paymentMethodsQuery, {
1787
1851
  first: 1,
1788
- filter: "disabled is false".concat(accountId ? " and accountId is ".concat(accountId) : ""),
1852
+ filter: "disabled is false",
1789
1853
  })
1790
1854
  .then(function (data) {
1791
1855
  var _a, _b;
@@ -1846,289 +1910,156 @@ var getQuoteAmountDue = function (quote) {
1846
1910
  return quote.amountDue;
1847
1911
  };
1848
1912
 
1849
- // Simulated payment creation and confirmation
1850
- var confirmPayment = function (_a) {
1851
- var amount = _a.amount, currency = _a.currency;
1852
- return { token: "DemoPayTestToken", amount: amount, currency: currency };
1853
- };
1854
- var DIGIT_REGEX = /\d/;
1855
- var isDigit = function (char) { return DIGIT_REGEX.test(char); };
1856
- var isDeletion = function (char) { return [8, 46].includes(char); }; // Backspace or Delete
1857
- var isNavigation = function (char) { return [9, 37, 38, 39, 40].includes(char); }; // Tab, Arrows
1858
- var isModifier = function (char) { return [16, 17, 18].includes(char); }; // Shift, Ctrl, Alt
1859
- var isValidKey = function (code) {
1860
- return isDeletion(code) || isNavigation(code) || isModifier(code);
1861
- };
1862
- var isValidExpiry = function (expiry) {
1863
- var month = parseInt(expiry.substring(0, 2), 10);
1864
- var year = parseInt(expiry.substring(2, 4), 10) + 2000;
1865
- if (isNaN(month) || isNaN(year))
1866
- return false;
1867
- if (month < 1 || month > 12)
1868
- return false;
1869
- return true;
1870
- };
1871
- var isCardExpired = function (expiry) {
1872
- var month = parseInt(expiry.substring(0, 2), 10);
1873
- var year = parseInt(expiry.substring(2, 4), 10) + 2000;
1874
- var expiryDate = new Date(year, month, 1);
1875
- return expiryDate < new Date();
1876
- };
1877
- var formatCardExpiry = function (cardExpiry) {
1878
- if (cardExpiry.length <= 2)
1879
- return cardExpiry;
1880
- return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
1881
- };
1882
- // removes spaces from a credit card number
1883
- var unformatCardNumber = function (cardNumber) {
1884
- var cardNumberArray = cardNumber.split("");
1885
- var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
1886
- return unformattedCardNumberArray.join("");
1913
+ var DEFAULT_HEADERS = {
1914
+ "Content-type": "application/json; charset=utf-8",
1887
1915
  };
1888
- var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
1889
- var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
1890
- return __generator(this, function (_a) {
1891
- switch (_a.label) {
1892
- case 0:
1893
- testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
1894
- return [4 /*yield*/, invokePlugin({
1895
- method: "store_payment_method",
1896
- plugin: plugin,
1897
- payload: {
1898
- test_credit_card_number: testCreditCardNumber,
1899
- test_credit_card_cvc: testCreditCardCvc,
1900
- test_credit_card_expiration_date: testCreditCardExpirationDate,
1901
- account_id: accountId,
1902
- },
1903
- token: token,
1904
- apiHost: apiHost,
1905
- })];
1906
- case 1:
1907
- response = _a.sent();
1908
- if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
1909
- throw new Error(response === null || response === void 0 ? void 0 : response.message);
1910
- return [2 /*return*/, response];
1911
- }
1912
- });
1913
- }); };
1914
-
1915
- function usePay$1(_a) {
1916
- var _this = this;
1917
- var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice;
1918
- var pay = function (_a) {
1919
- var plugin = _a.plugin, savePaymentMethod = _a.savePaymentMethod;
1920
- return __awaiter(_this, void 0, void 0, function () {
1921
- var amountDue, currencyId, response;
1922
- return __generator(this, function (_b) {
1923
- amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
1924
- currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
1925
- if (!amountDue || !currencyId) {
1926
- throw new Error("No amount or currencyId");
1927
- }
1928
- try {
1929
- response = confirmPayment({
1930
- amount: amountDue,
1931
- currency: currencyId,
1932
- });
1933
- onPaymentSuccess({
1934
- pluginPaymentResponse: {
1935
- plugin: plugin,
1936
- token: response.token,
1937
- savePaymentMethod: savePaymentMethod,
1938
- },
1939
- });
1940
- }
1941
- catch (error) {
1942
- onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error);
1943
- }
1944
- return [2 /*return*/];
1945
- });
1946
- });
1947
- };
1948
- return { pay: pay };
1949
- }
1950
-
1951
- var createPaymentMethod = function (_a) {
1952
- var paymentMethodId = _a.paymentMethodId, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
1916
+ // !!! Duplicated from @bunnyapp/common due to bug in signup. Uses BunnyProvider token instead of apiToken.
1917
+ var gqlRequest = function (_a) {
1918
+ var query = _a.query, _b = _a.vars, vars = _b === void 0 ? {} : _b, headers = _a.headers, token = _a.token, isInPreviewMode = _a.isInPreviewMode, apiHost = _a.apiHost;
1953
1919
  return __awaiter(void 0, void 0, void 0, function () {
1954
- var response;
1955
- return __generator(this, function (_b) {
1956
- switch (_b.label) {
1957
- case 0: return [4 /*yield*/, invokePlugin({
1958
- plugin: plugin,
1959
- method: "store_payment_method",
1960
- payload: {
1961
- payment_method_id: paymentMethodId,
1962
- account_id: accountId,
1963
- },
1964
- token: token,
1965
- apiHost: apiHost,
1966
- })];
1967
- case 1:
1968
- response = _b.sent();
1969
- if (response.status !== "success")
1970
- throw new Error(response.message || "Unknown error");
1971
- return [2 /*return*/, response];
1920
+ var graphqlEndpoint, requestHeaders, authorizationHeader, error_1;
1921
+ return __generator(this, function (_c) {
1922
+ switch (_c.label) {
1923
+ case 0:
1924
+ _c.trys.push([0, 2, , 3]);
1925
+ graphqlEndpoint = DEFAULT_CONFIG.graphqlEndpoint;
1926
+ requestHeaders = headers || DEFAULT_HEADERS;
1927
+ authorizationHeader = "Bearer ".concat(token);
1928
+ if (!requestHeaders.Authorization && !isInPreviewMode)
1929
+ requestHeaders.Authorization = authorizationHeader;
1930
+ return [4 /*yield*/, request("".concat(apiHost).concat(graphqlEndpoint), query, vars, requestHeaders)];
1931
+ case 1: return [2 /*return*/, _c.sent()];
1932
+ case 2:
1933
+ error_1 = _c.sent();
1934
+ throw error_1;
1935
+ case 3: return [2 /*return*/];
1972
1936
  }
1973
1937
  });
1974
1938
  });
1975
1939
  };
1976
- var createSetupIntent = function (plugin, token, apiHost, accountId) {
1977
- return invokePlugin({
1978
- plugin: plugin,
1979
- method: "create_setup_intent",
1980
- token: token,
1981
- apiHost: apiHost,
1982
- payload: {
1983
- account_id: accountId,
1984
- },
1985
- });
1986
- };
1987
- var createPaymentIntent = function (_a) {
1988
- var payable = _a.payable, savePaymentMethod = _a.savePaymentMethod, memo = _a.memo, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost;
1940
+
1941
+ var MUTATION$8 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
1942
+ var checkout = function (_a) {
1943
+ var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
1989
1944
  return __awaiter(void 0, void 0, void 0, function () {
1990
- var payload, response;
1945
+ var mutationVars, response, errors;
1991
1946
  return __generator(this, function (_b) {
1992
1947
  switch (_b.label) {
1993
1948
  case 0:
1994
- payload = {
1995
- payable_id: payable.payableId,
1996
- save_payment_method: savePaymentMethod,
1997
- memo: memo,
1949
+ mutationVars = {
1950
+ quoteId: quoteId,
1951
+ invoiceId: invoiceId,
1952
+ paymentMethodId: paymentMethodId,
1998
1953
  };
1999
- return [4 /*yield*/, invokePlugin({
2000
- plugin: plugin,
2001
- method: "create_payment_intent",
2002
- payload: payload,
1954
+ if (paymentMethodData) {
1955
+ mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
1956
+ }
1957
+ return [4 /*yield*/, gqlRequest({
1958
+ query: MUTATION$8,
2003
1959
  token: token,
1960
+ vars: mutationVars,
2004
1961
  apiHost: apiHost,
2005
1962
  })];
2006
1963
  case 1:
2007
1964
  response = _b.sent();
2008
- if (response.status !== "success")
2009
- throw new Error(response.message || "Unknown error");
2010
- return [2 /*return*/, response.payload];
1965
+ errors = (response === null || response === void 0 ? void 0 : response.checkout).errors;
1966
+ if (errors)
1967
+ throw errors;
1968
+ return [2 /*return*/, {
1969
+ savePaymentMethod: paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.savePaymentMethod,
1970
+ }];
2011
1971
  }
2012
1972
  });
2013
1973
  });
2014
1974
  };
2015
- var fetchStripeKey = function (plugin, token, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
2016
- var response;
2017
- return __generator(this, function (_a) {
2018
- switch (_a.label) {
2019
- case 0: return [4 /*yield*/, invokePlugin({
2020
- plugin: plugin,
2021
- method: "retrieve_config",
2022
- token: token,
2023
- apiHost: apiHost,
2024
- payload: {
2025
- account_id: accountId,
2026
- },
2027
- })];
2028
- case 1:
2029
- response = _a.sent();
2030
- return [2 /*return*/, response];
2031
- }
2032
- });
2033
- }); };
2034
- loadStripe.setLoadParameters({ advancedFraudSignals: false });
2035
- var useStripePlugin = function (plugin, token, apiHost, accountId) {
2036
- var _a = useState(null), stripe = _a[0], setStripe = _a[1];
2037
- var showErrorNotification = useErrorNotification();
2038
- var options = {
2039
- mode: "setup",
2040
- // TODO: Fetch currency from the entity/account
2041
- currency: "usd",
2042
- setupFutureUsage: "off_session",
2043
- };
2044
- if (!plugin)
2045
- return { stripe: null, options: options };
2046
- useEffect(function () {
2047
- fetchStripeKey(plugin, token, apiHost || "", accountId)
2048
- .then(function (_a) {
2049
- var payload = _a.payload;
2050
- return loadStripe(payload.publishable_key).then(setStripe);
2051
- })
2052
- .catch(function (error) {
2053
- console.error("Caught Error in fetching stripe key: ", error);
2054
- showErrorNotification(error.message, "Unexpected Error fetching key");
1975
+
1976
+ function usePay$1(_a) {
1977
+ var _this = this;
1978
+ var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice, storedPaymentMethod = _a.storedPaymentMethod, plugin = _a.plugin;
1979
+ var apiHost = useContext$1(BunnyContext).apiHost;
1980
+ var customCheckoutFunction = useContext$1(PaymentContext).customCheckoutFunction;
1981
+ var token = useToken();
1982
+ var pay = function () { return __awaiter(_this, void 0, void 0, function () {
1983
+ var amountDue, currencyId, response, response, error_1;
1984
+ return __generator(this, function (_a) {
1985
+ switch (_a.label) {
1986
+ case 0:
1987
+ amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
1988
+ currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
1989
+ if (!amountDue || !currencyId) {
1990
+ throw new Error("No amount or currencyId");
1991
+ }
1992
+ _a.label = 1;
1993
+ case 1:
1994
+ _a.trys.push([1, 6, , 7]);
1995
+ if (!customCheckoutFunction) return [3 /*break*/, 3];
1996
+ return [4 /*yield*/, customCheckoutFunction(plugin)];
1997
+ case 2:
1998
+ response = _a.sent();
1999
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
2000
+ return [3 /*break*/, 5];
2001
+ case 3: return [4 /*yield*/, checkout({
2002
+ invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
2003
+ quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
2004
+ paymentMethodId: storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.id,
2005
+ token: token,
2006
+ apiHost: apiHost,
2007
+ })];
2008
+ case 4:
2009
+ response = _a.sent();
2010
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
2011
+ _a.label = 5;
2012
+ case 5: return [3 /*break*/, 7];
2013
+ case 6:
2014
+ error_1 = _a.sent();
2015
+ onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error_1);
2016
+ return [3 /*break*/, 7];
2017
+ case 7: return [2 /*return*/];
2018
+ }
2055
2019
  });
2056
- // eslint-disable-next-line
2057
- }, [plugin, token]);
2058
- return { stripe: stripe, options: options };
2059
- };
2020
+ }); };
2021
+ return { pay: pay };
2022
+ }
2060
2023
 
2061
2024
  function usePay(_a) {
2062
2025
  var _this = this;
2063
- var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice;
2026
+ var onPaymentSuccess = _a.onPaymentSuccess, onPaymentError = _a.onPaymentError, quote = _a.quote, invoice = _a.invoice, storedPaymentMethod = _a.storedPaymentMethod, plugin = _a.plugin;
2064
2027
  // Hooks
2065
- var elements = useElements();
2066
- var stripe = useStripe();
2067
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost;
2068
- var pay = function (_a) {
2069
- var plugin = _a.plugin;
2070
- return __awaiter(_this, void 0, void 0, function () {
2071
- var payable, submitError, paymentIntent, clientSecret, response, paymentIntentId, error_1;
2072
- var _b;
2073
- return __generator(this, function (_c) {
2074
- switch (_c.label) {
2075
- case 0:
2076
- payable = (quote || invoice);
2077
- _c.label = 1;
2078
- case 1:
2079
- _c.trys.push([1, 5, , 6]);
2080
- if (!stripe)
2081
- throw new Error("Form is not ready");
2082
- if (!elements)
2083
- throw new Error("Elements couldn't be retrieved");
2084
- return [4 /*yield*/, elements.submit()];
2085
- case 2:
2086
- submitError = (_c.sent()).error;
2087
- if (submitError)
2088
- throw new Error(submitError.message);
2089
- return [4 /*yield*/, createPaymentIntent({
2090
- payable: payable,
2091
- savePaymentMethod: true,
2092
- plugin: plugin,
2093
- token: token,
2094
- apiHost: apiHost || "",
2095
- })];
2096
- case 3:
2097
- paymentIntent = _c.sent();
2098
- clientSecret = paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.client_secret;
2099
- return [4 /*yield*/, stripe.confirmPayment({
2100
- elements: elements,
2101
- clientSecret: clientSecret,
2102
- redirect: "if_required",
2103
- confirmParams: {
2104
- return_url: window.location.href,
2105
- },
2106
- })];
2107
- case 4:
2108
- response = _c.sent();
2109
- // See https://stripe.com/docs/payments/save-during-payment?platform=web#web-submit-payment
2110
- if (response.error)
2111
- throw new Error(response.error.message);
2112
- paymentIntentId = (_b = response.paymentIntent) === null || _b === void 0 ? void 0 : _b.id;
2113
- if (!paymentIntentId)
2114
- throw new Error("Payment intent couldn't be retrieved");
2115
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess({
2116
- pluginPaymentResponse: {
2117
- plugin: plugin,
2118
- token: paymentIntentId,
2119
- savePaymentMethod: true,
2120
- },
2121
- });
2122
- return [3 /*break*/, 6];
2123
- case 5:
2124
- error_1 = _c.sent();
2125
- onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error_1);
2126
- return [3 /*break*/, 6];
2127
- case 6: return [2 /*return*/];
2128
- }
2129
- });
2028
+ var apiHost = useContext$1(BunnyContext).apiHost;
2029
+ var customCheckoutFunction = useContext$1(PaymentContext).customCheckoutFunction;
2030
+ var token = useToken();
2031
+ var pay = function () { return __awaiter(_this, void 0, void 0, function () {
2032
+ var response, response, error_1;
2033
+ return __generator(this, function (_a) {
2034
+ switch (_a.label) {
2035
+ case 0:
2036
+ _a.trys.push([0, 5, , 6]);
2037
+ if (!customCheckoutFunction) return [3 /*break*/, 2];
2038
+ return [4 /*yield*/, customCheckoutFunction(plugin)];
2039
+ case 1:
2040
+ response = _a.sent();
2041
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
2042
+ return [3 /*break*/, 4];
2043
+ case 2: return [4 /*yield*/, checkout({
2044
+ invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
2045
+ quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
2046
+ paymentMethodId: storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.id,
2047
+ token: token,
2048
+ apiHost: apiHost,
2049
+ })];
2050
+ case 3:
2051
+ response = _a.sent();
2052
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(response);
2053
+ _a.label = 4;
2054
+ case 4: return [3 /*break*/, 6];
2055
+ case 5:
2056
+ error_1 = _a.sent();
2057
+ onPaymentError === null || onPaymentError === void 0 ? void 0 : onPaymentError(error_1);
2058
+ return [3 /*break*/, 6];
2059
+ case 6: return [2 /*return*/];
2060
+ }
2130
2061
  });
2131
- };
2062
+ }); };
2132
2063
  return { pay: pay };
2133
2064
  }
2134
2065
 
@@ -2137,30 +2068,31 @@ var ActualCheckoutFooter = function (_a) {
2137
2068
  var quote = _a.quote, invoice = _a.invoice, onPaymentSuccess = _a.onPaymentSuccess, noPadding = _a.noPadding, plugin = _a.plugin;
2138
2069
  var isMobile = useIsMobile();
2139
2070
  var _b = useState(false), isPaying = _b[0], setIsPaying = _b[1];
2071
+ var storedPaymentMethod = useContext$1(PaymentContext).storedPaymentMethod;
2140
2072
  var amountDue = quote ? getQuoteAmountDue(quote) : invoice === null || invoice === void 0 ? void 0 : invoice.amountDue;
2141
2073
  var currencyId = (quote === null || quote === void 0 ? void 0 : quote.currencyId) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency);
2142
2074
  // Payment hooks
2143
2075
  var payDemoPay = usePay$1({
2144
- onPaymentSuccess: function (response) {
2145
- onPaymentSuccess(response);
2146
- },
2076
+ onPaymentSuccess: onPaymentSuccess,
2147
2077
  onPaymentError: function (error) {
2148
2078
  setIsPaying(false);
2149
- showErrorNotification$1(error);
2079
+ showErrorNotification$1(JSON.stringify(error));
2150
2080
  },
2151
2081
  quote: quote,
2152
2082
  invoice: invoice,
2083
+ storedPaymentMethod: storedPaymentMethod,
2084
+ plugin: plugin,
2153
2085
  }).pay;
2154
2086
  var payStripe = usePay({
2155
- onPaymentSuccess: function (response) {
2156
- onPaymentSuccess(response);
2157
- },
2087
+ onPaymentSuccess: onPaymentSuccess,
2158
2088
  onPaymentError: function (error) {
2159
2089
  setIsPaying(false);
2160
- showErrorNotification$1(error);
2090
+ showErrorNotification$1(JSON.stringify(error));
2161
2091
  },
2162
2092
  quote: quote,
2163
2093
  invoice: invoice,
2094
+ storedPaymentMethod: storedPaymentMethod,
2095
+ plugin: plugin,
2164
2096
  }).pay;
2165
2097
  var handlePaymentSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
2166
2098
  var _a;
@@ -2170,22 +2102,17 @@ var ActualCheckoutFooter = function (_a) {
2170
2102
  case 0:
2171
2103
  if (!plugin)
2172
2104
  return [2 /*return*/];
2173
- _a = (_c = (_b = plugin === null || plugin === void 0 ? void 0 : plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name;
2105
+ _a = (_c = (_b = plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name;
2174
2106
  switch (_a) {
2175
2107
  case "StripePayment": return [3 /*break*/, 1];
2176
2108
  case "DemoPayPayment": return [3 /*break*/, 3];
2177
2109
  }
2178
2110
  return [3 /*break*/, 5];
2179
- case 1: return [4 /*yield*/, payStripe({
2180
- plugin: plugin,
2181
- })];
2111
+ case 1: return [4 /*yield*/, payStripe()];
2182
2112
  case 2:
2183
2113
  _d.sent();
2184
2114
  return [3 /*break*/, 6];
2185
- case 3: return [4 /*yield*/, payDemoPay({
2186
- plugin: plugin,
2187
- savePaymentMethod: false,
2188
- })];
2115
+ case 3: return [4 /*yield*/, payDemoPay()];
2189
2116
  case 4:
2190
2117
  _d.sent();
2191
2118
  return [3 /*break*/, 6];
@@ -2200,18 +2127,10 @@ var ActualCheckoutFooter = function (_a) {
2200
2127
  }, size: isMobile ? "large" : "middle", type: "primary" }, { children: "".concat(isPaying ? "Paying" : "Pay", " ").concat(amountDue && currencyId ? formatCurrency(amountDue, currencyId) : "") })) })));
2201
2128
  };
2202
2129
  var CheckoutFooter = function (_a) {
2203
- var _b, _c;
2204
2130
  var quote = _a.quote, invoice = _a.invoice, onPaymentSuccess = _a.onPaymentSuccess, noPadding = _a.noPadding, plugin = _a.plugin;
2205
2131
  if (!plugin)
2206
2132
  return null;
2207
- var _d = useContext$1(BunnyContext), token = _d.token, apiHost = _d.apiHost;
2208
- var accountId = useContext$1(PaymentContext).accountId;
2209
- // If plugin is not stripe, pass undefined to prevent errors
2210
- var stripePlugin = ((_c = (_b = plugin === null || plugin === void 0 ? void 0 : plugin.components) === null || _b === void 0 ? void 0 : _b.frontend) === null || _c === void 0 ? void 0 : _c[0].name) === "StripePayment"
2211
- ? plugin
2212
- : undefined;
2213
- var _e = useStripePlugin(stripePlugin, token, apiHost, accountId), stripe = _e.stripe, options = _e.options;
2214
- return (jsx(Elements, __assign({ options: options, stripe: stripe }, { children: jsx(ActualCheckoutFooter, { plugin: plugin, invoice: invoice, quote: quote, onPaymentSuccess: onPaymentSuccess, noPadding: noPadding }) })));
2133
+ return (jsx(ActualCheckoutFooter, { plugin: plugin, invoice: invoice, quote: quote, onPaymentSuccess: onPaymentSuccess, noPadding: noPadding }));
2215
2134
  };
2216
2135
 
2217
2136
  var dayjs_min = {exports: {}};
@@ -2239,13 +2158,13 @@ var PlusIcon = function (_a) {
2239
2158
  return (jsxs("svg", __assign({ width: "14", height: "15", viewBox: "0 0 14 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("path", { d: "M2.9165 7.5H11.0832", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M7 3.41663V11.5833", stroke: color, strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })] })));
2240
2159
  };
2241
2160
 
2242
- var Text$f = Typography.Text;
2161
+ var Text$g = Typography.Text;
2243
2162
  var CreditCard = function (_a) {
2244
2163
  var _b;
2245
2164
  var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, _d = _a.cardEnabled, cardEnabled = _d === void 0 ? true : _d;
2246
2165
  var isMobile = useIsMobile();
2247
2166
  var Wrapper = cardEnabled ? Card : "div";
2248
- return (jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$f, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.description })] })), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxs(Fragment, { children: [jsx(Divider, {}), jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsx(CardAttribute, { title: "EXPIRATION", value: expirationDate(paymentMethodData) }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
2167
+ return (jsxs(Wrapper, __assign({ className: "".concat(cardEnabled ? shadow : "", " m-0") }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-4 p-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$g, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier })] })), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), !isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] })), dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxs(Fragment, { children: [jsx(Divider, {}), jsxs("div", __assign({ className: "flex flex-col p-4" }, { children: [jsx(CardAttribute, { title: "EXPIRATION", value: expirationDate(paymentMethodData) }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
2249
2168
  };
2250
2169
  var MiniCreditCard = function (_a) {
2251
2170
  var _b;
@@ -2257,7 +2176,7 @@ var MiniCreditCard = function (_a) {
2257
2176
  var backgroundColor = useMemo(function () {
2258
2177
  return darkMode ? "var(--row-background-alternate)" : "bg-slate-50";
2259
2178
  }, [darkMode]);
2260
- return (jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 px-3 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border") }, { children: paymentMethodData ? (jsxs(Fragment, { children: [jsxs("div", __assign({ className: "flex flex-row gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$f, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.description })] })), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })), jsx("div", __assign({ className: "flex flex-row gap-1 items-center" }, { children: dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).isValid() && (jsxs(Fragment, { children: [jsx(Text$f, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "EXP" })), jsx(Text$f, { children: expirationDate(paymentMethodData) })] })) }))] })), !hideRemoveButton && (jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button$1, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove" })) })))] })) : (jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsx(CreditCardOutlined$1, {}), jsx(Text$f, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "No payment method selected" })), jsx(Button$1, { disabled: true, type: "link" })] }))) })));
2179
+ return (jsx("div", __assign({ className: "flex flex-row justify-between items-center p-1 px-3 border-solid ".concat(backgroundColor, " ").concat(borderColor, " rounded-md border") }, { children: paymentMethodData ? (jsxs(Fragment, { children: [jsx("div", __assign({ className: "flex flex-row gap-4" }, { children: jsxs("div", __assign({ className: "flex items-center gap-4 space-between w-full" }, { children: [jsx(CardImage, { paymentMethodData: paymentMethodData }), jsx(Text$g, { children: (_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.identifier }), jsx(Tag, __assign({ color: isExpired(paymentMethodData) ? "red" : "green" }, { children: isExpired(paymentMethodData) ? "Expired" : "Valid" }))] })) })), !hideRemoveButton && (jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button$1, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove" })) })))] })) : (jsxs("div", __assign({ className: "flex flex-row gap-2 items-center" }, { children: [jsx(CreditCardOutlined$1, {}), jsx(Text$g, __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: "No payment method selected" })), jsx(Button$1, { disabled: true, type: "link" })] }))) })));
2261
2180
  };
2262
2181
  var CardImage = function (_a) {
2263
2182
  var _b, _c;
@@ -2276,7 +2195,7 @@ var CardImage = function (_a) {
2276
2195
  };
2277
2196
  var CardAttribute = function (_a) {
2278
2197
  var title = _a.title, value = _a.value;
2279
- return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsx(Text$f, { children: value })] })));
2198
+ return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsx("div", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: title })), jsx(Text$g, { children: value })] })));
2280
2199
  };
2281
2200
  var CardActions = function (_a) {
2282
2201
  var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
@@ -2292,16 +2211,77 @@ var isExpired = function (paymentMethodData) {
2292
2211
  var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
2293
2212
  return expDate.isBefore(dayjs());
2294
2213
  };
2295
- var expirationDate = function (storedPaymentMethod) {
2296
- return dayjs(storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.expirationDate).format("MM/YY");
2214
+ var expirationDate = function (storedPaymentMethod) {
2215
+ return dayjs(storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.expirationDate).format("MM/YY");
2216
+ };
2217
+
2218
+ var SavePaymentMethodFooter = function (_a) {
2219
+ var isSaving = _a.isSaving, onSave = _a.onSave, noPadding = _a.noPadding;
2220
+ var isMobile = useIsMobile();
2221
+ var onClickCancel = useContext$1(PaymentContext).onClickCancel;
2222
+ return (jsxs("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "pt-6") }, { children: [onClickCancel && (jsx(Button$1, __assign({ className: "w-full", size: isMobile ? "large" : "middle", onClick: function () { return onClickCancel(); } }, { children: "Cancel" }))), jsx(Button$1, __assign({ className: "w-full", disabled: isSaving, onClick: onSave, size: isMobile ? "large" : "middle", type: "primary" }, { children: isSaving ? "Saving" : "Save" }))] })));
2223
+ };
2224
+
2225
+ var DIGIT_REGEX = /\d/;
2226
+ var isDigit = function (char) { return DIGIT_REGEX.test(char); };
2227
+ var isDeletion = function (char) { return [8, 46].includes(char); }; // Backspace or Delete
2228
+ var isNavigation = function (char) { return [9, 37, 38, 39, 40].includes(char); }; // Tab, Arrows
2229
+ var isModifier = function (char) { return [16, 17, 18].includes(char); }; // Shift, Ctrl, Alt
2230
+ var isValidKey = function (code) {
2231
+ return isDeletion(code) || isNavigation(code) || isModifier(code);
2232
+ };
2233
+ var isValidExpiry = function (expiry) {
2234
+ var month = parseInt(expiry.substring(0, 2), 10);
2235
+ var year = parseInt(expiry.substring(2, 4), 10) + 2000;
2236
+ if (isNaN(month) || isNaN(year))
2237
+ return false;
2238
+ if (month < 1 || month > 12)
2239
+ return false;
2240
+ return true;
2241
+ };
2242
+ var isCardExpired = function (expiry) {
2243
+ var month = parseInt(expiry.substring(0, 2), 10);
2244
+ var year = parseInt(expiry.substring(2, 4), 10) + 2000;
2245
+ var expiryDate = new Date(year, month, 1);
2246
+ return expiryDate < new Date();
2247
+ };
2248
+ var formatCardExpiry = function (cardExpiry) {
2249
+ if (cardExpiry.length <= 2)
2250
+ return cardExpiry;
2251
+ return cardExpiry.substring(0, 2) + "/" + cardExpiry.substring(2);
2297
2252
  };
2298
-
2299
- var SavePaymentMethodFooter = function (_a) {
2300
- var isSaving = _a.isSaving, onSave = _a.onSave, noPadding = _a.noPadding;
2301
- var isMobile = useIsMobile();
2302
- var onClickCancel = useContext$1(PaymentContext).onClickCancel;
2303
- return (jsxs("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "pt-6") }, { children: [onClickCancel && (jsx(Button$1, __assign({ className: "w-full", size: isMobile ? "large" : "middle", onClick: function () { return onClickCancel(); } }, { children: "Cancel" }))), jsx(Button$1, __assign({ className: "w-full", disabled: isSaving, onClick: onSave, size: isMobile ? "large" : "middle", type: "primary" }, { children: isSaving ? "Saving" : "Save" }))] })));
2253
+ // removes spaces from a credit card number
2254
+ var unformatCardNumber = function (cardNumber) {
2255
+ var cardNumberArray = cardNumber.split("");
2256
+ var unformattedCardNumberArray = cardNumberArray.filter(function (character) { return character !== " "; });
2257
+ return unformattedCardNumberArray.join("");
2304
2258
  };
2259
+ var storePayment = function (options, plugin, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
2260
+ var testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token, response;
2261
+ return __generator(this, function (_a) {
2262
+ switch (_a.label) {
2263
+ case 0:
2264
+ testCreditCardNumber = options.testCreditCardNumber, testCreditCardCvc = options.testCreditCardCvc, testCreditCardExpirationDate = options.testCreditCardExpirationDate, token = options.token;
2265
+ return [4 /*yield*/, invokePlugin({
2266
+ method: "store_payment_method",
2267
+ plugin: plugin,
2268
+ payload: {
2269
+ test_credit_card_number: testCreditCardNumber,
2270
+ test_credit_card_cvc: testCreditCardCvc,
2271
+ test_credit_card_expiration_date: testCreditCardExpirationDate,
2272
+ account_id: accountId,
2273
+ },
2274
+ token: token,
2275
+ apiHost: apiHost,
2276
+ })];
2277
+ case 1:
2278
+ response = _a.sent();
2279
+ if ((response === null || response === void 0 ? void 0 : response.status) !== "success")
2280
+ throw new Error(response === null || response === void 0 ? void 0 : response.message);
2281
+ return [2 /*return*/, response];
2282
+ }
2283
+ });
2284
+ }); };
2305
2285
 
2306
2286
  var DemoPayCardCvc = function (_a) {
2307
2287
  var autoFocus = _a.autoFocus, onChange = _a.onChange, placeholder = _a.placeholder, value = _a.value;
@@ -2396,7 +2376,7 @@ function useSave$1(_a) {
2396
2376
  return { save: save, isSaving: isSaving };
2397
2377
  }
2398
2378
 
2399
- var Text$e = Typography.Text;
2379
+ var Text$f = Typography.Text;
2400
2380
  var TEST_CARD = "4242424242424242";
2401
2381
  var DemoPayForm = function (_a) {
2402
2382
  var onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod, plugin = _a.plugin;
@@ -2457,7 +2437,7 @@ var DemoPayForm = function (_a) {
2457
2437
  var onCardCvcChange = function (cvc) {
2458
2438
  setCardDetails(__assign(__assign({}, cardDetails), { cvc: cvc }));
2459
2439
  };
2460
- return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsx(Text$e, __assign({ className: "text-xs" }, { children: "DemoPay is for testing only." })), jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSave })] })));
2440
+ return (jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs(StyledInputs, __assign({ className: "flex flex-col gap-2", darkMode: darkMode !== null && darkMode !== void 0 ? darkMode : false }, { children: [jsx(DemoPayCardNumber, { onChange: onCardNumberChange, value: cardDetails.number }), jsxs("div", __assign({ className: "flex gap-2" }, { children: [jsx(DemoPayExpiry, { onChange: onCardExpiryChange, value: cardDetails.expiry }), jsx(DemoPayCardCvc, { onChange: onCardCvcChange, value: cardDetails.cvc })] }))] })), jsx(Text$f, __assign({ className: "text-xs" }, { children: "DemoPay is for testing only." })), jsx(SavePaymentMethodFooter, { isSaving: isSaving, onSave: onSave })] })));
2461
2441
  };
2462
2442
  var StyledInputs = styled.div(templateObject_1$7 || (templateObject_1$7 = __makeTemplateObject(["\n .ant-input {\n background-color: ", " !important;\n }\n .ant-input:not(:focus) {\n border-color: ", " !important;\n }\n"], ["\n .ant-input {\n background-color: ", " !important;\n }\n .ant-input:not(:focus) {\n border-color: ", " !important;\n }\n"])), function (_a) {
2463
2443
  var darkMode = _a.darkMode;
@@ -2468,6 +2448,91 @@ var StyledInputs = styled.div(templateObject_1$7 || (templateObject_1$7 = __make
2468
2448
  });
2469
2449
  var templateObject_1$7;
2470
2450
 
2451
+ var createPaymentMethod = function (_a) {
2452
+ var paymentMethodId = _a.paymentMethodId, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
2453
+ return __awaiter(void 0, void 0, void 0, function () {
2454
+ var response;
2455
+ return __generator(this, function (_b) {
2456
+ switch (_b.label) {
2457
+ case 0: return [4 /*yield*/, invokePlugin({
2458
+ plugin: plugin,
2459
+ method: "store_payment_method",
2460
+ payload: {
2461
+ payment_method_id: paymentMethodId,
2462
+ account_id: accountId,
2463
+ },
2464
+ token: token,
2465
+ apiHost: apiHost,
2466
+ })];
2467
+ case 1:
2468
+ response = _b.sent();
2469
+ if (response.status !== "success")
2470
+ throw new Error(response.message || "Unknown error");
2471
+ return [2 /*return*/, response];
2472
+ }
2473
+ });
2474
+ });
2475
+ };
2476
+ var createSetupIntent = function (plugin, token, apiHost, accountId) {
2477
+ return invokePlugin({
2478
+ plugin: plugin,
2479
+ method: "create_setup_intent",
2480
+ token: token,
2481
+ apiHost: apiHost,
2482
+ payload: {
2483
+ account_id: accountId,
2484
+ },
2485
+ });
2486
+ };
2487
+ var fetchStripeKey = function (plugin, token, apiHost, accountId) { return __awaiter(void 0, void 0, void 0, function () {
2488
+ var response;
2489
+ return __generator(this, function (_a) {
2490
+ switch (_a.label) {
2491
+ case 0: return [4 /*yield*/, invokePlugin({
2492
+ plugin: plugin,
2493
+ method: "retrieve_config",
2494
+ token: token,
2495
+ apiHost: apiHost,
2496
+ payload: {
2497
+ account_id: accountId,
2498
+ },
2499
+ })];
2500
+ case 1:
2501
+ response = _a.sent();
2502
+ return [2 /*return*/, response];
2503
+ }
2504
+ });
2505
+ }); };
2506
+ loadStripe.setLoadParameters({ advancedFraudSignals: false });
2507
+ var useStripePlugin = function (plugin, token, apiHost, accountId) {
2508
+ var _a = useState(null), stripe = _a[0], setStripe = _a[1];
2509
+ var showErrorNotification = useErrorNotification();
2510
+ var options = {
2511
+ mode: "setup",
2512
+ // TODO: Fetch currency from the entity/account
2513
+ currency: "usd",
2514
+ setupFutureUsage: "off_session",
2515
+ };
2516
+ useEffect(function () {
2517
+ var _a, _b;
2518
+ if (!plugin)
2519
+ return;
2520
+ if (((_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.frontend) === null || _b === void 0 ? void 0 : _b[0].name) !== "StripePayment")
2521
+ return;
2522
+ fetchStripeKey(plugin, token, apiHost || "", accountId)
2523
+ .then(function (_a) {
2524
+ var payload = _a.payload;
2525
+ return loadStripe(payload.publishable_key).then(setStripe);
2526
+ })
2527
+ .catch(function (error) {
2528
+ console.error("Caught Error in fetching stripe key: ", error);
2529
+ showErrorNotification(error.message, "Unexpected Error fetching key");
2530
+ });
2531
+ // eslint-disable-next-line
2532
+ }, [plugin, token]);
2533
+ return { stripe: stripe, options: options };
2534
+ };
2535
+
2471
2536
  function useSave(_a) {
2472
2537
  var _this = this;
2473
2538
  var onSaveSuccess = _a.onSaveSuccess;
@@ -2475,7 +2540,8 @@ function useSave(_a) {
2475
2540
  var _b = useState(false), isSaving = _b[0], setIsSaving = _b[1];
2476
2541
  var elements = useElements();
2477
2542
  var stripe = useStripe();
2478
- var _c = useContext$1(BunnyContext), token = _c.token, apiHost = _c.apiHost;
2543
+ var apiHost = useContext$1(BunnyContext).apiHost;
2544
+ var token = useToken();
2479
2545
  var accountId = useContext$1(PaymentContext).accountId;
2480
2546
  var save = function (_a) {
2481
2547
  var plugin = _a.plugin;
@@ -2586,12 +2652,7 @@ var PaymentMethodForm = function (_a) {
2586
2652
  // This is just a wrapper to fetch the stripe object and pass it to the form
2587
2653
  var StripeForm = function (_a) {
2588
2654
  var plugin = _a.plugin, onFail = _a.onFail, onSavePaymentMethod = _a.onSavePaymentMethod;
2589
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost;
2590
- var accountId = useContext$1(PaymentContext).accountId;
2591
- var _c = useStripePlugin(plugin, token, apiHost, accountId), stripe = _c.stripe, options = _c.options;
2592
- if (!stripe)
2593
- return null;
2594
- return (jsx(Elements, __assign({ options: options, stripe: stripe }, { children: jsx(PaymentMethodForm, { plugin: plugin, onFail: onFail, onSavePaymentMethod: onSavePaymentMethod }) })));
2655
+ return (jsx(PaymentMethodForm, { plugin: plugin, onFail: onFail, onSavePaymentMethod: onSavePaymentMethod }));
2595
2656
  };
2596
2657
 
2597
2658
  var PaymentMethodDetails = function (_a) {
@@ -2614,20 +2675,20 @@ var CardIcon = function () {
2614
2675
  return (jsxs("svg", __assign({ width: "18", height: "18", viewBox: "0 0 18 18", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("path", { d: "M15 3.75H3C2.17157 3.75 1.5 4.42157 1.5 5.25V12.75C1.5 13.5784 2.17157 14.25 3 14.25H15C15.8284 14.25 16.5 13.5784 16.5 12.75V5.25C16.5 4.42157 15.8284 3.75 15 3.75Z", stroke: SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M1.5 7.5H16.5", stroke: SLATE_400, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
2615
2676
  };
2616
2677
 
2617
- var Text$d = Typography.Text;
2678
+ var Text$e = Typography.Text;
2618
2679
  var PaymentMethodSelector = function (_a) {
2619
2680
  var paymentMethodAllowedPlugins = _a.paymentMethodAllowedPlugins, onSelect = _a.onSelect, value = _a.value;
2620
- return (jsx("div", __assign({ className: "flex flex-col gap-2" }, { children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentOption: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); }) })));
2681
+ return (jsx("div", __assign({ className: "flex flex-col gap-2" }, { children: paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.map(function (plugin, index) { return (jsx(PaymentOption, { name: plugin.name, onClick: onSelect, paymentPlugin: plugin, selected: (value === null || value === void 0 ? void 0 : value.id) === plugin.id }, index)); }) })));
2621
2682
  };
2622
2683
  var PaymentOption = function (_a) {
2623
- var selected = _a.selected, paymentOption = _a.paymentOption, onClick = _a.onClick, name = _a.name;
2684
+ var selected = _a.selected, paymentPlugin = _a.paymentPlugin, onClick = _a.onClick, name = _a.name;
2624
2685
  var brandColor = useContext$1(BrandContext).brandColor;
2625
2686
  var darkMode = useContext$1(BunnyContext).darkMode;
2626
2687
  var isAch = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("ach");
2627
2688
  var isCard = name === null || name === void 0 ? void 0 : name.toLowerCase().includes("card");
2628
2689
  return (jsxs(PaymentOptionContainer, __assign({ "$brandColor": brandColor, "$selected": selected, className: "flex justify-between items-center w-full cursor-pointer py-2 px-4 rounded border-solid ".concat(darkMode
2629
2690
  ? "var(--row-background-dark) border-gray-500"
2630
- : "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentOption); } }, { children: [jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsx(Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsx(Text$d, { children: name })] })), isAch ? (jsx(BankOutlined$1, { className: "text-slate-400" })) : isCard ? (jsx(CardIcon, {})) : (jsx(CardIcon, {}))] })));
2691
+ : "bg-slate-50 border-slate-200", " border"), onClick: function () { return onClick(paymentPlugin); } }, { children: [jsxs("div", __assign({ className: "flex gap-2 items-center" }, { children: [jsx(Checkbox, { checked: selected, className: darkMode ? "border-gray-400" : "" }), jsx(Text$e, { children: name })] })), isAch ? (jsx(BankOutlined$1, { className: "text-slate-400" })) : isCard ? (jsx(CardIcon, {})) : (jsx(CardIcon, {}))] })));
2631
2692
  };
2632
2693
  var PaymentOptionContainer = styled.div(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject(["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"], ["\n transition: border 0.3s ease;\n\n ", "\n\n &:hover {\n border-color: ", ";\n }\n"])), function (_a) {
2633
2694
  var $brandColor = _a.$brandColor, $selected = _a.$selected;
@@ -2664,224 +2725,79 @@ function useRemovePaymentMethod(paymentPlugins, token, apiHost, accountId) {
2664
2725
  showErrorNotification(error.message, "Error removing payment method");
2665
2726
  });
2666
2727
  }
2667
- }, [paymentPlugins, token, apiHost, queryClient]);
2668
- return removePaymentMethod;
2669
- }
2670
-
2671
- var Panel = Collapse.Panel;
2672
- var PaymentForm = function (_a) {
2673
- var entityId = _a.entityId, invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, overrideToken = _a.overrideToken, graphQLClient = _a.graphQLClient;
2674
- // Local state
2675
- var _b = useState(), selectedPaymentMethod = _b[0], setSelectedPaymentMethod = _b[1];
2676
- var _c = useState(false), showPaymentMethodForm = _c[0], setShowPaymentMethodForm = _c[1];
2677
- var paying = !!(quote || invoice);
2678
- // Hooks
2679
- var _d = useContext$1(BunnyContext), token = _d.token, apiHost = _d.apiHost;
2680
- var storedPaymentMethod = usePaymentMethod(graphQLClient, accountId).data;
2681
- var isPaymentMethodFetched = storedPaymentMethod !== undefined;
2682
- var _e = usePaymentPlugins({ entityId: entityId, apiHost: apiHost, token: overrideToken || token }), paymentMethodAllowedPlugins = _e.paymentMethodAllowedPlugins, arePluginsFetched = _e.isFetched;
2683
- var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], overrideToken || token, apiHost, accountId);
2684
- var queryClient = useQueryClient();
2685
- // Set default plugin
2686
- useEffect(function () {
2687
- if (!arePluginsFetched ||
2688
- !isPaymentMethodFetched ||
2689
- selectedPaymentMethod) {
2690
- return;
2691
- }
2692
- var pluginPaymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a; return plugin.name === ((_a = storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.metadata) === null || _a === void 0 ? void 0 : _a.issuer); });
2693
- if (pluginPaymentMethod) {
2694
- setSelectedPaymentMethod(pluginPaymentMethod);
2695
- }
2696
- else if (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]) {
2697
- setSelectedPaymentMethod(paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]);
2698
- }
2699
- }, [
2700
- arePluginsFetched,
2701
- isPaymentMethodFetched,
2702
- paymentMethodAllowedPlugins,
2703
- selectedPaymentMethod,
2704
- setSelectedPaymentMethod,
2705
- storedPaymentMethod,
2706
- ]);
2707
- var showPaymentMethodSelector = useMemo(function () {
2708
- var pluginCount = (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.length) || 0;
2709
- return pluginCount > 1;
2710
- }, [paymentMethodAllowedPlugins]);
2711
- var handlePaymentSuccess = function (_a) {
2712
- var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
2713
- // Hide payment method selector and form
2714
- setShowPaymentMethodForm(false);
2715
- // Set new selected payment method
2716
- var paymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a; return plugin.id === ((_a = pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.plugin) === null || _a === void 0 ? void 0 : _a.id); });
2717
- setSelectedPaymentMethod(paymentMethod);
2718
- // Handle success keeps going up component tree
2719
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess({
2720
- pluginPaymentResponse: pluginPaymentResponse,
2721
- savedPaymentMethodResponse: savedPaymentMethodResponse,
2722
- });
2723
- };
2724
- var handleSavePaymentMethod = function () {
2725
- queryClient.invalidateQueries({
2726
- queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
2727
- });
2728
- onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
2729
- setShowPaymentMethodForm(false);
2730
- };
2731
- return (jsx(PaymentContext.Provider, __assign({ value: {
2732
- onClickCancel: function () { return setShowPaymentMethodForm(false); },
2733
- accountId: accountId,
2734
- overrideToken: overrideToken,
2735
- } }, { children: jsx("div", __assign({ className: "flex flex-col gap-0 w-full" }, { children: jsxs(Fragment, { children: [jsx("div", __assign({ className: "px-4" }, { children: jsx(MiniCreditCard, { hideRemoveButton: paying, onClickRemove: function () { return onClickRemove(storedPaymentMethod); }, paymentMethodData: storedPaymentMethod }) })), paying && storedPaymentMethod ? (jsx("div", __assign({ className: "px-4" }, { children: jsx(CheckoutFooter, { quote: quote, invoice: invoice, onPaymentSuccess: handlePaymentSuccess, plugin: selectedPaymentMethod }) }))) : (
2736
- //if not paying and payment method is saved, show Collapse
2737
- jsx(Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsx(Panel, __assign({ header: jsx(Fragment, { children: !showPaymentMethodForm ? (jsx("div", __assign({ className: "pt-4 px-4" }, { children: jsxs(Button$1, __assign({ onClick: function () {
2738
- setShowPaymentMethodForm(true);
2739
- }, type: "default", className: "w-full" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsx("div", { children: selectedPaymentMethod ? (jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsx("div", __assign({ className: "flex flex-col" }, { children: jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })));
2740
- };
2741
-
2742
- var MUTATION$8 = "\n mutation checkout(\n $invoiceId: ID,\n $quoteId: ID,\n $paymentMethodId: ID,\n $paymentMethodData: CheckoutPaymentMethodAttributes\n ) {\n checkout(\n invoiceId: $invoiceId,\n quoteId: $quoteId,\n paymentMethodId: $paymentMethodId,\n paymentMethodData: $paymentMethodData\n ) {\n invoice {\n id\n state\n amount\n amountDue\n }\n payment {\n id\n state\n amount\n }\n paymentApplication {\n id\n invoiceId\n paymentId\n }\n transaction {\n id\n amount\n }\n }\n }\n";
2743
- var checkout = function (_a) {
2744
- var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, apiHost = _a.apiHost;
2745
- return __awaiter(void 0, void 0, void 0, function () {
2746
- var mutationVars, response, errors;
2747
- return __generator(this, function (_b) {
2748
- switch (_b.label) {
2749
- case 0:
2750
- mutationVars = {
2751
- quoteId: quoteId,
2752
- invoiceId: invoiceId,
2753
- paymentMethodId: paymentMethodId,
2754
- };
2755
- if (paymentMethodData) {
2756
- mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
2757
- }
2758
- return [4 /*yield*/, gqlRequest$1({
2759
- query: MUTATION$8,
2760
- token: token,
2761
- vars: mutationVars,
2762
- apiHost: apiHost,
2763
- })];
2764
- case 1:
2765
- response = _b.sent();
2766
- errors = (response === null || response === void 0 ? void 0 : response.checkout).errors;
2767
- if (errors)
2768
- throw errors;
2769
- return [2 /*return*/, {
2770
- savePaymentMethod: paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.savePaymentMethod,
2771
- }];
2772
- }
2773
- });
2774
- });
2775
- };
2776
-
2777
- var InvoiceCheckout = function (_a) {
2778
- var onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, entityId = _a.entityId;
2779
- var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, token = _b.token, graphQLClient = _b.graphQLClient;
2780
- var checkoutMutation = useMutation({
2781
- mutationFn: function (_a) {
2782
- var pluginPaymentMethod = _a.pluginPaymentMethod, savedPaymentMethod = _a.savedPaymentMethod;
2783
- if (savedPaymentMethod) {
2784
- var paymentMethodId = savedPaymentMethod.paymentMethodId;
2785
- return checkout({
2786
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
2787
- paymentMethodId: paymentMethodId,
2788
- token: token,
2789
- apiHost: apiHost,
2790
- });
2791
- }
2792
- else if (pluginPaymentMethod) {
2793
- var plugin = pluginPaymentMethod.plugin, savePaymentMethod = pluginPaymentMethod.savePaymentMethod, metadata = pluginPaymentMethod.metadata;
2794
- var paymentToken = pluginPaymentMethod.token;
2795
- return checkout({
2796
- invoiceId: invoice === null || invoice === void 0 ? void 0 : invoice.id,
2797
- paymentMethodData: {
2798
- metadata: metadata,
2799
- pluginGuid: plugin.guid,
2800
- savePaymentMethod: savePaymentMethod,
2801
- token: paymentToken,
2802
- },
2803
- token: token,
2804
- apiHost: apiHost,
2805
- });
2806
- }
2807
- else
2808
- throw new Error("No payment method provided");
2809
- },
2810
- onSuccess: onSuccess,
2811
- onError: onFail,
2812
- });
2813
- // Handlers
2814
- var handleCheckout = function (_a) {
2815
- var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
2816
- return __awaiter(void 0, void 0, void 0, function () {
2817
- var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
2818
- return __generator(this, function (_b) {
2819
- if (pluginPaymentResponse) {
2820
- token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
2821
- checkoutMutation.mutate({
2822
- pluginPaymentMethod: {
2823
- savePaymentMethod: savePaymentMethod,
2824
- plugin: plugin,
2825
- metadata: metadata,
2826
- token: token_1,
2827
- },
2828
- });
2829
- }
2830
- else if (savedPaymentMethodResponse) {
2831
- paymentMethodId = savedPaymentMethodResponse.paymentMethodId;
2832
- checkoutMutation.mutate({
2833
- savedPaymentMethod: {
2834
- paymentMethodId: paymentMethodId,
2835
- },
2836
- });
2837
- }
2838
- return [2 /*return*/];
2839
- });
2840
- });
2841
- };
2842
- return (jsx("div", __assign({ className: "w-full pt-12" }, { children: jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: handleCheckout, onFail: onFail, invoice: invoice, graphQLClient: graphQLClient }) })));
2843
- };
2844
-
2845
- var fetchPDF = function (apiEndpoint, invoiceUuid) { return __awaiter(void 0, void 0, void 0, function () {
2846
- var response;
2847
- return __generator(this, function (_a) {
2848
- switch (_a.label) {
2849
- case 0:
2850
- if (!invoiceUuid) {
2851
- throw new Error("Invoice ID is required to fetch PDF");
2852
- }
2853
- return [4 /*yield*/, fetch("".concat(apiEndpoint, "/api/legacy_invoices/").concat(invoiceUuid))];
2854
- case 1:
2855
- response = _a.sent();
2856
- if (!response.ok)
2857
- throw new Error("Failed to fetch PDF");
2858
- return [2 /*return*/, response.blob()]; // Return the PDF as a blob
2859
- }
2860
- });
2861
- }); };
2862
- function InvoicePDF(_a) {
2863
- var invoiceUuid = _a.invoiceUuid, apiHost = _a.apiHost;
2864
- var _b = useState(undefined), pdfUrl = _b[0], setPdfUrl = _b[1];
2865
- var _c = useQuery({
2866
- queryKey: ["invoicePDF", invoiceUuid],
2867
- queryFn: function () { return fetchPDF(apiHost || "", invoiceUuid); },
2868
- enabled: Boolean(invoiceUuid),
2869
- }), pdfBlob = _c.data, isLoading = _c.isLoading;
2728
+ }, [paymentPlugins, token, apiHost, queryClient]);
2729
+ return removePaymentMethod;
2730
+ }
2731
+
2732
+ var Panel = Collapse.Panel;
2733
+ var PaymentForm = function (_a) {
2734
+ var entityId = _a.entityId, invoice = _a.invoice, onFail = _a.onFail, onPaymentSuccess = _a.onPaymentSuccess, quote = _a.quote, accountId = _a.accountId, onSavePaymentMethod = _a.onSavePaymentMethod, overrideToken = _a.overrideToken, graphQLClient = _a.graphQLClient, customCheckoutFunction = _a.customCheckoutFunction;
2735
+ // Local state
2736
+ var _b = useState(), selectedPaymentMethod = _b[0], setSelectedPaymentMethod = _b[1];
2737
+ var _c = useState(false), showPaymentMethodForm = _c[0], setShowPaymentMethodForm = _c[1];
2738
+ var paying = !!(quote || invoice);
2739
+ // Hooks
2740
+ var apiHost = useContext$1(BunnyContext).apiHost;
2741
+ var token = useToken();
2742
+ var storedPaymentMethod = usePaymentMethod(graphQLClient).data;
2743
+ var isPaymentMethodFetched = storedPaymentMethod !== undefined;
2744
+ var _d = usePaymentPlugins({ entityId: entityId, apiHost: apiHost, token: overrideToken || token }), paymentMethodAllowedPlugins = _d.paymentMethodAllowedPlugins, arePluginsFetched = _d.isFetched;
2745
+ var onClickRemove = useRemovePaymentMethod(paymentMethodAllowedPlugins || [], overrideToken || token, apiHost, accountId);
2746
+ var queryClient = useQueryClient();
2747
+ // Set default plugin
2870
2748
  useEffect(function () {
2871
- if (pdfBlob) {
2872
- var url_1 = URL.createObjectURL(pdfBlob);
2873
- setPdfUrl(url_1);
2874
- return function () { return URL.revokeObjectURL(url_1); };
2749
+ if (!arePluginsFetched ||
2750
+ !isPaymentMethodFetched ||
2751
+ selectedPaymentMethod) {
2752
+ return;
2875
2753
  }
2876
- }, [pdfBlob]);
2877
- if (isLoading || !pdfUrl)
2878
- return jsx(Fragment, {});
2879
- return (jsx("iframe", { src: pdfUrl, style: {
2880
- border: "none",
2881
- gridColumn: "1/-1",
2882
- minHeight: "1000px",
2883
- minWidth: "780px",
2884
- }, title: "Invoice PDF", width: "100%" }));
2754
+ var pluginPaymentMethod = paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.find(function (plugin) { var _a, _b, _c; return ((_a = plugin.id) === null || _a === void 0 ? void 0 : _a.toString()) === ((_c = (_b = storedPaymentMethod === null || storedPaymentMethod === void 0 ? void 0 : storedPaymentMethod.plugin) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.toString()); });
2755
+ if (pluginPaymentMethod) {
2756
+ setSelectedPaymentMethod(pluginPaymentMethod);
2757
+ }
2758
+ else if (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]) {
2759
+ setSelectedPaymentMethod(paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins[0]);
2760
+ }
2761
+ }, [
2762
+ arePluginsFetched,
2763
+ isPaymentMethodFetched,
2764
+ paymentMethodAllowedPlugins,
2765
+ selectedPaymentMethod,
2766
+ setSelectedPaymentMethod,
2767
+ storedPaymentMethod,
2768
+ ]);
2769
+ var showPaymentMethodSelector = useMemo(function () {
2770
+ var pluginCount = (paymentMethodAllowedPlugins === null || paymentMethodAllowedPlugins === void 0 ? void 0 : paymentMethodAllowedPlugins.length) || 0;
2771
+ return pluginCount > 1;
2772
+ }, [paymentMethodAllowedPlugins]);
2773
+ var handlePaymentSuccess = function () {
2774
+ // Hide payment method selector and form
2775
+ setShowPaymentMethodForm(false);
2776
+ onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess();
2777
+ };
2778
+ var handleSavePaymentMethod = function () {
2779
+ queryClient.invalidateQueries({
2780
+ queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
2781
+ });
2782
+ onSavePaymentMethod === null || onSavePaymentMethod === void 0 ? void 0 : onSavePaymentMethod();
2783
+ setShowPaymentMethodForm(false);
2784
+ };
2785
+ return (jsx(PaymentContext.Provider, __assign({ value: {
2786
+ onClickCancel: function () { return setShowPaymentMethodForm(false); },
2787
+ accountId: accountId,
2788
+ overrideToken: overrideToken,
2789
+ storedPaymentMethod: storedPaymentMethod,
2790
+ customCheckoutFunction: customCheckoutFunction,
2791
+ } }, { children: jsx(StripeWrapper, __assign({ plugin: selectedPaymentMethod, token: token, apiHost: apiHost, accountId: accountId }, { children: jsx("div", __assign({ className: "flex flex-col gap-0 w-full" }, { children: jsxs(Fragment, { children: [jsx("div", __assign({ className: "px-4" }, { children: jsx(MiniCreditCard, { onClickRemove: function () { return onClickRemove(storedPaymentMethod); }, paymentMethodData: storedPaymentMethod }) })), paying && storedPaymentMethod ? (jsx("div", __assign({ className: "px-4" }, { children: jsx(CheckoutFooter, { quote: quote, invoice: invoice, onPaymentSuccess: handlePaymentSuccess, plugin: selectedPaymentMethod }) }))) : (
2792
+ //if not paying and payment method is saved, show Collapse
2793
+ jsx(Collapse, __assign({ bordered: false, activeKey: showPaymentMethodForm ? "1" : undefined, ghost: true, collapsible: "disabled", destroyInactivePanel: true }, { children: jsx(Panel, __assign({ header: jsx(Fragment, { children: !showPaymentMethodForm ? (jsx("div", __assign({ className: "pt-2" }, { children: jsxs(Button$1, __assign({ onClick: function () {
2794
+ setShowPaymentMethodForm(true);
2795
+ }, type: "default", className: "w-full" }, { children: [storedPaymentMethod ? "Update" : "Add", " payment method"] })) }))) : null }), showArrow: false }, { children: jsx("div", { children: selectedPaymentMethod ? (jsxs("div", __assign({ className: "flex flex-col gap-2 mt-2" }, { children: [showPaymentMethodSelector && (jsx(PaymentMethodSelector, { onSelect: setSelectedPaymentMethod, paymentMethodAllowedPlugins: paymentMethodAllowedPlugins, value: selectedPaymentMethod })), jsx("div", __assign({ className: "flex flex-col" }, { children: jsx(PaymentMethodDetails, { onFail: onFail, onSavePaymentMethod: handleSavePaymentMethod, paymentMethod: selectedPaymentMethod }) }))] }))) : (jsx("div", { children: "No payment method selected" })) }) }), "1") })))] }) })) })) })));
2796
+ };
2797
+ function StripeWrapper(_a) {
2798
+ var children = _a.children, plugin = _a.plugin, token = _a.token, apiHost = _a.apiHost, accountId = _a.accountId;
2799
+ var _b = useStripePlugin(plugin, token, apiHost, accountId), stripe = _b.stripe, options = _b.options;
2800
+ return (jsx(Elements, __assign({ options: options, stripe: stripe }, { children: children })));
2885
2801
  }
2886
2802
 
2887
2803
  function Invoice(_a) {
@@ -2902,10 +2818,13 @@ function Invoice(_a) {
2902
2818
  function ActualInvoice() {
2903
2819
  // Context
2904
2820
  var queryClient = useQueryClient();
2905
- var _a = useContext$1(InvoiceQuoteContext), id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onPaymentSuccess = _a.onPaymentSuccess, entityId = _a.entityId, className = _a.className;
2906
- var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, token = _b.token, onTokenExpired = _b.onTokenExpired;
2821
+ var _a = useContext$1(InvoiceQuoteContext), id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick,
2822
+ // onPaymentSuccess,
2823
+ entityId = _a.entityId, className = _a.className;
2824
+ var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired, graphQLClient = _b.graphQLClient;
2825
+ var token = useToken();
2907
2826
  // Local state
2908
- var isMobile = useIsMobile();
2827
+ var isMobile = useIsMobile(BreakpointNumbers.lg);
2909
2828
  // Hooks
2910
2829
  var showSuccessNotification = useSuccessNotification();
2911
2830
  var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
@@ -2921,19 +2840,17 @@ function ActualInvoice() {
2921
2840
  }
2922
2841
  if (!formattedInvoice)
2923
2842
  return jsx(Fragment, {});
2924
- var onSuccess = function (_a) {
2925
- var savePaymentMethod = _a.savePaymentMethod;
2926
- if (savePaymentMethod)
2927
- queryClient.invalidateQueries({
2928
- queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
2929
- });
2843
+ var onSuccess = function () {
2844
+ // queryClient.invalidateQueries({
2845
+ // queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
2846
+ // });
2930
2847
  queryClient.invalidateQueries({
2931
2848
  queryKey: QueryKeyFactory.default.transactionsKey(),
2932
2849
  });
2933
2850
  queryClient.invalidateQueries({
2934
2851
  queryKey: QueryKeyFactory.default.createFormattedInvoiceKey(token, id),
2935
2852
  });
2936
- onPaymentSuccess === null || onPaymentSuccess === void 0 ? void 0 : onPaymentSuccess(savePaymentMethod);
2853
+ // onPaymentSuccess?.(savePaymentMethod);
2937
2854
  showSuccessNotification("Your invoice has been paid", "Payment successful");
2938
2855
  };
2939
2856
  var onFail = function (error) {
@@ -2942,9 +2859,7 @@ function ActualInvoice() {
2942
2859
  return (jsxs(Fragment, { children: [jsxs(Helmet, { children: [jsxs("title", { children: [formattedInvoice.vendorName, " ", DOCUMENT_NAME$1.INVOICE] }), jsx("meta", { name: "description", content: quoteMetaDescription(formattedInvoice.vendorName) }), jsx("meta", { property: "og:type", content: "website" }), jsx("meta", { property: "og:title", content: quoteMetaTitle({
2943
2860
  vendorName: formattedInvoice.vendorName,
2944
2861
  documentName: DOCUMENT_NAME$1.INVOICE,
2945
- }) }), jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedInvoice.vendorName) })] }), jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), !isMobile && isInvoicePayable && (jsx(Divider, { className: "h-full", type: "vertical" })), isInvoicePayable && (jsx(InvoiceCheckout, { invoice: formattedInvoice, onFail: function (error) {
2946
- onFail(error);
2947
- }, onSuccess: onSuccess, entityId: entityId }))] }))] }));
2862
+ }) }), jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedInvoice.vendorName) })] }), jsxs("div", __assign({ className: "flex gap-6 ".concat(isMobile ? "flex-col w-full overflow-hidden" : "shadow-padding-xb", " ").concat(className) }, { children: [formattedInvoice.isLegacy ? (jsx("div", __assign({ className: "flex justify-center w-full" }, { children: jsx(InvoicePDF, { invoiceUuid: formattedInvoice.uuid, apiHost: apiHost }) }))) : (invoiceQuoteViewComponent || (jsx(InvoiceQuoteView, { html: formattedInvoice.html, formattedInvoice: formattedInvoice, backButtonName: backButtonName, onBackButtonClick: onBackButtonClick }))), isInvoicePayable && (jsx("div", __assign({ className: "w-full pt-12" }, { children: jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: formattedInvoice, graphQLClient: graphQLClient }) })))] }))] }));
2948
2863
  }
2949
2864
 
2950
2865
  var MUTATION$7 = function (id) { return "\n query formattedQuote ($id: ID) {\n formattedQuote (id: $id) {\n payableId\n acceptedAt\n acceptedByName\n amount\n amountDue\n amountsByPeriod {\n id\n name\n amount\n }\n object { documents { id filename size date url } }\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n contactName\n currency\n customerBillingCity\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n discount\n discountValue\n duration\n endDate\n expiresAt\n html\n formattedLines {\n amount\n amountsByPeriod {\n quantity\n id\n name\n startDate\n endDate\n amount\n amountsByTier {\n id\n tier {\n starts\n ends\n price\n }\n quantity\n amount\n }\n prorationRate\n }\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n isRamp\n periods\n planName\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListId\n priceListName\n priceTiers {\n price\n starts\n }\n pricingModel\n productName\n prorationRate\n quantity\n showProductNameOnLineItem\n taxCode\n trialEndDate\n trialStartDate\n unitOfMeasure\n vatCode\n }\n netPaymentDays\n notes\n number\n poNumberRequired\n salesContactEmail\n sharedAt\n startDate\n state\n subtotal\n taxAmount\n taxNumberLabel\n taxNumberRequired\n vendorName\n }\n }"; };
@@ -3111,7 +3026,8 @@ var useIsExpired = function (expiresAt) {
3111
3026
 
3112
3027
  var PandadocPollingModal = function (_a) {
3113
3028
  var isVisible = _a.isVisible, setVisible = _a.setVisible, id = _a.id;
3114
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired;
3029
+ var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, onTokenExpired = _b.onTokenExpired;
3030
+ var token = useToken();
3115
3031
  var graphQLMutation = useGraphQLmutation(function () {
3116
3032
  console.log("graphQLMutation navigateOnTokenExpired not yet implemented");
3117
3033
  }, apiHost || "", function () {
@@ -3197,7 +3113,7 @@ var DOCUMENT_NAME;
3197
3113
  DOCUMENT_NAME["QUOTE"] = "quote";
3198
3114
  })(DOCUMENT_NAME || (DOCUMENT_NAME = {}));
3199
3115
 
3200
- var Text$c = Typography.Text;
3116
+ var Text$d = Typography.Text;
3201
3117
  var documentName = DOCUMENT_NAME.QUOTE;
3202
3118
  styled.div(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n span {\n width: 100%;\n }\n"], ["\n span {\n width: 100%;\n }\n"])));
3203
3119
  function Quote(_a) {
@@ -3218,7 +3134,8 @@ function ActualQuote(_a) {
3218
3134
  var _b, _c;
3219
3135
  var entityId = _a.entityId;
3220
3136
  // Context
3221
- var _d = useContext$1(BunnyContext), token = _d.token, apiHost = _d.apiHost, onTokenExpired = _d.onTokenExpired;
3137
+ var _d = useContext$1(BunnyContext), apiHost = _d.apiHost, onTokenExpired = _d.onTokenExpired;
3138
+ var token = useToken();
3222
3139
  var entityBranding = useContext$1(BrandContext);
3223
3140
  var _e = useContext$1(InvoiceQuoteContext), className = _e.className, id = _e.id, hideDownloadButton = _e.hideDownloadButton;
3224
3141
  // Queries
@@ -3266,7 +3183,7 @@ function ActualQuote(_a) {
3266
3183
  documentName: documentName,
3267
3184
  }) }), jsx("meta", { property: "og:description", content: quoteMetaDescription(formattedQuote.vendorName) })] }), jsxs("div", __assign({ className: "flex flex-col gap-4 ".concat(className) }, { children: [jsxs("div", __assign({ className: "flex flex-row justify-end items-center gap-4", id: "acceptance", style: {
3268
3185
  color: entityBranding.secondaryColor,
3269
- } }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsx(Text$c, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxs("div", __assign({ className: isMobile
3186
+ } }, { children: [isAccepted && formattedQuote.acceptedAt ? (jsx(Text$d, { children: "Quote was accepted by ".concat(formattedQuote.acceptedByName, " on ").concat(formatDate(formattedQuote.acceptedAt)) })) : null, (!isMobile || !isAccepted) && (jsxs("div", __assign({ className: isMobile
3270
3187
  ? "flex w-full justify-end gap-2"
3271
3188
  : "flex items-center justify-end gap-2" }, { children: [!isMobile && !hideDownloadButton ? (jsx(Button$1, __assign({ icon: jsx(DownloadOutlined$1, {}), onClick: function () {
3272
3189
  return downloadFile(apiHost + "/api/pdf/quote", token);
@@ -3361,10 +3278,10 @@ var getColor = function (state) {
3361
3278
  }
3362
3279
  };
3363
3280
 
3364
- var Text$b = Typography.Text;
3281
+ var Text$c = Typography.Text;
3365
3282
  var TransactionDate = function (_a) {
3366
3283
  var date = _a.date;
3367
- return jsx(Text$b, __assign({ className: "text-sm" }, { children: formatDate(date) }));
3284
+ return jsx(Text$c, __assign({ className: "text-sm" }, { children: formatDate(date) }));
3368
3285
  };
3369
3286
 
3370
3287
  // TODO: delete
@@ -3398,10 +3315,10 @@ var TransactionGridCell = styled.div.withConfig({
3398
3315
  })(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n ", "\n\n display: flex;\n align-items: center;\n justify-content: ", ";\n\n text-align: ", ";\n white-space: nowrap;\n font-size: 14px;\n color: ", ";\n\n background-color: inherit;\n\n padding: 1rem;\n min-width: 48px;\n"], ["\n ", "\n\n display: flex;\n align-items: center;\n justify-content: ", ";\n\n text-align: ", ";\n white-space: nowrap;\n font-size: 14px;\n color: ", ";\n\n background-color: inherit;\n\n padding: 1rem;\n min-width: 48px;\n"])), function (props) { return props.gridColumn && "grid-column: ".concat(props.gridColumn, ";"); }, function (props) { return (props.right ? "flex-end" : "flex-start"); }, function (props) { return (props.right ? "right" : "left"); }, SLATE_600);
3399
3316
  var templateObject_1$3;
3400
3317
 
3401
- var Text$a = Typography.Text;
3318
+ var Text$b = Typography.Text;
3402
3319
  var TransactionsEmptyState = function () {
3403
3320
  var noTransactionsMessage = useContext$1(TransactionsListContext).noTransactionsMessage;
3404
- return (jsx(Text$a, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
3321
+ return (jsx(Text$b, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
3405
3322
  };
3406
3323
 
3407
3324
  var isInvoice = function (transaction) {
@@ -3418,11 +3335,12 @@ var TransactionRowTitle = function (_a) {
3418
3335
  return (jsx("span", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
3419
3336
  };
3420
3337
 
3421
- var Text$9 = Typography.Text;
3338
+ var Text$a = Typography.Text;
3422
3339
  var TransactionsListDesktop = function (_a) {
3423
3340
  var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
3424
3341
  var columns = useContext$1(TransactionsListContext).columns;
3425
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost, darkMode = _b.darkMode;
3342
+ var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, darkMode = _b.darkMode;
3343
+ var token = useToken();
3426
3344
  var showAmount = columns.includes("amount");
3427
3345
  var showDateAndTitle = columns.includes("date-and-title");
3428
3346
  var showDownload = columns.includes("download");
@@ -3438,15 +3356,16 @@ var TransactionsListDesktop = function (_a) {
3438
3356
  backgroundColor: index % 2 === 0
3439
3357
  ? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
3440
3358
  : "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
3441
- } }, { children: [!showDateAndTitle && !showState && !showAmount && !showDownload && (jsx(TransactionGridCell, { children: jsx(Text$9, { children: "No columns selected" }) })), showDateAndTitle && (jsxs(Fragment, { children: [jsx(TransactionGridCell, __assign({ right: false }, { children: jsx(TransactionDate, { date: transaction.createdAt }) })), jsxs(TransactionGridCell, __assign({ right: false, className: "flex items-center gap-2" }, { children: [jsx(Text$9, { children: capitalize(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsx(TransactionGridCell, { children: jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })), showState ? (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(StateTag, { state: transaction.state }) }))) : null, showAmount && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(Text$9, { children: formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
3359
+ } }, { children: [!showDateAndTitle && !showState && !showAmount && !showDownload && (jsx(TransactionGridCell, { children: jsx(Text$a, { children: "No columns selected" }) })), showDateAndTitle && (jsxs(Fragment, { children: [jsx(TransactionGridCell, __assign({ right: false }, { children: jsx(TransactionDate, { date: transaction.createdAt }) })), jsxs(TransactionGridCell, __assign({ right: false, className: "flex items-center gap-2" }, { children: [jsx(Text$a, { children: capitalize(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsx(TransactionGridCell, { children: jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })), showState ? (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(StateTag, { state: transaction.state }) }))) : null, showAmount && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(Text$a, { children: formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
3442
3360
  });
3443
3361
  };
3444
3362
 
3445
- var Text$8 = Typography.Text;
3363
+ var Text$9 = Typography.Text;
3446
3364
  var TransactionsListMobile = function (_a) {
3447
3365
  var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
3448
3366
  var columns = useContext$1(TransactionsListContext).columns;
3449
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost, darkMode = _b.darkMode;
3367
+ var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, darkMode = _b.darkMode;
3368
+ var token = useToken();
3450
3369
  var showAmount = columns.includes("amount");
3451
3370
  var showDateAndTitle = columns.includes("date-and-title");
3452
3371
  var showDownload = columns.includes("download");
@@ -3461,11 +3380,11 @@ var TransactionsListMobile = function (_a) {
3461
3380
  backgroundColor: index % 2 === 0
3462
3381
  ? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
3463
3382
  : "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
3464
- } }, { children: [jsx(TransactionGridCell, { children: jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxs(Fragment, { children: [jsx(Text$8, { children: capitalize(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] })), showState && jsx(StateTag, { state: transaction.state })] })), jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsx(TransactionDate, { date: transaction.createdAt })), showAmount && showDateAndTitle && jsx(Text$8, { children: "\u00B7" }), showAmount && (jsx(Text$8, { children: formatCurrency(transaction.transactionable.amount || transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })))] }), index));
3383
+ } }, { children: [jsx(TransactionGridCell, { children: jsxs("div", __assign({ className: "flex flex-col gap-2" }, { children: [jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsxs(Fragment, { children: [jsx(Text$9, { children: capitalize(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] })), showState && jsx(StateTag, { state: transaction.state })] })), jsxs("div", __assign({ className: "flex items-center gap-2" }, { children: [showDateAndTitle && (jsx(TransactionDate, { date: transaction.createdAt })), showAmount && showDateAndTitle && jsx(Text$9, { children: "\u00B7" }), showAmount && (jsx(Text$9, { children: formatCurrency(transaction.transactionable.amount || transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(TransactionDownload, { transaction: transaction, token: token, apiHost: apiHost }) })))] }), index));
3465
3384
  });
3466
3385
  };
3467
3386
 
3468
- var Text$7 = Typography.Text;
3387
+ var Text$8 = Typography.Text;
3469
3388
  var DISPLAY_WIDTH = 1200;
3470
3389
  function Transactions(_a) {
3471
3390
  var transactionComponent = _a.transactionComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.title, title = _d === void 0 ? "Past transactions" : _d, _e = _a.columns, columns = _e === void 0 ? ["date-and-title", "state", "amount", "download"] : _e, className = _a.className, _f = _a.shadow, shadow = _f === void 0 ? "shadow-md" : _f, searchBarClassName = _a.searchBarClassName, _g = _a.useModal, useModal = _g === void 0 ? false : _g, onTransactionClick = _a.onTransactionClick, _h = _a.suppressTransactionDisplay, suppressTransactionDisplay = _h === void 0 ? false : _h, _j = _a.kindsToShow, kindsToShow = _j === void 0 ? [
@@ -3473,7 +3392,9 @@ function Transactions(_a) {
3473
3392
  TransactionKind.PAYMENT,
3474
3393
  TransactionKind.REFUND,
3475
3394
  TransactionKind.WRITE_OFF,
3476
- ] : _j, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage, entityId = _a.entityId, filterTransactions = _a.filterTransactions, sortTransactions = _a.sortTransactions;
3395
+ ] : _j, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage, entityId = _a.entityId, filterTransactions = _a.filterTransactions, _k = _a.sortTransactions, sortTransactions = _k === void 0 ? function (a, b) {
3396
+ return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
3397
+ } : _k;
3477
3398
  var contextValues = {
3478
3399
  showSearchBar: showSearchBar,
3479
3400
  showTitle: showTitle,
@@ -3494,7 +3415,8 @@ function Transactions(_a) {
3494
3415
  filterTransactions: filterTransactions,
3495
3416
  sortTransactions: sortTransactions,
3496
3417
  };
3497
- var _k = useContext$1(BunnyContext), token = _k.token, apiHost = _k.apiHost;
3418
+ var apiHost = useContext$1(BunnyContext).apiHost;
3419
+ var token = useToken();
3498
3420
  // Local state
3499
3421
  var _l = useState(""), search = _l[0], setSearch = _l[1];
3500
3422
  var filterValue = filter ||
@@ -3571,7 +3493,7 @@ function TransactionsDisplay(_a) {
3571
3493
  onTransactionDisplayClose === null || onTransactionDisplayClose === void 0 ? void 0 : onTransactionDisplayClose(selectedTransaction);
3572
3494
  setDrawerOpen(false);
3573
3495
  }
3574
- return (jsxs("div", __assign({ style: style }, { children: [jsxs("div", __assign({ className: "flex flex-col w-full shadow-padding-xb gap-2 ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: [showTitle || showSearchBar ? (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col gap-1" : "flex-row items-center", " justify-between") }, { children: [showTitle ? (jsx(Text$7, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title }))) : (jsx("div", {}) // Empty div so justify-between works
3496
+ return (jsxs("div", __assign({ style: style }, { children: [jsxs("div", __assign({ className: "flex flex-col w-full shadow-padding-xb gap-2 ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: [showTitle || showSearchBar ? (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col gap-1" : "flex-row items-center", " justify-between") }, { children: [showTitle ? (jsx(Text$8, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title }))) : (jsx("div", {}) // Empty div so justify-between works
3575
3497
  ), showSearchBar && (jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "") }, { children: jsx(Input, { className: searchBarClassName
3576
3498
  ? searchBarClassName
3577
3499
  : "border border-slate-200", onChange: function (e) {
@@ -3590,7 +3512,7 @@ function TransactionsDisplay(_a) {
3590
3512
  }) })) : (jsx(Fragment, { children: TransactionsListDesktop({
3591
3513
  transactions: updatedTransactions,
3592
3514
  onTransactionClick: handleTransactionClick,
3593
- }) })) }))] })), useModal ? (jsx(Modal, __assign({ title: "Basic Modal", open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null }, { children: jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "", entityId: entityId }) }))) : (jsx(Drawer, __assign({ title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsx(Invoice, { id: selectedTransaction.transactionableId, entityId: entityId })) : (jsxs(Card$1, __assign({ className: "shadow-md" }, { children: [jsx(Typography.Title, __assign({ level: 2, className: "mb-4" }, { children: "Transaction Details" })), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Amount:" }), " ", jsx(Typography.Text, { children: formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || "USD") })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Description:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Kind:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "State:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] }))) })))] })));
3515
+ }) })) }))] })), useModal ? (jsx(Modal, __assign({ title: drawerTitle(), open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null }, { children: jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "", entityId: entityId }) }))) : (jsx(Drawer, __assign({ title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsx(Invoice, { id: selectedTransaction.transactionableId, entityId: entityId })) : (jsxs(Card$1, __assign({ className: "shadow-md" }, { children: [jsx(Typography.Title, __assign({ level: 2, className: "mb-4" }, { children: "Transaction Details" })), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Amount:" }), " ", jsx(Typography.Text, { children: formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || "USD") })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Description:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Kind:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "State:" }), " ", jsx(Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] }))) })))] })));
3594
3516
  }
3595
3517
 
3596
3518
  function Quotes(_a) {
@@ -3656,10 +3578,11 @@ function Quotes(_a) {
3656
3578
  return (jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsx(QuotesWrapper, {}) })));
3657
3579
  }
3658
3580
  function QuotesWrapper() {
3659
- var _a = useContext$1(BunnyContext), token = _a.token, apiHost = _a.apiHost;
3581
+ var apiHost = useContext$1(BunnyContext).apiHost;
3582
+ var token = useToken();
3660
3583
  var filterFromContext = useContext$1(TransactionsListContext).filter;
3661
3584
  // Local state
3662
- var _b = useState(""), search = _b[0], setSearch = _b[1];
3585
+ var _a = useState(""), search = _a[0], setSearch = _a[1];
3663
3586
  var filter = filterFromContext || (search ? "filter: \"quote.id is ".concat(search, "\"") : "");
3664
3587
  // Queries
3665
3588
  var data = useQuery({
@@ -3687,14 +3610,16 @@ function QuotesWrapper() {
3687
3610
  return (jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search }));
3688
3611
  }
3689
3612
 
3613
+ var Text$7 = Typography.Text;
3690
3614
  var DrawerHeader = function (_a) {
3691
3615
  var description = _a.description, onClose = _a.onClose, title = _a.title;
3692
- return (jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsx("div", __assign({ className: "text-xl" }, { children: title })), jsx("button", __assign({ onClick: onClose, className: "ant-drawer-close" }, { children: jsx(CloseOutlined$1, {}) }))] })), description && jsx("div", __assign({ className: "text-xs" }, { children: description }))] })));
3616
+ return (jsxs("div", __assign({ className: "flex flex-col gap-4" }, { children: [jsxs("div", __assign({ className: "flex items-center justify-between gap-2" }, { children: [jsx(Text$7, __assign({ className: "text-xl", style: { fontWeight: 400 } }, { children: title })), jsx("button", __assign({ onClick: onClose, className: "ant-drawer-close" }, { children: jsx(CloseOutlined$1, {}) }))] })), description && jsx("div", __assign({ className: "text-xs" }, { children: description }))] })));
3693
3617
  };
3694
3618
 
3695
3619
  var PaymentMethod = function (_a) {
3696
3620
  var entityId = _a.entityId, className = _a.className, _b = _a.shadow, shadow = _b === void 0 ? "shadow-md" : _b, _c = _a.cardEnabled, cardEnabled = _c === void 0 ? true : _c;
3697
- var _d = useContext$1(BunnyContext), token = _d.token, apiHost = _d.apiHost, graphQLClient = _d.graphQLClient, onTokenExpired = _d.onTokenExpired;
3621
+ var _d = useContext$1(BunnyContext), apiHost = _d.apiHost, graphQLClient = _d.graphQLClient, onTokenExpired = _d.onTokenExpired;
3622
+ var token = useToken();
3698
3623
  // Hooks
3699
3624
  var queryClient = useQueryClient();
3700
3625
  var paymentPlugins = usePaymentPlugins({ entityId: entityId, apiHost: apiHost, token: token }).paymentPlugins;
@@ -3826,10 +3751,11 @@ var TaxationForm = function (_a) {
3826
3751
  var account = _a.account, quote = _a.quote;
3827
3752
  // Hooks
3828
3753
  var queryClient = useQueryClient();
3829
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost;
3754
+ var apiHost = useContext$1(BunnyContext).apiHost;
3755
+ var token = useToken();
3830
3756
  var form = Form.useForm()[0];
3831
3757
  // Mutations
3832
- var _c = useMutation({
3758
+ var _b = useMutation({
3833
3759
  mutationFn: function (changedFormData) { return __awaiter(void 0, void 0, void 0, function () {
3834
3760
  var account;
3835
3761
  return __generator(this, function (_a) {
@@ -3851,7 +3777,7 @@ var TaxationForm = function (_a) {
3851
3777
  queryKey: ["getTaxationRequiredAccountFields", token],
3852
3778
  });
3853
3779
  },
3854
- }), updateAccount = _c.mutate, isUpdatingAccount = _c.isPending;
3780
+ }), updateAccount = _b.mutate, isUpdatingAccount = _b.isPending;
3855
3781
  return (jsxs(Form, __assign({ className: "flex flex-col gap-4", form: form, initialValues: account, layout: "vertical", onFinish: updateAccount }, { children: [jsx(Form.Item, __assign({ label: "Billing street", name: "billingStreet" }, { children: jsx(Input, { placeholder: "Street" }) })), jsx(Form.Item, __assign({ label: "Billing city", name: "billingCity" }, { children: jsx(Input, { placeholder: "City" }) })), jsx(FormBillingState, { form: form }), jsx(Form.Item, __assign({ label: "Billing country", name: "billingCountry", rules: [{ required: true }] }, { children: jsx(Select, { options: Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
3856
3782
  var _a, _b;
3857
3783
  return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(input.toLowerCase()) ||
@@ -3867,86 +3793,41 @@ var FormBillingState = function (_a) {
3867
3793
 
3868
3794
  var QuoteCheckout = function (_a) {
3869
3795
  var account = _a.account, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, taxationRequiredAccountFields = _a.taxationRequiredAccountFields, entityId = _a.entityId;
3870
- // Context
3796
+ var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, graphQLClient = _b.graphQLClient;
3797
+ var token = useToken();
3871
3798
  var isMobile = useIsMobile();
3872
- var _b = useContext$1(BunnyContext), apiHost = _b.apiHost, token = _b.token, graphQLClient = _b.graphQLClient;
3873
3799
  var _c = useState(false), isSaving = _c[0], setIsSaving = _c[1];
3874
3800
  var paymentRequired = getQuoteAmountDue(quote) > 0;
3875
3801
  var checkoutMutation = useMutation({
3876
- mutationFn: function (_a) {
3877
- var pluginPaymentMethod = _a.pluginPaymentMethod, savedPaymentMethod = _a.storedPaymentMethod;
3878
- if (!quote)
3879
- throw new Error("Quote is required");
3880
- if (!paymentRequired)
3881
- return checkout({ quoteId: quote.id, token: token, apiHost: apiHost });
3882
- if (savedPaymentMethod) {
3883
- var paymentMethodId = savedPaymentMethod.paymentMethodId;
3884
- return checkout({
3885
- quoteId: quote.id,
3886
- paymentMethodId: paymentMethodId,
3887
- token: token,
3888
- apiHost: apiHost,
3889
- });
3890
- }
3891
- if (pluginPaymentMethod) {
3892
- var plugin = pluginPaymentMethod.plugin, savePaymentMethod = pluginPaymentMethod.savePaymentMethod, metadata = pluginPaymentMethod.metadata;
3893
- var paymentToken = pluginPaymentMethod.token;
3894
- return checkout({
3895
- quoteId: quote.id,
3896
- paymentMethodData: {
3897
- metadata: metadata,
3898
- pluginGuid: plugin.guid,
3899
- savePaymentMethod: savePaymentMethod,
3900
- token: paymentToken,
3901
- },
3902
- token: token,
3903
- apiHost: apiHost,
3904
- });
3905
- }
3906
- throw new Error("Pay payment method provided");
3907
- },
3802
+ mutationFn: function () { return __awaiter(void 0, void 0, void 0, function () {
3803
+ return __generator(this, function (_a) {
3804
+ switch (_a.label) {
3805
+ case 0:
3806
+ if (!quote)
3807
+ throw new Error("Quote is required");
3808
+ if (paymentRequired)
3809
+ throw new Error("Payment is required");
3810
+ return [4 /*yield*/, checkout({ quoteId: quote.id, token: token, apiHost: apiHost })];
3811
+ case 1: return [2 /*return*/, _a.sent()];
3812
+ }
3813
+ });
3814
+ }); },
3908
3815
  onSuccess: onSuccess,
3909
3816
  onError: onFail,
3910
3817
  });
3911
- // Handlers
3912
- var handleCheckout = function (_a) {
3913
- var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
3914
- return __awaiter(void 0, void 0, void 0, function () {
3915
- var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
3916
- return __generator(this, function (_b) {
3818
+ function handleCheckoutNoPayment() {
3819
+ return __awaiter(this, void 0, void 0, function () {
3820
+ return __generator(this, function (_a) {
3917
3821
  setIsSaving(true);
3918
- if (pluginPaymentResponse) {
3919
- token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
3920
- checkoutMutation.mutate({
3921
- pluginPaymentMethod: {
3922
- savePaymentMethod: savePaymentMethod,
3923
- plugin: plugin,
3924
- metadata: metadata,
3925
- token: token_1,
3926
- },
3927
- });
3928
- }
3929
- else if (savedPaymentMethodResponse) {
3930
- paymentMethodId = savedPaymentMethodResponse.paymentMethodId;
3931
- checkoutMutation.mutate({
3932
- storedPaymentMethod: {
3933
- paymentMethodId: paymentMethodId,
3934
- },
3935
- });
3936
- }
3937
- else {
3938
- checkoutMutation.mutate({});
3939
- }
3822
+ checkoutMutation.mutate();
3940
3823
  setIsSaving(false);
3941
3824
  return [2 /*return*/];
3942
3825
  });
3943
3826
  });
3944
- };
3827
+ }
3945
3828
  if (taxationRequiredAccountFields)
3946
3829
  return (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsx(TaxationForm, { account: account, quote: quote }) })));
3947
- return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: handleCheckout, quote: quote, graphQLClient: graphQLClient })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsx(Button$1, __assign({ onClick: function () {
3948
- handleCheckout({});
3949
- }, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
3830
+ return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { entityId: entityId, onFail: onFail, onPaymentSuccess: onSuccess, quote: quote, graphQLClient: graphQLClient })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsx(Button$1, __assign({ onClick: handleCheckoutNoPayment, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
3950
3831
  };
3951
3832
  var PaymentFormWrapper = function (_a) {
3952
3833
  var children = _a.children, setMaxHeight = _a.setMaxHeight, className = _a.className;
@@ -4023,55 +3904,11 @@ var Checkout = function (_a) {
4023
3904
  return null;
4024
3905
  return (jsx("div", __assign({ className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 bg-slate-50 overflow-auto", style: {
4025
3906
  zIndex: 1001,
4026
- } }, { children: jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsx(CloseOutlined$1, { className: "text-base shadow-padding-xb", onClick: onCancel }) })), jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "shadow-padding-xb") }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsx(InvoiceQuoteView, { html: invoice ? invoice.html : quote ? quote.formattedQuote.html : "" })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsx(Divider, { className: "h-full", type: "vertical" })), invoice ? (jsx(InvoiceCheckout, { invoice: invoice, onFail: function (error) {
4027
- onFail(error);
4028
- }, onSuccess: function (_a) {
4029
- var savePaymentMethod = _a.savePaymentMethod;
4030
- onSuccess({ savePaymentMethod: savePaymentMethod });
4031
- }, entityId: entityId })) : quote ? (jsx(QuoteCheckout, { account: account, entityId: entityId, onFail: function (error) {
3907
+ } }, { children: jsxs("div", __assign({ className: pageWrapperClassName(isMobile) }, { children: [jsx("div", __assign({ className: "flex justify-end w-full" }, { children: jsx(CloseOutlined$1, { className: "text-base shadow-padding-xb", onClick: onCancel }) })), jsxs("div", __assign({ className: "flex justify-end gap-6 pt-4 ".concat(isMobile ? "flex-col" : "shadow-padding-xb") }, { children: [((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_b = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _b === void 0 ? void 0 : _b.html)) && (jsx(InvoiceQuoteView, { html: invoice ? invoice.html : quote ? quote.formattedQuote.html : "" })), !isMobile && ((invoice === null || invoice === void 0 ? void 0 : invoice.html) || ((_c = quote === null || quote === void 0 ? void 0 : quote.formattedQuote) === null || _c === void 0 ? void 0 : _c.html)) && (jsx(Divider, { className: "h-full", type: "vertical" })), invoice ? (jsx("div", __assign({ className: "w-full pt-12" }, { children: jsx(PaymentForm, { entityId: entityId, onPaymentSuccess: onSuccess, onFail: onFail, invoice: invoice, graphQLClient: graphQLClient }) }))) : quote ? (jsx(QuoteCheckout, { account: account, entityId: entityId, onFail: function (error) {
4032
3908
  onFail(error);
4033
- }, onSuccess: function (_a) {
4034
- var savePaymentMethod = _a.savePaymentMethod;
4035
- onSuccess({ savePaymentMethod: savePaymentMethod });
4036
- }, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
3909
+ }, onSuccess: onSuccess, quote: quote, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token })) : (jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
4037
3910
  onFail(error);
4038
- }, onPaymentSuccess: function (_a) {
4039
- var pluginPaymentResponse = _a.pluginPaymentResponse;
4040
- onSuccess({
4041
- savePaymentMethod: pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.savePaymentMethod,
4042
- });
4043
- }, graphQLClient: graphQLClient }))] }))] })) })));
4044
- };
4045
-
4046
- var DEFAULT_HEADERS = {
4047
- "Content-type": "application/json; charset=utf-8",
4048
- };
4049
- // !!! Duplicated from @bunnyapp/common due to bug in signup. Uses BunnyProvider token instead of apiToken.
4050
- var gqlRequest = function (_a) {
4051
- var query = _a.query, _b = _a.vars, vars = _b === void 0 ? {} : _b, headers = _a.headers, token = _a.token, isInPreviewMode = _a.isInPreviewMode, apiHost = _a.apiHost;
4052
- return __awaiter(void 0, void 0, void 0, function () {
4053
- var graphqlEndpoint, requestHeaders, authorizationHeader, error_1;
4054
- return __generator(this, function (_c) {
4055
- switch (_c.label) {
4056
- case 0:
4057
- console.log("token in gqlRequest", token);
4058
- _c.label = 1;
4059
- case 1:
4060
- _c.trys.push([1, 3, , 4]);
4061
- graphqlEndpoint = DEFAULT_CONFIG.graphqlEndpoint;
4062
- requestHeaders = headers || DEFAULT_HEADERS;
4063
- authorizationHeader = "Bearer ".concat(token);
4064
- if (!requestHeaders.Authorization && !isInPreviewMode)
4065
- requestHeaders.Authorization = authorizationHeader;
4066
- return [4 /*yield*/, request("".concat(apiHost).concat(graphqlEndpoint), query, vars, requestHeaders)];
4067
- case 2: return [2 /*return*/, _c.sent()];
4068
- case 3:
4069
- error_1 = _c.sent();
4070
- throw error_1;
4071
- case 4: return [2 /*return*/];
4072
- }
4073
- });
4074
- });
3911
+ }, onPaymentSuccess: onSuccess, graphQLClient: graphQLClient }))] }))] })) })));
4075
3912
  };
4076
3913
 
4077
3914
  var MUTATION$4 = function () { return "\nmutation AccountSignup (\n $entityId: ID!,\n $pluginId: String!,\n $paymentMethodId: String,\n $priceListCode: String!,\n $accountId: ID!,\n $quoteId: ID!\n) {\n accountSignup(\n entityId: $entityId,\n pluginId: $pluginId,\n paymentMethodId: $paymentMethodId,\n priceListCode: $priceListCode,\n accountId: $accountId,\n quoteId: $quoteId\n ) {\n errors\n quote {\n acceptedByName\n acceptedByTitle\n accountId\n amount\n amountDue\n applicationDate\n applied\n backdatedPeriods\n backdatedQuote\n billingDay\n contactId\n createdAt\n credits\n currencyId\n dealId\n discount\n discountValue\n endDate\n evergreen\n expiresAt\n id\n invoiceImmediately\n invoiceImmediatelyAvailable\n invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n number\n ownerId\n payableId\n periodAmount\n poNumber\n requiresApproval\n smallUnitAmountDue\n splitInvoice\n startDate\n state\n subtotal\n taxAmount\n taxCode\n updatedAt\n uuid\n }\n }\n}"; };
@@ -4117,14 +3954,12 @@ var portalSessionCreate = function (_a) {
4117
3954
  var _b;
4118
3955
  return __generator(this, function (_c) {
4119
3956
  switch (_c.label) {
4120
- case 0:
4121
- console.log("token in portalSessionCreate", token);
4122
- return [4 /*yield*/, gqlRequest({
4123
- query: MUTATION$3,
4124
- token: token,
4125
- vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
4126
- apiHost: apiHost,
4127
- })];
3957
+ case 0: return [4 /*yield*/, gqlRequest({
3958
+ query: MUTATION$3,
3959
+ token: token,
3960
+ vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
3961
+ apiHost: apiHost,
3962
+ })];
4128
3963
  case 1:
4129
3964
  response = _c.sent();
4130
3965
  errors = (response === null || response === void 0 ? void 0 : response.portalSessionCreate).errors;
@@ -4190,41 +4025,24 @@ var getPriceList = function (_a) {
4190
4025
  };
4191
4026
 
4192
4027
  function PaymentForms(_a) {
4193
- var quote = _a.quote, handlePaymentSaveSuccess = _a.handlePaymentSaveSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, entityId = _a.entityId, accountId = _a.accountId, overrideToken = _a.overrideToken;
4028
+ var quote = _a.quote, handlePaymentSuccess = _a.handlePaymentSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, entityId = _a.entityId, accountId = _a.accountId, overrideToken = _a.overrideToken, customCheckoutFunction = _a.customCheckoutFunction;
4194
4029
  var apiHost = useContext$1(BunnyContext).apiHost;
4195
- return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: overrideToken ? (jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSaveSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, graphQLClient: createGraphQLClient(overrideToken, apiHost) })) : null })) : (jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
4030
+ return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: overrideToken ? (jsx(PaymentForm, { entityId: entityId, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSuccess, accountId: accountId, quote: quote, overrideToken: overrideToken, graphQLClient: createGraphQLClient(overrideToken, apiHost), customCheckoutFunction: customCheckoutFunction })) : null })) : (jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
4196
4031
  }
4197
4032
  function InitialSignupForm(_a) {
4198
4033
  var onSubmit = _a.onSubmit, submitting = _a.submitting;
4199
- var _b = useState({
4200
- firstName: "",
4201
- lastName: "",
4202
- email: "",
4203
- accountName: "",
4204
- }), formData = _b[0], setFormData = _b[1];
4205
- var handleInputChange = function (e) {
4206
- var _a;
4207
- var _b = e.target, name = _b.name, value = _b.value;
4208
- setFormData(__assign(__assign({}, formData), (_a = {}, _a[name] = value, _a)));
4209
- };
4210
- return (jsxs(Form, __assign({ className: "flex flex-col justify-between h-full w-full", onFinish: function () { return onSubmit(formData); } }, { children: [jsxs("div", __assign({ className: "flex flex-col space-y-2" }, { children: [jsx(Form.Item, __assign({ rules: [{ required: true, message: "Please input your first name!" }], initialValue: formData.firstName }, { children: jsx(Input, { placeholder: "First name", value: formData.firstName, onChange: function (e) {
4211
- handleInputChange(e);
4212
- setFormData(__assign(__assign({}, formData), { firstName: e.target.value }));
4213
- } }) })), jsx(Form.Item, __assign({ rules: [{ required: true, message: "Please input your last name!" }], initialValue: formData.lastName }, { children: jsx(Input, { placeholder: "Last name", value: formData.lastName, onChange: function (e) {
4214
- handleInputChange(e);
4215
- setFormData(__assign(__assign({}, formData), { lastName: e.target.value }));
4216
- } }) })), jsx(Form.Item, __assign({ rules: [
4034
+ var form = Form.useForm()[0];
4035
+ function handleSubmit() {
4036
+ form.validateFields({ validateOnly: true }).then(function () {
4037
+ onSubmit(form.getFieldsValue());
4038
+ });
4039
+ }
4040
+ return (jsxs(Form, __assign({ className: "flex flex-col justify-between h-full w-full", onFinish: handleSubmit, form: form }, { children: [jsxs("div", __assign({ className: "flex flex-col space-y-2" }, { children: [jsx(Form.Item, __assign({ name: "firstName", validateTrigger: "onBlur", rules: [{ required: true, message: "Please input your first name!" }] }, { children: jsx(Input, { placeholder: "First name" }) })), jsx(Form.Item, __assign({ name: "lastName", validateTrigger: "onBlur", rules: [{ required: true, message: "Please input your last name!" }] }, { children: jsx(Input, { placeholder: "Last name" }) })), jsx(Form.Item, __assign({ name: "email", validateTrigger: "onBlur", rules: [
4217
4041
  { required: true, message: "Please input your email!" },
4218
4042
  { type: "email", message: "Please enter a valid email!" },
4219
- ], initialValue: formData.email }, { children: jsx(Input, { placeholder: "Email", value: formData.email, onChange: function (e) {
4220
- handleInputChange(e);
4221
- setFormData(__assign(__assign({}, formData), { email: e.target.value }));
4222
- } }) })), jsx(Form.Item, __assign({ rules: [
4043
+ ] }, { children: jsx(Input, { placeholder: "Email" }) })), jsx(Form.Item, __assign({ name: "accountName", validateTrigger: "onBlur", rules: [
4223
4044
  { required: true, message: "Please input your account name!" },
4224
- ], initialValue: formData.accountName }, { children: jsx(Input, { placeholder: "Account name", value: formData.accountName, onChange: function (e) {
4225
- handleInputChange(e);
4226
- setFormData(__assign(__assign({}, formData), { accountName: e.target.value }));
4227
- } }) }))] })), jsx(Form.Item, { children: jsx(Button$1, __assign({ type: "primary", htmlType: "submit", loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
4045
+ ] }, { children: jsx(Input, { placeholder: "Account name" }) }))] })), jsx(Form.Item, { children: jsx(Button$1, __assign({ type: "primary", htmlType: "submit", loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
4228
4046
  }
4229
4047
 
4230
4048
  var Title = Typography.Title, Text$6 = Typography.Text;
@@ -4238,32 +4056,31 @@ function PriceListDisplay(_a) {
4238
4056
  var priceListData = _a.priceListData, topNavImageUrl = _a.topNavImageUrl;
4239
4057
  if (!priceListData)
4240
4058
  return null;
4241
- return (jsx(Fragment, { children: jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsx(Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsx(Text$5, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxs(Text$5, __assign({ className: "font-bold text-xl" }, { children: [formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxs(Text$5, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsx(Text$5, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))] })) })) }));
4059
+ console.log("topNavImageUrl", topNavImageUrl);
4060
+ return (jsx(Fragment, { children: jsx("div", __assign({ className: "flex flex-col justify-between h-full my-12" }, { children: jsxs("div", __assign({ className: "flex flex-col space-y-8" }, { children: [jsx(Image, { width: 24, src: topNavImageUrl, alt: "Logo", preview: false }), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsx(Text$5, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxs(Text$5, __assign({ className: "font-bold text-xl" }, { children: [formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), priceListData.trialAllowed ? (jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxs(Text$5, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsx(Text$5, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))) : null] })) })) }));
4242
4061
  }
4243
4062
 
4244
4063
  var showErrorNotification = useErrorNotification();
4245
4064
  function Signup(_a) {
4246
- var apiToken = _a.apiToken, companyName = _a.companyName, entityId = _a.entityId, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, _b = _a.isCardEnabled, isCardEnabled = _b === void 0 ? true : _b, className = _a.className, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, style = _a.style;
4065
+ var companyName = _a.companyName, entityId = _a.entityId, priceListCode = _a.priceListCode, returnUrl = _a.returnUrl, _b = _a.isCardEnabled, isCardEnabled = _b === void 0 ? true : _b, className = _a.className, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, style = _a.style;
4247
4066
  // Hooks
4248
4067
  var _d = useContext$1(BunnyContext), apiHost = _d.apiHost, graphQLClient = _d.graphQLClient;
4068
+ var token = useToken();
4249
4069
  var isMobile = useIsMobile();
4250
4070
  var topNavImageUrl = useContext$1(BrandContext).topNavImageUrl;
4071
+ console.log("topNavImageUrl in signup", topNavImageUrl);
4251
4072
  var _e = useState(undefined), quote = _e[0], setQuote = _e[1];
4252
4073
  var _f = useState(undefined), accountId = _f[0], setAccountId = _f[1];
4253
- var _g = useState(undefined), quoteId = _g[0], setQuoteId = _g[1];
4254
- var _h = useState(undefined), portalSessionToken = _h[0], setPortalSessionToken = _h[1];
4255
- var _j = useState(undefined), formData = _j[0], setFormData = _j[1];
4256
- var _k = useState(false), proceedingToPayment = _k[0], setProceedingToPayment = _k[1];
4257
- var _l = useState(false), purchaseSucceeded = _l[0], setPurchaseSucceeded = _l[1];
4258
- var _m = useState(undefined), paymentMethodGraphQLClient = _m[0], setPaymentMethodGraphQLClient = _m[1];
4259
- var paymentMethod = usePaymentMethod(paymentMethodGraphQLClient || graphQLClient, accountId).data;
4074
+ var _g = useState(undefined), portalSessionToken = _g[0], setPortalSessionToken = _g[1];
4075
+ var _h = useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
4076
+ var _j = useState(false), purchaseSucceeded = _j[0], setPurchaseSucceeded = _j[1];
4077
+ var _k = useState(undefined), paymentMethodGraphQLClient = _k[0], setPaymentMethodGraphQLClient = _k[1];
4078
+ var paymentMethod = usePaymentMethod(paymentMethodGraphQLClient || graphQLClient).data;
4260
4079
  var queryClient = useQueryClient();
4261
4080
  // Queries
4262
4081
  var priceListData = useQuery({
4263
4082
  queryKey: ["priceList", priceListCode],
4264
- queryFn: function () {
4265
- return getPriceList({ token: apiToken, apiHost: apiHost, code: priceListCode });
4266
- },
4083
+ queryFn: function () { return getPriceList({ token: token, apiHost: apiHost, code: priceListCode }); },
4267
4084
  }).data;
4268
4085
  function handleSubmit(formData) {
4269
4086
  return __awaiter(this, void 0, void 0, function () {
@@ -4273,9 +4090,8 @@ function Signup(_a) {
4273
4090
  case 0:
4274
4091
  _a.trys.push([0, 3, , 4]);
4275
4092
  setProceedingToPayment(true);
4276
- setFormData(formData);
4277
4093
  return [4 /*yield*/, quoteAccountSignup({
4278
- token: apiToken,
4094
+ token: token,
4279
4095
  apiHost: apiHost,
4280
4096
  entityId: entityId,
4281
4097
  priceListCode: priceListCode,
@@ -4289,9 +4105,8 @@ function Signup(_a) {
4289
4105
  case 1:
4290
4106
  data = _a.sent();
4291
4107
  setAccountId(data.account.id);
4292
- console.log("apiToken", apiToken);
4293
4108
  return [4 /*yield*/, portalSessionCreate({
4294
- token: apiToken,
4109
+ token: token,
4295
4110
  apiHost: apiHost,
4296
4111
  tenantCode: data.tenant.code,
4297
4112
  expiry: 24,
@@ -4306,12 +4121,8 @@ function Signup(_a) {
4306
4121
  queryClient.invalidateQueries({
4307
4122
  queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
4308
4123
  });
4309
- setQuoteId(data.quote.id);
4310
4124
  setProceedingToPayment(false);
4311
- setQuote({
4312
- amountDue: data.quote.amountDue,
4313
- currencyId: data.quote.currencyId,
4314
- });
4125
+ setQuote(data.quote);
4315
4126
  return [3 /*break*/, 4];
4316
4127
  case 3:
4317
4128
  error_1 = _a.sent();
@@ -4323,40 +4134,39 @@ function Signup(_a) {
4323
4134
  });
4324
4135
  });
4325
4136
  }
4326
- function handlePaymentSaveSuccess(paymentSuccess) {
4137
+ function handlePaymentSuccess() {
4138
+ return __awaiter(this, void 0, void 0, function () {
4139
+ return __generator(this, function (_a) {
4140
+ setPurchaseSucceeded(true);
4141
+ return [2 /*return*/];
4142
+ });
4143
+ });
4144
+ }
4145
+ function accountSignupFunction(plugin) {
4327
4146
  return __awaiter(this, void 0, void 0, function () {
4328
- var response, plugin;
4329
4147
  return __generator(this, function (_a) {
4330
4148
  switch (_a.label) {
4331
4149
  case 0:
4332
- if (!formData) {
4333
- throw new Error("Form data is required");
4334
- }
4335
- response = paymentSuccess.pluginPaymentResponse;
4336
- plugin = response === null || response === void 0 ? void 0 : response.plugin;
4337
- if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
4338
- throw new Error("Plugin ID is required");
4150
+ if (!portalSessionToken) {
4151
+ throw new Error("Portal session token is required");
4339
4152
  }
4340
4153
  if (!accountId) {
4341
4154
  throw new Error("Account ID is required");
4342
4155
  }
4343
- if (!portalSessionToken) {
4344
- throw new Error("Portal session token is required");
4156
+ if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
4157
+ throw new Error("Plugin ID is required");
4345
4158
  }
4346
4159
  return [4 /*yield*/, accountSignup({
4347
4160
  token: portalSessionToken,
4348
4161
  apiHost: apiHost,
4349
4162
  entityId: entityId,
4350
- quoteId: quoteId,
4163
+ quoteId: quote === null || quote === void 0 ? void 0 : quote.id,
4351
4164
  paymentMethodId: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id,
4352
- pluginId: plugin.id.toString(),
4165
+ pluginId: plugin === null || plugin === void 0 ? void 0 : plugin.id.toString(),
4353
4166
  priceListCode: priceListCode,
4354
4167
  accountId: accountId,
4355
4168
  })];
4356
- case 1:
4357
- _a.sent();
4358
- setPurchaseSucceeded(true);
4359
- return [2 /*return*/];
4169
+ case 1: return [2 /*return*/, _a.sent()];
4360
4170
  }
4361
4171
  });
4362
4172
  });
@@ -4370,7 +4180,7 @@ function Signup(_a) {
4370
4180
  };
4371
4181
  return (jsx(WrapperComponent, __assign({ className: "p-4 flex flex-col ".concat(shadow, " ").concat(className), style: style }, { children: purchaseSucceeded ? (jsx(PaymentSuccessDisplay, { amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, className: "w-full", companyName: companyName, returnUrl: returnUrl })) : (jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col" : "flex-row", " h-full w-full") }, { children: [jsx("div", __assign({ className: "flex flex-col ".concat(isMobile ? "items-center" : "w-1/2 items-center") }, { children: jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsx("div", __assign({ className: "".concat(isMobile ? "h-full" : "my-4") }, { children: jsx(Divider, { className: "h-full", type: isMobile ? undefined : "vertical" }) })), jsx("div", __assign({ className: "flex ".concat(isMobile
4372
4182
  ? "items-center justify-center my-12"
4373
- : "w-1/2 items-center justify-center my-12") }, { children: jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "w-1/2") }, { children: jsx(PaymentForms, { entityId: entityId, quote: quote, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId, overrideToken: portalSessionToken }) })) }))] }))) })));
4183
+ : "w-1/2 items-center justify-center my-12") }, { children: jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "w-1/2") }, { children: jsx(PaymentForms, { entityId: entityId, quote: quote, handlePaymentSuccess: handlePaymentSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId, overrideToken: portalSessionToken, customCheckoutFunction: accountSignupFunction }) })) }))] }))) })));
4374
4184
  }
4375
4185
 
4376
4186
  // WARNING: There is a preview button on APP that will need to be changed if this query is changed
@@ -4799,8 +4609,9 @@ var SubscriptionCardActions = function (_a) {
4799
4609
  var _b, _c;
4800
4610
  var planChangeOptions = _a.planChangeOptions, subscription = _a.subscription, setEditingQuoteData = _a.setEditingQuoteData, setPayModalVisible = _a.setPayModalVisible;
4801
4611
  // Context
4802
- var _d = useContext$1(BunnyContext), token = _d.token, apiHost = _d.apiHost;
4803
- var _e = useContext$1(SubscriptionsContext), onChangePlanClick = _e.onChangePlanClick, onClickUpgrade = _e.onClickUpgrade, isTempViewOnly = _e.isTempViewOnly;
4612
+ var apiHost = useContext$1(BunnyContext).apiHost;
4613
+ var token = useToken();
4614
+ var _d = useContext$1(SubscriptionsContext), onChangePlanClick = _d.onChangePlanClick, onClickUpgrade = _d.onClickUpgrade, isTempViewOnly = _d.isTempViewOnly;
4804
4615
  // Hooks
4805
4616
  useSuccessNotification();
4806
4617
  // const cancelSubscription = useCancelSubscription();
@@ -4988,7 +4799,8 @@ var SubscriptionCardDesktop = function (_a) {
4988
4799
  var SubscriptionCardDesktopRow = function (_a) {
4989
4800
  var charge = _a.charge, chargeIndex = _a.chargeIndex, subscription = _a.subscription;
4990
4801
  // Context
4991
- var _b = useContext$1(BunnyContext), token = _b.token, apiHost = _b.apiHost;
4802
+ var apiHost = useContext$1(BunnyContext).apiHost;
4803
+ var token = useToken();
4992
4804
  // Derived state
4993
4805
  var isRamp = charge.isRamp;
4994
4806
  var prevCharge = subscription.charges[chargeIndex - 1];
@@ -5109,7 +4921,8 @@ var SubscriptionsNavigation = function (_a) {
5109
4921
  var Subscriptions = function (_a) {
5110
4922
  var companyName = _a.companyName, entityId = _a.entityId, gap = _a.gap, shadow = _a.shadow, _b = _a.showTitle, showTitle = _b === void 0 ? true : _b, className = _a.className;
5111
4923
  // Context
5112
- var _c = useContext$1(BunnyContext), token = _c.token, apiHost = _c.apiHost, onTokenExpired = _c.onTokenExpired;
4924
+ var _c = useContext$1(BunnyContext), apiHost = _c.apiHost, onTokenExpired = _c.onTokenExpired;
4925
+ var token = useToken();
5113
4926
  // Recoil state
5114
4927
  // const [updatingChargeQuantityId, setUpdatingChargeQuantityId] =
5115
4928
  // useRecoilState(updatingChargeQuantityIdState);
@@ -8387,39 +8200,53 @@ var getAccount = function (_a) {
8387
8200
  };
8388
8201
 
8389
8202
  var BillingDetails = function (_a) {
8390
- var entityId = _a.entityId, accountId = _a.accountId, _b = _a.isCardEnabled, isCardEnabled = _b === void 0 ? true : _b, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, className = _a.className;
8391
- var _d = useContext$1(BunnyContext), token = _d.token, apiHost = _d.apiHost, onTokenExpired = _d.onTokenExpired, graphQLClient = _d.graphQLClient;
8203
+ var entityId = _a.entityId, _b = _a.isCardEnabled, isCardEnabled = _b === void 0 ? true : _b, _c = _a.shadow, shadow = _c === void 0 ? "shadow-md" : _c, className = _a.className, accountIdProp = _a.accountId, hidePaymentMethodForm = _a.hidePaymentMethodForm, countryListFilter = _a.countryListFilter;
8204
+ var _d = useContext$1(BunnyContext), apiHost = _d.apiHost, onTokenExpired = _d.onTokenExpired, graphQLClient = _d.graphQLClient;
8205
+ var token = useToken();
8392
8206
  // Hooks
8393
8207
  var isMobile = useIsMobile();
8394
8208
  var queryClient = useQueryClient();
8395
- var form = Form.useForm()[0];
8396
- var _e = useState(false), isFormEdited = _e[0], setIsFormEdited = _e[1];
8397
8209
  var showSuccessNotification = useSuccessNotification();
8398
8210
  var showErrorNotification = useErrorNotification();
8399
8211
  var handleAllErrorFormats = useAllErrorFormats(onTokenExpired);
8212
+ var paymentMethod = usePaymentMethod(graphQLClient).data;
8213
+ // State
8214
+ var form = Form.useForm()[0];
8215
+ var _e = useState(false), isFormEdited = _e[0], setIsFormEdited = _e[1];
8216
+ var _f = useState(accountIdProp), accountId = _f[0], setAccountId = _f[1];
8217
+ var filteredCountryList = useMemo(function () {
8218
+ return countryListFilter
8219
+ ? Lists.COUNTRY_LIST.filter(countryListFilter)
8220
+ : Lists.COUNTRY_LIST;
8221
+ }, [countryListFilter]);
8400
8222
  // Queries
8401
- var _f = useQuery({
8223
+ var _g = useQuery({
8402
8224
  queryKey: ["account", accountId],
8403
8225
  queryFn: function () { return getAccount({ token: token, apiHost: apiHost, id: accountId }); },
8404
- }), account = _f.data, isLoadingAccount = _f.isLoading;
8405
- var _g = useMutation({
8226
+ enabled: !!accountId,
8227
+ }), account = _g.data, isLoadingAccount = _g.isLoading;
8228
+ var _h = useMutation({
8406
8229
  mutationFn: function (changedFormData) { return __awaiter(void 0, void 0, void 0, function () {
8407
8230
  var account;
8408
8231
  return __generator(this, function (_a) {
8409
8232
  switch (_a.label) {
8410
- case 0: return [4 /*yield*/, accountUpdate({
8411
- accountId: accountId,
8412
- attributes: {
8413
- name: changedFormData.name,
8414
- billingStreet: changedFormData.billingStreet,
8415
- billingCity: changedFormData.billingCity,
8416
- billingZip: changedFormData.billingZip,
8417
- billingState: changedFormData.billingState,
8418
- billingCountry: changedFormData.billingCountry,
8419
- },
8420
- token: token,
8421
- apiHost: apiHost,
8422
- })];
8233
+ case 0:
8234
+ if (!accountId) {
8235
+ throw new Error("Account ID is required");
8236
+ }
8237
+ return [4 /*yield*/, accountUpdate({
8238
+ accountId: accountId,
8239
+ attributes: {
8240
+ name: changedFormData.name,
8241
+ billingStreet: changedFormData.billingStreet,
8242
+ billingCity: changedFormData.billingCity,
8243
+ billingZip: changedFormData.billingZip,
8244
+ billingState: changedFormData.billingState,
8245
+ billingCountry: changedFormData.billingCountry,
8246
+ },
8247
+ token: token,
8248
+ apiHost: apiHost,
8249
+ })];
8423
8250
  case 1:
8424
8251
  account = _a.sent();
8425
8252
  queryClient.setQueryData(["account", accountId], function (old) {
@@ -8430,11 +8257,17 @@ var BillingDetails = function (_a) {
8430
8257
  });
8431
8258
  }); },
8432
8259
  onSuccess: function () {
8260
+ showSuccessNotification("Your account details have been saved");
8433
8261
  queryClient.invalidateQueries({
8434
8262
  queryKey: ["getTaxationRequiredAccountFields", token],
8435
8263
  });
8436
8264
  },
8437
- }), updateAccount = _g.mutate, isUpdatingAccount = _g.isPending;
8265
+ }), updateAccount = _h.mutate, isUpdatingAccount = _h.isPending;
8266
+ useEffect(function () {
8267
+ if (paymentMethod) {
8268
+ setAccountId(paymentMethod.accountId);
8269
+ }
8270
+ }, [paymentMethod]);
8438
8271
  useEffect(function () {
8439
8272
  if (account) {
8440
8273
  form.setFieldsValue({
@@ -8451,33 +8284,35 @@ var BillingDetails = function (_a) {
8451
8284
  showSuccessNotification("Your payment method has been saved");
8452
8285
  }, [queryClient]);
8453
8286
  var savePaymentPreCondition = function () { return __awaiter(void 0, void 0, void 0, function () {
8454
- var error_1;
8455
8287
  return __generator(this, function (_a) {
8456
- switch (_a.label) {
8457
- case 0:
8458
- _a.trys.push([0, 3, 4, 5]);
8459
- return [4 /*yield*/, form.validateFields()];
8460
- case 1:
8461
- _a.sent();
8462
- return [4 /*yield*/, updateAccount(form.getFieldsValue())];
8463
- case 2:
8464
- _a.sent();
8465
- return [2 /*return*/, true];
8466
- case 3:
8467
- error_1 = _a.sent();
8468
- if (error_1 instanceof Error) {
8469
- showErrorNotification("Failed to update account", error_1.message);
8470
- }
8471
- else {
8472
- showErrorNotification("Please fill out all required fields");
8288
+ form.validateFields({ validateOnly: true }).then(function () { return __awaiter(void 0, void 0, void 0, function () {
8289
+ var error_1;
8290
+ return __generator(this, function (_a) {
8291
+ switch (_a.label) {
8292
+ case 0:
8293
+ _a.trys.push([0, 2, 3, 4]);
8294
+ return [4 /*yield*/, form.validateFields()];
8295
+ case 1:
8296
+ _a.sent();
8297
+ updateAccount(form.getFieldsValue());
8298
+ return [2 /*return*/, true];
8299
+ case 2:
8300
+ error_1 = _a.sent();
8301
+ if (error_1 instanceof Error) {
8302
+ showErrorNotification("Failed to update account", error_1.message);
8303
+ }
8304
+ else {
8305
+ showErrorNotification("Please fill out all required fields");
8306
+ }
8307
+ return [2 /*return*/, false];
8308
+ case 3:
8309
+ setIsFormEdited(false);
8310
+ return [7 /*endfinally*/];
8311
+ case 4: return [2 /*return*/];
8473
8312
  }
8474
- return [2 /*return*/, false];
8475
- case 4:
8476
- setIsFormEdited(false);
8477
- showSuccessNotification("Your account details have been saved");
8478
- return [7 /*endfinally*/];
8479
- case 5: return [2 /*return*/];
8480
- }
8313
+ });
8314
+ }); });
8315
+ return [2 /*return*/];
8481
8316
  });
8482
8317
  }); };
8483
8318
  function handleValuesChange(changedValues) {
@@ -8492,13 +8327,13 @@ var BillingDetails = function (_a) {
8492
8327
  };
8493
8328
  setIsFormEdited(isFormEdited());
8494
8329
  }
8495
- return (jsx(WrapperComponent, __assign({ isCardEnabled: isCardEnabled, shadow: shadow, className: className }, { children: jsxs("div", __assign({ className: "flex p-2 my-2 ".concat(isMobile ? "flex-col space-y-4" : "flex-row", " gap-4") }, { children: [jsxs("div", __assign({ className: "".concat(isMobile ? "w-full" : "w-1/2", " px-4") }, { children: [jsx(ReactQueryDevtools2, {}), jsx(Skeleton, __assign({ loading: isLoadingAccount }, { children: jsxs(Form, __assign({ className: "flex flex-col gap-2", form: form, layout: "vertical", disabled: isUpdatingAccount, onValuesChange: function (changedValues) {
8330
+ return (jsx(WrapperComponent, __assign({ isCardEnabled: isCardEnabled, shadow: shadow, className: className }, { children: jsxs("div", __assign({ className: "flex p-2 my-2 ".concat(isMobile ? "flex-col space-y-4" : "flex-row", " gap-4") }, { children: [jsxs("div", __assign({ className: "".concat(isMobile || hidePaymentMethodForm ? "w-full" : "w-1/2", " px-4") }, { children: [jsx(ReactQueryDevtools2, {}), jsx(Skeleton, __assign({ loading: isLoadingAccount }, { children: jsxs(Form, __assign({ className: "flex flex-col gap-2", form: form, layout: "vertical", disabled: isUpdatingAccount, onValuesChange: function (changedValues) {
8496
8331
  handleValuesChange(changedValues);
8497
8332
  } }, { children: [jsx(Form.Item, __assign({ label: "Account name", name: "name", rules: [
8498
8333
  { required: true, message: "Account name is required" },
8499
8334
  ] }, { children: jsx(Input, {}) })), jsx(Form.Item, __assign({ label: "Street address", name: "billingStreet", rules: [
8500
8335
  { required: true, message: "Street address is required" },
8501
- ] }, { children: jsx(Input, {}) })), jsxs("div", __assign({ className: "flex gap-4" }, { children: [jsx(Form.Item, __assign({ label: "City", name: "billingCity", rules: [{ required: true, message: "City is required" }], className: "flex-1" }, { children: jsx(Input, {}) })), jsx(Form.Item, __assign({ label: "Zipcode", name: "billingZip", rules: [{ required: true, message: "Zipcode is required" }], className: "flex-1" }, { children: jsx(Input, {}) }))] })), jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col pb-2" : "flex-row", " gap-4") }, { children: [jsx(Form.Item, __assign({ label: "State", name: "billingState", className: "flex-1" }, { children: jsx(Input, {}) })), jsx(Form.Item, __assign({ label: "Country", name: "billingCountry", className: "flex-1", rules: [{ required: true, message: "Country is required" }] }, { children: jsx(Select, { options: Lists.COUNTRY_LIST, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
8336
+ ] }, { children: jsx(Input, {}) })), jsxs("div", __assign({ className: "flex gap-4" }, { children: [jsx(Form.Item, __assign({ label: "City", name: "billingCity", rules: [{ required: true, message: "City is required" }], className: "flex-1" }, { children: jsx(Input, {}) })), jsx(Form.Item, __assign({ label: "Zipcode", name: "billingZip", rules: [{ required: true, message: "Zipcode is required" }], className: "flex-1" }, { children: jsx(Input, {}) }))] })), jsxs("div", __assign({ className: "flex ".concat(isMobile ? "flex-col pb-2" : "flex-row", " gap-4") }, { children: [jsx(Form.Item, __assign({ label: "State", name: "billingState", className: "flex-1" }, { children: jsx(Input, {}) })), jsx(Form.Item, __assign({ label: "Country", name: "billingCountry", className: "flex-1", rules: [{ required: true, message: "Country is required" }] }, { children: jsx(Select, { options: filteredCountryList, placeholder: "Select a country", showSearch: true, filterOption: function (input, option) {
8502
8337
  var _a, _b;
8503
8338
  return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "")
8504
8339
  .toLowerCase()
@@ -8506,13 +8341,13 @@ var BillingDetails = function (_a) {
8506
8341
  ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : "")
8507
8342
  .toLowerCase()
8508
8343
  .includes(input.toLowerCase());
8509
- } }) }))] })), jsx(Form.Item, __assign({ label: "Email", name: "email" }, { children: jsx(Input, { disabled: true }) }))] })) })), jsx(Button$1, __assign({ disabled: !isFormEdited || isUpdatingAccount, className: "w-full mt-4", type: "primary", onClick: function () {
8344
+ } }) }))] })), jsx(Form.Item, __assign({ label: "Email", name: "email" }, { children: jsx(Input, { disabled: true, placeholder: "Available soon" }) })), jsx(Form.Item, __assign({ label: "Tax ID", name: "taxId", tooltip: "Tax ID will be printed on quotes and invoices below the account's address" }, { children: jsx(Input, { disabled: true, placeholder: "Available soon" }) }))] })) })), jsx(Button$1, __assign({ disabled: !isFormEdited || isUpdatingAccount, className: "w-full mt-4", type: "primary", onClick: function () {
8510
8345
  savePaymentPreCondition();
8511
- } }, { children: "Save" }))] })), isMobile ? (jsx("div", __assign({ className: "mx-4" }, { children: jsx(Divider, {}) }))) : (jsx("div", { children: jsx(Divider, { className: "h-full", type: "vertical" }) })), jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "w-1/2 pt-4", " flex justify-center") }, { children: jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
8512
- handleAllErrorFormats(error);
8513
- }, onSavePaymentMethod: function () {
8514
- onSuccess();
8515
- }, graphQLClient: graphQLClient }) }))] })) })));
8346
+ } }, { children: "Save" }))] })), !hidePaymentMethodForm ? (jsxs(Fragment, { children: [isMobile ? (jsx("div", __assign({ className: "mx-4" }, { children: jsx(Divider, {}) }))) : (jsx("div", { children: jsx(Divider, { className: "h-full", type: "vertical" }) })), jsx("div", __assign({ className: "".concat(isMobile ? "w-full" : "w-1/2 pt-4", " flex justify-center") }, { children: jsx(PaymentForm, { entityId: entityId, onFail: function (error) {
8347
+ handleAllErrorFormats(error);
8348
+ }, onSavePaymentMethod: function () {
8349
+ onSuccess();
8350
+ }, graphQLClient: graphQLClient }) }))] })) : null] })) })));
8516
8351
  };
8517
8352
  var WrapperComponent = function (_a) {
8518
8353
  var children = _a.children, isCardEnabled = _a.isCardEnabled, shadow = _a.shadow, className = _a.className;