@bunnyapp/components 1.0.5 → 1.0.7

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.
package/dist/esm/index.js CHANGED
@@ -2,16 +2,16 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import React__default, { createContext, useContext, useEffect, useState, useMemo, useRef } from 'react';
4
4
  import { Markup } from 'interweave';
5
- import { ConfigProvider, Button, Typography, Checkbox, Input, Divider, Modal, Form, Tag, Popconfirm, Drawer, Select, Image, Card as Card$1, Dropdown } from 'antd';
5
+ import { ConfigProvider, Button, Typography, Checkbox, Input, Divider, Modal, Form, Tag, Drawer, Card as Card$1, Popconfirm, Select, Image, Dropdown } 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, createGraphQLClient, Misc, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, QueryKeyFactory, useDownloadFile, NotificationUtils, invokePlugin, useIsMobile as useIsMobile$1, GRAY_500, GRAY_200, CHARCOAL_GRAY, StringUtils, usePaymentPlugins, ApiUtils, PAYABLE_INVOICE_STATES, DOCUMENT_NAME as DOCUMENT_NAME$1, QuoteInvoiceUtils, usePlugins, GraphqlUtils, Lists, getTaxationRequiredAccountFields, getAccount, useCurrentUserData, SLATE_500, PRIMARY_COLOR, FrontendTransaction, SLATE_600, WHITE, TransactionKind, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, DataInterval, TAG_COLORS, ChargeType } from '@bunnyapp/common';
7
+ import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest, createGraphQLClient, Misc, MARK_PRO, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, QueryKeyFactory, useDownloadFile, NotificationUtils, invokePlugin, useIsMobile as useIsMobile$1, GRAY_500, GRAY_200, CHARCOAL_GRAY, StringUtils, usePaymentPlugins, ApiUtils, PAYABLE_INVOICE_STATES, DOCUMENT_NAME as DOCUMENT_NAME$1, QuoteInvoiceUtils, usePlugins, GraphqlUtils, FrontendTransaction, SLATE_600, WHITE, TransactionKind, Lists, getTaxationRequiredAccountFields, getAccount, useCurrentUserData, SLATE_500, PRIMARY_COLOR, SubscriptionState as SubscriptionState$2, MODAL_MAX_HEIGHT, DataInterval, TAG_COLORS, ChargeType } from '@bunnyapp/common';
8
8
  import { QueryClient, QueryClientProvider, useQuery, useMutation, useQueryClient, keepPreviousData } from '@tanstack/react-query';
9
- import { RecoilRoot, atom, useRecoilValue, useSetRecoilState, useRecoilState } from 'recoil';
9
+ import { RecoilRoot, atom, useSetRecoilState, useRecoilValue, useRecoilState } from 'recoil';
10
10
  import theme from 'antd/lib/theme';
11
+ import { HelmetProvider, Helmet } from 'react-helmet-async';
11
12
  import { useElements, useStripe, PaymentElement, Elements } from '@stripe/react-stripe-js';
12
13
  import { loadStripe } from '@stripe/stripe-js/pure';
13
14
  import { capitalize, startCase, cloneDeep, omit } from 'lodash';
14
- import { HelmetProvider, Helmet } from 'react-helmet-async';
15
15
  import request from 'graphql-request';
16
16
  import { BarChart, ResponsiveContainer, XAxis, Tooltip, Bar, Rectangle } from 'recharts';
17
17
 
@@ -88,6 +88,36 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
88
88
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
89
89
  };
90
90
 
91
+ function styleInject(css, ref) {
92
+ if ( ref === void 0 ) ref = {};
93
+ var insertAt = ref.insertAt;
94
+
95
+ if (!css || typeof document === 'undefined') { return; }
96
+
97
+ var head = document.head || document.getElementsByTagName('head')[0];
98
+ var style = document.createElement('style');
99
+ style.type = 'text/css';
100
+
101
+ if (insertAt === 'top') {
102
+ if (head.firstChild) {
103
+ head.insertBefore(style, head.firstChild);
104
+ } else {
105
+ head.appendChild(style);
106
+ }
107
+ } else {
108
+ head.appendChild(style);
109
+ }
110
+
111
+ if (style.styleSheet) {
112
+ style.styleSheet.cssText = css;
113
+ } else {
114
+ style.appendChild(document.createTextNode(css));
115
+ }
116
+ }
117
+
118
+ var css_248z = ".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-primary:disabled {\n background: #eef0f2 !important;\n color: rgba(0, 0, 0, 0.25) !important;\n border: none;\n}\n.ant-btn {\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 box-shadow: none;\n text-shadow: none;\n outline: none !important;\n line-height: 1;\n font-size: 0.875rem;\n font-weight: normal;\n}\n.ant-btn > span {\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.ant-btn-lg {\n height: 44px !important;\n}\n.ant-btn-default:disabled {\n border-color: rgba(113, 125, 148, 0.2) !important;\n}\n.ant-btn-link {\n border: none !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}\n.ant-btn-link > span {\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.ant-btn-link:disabled {\n background-color: transparent !important;\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-select-selector {\n box-shadow: none !important;\n background-color: transparent !important;\n border: none !important;\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-divider {\n margin: 0;\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.relative {\n position: relative;\n}\n.absolute {\n position: absolute;\n}\n.fixed {\n position: fixed;\n}\n.top-0 {\n top: 0;\n}\n.right-0 {\n right: 0;\n}\n.bottom-0 {\n bottom: 0;\n}\n.left-0 {\n left: 0;\n}\n.overflow-hidden {\n overflow: hidden !important;\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-visible {\n overflow: visible;\n}\n.z-50 {\n z-index: 50;\n}\n.-top-1\\/10 {\n top: -10%;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.rounded-lg {\n border-radius: 0.5rem;\n}\n.rounded-xl {\n border-radius: 0.75rem;\n}\n.rounded-full {\n border-radius: 9999px;\n}\n.rounded-tr {\n border-top-right-radius: 0.25rem;\n}\n.rounded-br {\n border-bottom-right-radius: 0.25rem;\n}\n.rounded-bl {\n border-bottom-left-radius: 0.25rem;\n}\n.rounded-tl {\n border-top-left-radius: 0.25rem;\n}\n.rounded-t {\n border-top-right-radius: 0.25rem;\n border-top-left-radius: 0.25rem;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.flex {\n display: flex;\n}\n.flex-col {\n flex-direction: column;\n}\n.flex-wrap {\n flex-wrap: wrap;\n}\n.grow {\n flex-grow: 1;\n}\n.shrink {\n flex-shrink: 1;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.basis-0 {\n flex-basis: 0;\n}\n.max-w-32 {\n max-width: 8rem;\n}\n.items-center {\n align-items: center;\n}\n.items-end {\n align-items: flex-end;\n}\n.items-start {\n align-items: flex-start;\n}\n.justify-center {\n justify-content: center;\n}\n.justify-between {\n justify-content: space-between;\n}\n.justify-end {\n justify-content: flex-end;\n}\n.justify-start {\n justify-content: flex-start;\n}\n.whitespace-nowrap {\n white-space: nowrap;\n}\n.underline {\n text-decoration: underline;\n}\n.no-underline {\n text-decoration: none;\n}\n.text-nowrap {\n white-space: nowrap;\n}\n.text-white {\n color: white;\n}\n.text-xxs {\n font-size: 0.625rem;\n}\n.text-xs {\n font-size: 0.75rem;\n}\n.text-sm {\n font-size: 0.875rem;\n}\n.text-base {\n font-size: 1rem;\n}\n.text-lg {\n font-size: 1.125rem;\n}\n.text-xl {\n font-size: 1.25rem;\n}\n.text-2xl {\n font-size: 1.5rem;\n}\n.text-3xl {\n font-size: 2rem;\n}\n.text-4xl {\n font-size: 2.5rem;\n}\n.text-5xl {\n font-size: 3rem;\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.text-gray {\n color: #808080 !important;\n}\n.text-gray-400 {\n color: #9ca3af !important;\n}\n.text-gray-500 {\n color: #6b7280 !important;\n}\n.text-blue-gray {\n color: #717d94;\n}\n.text-primary {\n color: #ff6e1c;\n}\n.text-secondary {\n color: #4956dc;\n}\n.capitalize {\n text-transform: capitalize !important;\n}\n.font-normal {\n font-weight: 400;\n}\n.font-medium {\n font-weight: 500;\n}\n.font-bold {\n font-weight: 700;\n}\n.bg-transparent {\n background-color: transparent;\n}\n.bg-white {\n background-color: white;\n}\n.border-collapse {\n border-collapse: collapse;\n}\n.border-t-solid {\n border-top-style: solid;\n}\n.border-b-solid {\n border-bottom-style: solid;\n}\n.border-t-1 {\n border-top-width: 1px;\n}\n.border-b-1 {\n border-bottom-width: 1px;\n}\n.gap-0 {\n gap: 0 !important;\n}\n.gap-0\\.5 {\n gap: 0.125rem;\n}\n.gap-1 {\n gap: 0.25rem;\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-3 {\n gap: 0.75rem;\n}\n.gap-4 {\n gap: 1rem !important;\n}\n.gap-5 {\n gap: 1.25rem;\n}\n.gap-6 {\n gap: 1.5rem !important;\n}\n.gap-8 {\n gap: 2rem !important;\n}\n.gap-12 {\n gap: 3rem !important;\n}\n/* Padding Utilities */\n.p-0 {\n padding: 0;\n}\n.p-1 {\n padding: 0.25rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-3 {\n padding: 0.75rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-5 {\n padding: 1.25rem;\n}\n.p-6 {\n padding: 1.5rem;\n}\n.p-8 {\n padding: 2rem;\n}\n/* Padding X Utilities */\n.px-0 {\n padding-right: 0;\n padding-left: 0;\n}\n.px-1 {\n padding-right: 0.25rem;\n padding-left: 0.25rem;\n}\n.px-2 {\n padding-right: 0.5rem;\n padding-left: 0.5rem;\n}\n.px-3 {\n padding-right: 0.75rem;\n padding-left: 0.75rem;\n}\n.px-4 {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.px-5 {\n padding-right: 1.25rem;\n padding-left: 1.25rem;\n}\n.px-6 {\n padding-right: 1.5rem;\n padding-left: 1.5rem;\n}\n.px-8 {\n padding-right: 2rem;\n padding-left: 2rem;\n}\n.px-12 {\n padding-right: 3rem;\n padding-left: 3rem;\n}\n/* Padding Y Utilities */\n.py-0 {\n padding-top: 0;\n padding-bottom: 0;\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-3 {\n padding-top: 0.75rem;\n padding-bottom: 0.75rem;\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/* Padding Top Utilities */\n.pt-0 {\n padding-top: 0;\n}\n.pt-1 {\n padding-top: 0.25rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pt-3 {\n padding-top: 0.75rem;\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/* Padding Right Utilities */\n.pr-0 {\n padding-right: 0;\n}\n.pr-4 {\n padding-right: 1rem;\n}\n.pr-8 {\n padding-right: 2rem;\n}\n/* Padding Bottom Utilities */\n.pb-0 {\n padding-bottom: 0;\n}\n.pb-1 {\n padding-bottom: 0.25rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.pb-3 {\n padding-bottom: 0.75rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pb-5 {\n padding-bottom: 1.25rem;\n}\n.pb-6 {\n padding-bottom: 1.5rem;\n}\n.pb-8 {\n padding-bottom: 2rem;\n}\n/* Padding Left Utilities */\n.pl-0 {\n padding-left: 0;\n}\n.pl-1 {\n padding-left: 0.25rem;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pl-4 {\n padding-left: 1rem;\n}\n.pl-8 {\n padding-left: 2rem;\n}\n/* Space Utilities */\n.space-y-2 {\n gap: 0.5rem;\n}\n.space-y-4 {\n gap: 1rem;\n}\n.space-y-8 {\n gap: 2rem;\n}\n/* Margin Utilities */\n.ml-2 {\n margin-left: 0.5rem;\n}\n.ml-6 {\n margin-left: 1.5rem;\n}\n.ml-8 {\n margin-left: 2rem;\n}\n.mb-0 {\n margin-bottom: 0;\n}\n.mb-1 {\n margin-bottom: 0.25rem;\n}\n.mb-2 {\n margin-bottom: 0.5rem;\n}\n.mb-3 {\n margin-bottom: 0.75rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.mb-5 {\n margin-bottom: 1.25rem;\n}\n.mb-6 {\n margin-bottom: 1.5rem;\n}\n.mb-8 {\n margin-bottom: 2rem;\n}\n.mr-2 {\n margin-right: 0.5rem;\n}\n.mr-4 {\n margin-right: 1rem;\n}\n.mr-6 {\n margin-right: 1.5rem;\n}\n.mr-8 {\n margin-right: 2rem;\n}\n.mt-0 {\n margin-top: 0;\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-5 {\n margin-top: 1.25rem;\n}\n.mt-6 {\n margin-top: 1.5rem;\n}\n.mt-8 {\n margin-top: 2rem;\n}\n.my-1 {\n margin-top: 0.25rem;\n margin-bottom: 0.25rem;\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.my-8 {\n margin-top: 2rem;\n margin-bottom: 2rem;\n}\n.my-12 {\n margin-top: 3rem;\n margin-bottom: 3rem;\n}\n.mx-2 {\n margin-left: 0.5rem;\n margin-right: 0.5rem;\n}\n.mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.mx-8 {\n margin-left: 2rem;\n margin-right: 2rem;\n}\n.w-full {\n width: 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-14 {\n width: 3.5rem;\n /* 56px */\n}\n.w-20 {\n width: 5rem;\n /* 80px */\n}\n.h-full {\n height: 100%;\n}\n.h-4 {\n height: 1rem;\n}\n.h-5 {\n height: 1.25rem;\n}\n.h-6 {\n height: 1.5rem;\n}\n.h-8 {\n height: 2rem;\n}\n.h-14 {\n height: 3.5rem;\n /* 56px */\n}\n.h-80 {\n height: 20rem;\n}\n.h-96 {\n height: 24rem;\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.cursor-not-allowed {\n cursor: not-allowed;\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.grid-cols-4 {\n grid-template-columns: repeat(4, minMax(0, 1fr));\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.col-span-4 {\n grid-column: span 4 / span 4;\n}\n.col-span-full {\n grid-column: 1 / -1;\n}\n/* Background colors */\n.bg-black {\n background-color: #000000;\n}\n.bg-slate-50 {\n background-color: #f8fafc;\n}\n.bg-slate-100 {\n background-color: #f1f5f9;\n}\n.bg-slate-200 {\n background-color: #e2e8f0;\n}\n.bg-slate-300 {\n background-color: #cbd5e1;\n}\n.bg-slate-400 {\n background-color: #94a3b8;\n}\n.bg-slate-500 {\n background-color: #64748b;\n}\n.bg-slate-600 {\n background-color: #475569;\n}\n.bg-slate-700 {\n background-color: #334155;\n}\n.bg-slate-800 {\n background-color: #1e293b;\n}\n.bg-slate-900 {\n background-color: #0f172a;\n}\n.bg-slate-950 {\n background-color: #020617;\n}\n.bg-gray-50 {\n background-color: #f9fafb;\n}\n.bg-gray-100 {\n background-color: #f3f4f6;\n}\n.bg-gray-200 {\n background-color: #e5e7eb;\n}\n.bg-gray-300 {\n background-color: #d1d5db;\n}\n.bg-gray-400 {\n background-color: #9ca3af;\n}\n.bg-gray-500 {\n background-color: #6b7280;\n}\n.bg-gray-600 {\n background-color: #4b5563;\n}\n.bg-gray-700 {\n background-color: #374151;\n}\n.bg-gray-800 {\n background-color: #1f2937;\n}\n.bg-gray-900 {\n background-color: #111827;\n}\n.bg-gray-950 {\n background-color: #030712;\n}\n.bg-green-200 {\n background-color: #a7f3d0;\n}\n.bg-green-500 {\n background-color: #10b981;\n}\n.bg-blue-50 {\n background-color: #eff6ff;\n}\n.bg-blue-100 {\n background-color: #dbeafe;\n}\n.bg-blue-200 {\n background-color: #bfdbfe;\n}\n.bg-blue-300 {\n background-color: #93c5fd;\n}\n.bg-blue-400 {\n background-color: #60a5fa;\n}\n.bg-blue-500 {\n background-color: #3b82f6;\n}\n.bg-blue-600 {\n background-color: #2563eb;\n}\n.bg-blue-700 {\n background-color: #1d4ed8;\n}\n.bg-blue-800 {\n background-color: #1e40af;\n}\n.bg-blue-900 {\n background-color: #1e3a8a;\n}\n.bg-blue-950 {\n background-color: #172554;\n}\n.bg-orange-50 {\n background-color: #fff7ed;\n}\n.bg-orange-100 {\n background-color: #ffedd5;\n}\n.bg-orange-200 {\n background-color: #fed7aa;\n}\n.bg-orange-300 {\n background-color: #fdba74;\n}\n.bg-orange-400 {\n background-color: #fb923c;\n}\n.bg-orange-500 {\n background-color: #f97316;\n}\n.bg-orange-600 {\n background-color: #ea580c;\n}\n.bg-orange-700 {\n background-color: #c2410c;\n}\n.bg-orange-800 {\n background-color: #9a3412;\n}\n.bg-orange-900 {\n background-color: #7c2d12;\n}\n.bg-orange-950 {\n background-color: #431407;\n}\n.bg-yellow-200 {\n background-color: #fde68a;\n}\n.bg-red-200 {\n background-color: #fecaca;\n}\n/* Text colors */\n.text-black {\n color: #000000;\n}\n.text-white {\n color: #ffffff;\n}\n.text-slate-50 {\n color: #f8fafc;\n}\n.text-slate-100 {\n color: #f1f5f9;\n}\n.text-slate-200 {\n color: #e2e8f0;\n}\n.text-slate-300 {\n color: #cbd5e1;\n}\n.text-slate-400 {\n color: #94a3b8;\n}\n.text-slate-500 {\n color: #64748b;\n}\n.text-slate-600 {\n color: #475569;\n}\n.text-slate-700 {\n color: #334155;\n}\n.text-slate-800 {\n color: #1e293b;\n}\n.text-slate-900 {\n color: #0f172a;\n}\n.text-slate-950 {\n color: #020617;\n}\n.text-gray-50 {\n color: #f9fafb;\n}\n.text-gray-100 {\n color: #f3f4f6;\n}\n.text-gray-200 {\n color: #e5e7eb;\n}\n.text-gray-300 {\n color: #d1d5db;\n}\n.text-gray-400 {\n color: #9ca3af;\n}\n.text-gray-500 {\n color: #6b7280;\n}\n.text-gray-600 {\n color: #4b5563;\n}\n.text-gray-700 {\n color: #374151;\n}\n.text-gray-800 {\n color: #1f2937;\n}\n.text-gray-900 {\n color: #111827;\n}\n.text-gray-950 {\n color: #030712;\n}\n.text-green-600 {\n color: #059669;\n}\n.text-green-700 {\n color: #047857;\n}\n.text-blue-50 {\n color: #eff6ff;\n}\n.text-blue-100 {\n color: #dbeafe;\n}\n.text-blue-200 {\n color: #bfdbfe;\n}\n.text-blue-300 {\n color: #93c5fd;\n}\n.text-blue-400 {\n color: #60a5fa;\n}\n.text-blue-500 {\n color: #3b82f6;\n}\n.text-blue-600 {\n color: #2563eb;\n}\n.text-blue-700 {\n color: #1d4ed8;\n}\n.text-blue-800 {\n color: #1e40af;\n}\n.text-blue-900 {\n color: #1e3a8a;\n}\n.text-blue-950 {\n color: #172554;\n}\n.text-orange-50 {\n color: #fff7ed;\n}\n.text-orange-100 {\n color: #ffedd5;\n}\n.text-orange-200 {\n color: #fed7aa;\n}\n.text-orange-300 {\n color: #fdba74;\n}\n.text-orange-400 {\n color: #fb923c;\n}\n.text-orange-500 {\n color: #f97316;\n}\n.text-orange-600 {\n color: #ea580c;\n}\n.text-orange-700 {\n color: #c2410c;\n}\n.text-orange-800 {\n color: #9a3412;\n}\n.text-orange-900 {\n color: #7c2d12;\n}\n.text-orange-950 {\n color: #431407;\n}\n.text-yellow-500 {\n color: #f59e0b;\n}\n.text-yellow-700 {\n color: #b45309;\n}\n.text-red-500 {\n color: #ef4444;\n}\n.text-red-700 {\n color: #b91c1c;\n}\n.border {\n border-width: 1px;\n}\n.border-2 {\n border-width: 2px;\n}\n.border-l {\n border-left-width: 1px;\n}\n.border-dashed {\n border-style: dashed;\n}\n.border-solid {\n border-style: solid;\n}\n.border-slate-50 {\n border-color: #f8fafc;\n}\n.border-slate-100 {\n border-color: #f1f5f9;\n}\n.border-slate-200 {\n border-color: #e2e8f0;\n}\n.border-slate-300 {\n border-color: #cbd5e1;\n}\n.border-slate-400 {\n border-color: #94a3b8;\n}\n.border-slate-500 {\n border-color: #64748b;\n}\n.border-slate-600 {\n border-color: #475569;\n}\n.border-slate-700 {\n border-color: #334155;\n}\n.border-slate-800 {\n border-color: #1e293b;\n}\n.border-slate-900 {\n border-color: #0f172a;\n}\n.border-slate-950 {\n border-color: #020617;\n}\n.border-gray-400 {\n border-color: #9ca3af;\n}\n.border-gray-500 {\n border-color: #6b7280;\n}\n.origin-center {\n transform-origin: center;\n}\n.rotate-45 {\n transform: rotate(45deg);\n}\n.translate-x-2\\/4 {\n transform: translateX(50%);\n}\n.-translate-x-2\\/4 {\n transform: translateX(-50%);\n}\n.translate-y-2\\/4 {\n transform: translateY(50%);\n}\n.translate-y-full {\n transform: translateY(100%);\n}\n.-translate-y-full {\n transform: translateY(-100%);\n}\n.shadow-sm {\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n}\n.shadow {\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);\n}\n.shadow-md {\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);\n}\n.shadow-lg {\n box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n}\n.shadow-xl {\n box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n}\n.shadow-2xl {\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n}\n.shadow-inner {\n box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);\n}\n.shadow-none {\n box-shadow: 0 0 #0000;\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex !important;\n }\n .sm\\:hidden {\n display: none !important;\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";
119
+ styleInject(css_248z);
120
+
91
121
  var IconContext = /*#__PURE__*/createContext({});
92
122
  var Context = IconContext;
93
123
 
@@ -1715,35 +1745,28 @@ var InvoiceQuoteView = function (_a) {
1715
1745
  };
1716
1746
  var templateObject_1$9;
1717
1747
 
1718
- function styleInject(css, ref) {
1719
- if ( ref === void 0 ) ref = {};
1720
- var insertAt = ref.insertAt;
1721
-
1722
- if (!css || typeof document === 'undefined') { return; }
1723
-
1724
- var head = document.head || document.getElementsByTagName('head')[0];
1725
- var style = document.createElement('style');
1726
- style.type = 'text/css';
1727
-
1728
- if (insertAt === 'top') {
1729
- if (head.firstChild) {
1730
- head.insertBefore(style, head.firstChild);
1731
- } else {
1732
- head.appendChild(style);
1733
- }
1734
- } else {
1735
- head.appendChild(style);
1736
- }
1737
-
1738
- if (style.styleSheet) {
1739
- style.styleSheet.cssText = css;
1740
- } else {
1741
- style.appendChild(document.createTextNode(css));
1742
- }
1743
- }
1744
-
1745
- var css_248z = ".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-primary:disabled {\n background: #eef0f2 !important;\n color: rgba(0, 0, 0, 0.25) !important;\n border: none;\n}\n.ant-btn {\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 box-shadow: none;\n text-shadow: none;\n outline: none !important;\n line-height: 1;\n font-size: 0.875rem;\n font-weight: normal;\n}\n.ant-btn > span {\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.ant-btn-lg {\n height: 44px !important;\n}\n.ant-btn-default:disabled {\n border-color: rgba(113, 125, 148, 0.2) !important;\n}\n.ant-btn-link {\n border: none !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}\n.ant-btn-link > span {\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.ant-btn-link:disabled {\n background-color: transparent !important;\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-select-selector {\n box-shadow: none !important;\n background-color: transparent !important;\n border: none !important;\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-divider {\n margin: 0;\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.relative {\n position: relative;\n}\n.absolute {\n position: absolute;\n}\n.fixed {\n position: fixed;\n}\n.top-0 {\n top: 0;\n}\n.right-0 {\n right: 0;\n}\n.bottom-0 {\n bottom: 0;\n}\n.left-0 {\n left: 0;\n}\n.overflow-hidden {\n overflow: hidden !important;\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-visible {\n overflow: visible;\n}\n.z-50 {\n z-index: 50;\n}\n.-top-1\\/10 {\n top: -10%;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.rounded-md {\n border-radius: 0.375rem;\n}\n.rounded-lg {\n border-radius: 0.5rem;\n}\n.rounded-xl {\n border-radius: 0.75rem;\n}\n.rounded-full {\n border-radius: 9999px;\n}\n.rounded-tr {\n border-top-right-radius: 0.25rem;\n}\n.rounded-br {\n border-bottom-right-radius: 0.25rem;\n}\n.rounded-bl {\n border-bottom-left-radius: 0.25rem;\n}\n.rounded-tl {\n border-top-left-radius: 0.25rem;\n}\n.rounded-t {\n border-top-right-radius: 0.25rem;\n border-top-left-radius: 0.25rem;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.flex {\n display: flex;\n}\n.flex-col {\n flex-direction: column;\n}\n.flex-wrap {\n flex-wrap: wrap;\n}\n.grow {\n flex-grow: 1;\n}\n.shrink {\n flex-shrink: 1;\n}\n.shrink-0 {\n flex-shrink: 0;\n}\n.basis-0 {\n flex-basis: 0;\n}\n.max-w-32 {\n max-width: 8rem;\n}\n.items-center {\n align-items: center;\n}\n.items-end {\n align-items: flex-end;\n}\n.items-start {\n align-items: flex-start;\n}\n.justify-center {\n justify-content: center;\n}\n.justify-between {\n justify-content: space-between;\n}\n.justify-end {\n justify-content: flex-end;\n}\n.justify-start {\n justify-content: flex-start;\n}\n.whitespace-nowrap {\n white-space: nowrap;\n}\n.underline {\n text-decoration: underline;\n}\n.no-underline {\n text-decoration: none;\n}\n.text-nowrap {\n white-space: nowrap;\n}\n.text-white {\n color: white;\n}\n.text-xxs {\n font-size: 0.625rem;\n}\n.text-xs {\n font-size: 0.75rem;\n}\n.text-sm {\n font-size: 0.875rem;\n}\n.text-base {\n font-size: 1rem;\n}\n.text-lg {\n font-size: 1.125rem;\n}\n.text-xl {\n font-size: 1.25rem;\n}\n.text-2xl {\n font-size: 1.5rem;\n}\n.text-3xl {\n font-size: 2rem;\n}\n.text-4xl {\n font-size: 2.5rem;\n}\n.text-5xl {\n font-size: 3rem;\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.text-gray {\n color: #808080 !important;\n}\n.text-gray-400 {\n color: #9ca3af !important;\n}\n.text-gray-500 {\n color: #6b7280 !important;\n}\n.text-blue-gray {\n color: #717d94;\n}\n.text-primary {\n color: #ff6e1c;\n}\n.text-secondary {\n color: #4956dc;\n}\n.capitalize {\n text-transform: capitalize !important;\n}\n.font-normal {\n font-weight: 400;\n}\n.font-medium {\n font-weight: 500;\n}\n.font-bold {\n font-weight: 700;\n}\n.bg-transparent {\n background-color: transparent;\n}\n.bg-white {\n background-color: white;\n}\n.border-collapse {\n border-collapse: collapse;\n}\n.border-t-solid {\n border-top-style: solid;\n}\n.border-b-solid {\n border-bottom-style: solid;\n}\n.border-t-1 {\n border-top-width: 1px;\n}\n.border-b-1 {\n border-bottom-width: 1px;\n}\n.gap-0 {\n gap: 0 !important;\n}\n.gap-0\\.5 {\n gap: 0.125rem;\n}\n.gap-1 {\n gap: 0.25rem;\n}\n.gap-2 {\n gap: 0.5rem;\n}\n.gap-3 {\n gap: 0.75rem;\n}\n.gap-4 {\n gap: 1rem !important;\n}\n.gap-5 {\n gap: 1.25rem;\n}\n.gap-6 {\n gap: 1.5rem !important;\n}\n.gap-8 {\n gap: 2rem !important;\n}\n.gap-12 {\n gap: 3rem !important;\n}\n/* Padding Utilities */\n.p-0 {\n padding: 0;\n}\n.p-1 {\n padding: 0.25rem;\n}\n.p-2 {\n padding: 0.5rem;\n}\n.p-3 {\n padding: 0.75rem;\n}\n.p-4 {\n padding: 1rem;\n}\n.p-5 {\n padding: 1.25rem;\n}\n.p-6 {\n padding: 1.5rem;\n}\n.p-8 {\n padding: 2rem;\n}\n/* Padding X Utilities */\n.px-0 {\n padding-right: 0;\n padding-left: 0;\n}\n.px-1 {\n padding-right: 0.25rem;\n padding-left: 0.25rem;\n}\n.px-2 {\n padding-right: 0.5rem;\n padding-left: 0.5rem;\n}\n.px-3 {\n padding-right: 0.75rem;\n padding-left: 0.75rem;\n}\n.px-4 {\n padding-right: 1rem;\n padding-left: 1rem;\n}\n.px-5 {\n padding-right: 1.25rem;\n padding-left: 1.25rem;\n}\n.px-6 {\n padding-right: 1.5rem;\n padding-left: 1.5rem;\n}\n.px-8 {\n padding-right: 2rem;\n padding-left: 2rem;\n}\n.px-12 {\n padding-right: 3rem;\n padding-left: 3rem;\n}\n/* Padding Y Utilities */\n.py-0 {\n padding-top: 0;\n padding-bottom: 0;\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-3 {\n padding-top: 0.75rem;\n padding-bottom: 0.75rem;\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/* Padding Top Utilities */\n.pt-0 {\n padding-top: 0;\n}\n.pt-1 {\n padding-top: 0.25rem;\n}\n.pt-2 {\n padding-top: 0.5rem;\n}\n.pt-3 {\n padding-top: 0.75rem;\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/* Padding Right Utilities */\n.pr-0 {\n padding-right: 0;\n}\n.pr-4 {\n padding-right: 1rem;\n}\n.pr-8 {\n padding-right: 2rem;\n}\n/* Padding Bottom Utilities */\n.pb-0 {\n padding-bottom: 0;\n}\n.pb-1 {\n padding-bottom: 0.25rem;\n}\n.pb-2 {\n padding-bottom: 0.5rem;\n}\n.pb-3 {\n padding-bottom: 0.75rem;\n}\n.pb-4 {\n padding-bottom: 1rem;\n}\n.pb-5 {\n padding-bottom: 1.25rem;\n}\n.pb-6 {\n padding-bottom: 1.5rem;\n}\n.pb-8 {\n padding-bottom: 2rem;\n}\n/* Padding Left Utilities */\n.pl-0 {\n padding-left: 0;\n}\n.pl-1 {\n padding-left: 0.25rem;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pl-4 {\n padding-left: 1rem;\n}\n.pl-8 {\n padding-left: 2rem;\n}\n/* Space Utilities */\n.space-y-2 {\n gap: 0.5rem;\n}\n.space-y-4 {\n gap: 1rem;\n}\n.space-y-8 {\n gap: 2rem;\n}\n/* Margin Utilities */\n.ml-2 {\n margin-left: 0.5rem;\n}\n.ml-6 {\n margin-left: 1.5rem;\n}\n.ml-8 {\n margin-left: 2rem;\n}\n.mb-0 {\n margin-bottom: 0;\n}\n.mb-1 {\n margin-bottom: 0.25rem;\n}\n.mb-2 {\n margin-bottom: 0.5rem;\n}\n.mb-3 {\n margin-bottom: 0.75rem;\n}\n.mb-4 {\n margin-bottom: 1rem;\n}\n.mb-5 {\n margin-bottom: 1.25rem;\n}\n.mb-6 {\n margin-bottom: 1.5rem;\n}\n.mb-8 {\n margin-bottom: 2rem;\n}\n.mr-2 {\n margin-right: 0.5rem;\n}\n.mr-4 {\n margin-right: 1rem;\n}\n.mr-6 {\n margin-right: 1.5rem;\n}\n.mr-8 {\n margin-right: 2rem;\n}\n.mt-0 {\n margin-top: 0;\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-5 {\n margin-top: 1.25rem;\n}\n.mt-6 {\n margin-top: 1.5rem;\n}\n.mt-8 {\n margin-top: 2rem;\n}\n.my-1 {\n margin-top: 0.25rem;\n margin-bottom: 0.25rem;\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.my-8 {\n margin-top: 2rem;\n margin-bottom: 2rem;\n}\n.my-12 {\n margin-top: 3rem;\n margin-bottom: 3rem;\n}\n.mx-2 {\n margin-left: 0.5rem;\n margin-right: 0.5rem;\n}\n.mx-4 {\n margin-left: 1rem;\n margin-right: 1rem;\n}\n.mx-8 {\n margin-left: 2rem;\n margin-right: 2rem;\n}\n.w-full {\n width: 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-14 {\n width: 3.5rem;\n /* 56px */\n}\n.w-20 {\n width: 5rem;\n /* 80px */\n}\n.h-full {\n height: 100%;\n}\n.h-4 {\n height: 1rem;\n}\n.h-5 {\n height: 1.25rem;\n}\n.h-6 {\n height: 1.5rem;\n}\n.h-8 {\n height: 2rem;\n}\n.h-14 {\n height: 3.5rem;\n /* 56px */\n}\n.h-80 {\n height: 20rem;\n}\n.h-96 {\n height: 24rem;\n}\n.cursor-pointer {\n cursor: pointer;\n}\n.cursor-not-allowed {\n cursor: not-allowed;\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.grid-cols-4 {\n grid-template-columns: repeat(4, minMax(0, 1fr));\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.col-span-4 {\n grid-column: span 4 / span 4;\n}\n.col-span-full {\n grid-column: 1 / -1;\n}\n/* Background colors */\n.bg-black {\n background-color: #000000;\n}\n.bg-slate-50 {\n background-color: #f8fafc;\n}\n.bg-slate-100 {\n background-color: #f1f5f9;\n}\n.bg-slate-200 {\n background-color: #e2e8f0;\n}\n.bg-slate-300 {\n background-color: #cbd5e1;\n}\n.bg-slate-400 {\n background-color: #94a3b8;\n}\n.bg-slate-500 {\n background-color: #64748b;\n}\n.bg-slate-600 {\n background-color: #475569;\n}\n.bg-slate-700 {\n background-color: #334155;\n}\n.bg-slate-800 {\n background-color: #1e293b;\n}\n.bg-slate-900 {\n background-color: #0f172a;\n}\n.bg-slate-950 {\n background-color: #020617;\n}\n.bg-gray-50 {\n background-color: #f9fafb;\n}\n.bg-gray-100 {\n background-color: #f3f4f6;\n}\n.bg-gray-200 {\n background-color: #e5e7eb;\n}\n.bg-gray-300 {\n background-color: #d1d5db;\n}\n.bg-gray-400 {\n background-color: #9ca3af;\n}\n.bg-gray-500 {\n background-color: #6b7280;\n}\n.bg-gray-600 {\n background-color: #4b5563;\n}\n.bg-gray-700 {\n background-color: #374151;\n}\n.bg-gray-800 {\n background-color: #1f2937;\n}\n.bg-gray-900 {\n background-color: #111827;\n}\n.bg-gray-950 {\n background-color: #030712;\n}\n.bg-green-200 {\n background-color: #a7f3d0;\n}\n.bg-green-500 {\n background-color: #10b981;\n}\n.bg-blue-50 {\n background-color: #eff6ff;\n}\n.bg-blue-100 {\n background-color: #dbeafe;\n}\n.bg-blue-200 {\n background-color: #bfdbfe;\n}\n.bg-blue-300 {\n background-color: #93c5fd;\n}\n.bg-blue-400 {\n background-color: #60a5fa;\n}\n.bg-blue-500 {\n background-color: #3b82f6;\n}\n.bg-blue-600 {\n background-color: #2563eb;\n}\n.bg-blue-700 {\n background-color: #1d4ed8;\n}\n.bg-blue-800 {\n background-color: #1e40af;\n}\n.bg-blue-900 {\n background-color: #1e3a8a;\n}\n.bg-blue-950 {\n background-color: #172554;\n}\n.bg-orange-50 {\n background-color: #fff7ed;\n}\n.bg-orange-100 {\n background-color: #ffedd5;\n}\n.bg-orange-200 {\n background-color: #fed7aa;\n}\n.bg-orange-300 {\n background-color: #fdba74;\n}\n.bg-orange-400 {\n background-color: #fb923c;\n}\n.bg-orange-500 {\n background-color: #f97316;\n}\n.bg-orange-600 {\n background-color: #ea580c;\n}\n.bg-orange-700 {\n background-color: #c2410c;\n}\n.bg-orange-800 {\n background-color: #9a3412;\n}\n.bg-orange-900 {\n background-color: #7c2d12;\n}\n.bg-orange-950 {\n background-color: #431407;\n}\n.bg-yellow-200 {\n background-color: #fde68a;\n}\n.bg-red-200 {\n background-color: #fecaca;\n}\n/* Text colors */\n.text-black {\n color: #000000;\n}\n.text-white {\n color: #ffffff;\n}\n.text-slate-50 {\n color: #f8fafc;\n}\n.text-slate-100 {\n color: #f1f5f9;\n}\n.text-slate-200 {\n color: #e2e8f0;\n}\n.text-slate-300 {\n color: #cbd5e1;\n}\n.text-slate-400 {\n color: #94a3b8;\n}\n.text-slate-500 {\n color: #64748b;\n}\n.text-slate-600 {\n color: #475569;\n}\n.text-slate-700 {\n color: #334155;\n}\n.text-slate-800 {\n color: #1e293b;\n}\n.text-slate-900 {\n color: #0f172a;\n}\n.text-slate-950 {\n color: #020617;\n}\n.text-gray-50 {\n color: #f9fafb;\n}\n.text-gray-100 {\n color: #f3f4f6;\n}\n.text-gray-200 {\n color: #e5e7eb;\n}\n.text-gray-300 {\n color: #d1d5db;\n}\n.text-gray-400 {\n color: #9ca3af;\n}\n.text-gray-500 {\n color: #6b7280;\n}\n.text-gray-600 {\n color: #4b5563;\n}\n.text-gray-700 {\n color: #374151;\n}\n.text-gray-800 {\n color: #1f2937;\n}\n.text-gray-900 {\n color: #111827;\n}\n.text-gray-950 {\n color: #030712;\n}\n.text-green-600 {\n color: #059669;\n}\n.text-green-700 {\n color: #047857;\n}\n.text-blue-50 {\n color: #eff6ff;\n}\n.text-blue-100 {\n color: #dbeafe;\n}\n.text-blue-200 {\n color: #bfdbfe;\n}\n.text-blue-300 {\n color: #93c5fd;\n}\n.text-blue-400 {\n color: #60a5fa;\n}\n.text-blue-500 {\n color: #3b82f6;\n}\n.text-blue-600 {\n color: #2563eb;\n}\n.text-blue-700 {\n color: #1d4ed8;\n}\n.text-blue-800 {\n color: #1e40af;\n}\n.text-blue-900 {\n color: #1e3a8a;\n}\n.text-blue-950 {\n color: #172554;\n}\n.text-orange-50 {\n color: #fff7ed;\n}\n.text-orange-100 {\n color: #ffedd5;\n}\n.text-orange-200 {\n color: #fed7aa;\n}\n.text-orange-300 {\n color: #fdba74;\n}\n.text-orange-400 {\n color: #fb923c;\n}\n.text-orange-500 {\n color: #f97316;\n}\n.text-orange-600 {\n color: #ea580c;\n}\n.text-orange-700 {\n color: #c2410c;\n}\n.text-orange-800 {\n color: #9a3412;\n}\n.text-orange-900 {\n color: #7c2d12;\n}\n.text-orange-950 {\n color: #431407;\n}\n.text-yellow-500 {\n color: #f59e0b;\n}\n.text-yellow-700 {\n color: #b45309;\n}\n.text-red-500 {\n color: #ef4444;\n}\n.text-red-700 {\n color: #b91c1c;\n}\n.border {\n border-width: 1px;\n}\n.border-2 {\n border-width: 2px;\n}\n.border-l {\n border-left-width: 1px;\n}\n.border-dashed {\n border-style: dashed;\n}\n.border-solid {\n border-style: solid;\n}\n.border-slate-50 {\n border-color: #f8fafc;\n}\n.border-slate-100 {\n border-color: #f1f5f9;\n}\n.border-slate-200 {\n border-color: #e2e8f0;\n}\n.border-slate-300 {\n border-color: #cbd5e1;\n}\n.border-slate-400 {\n border-color: #94a3b8;\n}\n.border-slate-500 {\n border-color: #64748b;\n}\n.border-slate-600 {\n border-color: #475569;\n}\n.border-slate-700 {\n border-color: #334155;\n}\n.border-slate-800 {\n border-color: #1e293b;\n}\n.border-slate-900 {\n border-color: #0f172a;\n}\n.border-slate-950 {\n border-color: #020617;\n}\n.border-gray-400 {\n border-color: #9ca3af;\n}\n.border-gray-500 {\n border-color: #6b7280;\n}\n.origin-center {\n transform-origin: center;\n}\n.rotate-45 {\n transform: rotate(45deg);\n}\n.translate-x-2\\/4 {\n transform: translateX(50%);\n}\n.-translate-x-2\\/4 {\n transform: translateX(-50%);\n}\n.translate-y-2\\/4 {\n transform: translateY(50%);\n}\n.translate-y-full {\n transform: translateY(100%);\n}\n.-translate-y-full {\n transform: translateY(-100%);\n}\n.shadow-sm {\n box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);\n}\n.shadow {\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);\n}\n.shadow-md {\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);\n}\n.shadow-lg {\n box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n}\n.shadow-xl {\n box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);\n}\n.shadow-2xl {\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\n}\n.shadow-inner {\n box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);\n}\n.shadow-none {\n box-shadow: 0 0 #0000;\n}\n@media (min-width: 768px) {\n .sm\\:flex {\n display: flex !important;\n }\n .sm\\:hidden {\n display: none !important;\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";
1746
- styleInject(css_248z);
1748
+ var MUTATION$8 = "\nquery FormattedInvoice($id: ID) {\n formattedInvoice(id: $id) {\n amount\n amountDue\n amountPaid\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n createdAt\n credits\n currency\n currencyId\n currencySymbol\n customerBillingCity\n customerBillingContact\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n dueAt\n html\n id\n isLegacy\n netPaymentDays\n number\n payableId\n poNumber\n printedState\n smallUnitAmountDue\n state\n subscriptionEndDate\n subscriptionStartDate\n subtotal\n taxAmount\n taxNumber\n uuid\n vendorName\n formattedLines {\n amount\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n lineText\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListName\n prorationRate\n quantity\n unitOfMeasure\n priceTiers {\n price\n starts\n }\n }\n }\n}";
1749
+ var getFormattedInvoice = function (_a) {
1750
+ var id = _a.id, token = _a.token, subdomain = _a.subdomain;
1751
+ return __awaiter(void 0, void 0, void 0, function () {
1752
+ var vars, response;
1753
+ return __generator(this, function (_b) {
1754
+ switch (_b.label) {
1755
+ case 0:
1756
+ vars = { id: id };
1757
+ return [4 /*yield*/, gqlRequest({
1758
+ query: MUTATION$8,
1759
+ token: token,
1760
+ vars: vars,
1761
+ subdomain: subdomain,
1762
+ })];
1763
+ case 1:
1764
+ response = _b.sent();
1765
+ return [2 /*return*/, response === null || response === void 0 ? void 0 : response.formattedInvoice];
1766
+ }
1767
+ });
1768
+ });
1769
+ };
1747
1770
 
1748
1771
  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}";
1749
1772
  var usePaymentMethod = function (graphQLClient) {
@@ -1901,7 +1924,6 @@ var PaymentContext = createContext({});
1901
1924
  var CheckoutFooter = function (_a) {
1902
1925
  var amountDue = _a.amountDue, currencyId = _a.currencyId, isSaving = _a.isSaving, onPaymentSubmit = _a.onPaymentSubmit, onlySavePaymentMethod = _a.onlySavePaymentMethod, noPadding = _a.noPadding;
1903
1926
  var isMobile = useIsMobile$1();
1904
- var invoice = useContext(InvoiceCheckoutContext).invoice;
1905
1927
  var displayPayButtonNameAnyways = useContext(PaymentContext).displayPayButtonNameAnyways;
1906
1928
  var buttonName = function () {
1907
1929
  return onlySavePaymentMethod && !displayPayButtonNameAnyways
@@ -1912,11 +1934,6 @@ var CheckoutFooter = function (_a) {
1912
1934
  ? "Paying"
1913
1935
  : "Pay";
1914
1936
  };
1915
- useEffect(function () {
1916
- if (invoice) {
1917
- onPaymentSubmit();
1918
- }
1919
- }, [invoice]);
1920
1937
  return (jsx("div", __assign({ className: "flex justify-end gap-2 ".concat(noPadding ? "" : "pt-6") }, { children: jsx(Button, __assign({ className: "w-full", disabled: isSaving, onClick: onPaymentSubmit, size: isMobile ? "large" : "middle", type: "primary" }, { children: "".concat(buttonName()).concat(amountDue && currencyId
1921
1938
  ? " ".concat(Misc.formatCurrency(amountDue, currencyId))
1922
1939
  : "") })) })));
@@ -2252,8 +2269,8 @@ var DemoPayForm = function (_a) {
2252
2269
  switch (_a.label) {
2253
2270
  case 0:
2254
2271
  _a.trys.push([0, 6, , 7]);
2255
- validateCardDetails();
2256
2272
  if (!onlySavePaymentMethod) return [3 /*break*/, 2];
2273
+ validateCardDetails();
2257
2274
  setIsSaving(true);
2258
2275
  return [4 /*yield*/, storePayment({
2259
2276
  testCreditCardNumber: unformatCardNumber(cardDetails.number),
@@ -2279,6 +2296,7 @@ var DemoPayForm = function (_a) {
2279
2296
  return [3 /*break*/, 5];
2280
2297
  case 2:
2281
2298
  if (!(amountDue !== undefined && currencyId)) return [3 /*break*/, 4];
2299
+ validateCardDetails();
2282
2300
  setIsSaving(true);
2283
2301
  return [4 /*yield*/, confirmPayment({
2284
2302
  amount: amountDue,
@@ -2769,7 +2787,7 @@ var PaymentForm = function (_a) {
2769
2787
  return (jsx(ActualPaymentForm, { invoice: invoice, isSaving: isSaving, onFail: onFail, onPaymentSuccess: onPaymentSuccess, quote: quote, setIsSaving: setIsSaving }));
2770
2788
  };
2771
2789
 
2772
- 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";
2790
+ var MUTATION$7 = "\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";
2773
2791
  var checkout = function (_a) {
2774
2792
  var quoteId = _a.quoteId, invoiceId = _a.invoiceId, paymentMethodId = _a.paymentMethodId, paymentMethodData = _a.paymentMethodData, token = _a.token, subdomain = _a.subdomain;
2775
2793
  return __awaiter(void 0, void 0, void 0, function () {
@@ -2786,7 +2804,7 @@ var checkout = function (_a) {
2786
2804
  mutationVars.paymentMethodData = __assign(__assign({}, paymentMethodData), { metadata: paymentMethodData.metadata });
2787
2805
  }
2788
2806
  return [4 /*yield*/, gqlRequest({
2789
- query: MUTATION$8,
2807
+ query: MUTATION$7,
2790
2808
  token: token,
2791
2809
  vars: mutationVars,
2792
2810
  subdomain: subdomain,
@@ -2923,31 +2941,8 @@ function InvoicePDF(_a) {
2923
2941
  }, title: "Invoice PDF", width: "100%" }));
2924
2942
  }
2925
2943
 
2926
- var MUTATION$7 = "\nquery FormattedInvoice($id: ID) {\n formattedInvoice(id: $id) {\n amount\n amountDue\n amountPaid\n billingCity\n billingCountry\n billingState\n billingStreet\n billingZip\n createdAt\n credits\n currency\n currencyId\n currencySymbol\n customerBillingCity\n customerBillingContact\n customerBillingCountry\n customerBillingState\n customerBillingStreet\n customerBillingZip\n customerName\n dueAt\n html\n id\n isLegacy\n netPaymentDays\n number\n payableId\n poNumber\n printedState\n smallUnitAmountDue\n state\n subscriptionEndDate\n subscriptionStartDate\n subtotal\n taxAmount\n taxNumber\n uuid\n vendorName\n formattedLines {\n amount\n billingPeriodEnd\n billingPeriodStart\n chargeType\n discount\n frequency\n lineText\n position\n price\n priceDecimals\n priceListChargeId\n priceListChargeName\n priceListName\n prorationRate\n quantity\n unitOfMeasure\n priceTiers {\n price\n starts\n }\n }\n }\n}";
2927
- var getFormattedInvoice = function (_a) {
2928
- var id = _a.id, token = _a.token, subdomain = _a.subdomain;
2929
- return __awaiter(void 0, void 0, void 0, function () {
2930
- var vars, response;
2931
- return __generator(this, function (_b) {
2932
- switch (_b.label) {
2933
- case 0:
2934
- vars = { id: id };
2935
- return [4 /*yield*/, gqlRequest({
2936
- query: MUTATION$7,
2937
- token: token,
2938
- vars: vars,
2939
- subdomain: subdomain,
2940
- })];
2941
- case 1:
2942
- response = _b.sent();
2943
- return [2 /*return*/, response === null || response === void 0 ? void 0 : response.formattedInvoice];
2944
- }
2945
- });
2946
- });
2947
- };
2948
-
2949
2944
  function ActualInvoice(_a) {
2950
- var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onPaymentSuccess = _a.onPaymentSuccess; _a.storedPaymentMethod;
2945
+ var id = _a.id, invoiceQuoteViewComponent = _a.invoiceQuoteViewComponent, backButtonName = _a.backButtonName, onBackButtonClick = _a.onBackButtonClick, onPaymentSuccess = _a.onPaymentSuccess;
2951
2946
  var _b = useState(false), isSaving = _b[0], setIsSaving = _b[1];
2952
2947
  var queryClient = useQueryClient();
2953
2948
  var isMobile = useIsMobile$1();
@@ -3298,1095 +3293,1175 @@ function Quote(_a) {
3298
3293
  }
3299
3294
  var templateObject_1$5;
3300
3295
 
3301
- var DrawerHeader = function (_a) {
3302
- var description = _a.description, onClose = _a.onClose, title = _a.title;
3303
- 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 }))] })));
3304
- };
3305
-
3306
- var LargeCardIcon = function () {
3307
- return (jsx("svg", __assign({ width: "72", height: "56", viewBox: "0 0 72 56", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: jsx("path", { d: "M8 0H64C68.375 0 72 3.625 72 8V12H0V8C0 3.625 3.5 0 8 0ZM72 24V48C72 52.5 68.375 56 64 56H8C3.5 56 0 52.5 0 48V24H72ZM14 40C12.875 40 12 41 12 42C12 43.125 12.875 44 14 44H22C23 44 24 43.125 24 42C24 41 23 40 22 40H14ZM28 42C28 43.125 28.875 44 30 44H46C47 44 48 43.125 48 42C48 41 47 40 46 40H30C28.875 40 28 41 28 42Z", fill: "#E2E8F0" }) })));
3296
+ var QUOTES_QUERY = function (filter) { return "\n query quotes {\n quotes ".concat(filter ? "(".concat(filter, ")") : "", " {\n pageInfo {\n startCursor\n endCursor\n hasNextPage\n hasPreviousPage\n }\n nodes {\n id\n name\n account {\n name\n id\n }\n applicationDate\n state\n createdAt\n expiresAt\n currencyId\n amount\n number\n }\n }\n }"); };
3297
+ var getQuotes = function (_a) {
3298
+ var token = _a.token, subdomain = _a.subdomain, filter = _a.filter;
3299
+ return __awaiter(void 0, void 0, void 0, function () {
3300
+ var response;
3301
+ return __generator(this, function (_b) {
3302
+ switch (_b.label) {
3303
+ case 0: return [4 /*yield*/, gqlRequest({
3304
+ query: QUOTES_QUERY(filter),
3305
+ token: token,
3306
+ vars: {},
3307
+ subdomain: subdomain,
3308
+ })];
3309
+ case 1:
3310
+ response = _b.sent();
3311
+ return [2 /*return*/, response === null || response === void 0 ? void 0 : response.quotes];
3312
+ }
3313
+ });
3314
+ });
3308
3315
  };
3309
3316
 
3310
- var PlusIcon = function (_a) {
3311
- var color = _a.color;
3312
- 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" })] })));
3313
- };
3317
+ var transactionMutation = function (filter) { return "\nquery transactions {\n transactions ".concat(filter ? "(".concat(filter, ")") : "", " {\n nodes {\n amount\n createdAt\n currencyId\n description\n id\n kind\n state\n transactionableId\n transactionable {\n ...on Payment { amount }\n ...on Invoice { amount number }\n }\n }\n }\n}"); };
3318
+ var getTransactions = function (filter, token, subdomain, kindsToShow) { return __awaiter(void 0, void 0, void 0, function () {
3319
+ var response, _a, data, errors, transactions;
3320
+ var _b, _c;
3321
+ return __generator(this, function (_d) {
3322
+ switch (_d.label) {
3323
+ case 0: return [4 /*yield*/, fetch(subdomain + "/graphql", {
3324
+ method: "POST",
3325
+ headers: {
3326
+ "Content-type": "application/json; charset=utf-8",
3327
+ Authorization: "Bearer ".concat(token),
3328
+ },
3329
+ body: JSON.stringify({
3330
+ query: transactionMutation(filter),
3331
+ }),
3332
+ })];
3333
+ case 1:
3334
+ response = _d.sent();
3335
+ return [4 /*yield*/, response.json()];
3336
+ case 2:
3337
+ _a = _d.sent(), data = _a.data, errors = _a.errors;
3338
+ if (errors) {
3339
+ throw new Error(errors[0].message);
3340
+ }
3341
+ transactions = (_c = (_b = data === null || data === void 0 ? void 0 : data.transactions) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.filter(function (transaction) { return kindsToShow.includes(transaction.kind); });
3342
+ return [2 /*return*/, transactions === null || transactions === void 0 ? void 0 : transactions.reverse()];
3343
+ }
3344
+ });
3345
+ }); };
3314
3346
 
3315
- var PaymentMethodContext = createContext({});
3347
+ var pageContentRefState = atom({
3348
+ key: "pageContentRefState",
3349
+ default: undefined,
3350
+ });
3316
3351
 
3317
- var Card = function (_a) {
3352
+ var PageContent = function (_a) {
3318
3353
  var children = _a.children, className = _a.className, style = _a.style;
3319
- var darkMode = useContext(BunnyContext).darkMode;
3320
- return (jsx("div", __assign({ className: "flex flex-col rounded-md shadow-md ".concat(className), style: __assign(__assign({}, style), { backgroundColor: darkMode
3321
- ? "var(--row-background-dark)"
3322
- : "var(--row-background)" }) }, { children: children })));
3354
+ var pageContentRef = useRef(null);
3355
+ var setPageContentRef = useSetRecoilState(pageContentRefState);
3356
+ useEffect(function () {
3357
+ setPageContentRef(pageContentRef === null || pageContentRef === void 0 ? void 0 : pageContentRef.current);
3358
+ }, [pageContentRef, setPageContentRef]);
3359
+ return (jsx("div", __assign({ className: className, ref: pageContentRef, style: style }, { children: children })));
3323
3360
  };
3324
3361
 
3325
3362
  var Text$b = Typography.Text;
3326
- var CreditCard = function (_a) {
3327
- var _b, _c, _d;
3328
- var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData;
3329
- var isExpired = function (paymentMethodData) {
3330
- // paymentMethodData.expirationDate
3331
- var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
3332
- return expDate.isBefore(dayjs());
3333
- };
3363
+ var PageHeaderWithActions = function (_a) {
3364
+ var children = _a.children, title = _a.title;
3334
3365
  var isMobile = useIsMobile$1();
3335
- var processPublicUrl = useContext(PaymentMethodContext).processPublicUrl;
3336
- return (jsxs(Card, __assign({ className: "shadow-md 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: [getCardImage((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer) && (jsx("img", { alt: "Card", width: "24px", src: "".concat(processPublicUrl, "/").concat(getCardImage((_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.issuer)) })), jsx(Text$b, { children: (_d = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _d === void 0 ? void 0 : _d.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: dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).format("MM/YY") }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
3366
+ return (jsxs("div", __assign({ className: "flex pb-4 shadow-padding-x ".concat(isMobile ? "flex-col gap-2" : "items-center justify-between h-8") }, { children: [jsx(PageSubTitle, { title: title }), children] })));
3337
3367
  };
3338
- var CardAttribute = function (_a) {
3339
- var title = _a.title, value = _a.value;
3340
- 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$b, { children: value })] })));
3368
+ var PageSubTitle = function (_a) {
3369
+ var title = _a.title;
3370
+ var secondaryColor = useContext(BrandContext).secondaryColor;
3371
+ var darkMode = useContext(BunnyContext).darkMode;
3372
+ return (jsx(Text$b, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title })));
3341
3373
  };
3342
- var CardActions = function (_a) {
3343
- var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
3344
- var isMobile = useIsMobile$1();
3345
- return (jsxs("div", __assign({ className: "flex items-center gap-6 ".concat(isMobile ? "justify-center mt-4" : "") }, { children: [jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove payment method" })) })), jsx(Divider, { style: { height: "24px" }, type: "vertical" }), jsx(Button, __assign({ onClick: onClickUpdate, type: "primary" }, { children: "Update" }))] })));
3374
+
3375
+ var StateTag = function (_a) {
3376
+ var state = _a.state;
3377
+ return jsx(Tag, __assign({ color: getColor(state) }, { children: capitalize(startCase(state)) }));
3346
3378
  };
3347
- var EmptyCard = function (_a) {
3348
- var onClick = _a.onClick;
3349
- var brandColor = useContext(BrandContext).brandColor;
3350
- return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center w-full pt-8 px-4 pb-6 cursor-pointer bg-white shadow-md rounded-md", onClick: onClick }, { children: [jsx(LargeCardIcon, {}), jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsx(Button, __assign({ type: "link" }, { children: jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
3379
+ var getColor = function (state) {
3380
+ switch (state) {
3381
+ case FrontendTransaction.TransactionState.not_due:
3382
+ return "yellow";
3383
+ case FrontendTransaction.TransactionState.voided:
3384
+ return "black";
3385
+ case FrontendTransaction.TransactionState.ready:
3386
+ return "orange";
3387
+ case FrontendTransaction.TransactionState.preparing:
3388
+ return "purple";
3389
+ case FrontendTransaction.TransactionState.unapplied:
3390
+ case FrontendTransaction.TransactionState.partially_applied:
3391
+ case FrontendTransaction.TransactionState.applied:
3392
+ return "blue";
3393
+ case FrontendTransaction.TransactionState.due:
3394
+ case FrontendTransaction.TransactionState.unpaid:
3395
+ return "orange";
3396
+ case FrontendTransaction.TransactionState.failed:
3397
+ return "red";
3398
+ case FrontendTransaction.TransactionState.paid:
3399
+ return "green";
3400
+ default:
3401
+ return "blue";
3402
+ }
3351
3403
  };
3352
- var getCardImage = function (issuer) {
3353
- if (issuer === "visa")
3354
- return "Visa_Brandmark_Blue_RGB_2021.png";
3355
- else if (issuer === "mastercard")
3356
- return "mc_symbol_opt_73_3x.png";
3404
+
3405
+ var TransactionGridCell = styled.div.withConfig({
3406
+ shouldForwardProp: function (prop) {
3407
+ return !["gridColumn", "padding", "right"].includes(prop);
3408
+ },
3409
+ })(templateObject_1$4 || (templateObject_1$4 = __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);
3410
+ var templateObject_1$4;
3411
+
3412
+ var Text$a = Typography.Text;
3413
+ var TransactionDate = function (_a) {
3414
+ var date = _a.date;
3415
+ return jsx(Text$a, __assign({ className: "text-sm" }, { children: Misc.formatDate(date) }));
3357
3416
  };
3358
3417
 
3359
- var ActualPaymentMethod = function () {
3360
- var _a = useContext(BunnyContext), token = _a.token, subdomain = _a.subdomain, graphQLClient = _a.graphQLClient;
3361
- var accountId = useContext(PaymentContext).accountId;
3362
- // Hooks
3363
- var queryClient = useQueryClient();
3364
- var paymentPlugins = usePaymentPlugins({ subdomain: subdomain, token: token }).paymentPlugins;
3365
- var showErrorNotification = NotificationUtils.useErrorNotification();
3366
- var showSuccessNotification = NotificationUtils.useSuccessNotification();
3367
- var handleAllErrorFormats = NotificationUtils.useAllErrorFormats(function () {
3368
- console.log("Navigation in PaymentMethod.tsx useAllErrorFormats not implemented");
3369
- });
3370
- var isMobile = useIsMobile$1();
3371
- var data = usePaymentMethod(graphQLClient).data;
3372
- // Local state
3373
- var _b = useState(false), showModal = _b[0], setShowModal = _b[1];
3374
- var _c = useState(false), isSaving = _c[0], setIsSaving = _c[1];
3375
- // Queries
3376
- useQuery({
3377
- queryKey: QueryKeyFactory.default.currentUserKey,
3378
- queryFn: function () { return getCurrentUserData({ token: token, subdomain: subdomain }); },
3379
- });
3380
- var plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(function (paymentPlugin) { var _a; return String(paymentPlugin.id) === ((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
3381
- var onClickRemove = function () {
3382
- if (data && plugin) {
3383
- invokePlugin({
3384
- plugin: plugin,
3385
- method: "remove_payment_method",
3386
- payload: {
3387
- payment_method_id: data.id,
3388
- account_id: accountId,
3389
- },
3390
- token: token,
3391
- subdomain: subdomain,
3392
- })
3393
- .then(function () {
3394
- showSuccessNotification("Payment method was removed", "Success");
3395
- queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey, null);
3396
- })
3397
- .catch(function (error) {
3398
- showErrorNotification(error.message, "Error removing Payment Method");
3399
- });
3400
- }
3401
- };
3402
- var onSuccess = function () {
3403
- queryClient.invalidateQueries({
3404
- queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
3405
- });
3406
- setShowModal(false);
3407
- showSuccessNotification("Your payment method has been saved");
3408
- };
3409
- if (data === undefined)
3418
+ var isInvoice = function (transaction) {
3419
+ return transaction.kind === "INVOICE";
3420
+ };
3421
+ var isQuote = function (transaction) {
3422
+ return transaction.kind === "QUOTE";
3423
+ };
3424
+ var TransactionRowTitle = function (_a) {
3425
+ var transaction = _a.transaction;
3426
+ if (!isInvoice(transaction) && !isQuote(transaction)) {
3410
3427
  return jsx(Fragment, {});
3411
- return (jsxs(Fragment, { children: [data ? (jsx(CreditCard, { onClickRemove: onClickRemove, onClickUpdate: function () { return setShowModal(true); }, paymentMethodData: data })) : (jsx(EmptyCard, { onClick: function () { return setShowModal(true); } })), jsx(Drawer, __assign({ closeIcon: null, onClose: function () { return setShowModal(false); }, open: showModal, styles: {
3412
- body: isMobile
3413
- ? {
3414
- padding: "1rem 0 0",
3415
- }
3416
- : {},
3417
- wrapper: isMobile ? { width: "100vw" } : { width: "min-content" },
3418
- }, title: jsx(DrawerHeader, { onClose: function () { return setShowModal(false); }, title: "New payment method" }) }, { children: jsx(PaymentForm, { isSaving: isSaving, onFail: function (error) {
3419
- handleAllErrorFormats(error);
3420
- setIsSaving(false);
3421
- }, onPaymentSuccess: function () {
3422
- onSuccess();
3423
- setIsSaving(false);
3424
- }, setIsSaving: setIsSaving }) }))] }));
3428
+ }
3429
+ return (jsx("span", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
3425
3430
  };
3426
- function PaymentMethod(_a) {
3427
- var footer = _a.footer, processPublicUrl = _a.processPublicUrl;
3428
- return (jsx(PaymentMethodContext.Provider, __assign({ value: { footer: footer, processPublicUrl: processPublicUrl } }, { children: jsx(ActualPaymentMethod, {}) })));
3429
- }
3430
3431
 
3431
- var MUTATION$5 = "\nmutation accountUpdate(\n $id: ID!,\n $attributes: AccountAttributes!) {\n accountUpdate(\n id: $id,\n attributes: $attributes\n ) {\n account { id }\n errors\n }\n }\n";
3432
- var accountUpdate = function (_a) {
3433
- var accountId = _a.accountId, attributes = _a.attributes, token = _a.token;
3434
- return __awaiter(void 0, void 0, void 0, function () {
3435
- var vars, response, errors;
3436
- var _b;
3437
- return __generator(this, function (_c) {
3438
- switch (_c.label) {
3439
- case 0:
3440
- vars = { id: accountId, attributes: attributes };
3441
- return [4 /*yield*/, gqlRequest({ query: MUTATION$5, token: token, vars: vars })];
3442
- case 1:
3443
- response = _c.sent();
3444
- errors = (_b = response === null || response === void 0 ? void 0 : response.accountUpdate) === null || _b === void 0 ? void 0 : _b.errors;
3445
- if (errors)
3446
- throw errors;
3447
- return [2 /*return*/, response.accountUpdate];
3448
- }
3449
- });
3450
- });
3432
+ // TODO: delete
3433
+ var ArrowDownToLine = function (_a) {
3434
+ var className = _a.className, _b = _a.color, color = _b === void 0 ? SLATE_600 : _b;
3435
+ return (jsxs("svg", __assign({ className: className, fill: "none", height: "16", viewBox: "0 0 16 16", width: "16", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("path", { d: "M8 11.3333V2", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M4 7.33301L8 11.333L12 7.33301", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M12.6654 14H3.33203", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
3451
3436
  };
3452
3437
 
3453
- var COUNTRIES_REQUIRING_STATE = ["US", "CA"];
3454
- var TaxationForm = function (_a) {
3455
- var account = _a.account, quote = _a.quote;
3456
- // Hooks
3457
- var queryClient = useQueryClient();
3458
- var token = useContext(BunnyContext).token;
3459
- var form = Form.useForm()[0];
3460
- // Mutations
3461
- var _b = useMutation({
3462
- mutationFn: function (changedFormData) { return __awaiter(void 0, void 0, void 0, function () {
3463
- var account;
3464
- return __generator(this, function (_a) {
3465
- switch (_a.label) {
3466
- case 0: return [4 /*yield*/, accountUpdate({
3467
- accountId: quote.accountId,
3468
- attributes: changedFormData,
3469
- token: token,
3470
- })];
3471
- case 1:
3472
- account = _a.sent();
3473
- return [2 /*return*/, account];
3474
- }
3475
- });
3476
- }); },
3477
- onSuccess: function () {
3478
- queryClient.invalidateQueries({
3479
- queryKey: ["getTaxationRequiredAccountFields", token],
3480
- });
3481
- },
3482
- }), updateAccount = _b.mutate, isUpdatingAccount = _b.isPending;
3483
- 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) {
3484
- var _a, _b;
3485
- return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(input.toLowerCase()) ||
3486
- ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : "").toLowerCase().includes(input.toLowerCase());
3487
- } }) })), jsx(Form.Item, __assign({ label: "Billing zip", name: "billingZip" }, { children: jsx(Input, { placeholder: "Zip" }) })), jsx(Form.Item, { children: jsx(Button, __assign({ className: "w-full", disabled: isUpdatingAccount, htmlType: "submit", type: "primary" }, { children: "Submit" })) })] })));
3488
- };
3489
- var FormBillingState = function (_a) {
3490
- _a.form;
3491
- var billingCountry = Form.useWatch("billingCountry");
3492
- var billingStateRequired = COUNTRIES_REQUIRING_STATE.includes(billingCountry);
3493
- return (jsx(Form.Item, __assign({ label: "Billing state", name: "billingState", rules: [{ required: billingStateRequired }] }, { children: jsx(Input, { placeholder: "State" }) })));
3494
- };
3438
+ var TransactionsListContext = createContext({});
3495
3439
 
3496
- var QuoteCheckout = function (_a) {
3497
- var account = _a.account, isSaving = _a.isSaving, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, setIsSaving = _a.setIsSaving, taxationRequiredAccountFields = _a.taxationRequiredAccountFields; _a.storedPaymentMethod;
3498
- // Context
3440
+ var TransactionDownload = function (_a) {
3441
+ var transaction = _a.transaction, token = _a.token, subdomain = _a.subdomain;
3442
+ var darkMode = useContext(BunnyContext).darkMode;
3443
+ var downloadTransactionLink = useContext(TransactionsListContext).downloadTransactionLink;
3444
+ var downloadFile = useDownloadFile();
3499
3445
  var isMobile = useIsMobile$1();
3500
- var _b = useContext(BunnyContext), subdomain = _b.subdomain, token = _b.token;
3501
- var paymentRequired = getQuoteAmountDue(quote) > 0;
3502
- var checkoutMutation = useMutation({
3503
- mutationFn: function (_a) {
3504
- var pluginPaymentMethod = _a.pluginPaymentMethod, savedPaymentMethod = _a.storedPaymentMethod;
3505
- if (!quote)
3506
- throw new Error("Quote is required");
3507
- if (!paymentRequired)
3508
- return checkout({ quoteId: quote.id, token: token, subdomain: subdomain });
3509
- if (savedPaymentMethod) {
3510
- var paymentMethodId = savedPaymentMethod.paymentMethodId;
3511
- return checkout({
3512
- quoteId: quote.id,
3513
- paymentMethodId: paymentMethodId,
3514
- token: token,
3515
- subdomain: subdomain,
3516
- });
3517
- }
3518
- if (pluginPaymentMethod) {
3519
- var plugin = pluginPaymentMethod.plugin, savePaymentMethod = pluginPaymentMethod.savePaymentMethod, metadata = pluginPaymentMethod.metadata;
3520
- var paymentToken = pluginPaymentMethod.token;
3521
- return checkout({
3522
- quoteId: quote.id,
3523
- paymentMethodData: {
3524
- metadata: metadata,
3525
- pluginGuid: plugin.guid,
3526
- savePaymentMethod: savePaymentMethod,
3527
- token: paymentToken,
3528
- },
3529
- token: token,
3530
- subdomain: subdomain,
3531
- });
3532
- }
3533
- throw new Error("Pay payment method provided");
3534
- },
3535
- onSuccess: onSuccess,
3536
- onError: onFail,
3537
- });
3538
- // Handlers
3539
- var handleCheckout = function (_a) {
3540
- var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
3541
- return __awaiter(void 0, void 0, void 0, function () {
3542
- var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
3543
- return __generator(this, function (_b) {
3544
- if (pluginPaymentResponse) {
3545
- token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
3546
- checkoutMutation.mutate({
3547
- pluginPaymentMethod: {
3548
- savePaymentMethod: savePaymentMethod,
3549
- plugin: plugin,
3550
- metadata: metadata,
3551
- token: token_1,
3552
- },
3553
- });
3554
- }
3555
- else if (savedPaymentMethodResponse) {
3556
- paymentMethodId = savedPaymentMethodResponse.paymentMethodId;
3557
- checkoutMutation.mutate({
3558
- storedPaymentMethod: {
3559
- paymentMethodId: paymentMethodId,
3560
- },
3561
- });
3562
- }
3563
- else {
3564
- checkoutMutation.mutate({});
3565
- }
3566
- return [2 /*return*/];
3567
- });
3568
- });
3569
- };
3570
- if (taxationRequiredAccountFields)
3571
- return (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsx(TaxationForm, { account: account, quote: quote }) })));
3572
- return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { isSaving: isSaving, onFail: onFail, onPaymentSuccess: handleCheckout, quote: quote, setIsSaving: setIsSaving })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsx(Button, __assign({ disabled: isSaving, onClick: function () {
3573
- setIsSaving(true);
3574
- handleCheckout({});
3575
- }, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
3446
+ var isClickable = transaction.kind === "INVOICE" || downloadTransactionLink !== undefined;
3447
+ var downloadLink = downloadTransactionLink
3448
+ ? downloadTransactionLink(transaction.transactionableId)
3449
+ : "".concat(subdomain, "/api/pdf/invoice/").concat(transaction.transactionableId);
3450
+ if (!isClickable)
3451
+ return null;
3452
+ return (jsx("div", __assign({ onClick: function (e) {
3453
+ e.stopPropagation();
3454
+ downloadFile(downloadLink, token);
3455
+ } }, { children: jsx(ArrowDownToLine, { className: "".concat(isMobile ? "" : "show-on-hover"), color: darkMode ? WHITE : SLATE_600 }) })));
3576
3456
  };
3577
3457
 
3578
- var useHasTaxPlugin = function (_a) {
3579
- var subdomain = _a.subdomain, token = _a.token;
3580
- var plugins = usePlugins({
3581
- subdomain: subdomain,
3582
- token: token,
3583
- }).data;
3584
- return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some(function (plugin) { return plugin.type === "taxation"; }));
3458
+ var Text$9 = Typography.Text;
3459
+ var TransactionsEmptyState = function () {
3460
+ var noTransactionsMessage = useContext(TransactionsListContext).noTransactionsMessage;
3461
+ return (jsx(Text$9, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no transactions" })));
3585
3462
  };
3586
3463
 
3587
- var QUOTE_FIELDS = "quote {\n formattedQuote {\n html\n }\n acceptedByName\n acceptedByTitle\n accountId\n amount\n amountDue\n applicationDate\n applied\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 invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n ownerId\n periodAmount\n poNumber\n requiresApproval\n startDate\n state\n subtotal\n taxAmount\n updatedAt\n uuid\n amountsByPeriod {\n amount\n id\n name\n }\n endDateOptions {\n endDate\n label\n }\n invoiceUntilOptions {\n endDate\n label\n }\n quoteChanges {\n id\n priceListId\n charges {\n amount\n amountsByPeriod { amount startDate }\n billingPeriod\n billingPeriodAmounts { id amount prorationRate }\n chargeType\n couponId\n createdAt\n currencyId\n discount\n endDate\n feature { id name code isUnit unitName }\n id\n invoiceLineText\n name\n price\n priceDecimals\n priceTiers { starts price }\n pricingModel\n prorationRate\n quantity\n quantityMax\n quantityMin\n startDate\n tieredAveragePrice\n updatedAt\n }\n }\n}";
3588
-
3589
- var QUOTE_RECALCULATE_TAXES = "\n mutation QuoteRecalculateTaxes($id: ID!) {\n quoteRecalculateTaxes(id: $id) {\n ".concat(QUOTE_FIELDS, "\n errors\n }\n }\n");
3590
- var quoteRecalculateTaxes = function (_a) {
3591
- var quoteId = _a.quoteId, token = _a.token;
3592
- return __awaiter(void 0, void 0, void 0, function () {
3593
- var vars, response, errors;
3594
- var _b, _c;
3595
- return __generator(this, function (_d) {
3596
- switch (_d.label) {
3597
- case 0:
3598
- vars = { id: quoteId };
3599
- return [4 /*yield*/, gqlRequest({
3600
- query: QUOTE_RECALCULATE_TAXES,
3601
- token: token,
3602
- vars: vars,
3603
- })];
3604
- case 1:
3605
- response = _d.sent();
3606
- errors = (_b = response === null || response === void 0 ? void 0 : response.quoteRecalculateTaxes) === null || _b === void 0 ? void 0 : _b.errors;
3607
- if (errors)
3608
- throw errors;
3609
- return [2 /*return*/, (_c = response.quoteRecalculateTaxes) === null || _c === void 0 ? void 0 : _c.quote];
3610
- }
3611
- });
3612
- });
3464
+ function capitalizeFirstLetter(string) {
3465
+ return string.charAt(0).toUpperCase() + string.slice(1);
3466
+ }
3467
+ var WARREN_STATE_LS_KEY = "warrenState";
3468
+ var CURRENT_WARREN_ID_LS_KEY = "currentWarrenId";
3469
+ var getIsCapacitorApp = function () {
3470
+ var isAndroid = window.location.origin === "http://localhost";
3471
+ var isIOS = window.location.protocol === "capacitor:";
3472
+ return isAndroid || isIOS;
3613
3473
  };
3614
-
3615
- var planPickerQuoteDataState = atom({
3616
- key: "planPickerQuoteDataState",
3617
- default: undefined,
3618
- });
3619
-
3620
- var pageWrapperClassName = function (isMobile) {
3621
- return "flex flex-col grow pt-4 ".concat(isMobile ? "pb-4 overflow-hidden" : "pb-8", " ").concat("content-container");
3474
+ var getLocalStorageSubdomain = function () {
3475
+ var warrenState = JSON.parse(window.localStorage.getItem(WARREN_STATE_LS_KEY) || "{}");
3476
+ var subdomain = warrenState[CURRENT_WARREN_ID_LS_KEY];
3477
+ if (!subdomain) {
3478
+ console.warn("ERROR_MESSAGE_NO_SUBDOMAIN_DEFINED");
3479
+ //throw new Error(ERROR_MESSAGE_NO_SUBDOMAIN_DEFINED);
3480
+ }
3481
+ return subdomain;
3482
+ };
3483
+ var getApiHost = function (subdomain) {
3484
+ var isLocalHost = window.location.href.indexOf(".internal") > 0;
3485
+ var sub = subdomain || getLocalStorageSubdomain();
3486
+ if (getIsCapacitorApp()) {
3487
+ return isLocalHost || process.env.REACT_APP_IS_INTERNAL === "true"
3488
+ ? "https://".concat(sub, ".bunny.internal")
3489
+ : "https://".concat(sub, ".").concat(process.env.REACT_APP_ROOT_DOMAIN);
3490
+ }
3491
+ return "";
3622
3492
  };
3493
+ var getGraphQLBase = function () {
3494
+ if (getIsCapacitorApp()) {
3495
+ return "".concat(getApiHost(), "/graphql");
3496
+ }
3497
+ return "/graphql";
3498
+ };
3499
+ var createRequestHeaders = function (token) {
3500
+ var bearerToken = "Bearer ".concat(token);
3501
+ var headers = {
3502
+ "Content-type": "application/json; charset=utf-8",
3503
+ };
3504
+ headers["Authorization"] = bearerToken;
3505
+ return headers;
3506
+ };
3507
+ var useGraphQLRequest = function () { return function (query, token, variables) { return __awaiter(void 0, void 0, void 0, function () {
3508
+ var error_1;
3509
+ return __generator(this, function (_a) {
3510
+ switch (_a.label) {
3511
+ case 0:
3512
+ _a.trys.push([0, 2, , 3]);
3513
+ return [4 /*yield*/, request(getGraphQLBase(), query, variables, createRequestHeaders(token))];
3514
+ case 1: return [2 /*return*/, _a.sent()];
3515
+ case 2:
3516
+ error_1 = _a.sent();
3517
+ throw error_1;
3518
+ case 3: return [2 /*return*/];
3519
+ }
3520
+ });
3521
+ }); }; };
3623
3522
 
3624
- var queryKeyFactory = QueryKeyFactory.default;
3625
- var Checkout = function (_a) {
3626
- var _b, _c;
3627
- var onCancel = _a.onCancel, onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, open = _a.open, quote = _a.quote, selectedPriceList = _a.selectedPriceList, isMobile = _a.isMobile, token = _a.token, storedPaymentMethod = _a.storedPaymentMethod;
3628
- var subdomain = useContext(BunnyContext).subdomain;
3629
- var _d = useState(false), isSaving = _d[0], setIsSaving = _d[1];
3630
- var hasTaxPlugin = useHasTaxPlugin({ subdomain: subdomain || "", token: token });
3631
- var queryClient = useQueryClient();
3632
- var quotePreviewData = useRecoilValue(planPickerQuoteDataState);
3633
- // Queries
3634
- var _e = useQuery({
3635
- queryKey: ["getTaxationRequiredAccountFields", token],
3636
- queryFn: function () { return getTaxationRequiredAccountFields({ token: token }); },
3637
- enabled: Boolean(quote),
3638
- staleTime: 0,
3639
- }), taxationRequiredAccountFields = _e.data, isLoadingTaxationRequiredAccountFields = _e.isLoading;
3640
- var _f = useQuery({
3641
- queryKey: ["account", quote === null || quote === void 0 ? void 0 : quote.accountId],
3642
- queryFn: function () {
3643
- return (quote === null || quote === void 0 ? void 0 : quote.accountId) && getAccount({ id: quote.accountId, token: token });
3644
- },
3645
- enabled: Boolean(quote === null || quote === void 0 ? void 0 : quote.accountId) &&
3646
- ((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
3647
- }), account = _f.data, isLoadingAccount = _f.isLoading;
3648
- useQuery({
3649
- queryKey: queryKeyFactory.createQuoteTaxCalculateKey(quote === null || quote === void 0 ? void 0 : quote.id),
3650
- queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
3651
- var updatedQuote;
3652
- return __generator(this, function (_a) {
3653
- switch (_a.label) {
3654
- case 0:
3655
- if (!quote) return [3 /*break*/, 2];
3656
- return [4 /*yield*/, quoteRecalculateTaxes({
3657
- quoteId: quote.id,
3658
- token: token,
3659
- })];
3660
- case 1:
3661
- updatedQuote = _a.sent();
3662
- if (updatedQuote) {
3663
- queryClient.setQueryData(queryKeyFactory.createObjectKey("editingQuote", updatedQuote.id), updatedQuote);
3664
- queryClient.setQueryData(queryKeyFactory.calculatedPricesKey((quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity) || 0, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), updatedQuote);
3665
- }
3666
- _a.label = 2;
3667
- case 2: return [2 /*return*/, {}];
3668
- }
3669
- });
3670
- }); },
3671
- // Recalculate taxes if the quote is open, has a tax plugin, and the taxation required account fields are not required
3672
- enabled: Boolean(quote) &&
3673
- open &&
3674
- hasTaxPlugin &&
3675
- !taxationRequiredAccountFields &&
3676
- !isLoadingTaxationRequiredAccountFields,
3677
- staleTime: 0,
3523
+ var Text$8 = Typography.Text;
3524
+ var TransactionsListDesktop = function (_a) {
3525
+ var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
3526
+ var columns = useContext(TransactionsListContext).columns;
3527
+ var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain, darkMode = _b.darkMode;
3528
+ var showAmount = columns.includes("amount");
3529
+ var showDateAndTitle = columns.includes("date-and-title");
3530
+ var showDownload = columns.includes("download");
3531
+ var showState = columns.includes("state");
3532
+ if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
3533
+ return jsx(TransactionsEmptyState, {});
3534
+ return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
3535
+ var _a;
3536
+ var isClickable = onTransactionClick !== undefined;
3537
+ return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
3538
+ onTransactionClick === null || onTransactionClick === void 0 ? void 0 : onTransactionClick(transaction);
3539
+ }, style: {
3540
+ backgroundColor: index % 2 === 0
3541
+ ? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
3542
+ : "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
3543
+ } }, { children: [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$8, { children: capitalizeFirstLetter(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsx(TransactionGridCell, { children: jsx(TransactionDownload, { transaction: transaction, token: token, subdomain: subdomain }) })), showState && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(StateTag, { state: transaction.state }) }))), showAmount && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(Text$8, { children: Misc.formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
3678
3544
  });
3679
- if (!open || isLoadingTaxationRequiredAccountFields || isLoadingAccount)
3680
- return null;
3681
- return (jsx("div", __assign({ className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 bg-slate-50 overflow-auto", style: {
3682
- zIndex: 1001,
3683
- } }, { 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: isMobile })), !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, isSaving: isSaving, onFail: function (error) {
3684
- onFail(error);
3685
- setIsSaving(false);
3686
- }, onSuccess: function (_a) {
3687
- var savePaymentMethod = _a.savePaymentMethod;
3688
- onSuccess({ savePaymentMethod: savePaymentMethod });
3689
- setIsSaving(false);
3690
- }, setIsSaving: setIsSaving })) : quote ? (jsx(QuoteCheckout, { account: account, isSaving: isSaving, onFail: function (error) {
3691
- onFail(error);
3692
- setIsSaving(false);
3693
- }, onSuccess: function (_a) {
3694
- var savePaymentMethod = _a.savePaymentMethod;
3695
- onSuccess({ savePaymentMethod: savePaymentMethod });
3696
- setIsSaving(false);
3697
- }, quote: quote, setIsSaving: setIsSaving, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token, storedPaymentMethod: storedPaymentMethod })) : (jsx(PaymentForm, { isSaving: isSaving, onFail: function (error) {
3698
- onFail(error);
3699
- setIsSaving(false);
3700
- }, onPaymentSuccess: function (_a) {
3701
- var pluginPaymentResponse = _a.pluginPaymentResponse;
3702
- onSuccess({
3703
- savePaymentMethod: pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.savePaymentMethod,
3704
- });
3705
- setIsSaving(false);
3706
- }, setIsSaving: setIsSaving }))] }))] })) })));
3707
3545
  };
3708
3546
 
3709
- 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}"; };
3710
- var accountSignup = function (_a) {
3711
- var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, accountId = _a.accountId, quoteId = _a.quoteId, paymentToken = _a.paymentToken, paymentMethodId = _a.paymentMethodId, pluginId = _a.pluginId, priceListCode = _a.priceListCode;
3712
- return __awaiter(void 0, void 0, void 0, function () {
3713
- var vars, response, errors;
3714
- var _b;
3715
- return __generator(this, function (_c) {
3716
- switch (_c.label) {
3717
- case 0:
3718
- vars = {
3719
- entityId: entityId,
3720
- accountId: accountId,
3721
- quoteId: quoteId,
3722
- paymentToken: paymentToken,
3723
- pluginId: pluginId,
3724
- paymentMethodId: paymentMethodId,
3725
- priceListCode: priceListCode,
3726
- };
3727
- return [4 /*yield*/, gqlRequest({
3728
- query: MUTATION$4(),
3729
- token: token,
3730
- vars: vars,
3731
- subdomain: subdomain,
3732
- })];
3733
- case 1:
3734
- response = _c.sent();
3735
- errors = (_b = response === null || response === void 0 ? void 0 : response.accountSignup) === null || _b === void 0 ? void 0 : _b.errors;
3736
- if (errors)
3737
- throw errors;
3738
- return [2 /*return*/, response === null || response === void 0 ? void 0 : response.accountSignup];
3739
- }
3740
- });
3547
+ var Text$7 = Typography.Text;
3548
+ var TransactionsListMobile = function (_a) {
3549
+ var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
3550
+ var columns = useContext(TransactionsListContext).columns;
3551
+ var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain, darkMode = _b.darkMode;
3552
+ var showAmount = columns.includes("amount");
3553
+ var showDateAndTitle = columns.includes("date-and-title");
3554
+ var showDownload = columns.includes("download");
3555
+ var showState = columns.includes("state");
3556
+ if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
3557
+ return jsx(TransactionsEmptyState, {});
3558
+ return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
3559
+ var isClickable = transaction.kind === "INVOICE";
3560
+ return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
3561
+ onTransactionClick(transaction);
3562
+ }, style: {
3563
+ backgroundColor: index % 2 === 0
3564
+ ? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
3565
+ : "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
3566
+ } }, { 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$7, { children: capitalizeFirstLetter(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$7, { children: "\u00B7" }), showAmount && (jsx(Text$7, { children: Misc.formatCurrency(transaction.transactionable.amount || transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(TransactionDownload, { transaction: transaction, token: token, subdomain: subdomain }) })))] }), index));
3741
3567
  });
3742
3568
  };
3743
3569
 
3744
- var MUTATION$3 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $entityId: ID!,\n $priceListCode: String!\n) {\n quoteAccountSignup(\n entityId: $entityId,\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact\n ) {\n account {\n id\n }\n amount\n currencyId\n quote {\n id\n }\n tenant {\n code\n }\n errors\n }\n}"; };
3745
- var quoteAccountSignup = function (_a) {
3746
- var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
3747
- return __awaiter(void 0, void 0, void 0, function () {
3748
- var vars, response, errors;
3749
- var _b;
3750
- return __generator(this, function (_c) {
3751
- switch (_c.label) {
3752
- case 0:
3753
- vars = {
3754
- entityId: entityId,
3755
- priceListCode: priceListCode,
3756
- accountName: accountName,
3757
- billingContact: billingContact,
3758
- };
3759
- return [4 /*yield*/, gqlRequest({
3760
- query: MUTATION$3(),
3761
- token: token,
3762
- vars: vars,
3763
- subdomain: subdomain,
3764
- })];
3765
- case 1:
3766
- response = _c.sent();
3767
- errors = (_b = response === null || response === void 0 ? void 0 : response.quoteAccountSignup) === null || _b === void 0 ? void 0 : _b.errors;
3768
- if (errors)
3769
- throw errors;
3770
- return [2 /*return*/, response === null || response === void 0 ? void 0 : response.quoteAccountSignup];
3570
+ // Create a client
3571
+ var queryClient = new QueryClient();
3572
+ function Transactions(_a) {
3573
+ var transactionComponent = _a.transactionComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.columns, columns = _d === void 0 ? ["date-and-title", "state", "amount"] : _d, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? "md" : _e, searchBarClassName = _a.searchBarClassName, _f = _a.useModal, useModal = _f === void 0 ? false : _f, onTransactionClick = _a.onTransactionClick, _g = _a.suppressTransactionDisplay, suppressTransactionDisplay = _g === void 0 ? false : _g, _h = _a.kindsToShow, kindsToShow = _h === void 0 ? [
3574
+ TransactionKind.INVOICE,
3575
+ TransactionKind.PAYMENT,
3576
+ TransactionKind.REFUND,
3577
+ TransactionKind.WRITE_OFF,
3578
+ ] : _h, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage;
3579
+ var contextValues = {
3580
+ showSearchBar: showSearchBar,
3581
+ showTitle: showTitle,
3582
+ transactionComponent: transactionComponent,
3583
+ columns: columns,
3584
+ className: className,
3585
+ searchBarClassName: searchBarClassName,
3586
+ shadow: shadow,
3587
+ useModal: useModal,
3588
+ onTransactionClick: onTransactionClick,
3589
+ suppressTransactionDisplay: suppressTransactionDisplay,
3590
+ kindsToShow: kindsToShow,
3591
+ style: style,
3592
+ filter: filter,
3593
+ noTransactionsMessage: noTransactionsMessage,
3594
+ };
3595
+ return (jsx(QueryClientProvider, __assign({ client: queryClient }, { children: jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsx(TransactionsWrapper, {}) })) })));
3596
+ }
3597
+ function TransactionsWrapper() {
3598
+ var _a = useContext(TransactionsListContext), kindsToShow = _a.kindsToShow, filterFromContext = _a.filter;
3599
+ var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain;
3600
+ // Local state
3601
+ var _c = useState(""), search = _c[0], setSearch = _c[1];
3602
+ var filter = filterFromContext ||
3603
+ (search ? "filter: \"transaction.transactionableId is ".concat(search, "\"") : "");
3604
+ // Queries
3605
+ var data = useQuery({
3606
+ queryKey: ["transactions", token, filter],
3607
+ queryFn: function () { return getTransactions(filter, token, subdomain, kindsToShow); },
3608
+ placeholderData: keepPreviousData,
3609
+ }).data;
3610
+ return (jsx(TransactionsDisplay, { transactions: data, onSearchValueChanged: setSearch, search: search }));
3611
+ }
3612
+ function TransactionsDisplay(_a) {
3613
+ var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search, title = _a.title;
3614
+ var _b = useContext(TransactionsListContext), showSearchBar = _b.showSearchBar, showTitle = _b.showTitle, transactionComponent = _b.transactionComponent, useModal = _b.useModal, suppressTransactionDisplay = _b.suppressTransactionDisplay, className = _b.className, shadow = _b.shadow, searchBarClassName = _b.searchBarClassName, style = _b.style, onTransactionClick = _b.onTransactionClick;
3615
+ var columns = useContext(TransactionsListContext).columns;
3616
+ var darkMode = useContext(BunnyContext).darkMode;
3617
+ // Local state
3618
+ var _c = useState(null), selectedTransaction = _c[0], setSelectedTransaction = _c[1];
3619
+ var _d = useState(false), drawerOpen = _d[0], setDrawerOpen = _d[1];
3620
+ // Hooks
3621
+ var isMobile = useIsMobile$1();
3622
+ function handleTransactionClick(transaction) {
3623
+ if (onTransactionClick) {
3624
+ onTransactionClick(transaction);
3625
+ }
3626
+ if (!suppressTransactionDisplay) {
3627
+ setSelectedTransaction(transaction);
3628
+ setDrawerOpen(true);
3629
+ }
3630
+ }
3631
+ // Since the columns are dynamic, we need to calculate the grid template columns
3632
+ var gridTemplateColumns = function () {
3633
+ var templateColumns = [];
3634
+ if (isMobile) {
3635
+ if (columns.includes("date-and-title") ||
3636
+ columns.includes("state") ||
3637
+ columns.includes("amount")) {
3638
+ templateColumns.push("auto");
3771
3639
  }
3772
- });
3773
- });
3774
- };
3775
-
3776
- var MUTATION$2 = function () { return "\nquery PriceList($code: String!) {\n priceList (code: $code) {\n basePrice\n code\n createdAt\n currencyId\n id\n isVisible\n name\n periodMonths\n planId\n priceDescription\n productId\n sku\n trialAllowed\n trialLengthDays\n updatedAt\n }\n}"; };
3777
- var getPriceList = function (_a) {
3778
- var token = _a.token, code = _a.code, subdomain = _a.subdomain;
3779
- return __awaiter(void 0, void 0, void 0, function () {
3780
- var response;
3781
- return __generator(this, function (_b) {
3782
- switch (_b.label) {
3783
- case 0: return [4 /*yield*/, gqlRequest({
3784
- query: MUTATION$2(),
3785
- token: token,
3786
- vars: { code: code },
3787
- subdomain: subdomain,
3788
- })];
3789
- case 1:
3790
- response = _b.sent();
3791
- return [2 /*return*/, response === null || response === void 0 ? void 0 : response.priceList];
3640
+ if (columns.includes("download")) {
3641
+ templateColumns.push("auto");
3792
3642
  }
3793
- });
3794
- });
3795
- };
3796
-
3797
- function PaymentForms(_a) {
3798
- var quote = _a.quote, paying = _a.paying, setIsPaying = _a.setIsPaying, handlePaymentSaveSuccess = _a.handlePaymentSaveSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId;
3799
- return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: accountId && (jsx(PaymentContext.Provider, __assign({ value: { accountId: accountId, displayPayButtonNameAnyways: true } }, { children: jsx(PaymentForm, { isSaving: paying, setIsSaving: setIsPaying, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSaveSuccess }) }))) })) : (jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
3800
- }
3801
- function InitialSignupForm(_a) {
3802
- var onSubmit = _a.onSubmit, submitting = _a.submitting;
3803
- var _b = useState({
3804
- firstName: "",
3805
- lastName: "",
3806
- email: "",
3807
- accountName: "",
3808
- }), formData = _b[0], setFormData = _b[1];
3809
- var handleInputChange = function (e) {
3810
- var _a;
3811
- var _b = e.target, name = _b.name, value = _b.value;
3812
- setFormData(__assign(__assign({}, formData), (_a = {}, _a[name] = value, _a)));
3643
+ }
3644
+ else {
3645
+ if (columns.includes("date-and-title")) {
3646
+ templateColumns.push("auto 3fr");
3647
+ }
3648
+ if (columns.includes("download")) {
3649
+ templateColumns.push("auto");
3650
+ }
3651
+ if (columns.includes("state")) {
3652
+ templateColumns.push("auto");
3653
+ }
3654
+ if (columns.includes("amount")) {
3655
+ templateColumns.push("auto");
3656
+ }
3657
+ }
3658
+ return templateColumns.join(" ");
3813
3659
  };
3814
- return (jsxs(Form, __assign({ className: "flex w-1/2 flex-col justify-between h-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) {
3815
- handleInputChange(e);
3816
- setFormData(__assign(__assign({}, formData), { firstName: e.target.value }));
3817
- } }) })), 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) {
3818
- handleInputChange(e);
3819
- setFormData(__assign(__assign({}, formData), { lastName: e.target.value }));
3820
- } }) })), jsx(Form.Item, __assign({ rules: [
3821
- { required: true, message: "Please input your email!" },
3822
- { type: "email", message: "Please enter a valid email!" },
3823
- ], initialValue: formData.email }, { children: jsx(Input, { placeholder: "Email", value: formData.email, onChange: function (e) {
3824
- handleInputChange(e);
3825
- setFormData(__assign(__assign({}, formData), { email: e.target.value }));
3826
- } }) })), jsx(Form.Item, __assign({ rules: [
3827
- { required: true, message: "Please input your account name!" },
3828
- ], initialValue: formData.accountName }, { children: jsx(Input, { placeholder: "Account name", value: formData.accountName, onChange: function (e) {
3829
- handleInputChange(e);
3830
- setFormData(__assign(__assign({}, formData), { accountName: e.target.value }));
3831
- } }) }))] })), jsx(Form.Item, { children: jsx(Button, __assign({ type: "primary", htmlType: "submit", loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
3660
+ var drawerTitle = function () {
3661
+ if (!selectedTransaction)
3662
+ return "";
3663
+ var kind = selectedTransaction.kind.toLowerCase();
3664
+ return kind.charAt(0).toUpperCase() + kind.slice(1);
3665
+ };
3666
+ return (jsxs("div", __assign({ style: style }, { children: [jsx(PageHeaderWithActions, __assign({ title: title || (showTitle ? "Past transactions" : undefined) }, { children: showSearchBar && (jsx("div", { children: jsx(Input, { className: searchBarClassName
3667
+ ? searchBarClassName
3668
+ : "border border-slate-200", onChange: function (e) {
3669
+ if (isNaN(Number(e.target.value))) {
3670
+ return;
3671
+ }
3672
+ onSearchValueChanged(e.target.value);
3673
+ }, prefix: jsx(SearchOutlined$1, {}), placeholder: "Search by id #", style: {
3674
+ minWidth: "300px",
3675
+ }, value: search }) })) })), jsx(PageContent, __assign({ className: "flex w-full shadow-padding-xb ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: jsx("div", __assign({ className: "grid w-full rounded-md overflow-auto ".concat("shadow-".concat(shadow)), style: {
3676
+ gridTemplateColumns: gridTemplateColumns(),
3677
+ backgroundColor: "var(--row-background".concat(darkMode ? "-dark" : "", ")"),
3678
+ } }, { children: isMobile ? (jsx(Fragment, { children: TransactionsListMobile({
3679
+ transactions: transactions,
3680
+ onTransactionClick: handleTransactionClick,
3681
+ }) })) : (jsx(Fragment, { children: TransactionsListDesktop({
3682
+ transactions: transactions,
3683
+ onTransactionClick: handleTransactionClick,
3684
+ }) })) })) })), useModal ? (jsx(Modal, __assign({ title: "Basic Modal", open: drawerOpen, onOk: function () { return setDrawerOpen(false); }, onCancel: function () { return setDrawerOpen(false); }, width: 900, footer: null }, { children: jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "" }) }))) : (jsx(Drawer, __assign({ title: drawerTitle(), onClose: function () { return setDrawerOpen(false); }, open: drawerOpen, width: 900 }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsx(Invoice, { id: selectedTransaction.transactionableId })) : (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: Misc.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 })] })] }))) })))] })));
3832
3685
  }
3833
3686
 
3834
- var Title = Typography.Title, Text$a = Typography.Text;
3835
- function PaymentSuccessDisplay(_a) {
3836
- var className = _a.className, amountPaid = _a.amountPaid, style = _a.style, returnUrl = _a.returnUrl;
3837
- var window = useContext(BunnyContext).window;
3838
- var companyName = useCurrentUserData().companyName;
3839
- return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", Misc.formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxs(Text$a, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
3687
+ function Quotes(_a) {
3688
+ var filter = _a.filter, quoteComponent = _a.quoteComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.columns, columns = _d === void 0 ? ["date-and-title", "amount", "download"] : _d, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? "md" : _e, searchBarClassName = _a.searchBarClassName, _f = _a.useModal, useModal = _f === void 0 ? false : _f; _a.onQuoteClick; var _g = _a.suppressQuoteDisplay, suppressQuoteDisplay = _g === void 0 ? false : _g, style = _a.style, _h = _a.noQuotesMessage, noQuotesMessage = _h === void 0 ? "There are no quotes" : _h;
3689
+ var subdomain = useContext(BunnyContext).subdomain;
3690
+ var _j = useState(null), component = _j[0], setComponent = _j[1];
3691
+ var contextValues = {
3692
+ columns: columns,
3693
+ kindsToShow: [],
3694
+ onTransactionClick: handleQuoteClick,
3695
+ transactionComponent: component,
3696
+ showSearchBar: showSearchBar,
3697
+ showTitle: showTitle,
3698
+ className: className,
3699
+ shadow: shadow,
3700
+ searchBarClassName: searchBarClassName,
3701
+ useModal: useModal,
3702
+ suppressTransactionDisplay: suppressQuoteDisplay,
3703
+ style: style,
3704
+ noTransactionsMessage: noQuotesMessage,
3705
+ filter: filter,
3706
+ downloadTransactionLink: function (id) { return "".concat(subdomain, "/api/pdf/quote/").concat(id); },
3707
+ };
3708
+ function handleQuoteClick(quote) {
3709
+ if (quoteComponent) {
3710
+ setComponent(quoteComponent);
3711
+ }
3712
+ else {
3713
+ setComponent(jsx(Quote, { id: quote === null || quote === void 0 ? void 0 : quote.transactionableId }));
3714
+ }
3715
+ }
3716
+ return (jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsx(QuotesWrapper, {}) })));
3840
3717
  }
3841
-
3842
- var Text$9 = Typography.Text;
3843
- function PriceListDisplay(_a) {
3844
- var priceListData = _a.priceListData, topNavImageUrl = _a.topNavImageUrl;
3845
- if (!priceListData)
3718
+ function QuotesWrapper() {
3719
+ var _a = useContext(BunnyContext), token = _a.token, subdomain = _a.subdomain;
3720
+ var filterFromContext = useContext(TransactionsListContext).filter;
3721
+ // Local state
3722
+ var _b = useState(""), search = _b[0], setSearch = _b[1];
3723
+ var filter = filterFromContext || (search ? "filter: \"quote.id is ".concat(search, "\"") : "");
3724
+ // Queries
3725
+ var data = useQuery({
3726
+ queryKey: ["quotes", token, filter],
3727
+ queryFn: function () { return getQuotes({ token: token, subdomain: subdomain, filter: filter }); },
3728
+ placeholderData: keepPreviousData,
3729
+ }).data;
3730
+ if (data === undefined)
3846
3731
  return null;
3847
- 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$9, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxs(Text$9, __assign({ className: "font-bold text-xl" }, { children: [Misc.formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxs(Text$9, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsx(Text$9, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))] })) })) }));
3732
+ var quotesAsTransactions = data.nodes.map(function (quote) { return ({
3733
+ transactionableId: quote.id,
3734
+ state: "unapplied",
3735
+ amount: quote.amount || quote.amountDue,
3736
+ kind: "QUOTE",
3737
+ currencyId: quote.currencyId,
3738
+ transactionable: {
3739
+ number: quote.number,
3740
+ },
3741
+ createdAt: quote.createdAt,
3742
+ }); });
3743
+ return (jsx(TransactionsDisplay, { transactions: quotesAsTransactions, onSearchValueChanged: setSearch, search: search, title: "Past quotes" }));
3848
3744
  }
3849
3745
 
3850
- var BunnyFooterIcon = function (_a) {
3851
- var color = _a.color;
3852
- return (jsxs("svg", __assign({ width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxs("g", __assign({ clipPath: "url(#clip0_6_851)" }, { children: [jsx("path", { className: "icon-path", d: "M14.5898 7.19708C14.5898 9.35053 13.0926 10.325 11.2495 10.325C9.39955 10.325 7.90234 9.35001 7.90234 7.18967V3.26221H10.1125V7.00052C10.1125 7.87719 10.5855 8.27725 11.2495 8.27725C11.9061 8.27725 12.3865 7.87719 12.3865 7.00052V3.26221H14.5898V7.19708Z", fill: color }), jsx("path", { className: "icon-path", d: "M31.8943 12.9625H29.4793L31.8523 8.62816L28.9355 3.26221H31.4708L33.0457 6.35524L34.5924 3.26221H37.0075L31.8943 12.9625Z", fill: color }), jsx("path", { className: "icon-path", d: "M15.1602 5.96827C15.1602 3.8148 16.6574 2.84033 18.5005 2.84033C20.3504 2.84033 21.8476 3.81533 21.8476 5.97568V10.1473H19.6374V6.16483C19.6374 5.28815 19.1645 4.8881 18.5005 4.8881C17.8439 4.8881 17.3634 5.28815 17.3634 6.16483V10.1473H15.1602V5.96827Z", fill: color }), jsx("path", { className: "icon-path", d: "M22.4316 5.96827C22.4316 3.8148 23.9289 2.84033 25.7719 2.84033C27.6219 2.84033 29.1191 3.81533 29.1191 5.97568V10.1473H26.9089V6.16483C26.9089 5.28815 26.4359 4.8881 25.7719 4.8881C25.1154 4.8881 24.6349 5.28815 24.6349 6.16483V10.1473H22.4316V5.96827Z", fill: color }), jsx("path", { className: "icon-path", d: "M7.40511 6.68957C7.40511 8.7236 6.02815 10.3227 4.17816 10.3227C3.23907 10.3227 2.61071 9.94378 2.19358 9.40371V10.1404H0.0605469V0.0405273H2.26381V3.91939C2.68041 3.42158 3.28802 3.07069 4.17763 3.07069C6.02759 3.07069 7.40511 4.66981 7.40511 6.68957ZM2.17229 6.69642C2.17229 7.60802 2.77937 8.2744 3.64823 8.2744C4.53783 8.2744 5.13107 7.59372 5.13107 6.69642C5.13107 5.79912 4.53783 5.11844 3.64823 5.11844C2.77937 5.11844 2.17229 5.78482 2.17229 6.69642Z", fill: color }), jsx("path", { className: "icon-path", d: "M38.966 8.94801C38.966 9.76181 38.2668 10.4631 37.4618 10.4631C36.6499 10.4631 35.9434 9.76181 35.9434 8.94801C35.9434 8.14846 36.6494 7.46094 37.4618 7.46094C38.2668 7.46094 38.966 8.14846 38.966 8.94801Z", fill: color })] })), jsx("defs", { children: jsx("clipPath", __assign({ id: "clip0_6_851" }, { children: jsx("rect", { width: "39", height: "13", fill: "white" }) })) })] })));
3746
+ var DrawerHeader = function (_a) {
3747
+ var description = _a.description, onClose = _a.onClose, title = _a.title;
3748
+ 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 }))] })));
3853
3749
  };
3854
3750
 
3855
- var Footer = function (_a) {
3856
- var className = _a.className;
3857
- var _b = useCurrentUserData(), privacyUrl = _b.privacyUrl, termsUrl = _b.termsUrl;
3858
- var window = useContext(BunnyContext).window;
3859
- var isMobile = useIsMobile(window);
3860
- var quotePreviewData = useRecoilValue(planPickerQuoteDataState);
3861
- var selectedPriceList = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList;
3862
- if (selectedPriceList && isMobile)
3863
- return null;
3864
- return (jsxs("div", __assign({ className: "flex items-center justify-between shrink-0 ".concat(className, " ").concat(isMobile ? "flex-col gap-2 grow" : "") }, { children: [(termsUrl || privacyUrl) && (jsxs("div", __assign({ className: "flex items-center gap-3" }, { children: [termsUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: termsUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Terms" }))), privacyUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: privacyUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Privacy" })))] }))), jsx(BunnyMarketingLink, {})] })));
3865
- };
3866
- var BunnyMarketingLink = function () {
3867
- var _a = useState(false), isHovered = _a[0], setIsHovered = _a[1];
3868
- var window = useContext(BunnyContext).window;
3869
- var isMobile = useIsMobile(window);
3870
- return (jsx("div", __assign({ className: "flex items-end justify-end ".concat(isMobile ? "" : "grow") }, { children: jsx(StyledBunnyLink, __assign({ className: "flex items-end justify-end text-slate-400", href: "https://bunny.com/", rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: jsxs("div", __assign({ className: "flex items-center", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }, { children: ["Powered by\u00A0", jsx("div", __assign({ style: { paddingTop: "5px" } }, { children: jsx(BunnyFooterIcon, { color: isHovered ? PRIMARY_COLOR : SLATE_400 }) }))] })) })) })));
3751
+ var LargeCardIcon = function () {
3752
+ return (jsx("svg", __assign({ width: "72", height: "56", viewBox: "0 0 72 56", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: jsx("path", { d: "M8 0H64C68.375 0 72 3.625 72 8V12H0V8C0 3.625 3.5 0 8 0ZM72 24V48C72 52.5 68.375 56 64 56H8C3.5 56 0 52.5 0 48V24H72ZM14 40C12.875 40 12 41 12 42C12 43.125 12.875 44 14 44H22C23 44 24 43.125 24 42C24 41 23 40 22 40H14ZM28 42C28 43.125 28.875 44 30 44H46C47 44 48 43.125 48 42C48 41 47 40 46 40H30C28.875 40 28 41 28 42Z", fill: "#E2E8F0" }) })));
3871
3753
  };
3872
- var StyedLink = styled.a(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n"], ["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n"])), SLATE_400, SLATE_500);
3873
- var StyledBunnyLink = styled(StyedLink)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), PRIMARY_COLOR);
3874
- var templateObject_1$4, templateObject_2;
3875
3754
 
3876
- var MUTATION$1 = "\n mutation portalSessionCreate ($tenantCode: String!, $expiry: Int!, $returnUrl: String!) {\n portalSessionCreate (tenantCode: $tenantCode, expiry: $expiry, returnUrl: $returnUrl) {\n errors\n token\n }\n }\n";
3877
- var portalSessionCreate = function (_a) {
3878
- var tenantCode = _a.tenantCode, expiry = _a.expiry, returnUrl = _a.returnUrl, token = _a.token, subdomain = _a.subdomain;
3879
- return __awaiter(void 0, void 0, void 0, function () {
3880
- var response, errors;
3881
- var _b;
3882
- return __generator(this, function (_c) {
3883
- switch (_c.label) {
3884
- case 0: return [4 /*yield*/, gqlRequest({
3885
- query: MUTATION$1,
3886
- token: token,
3887
- vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
3888
- subdomain: subdomain,
3889
- })];
3890
- case 1:
3891
- response = _c.sent();
3892
- errors = (response === null || response === void 0 ? void 0 : response.portalSessionCreate).errors;
3893
- if (errors)
3894
- throw errors;
3895
- return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.portalSessionCreate) === null || _b === void 0 ? void 0 : _b.token];
3896
- }
3897
- });
3898
- });
3755
+ var PlusIcon = function (_a) {
3756
+ var color = _a.color;
3757
+ 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" })] })));
3899
3758
  };
3900
3759
 
3901
- var showErrorNotification = NotificationUtils.useErrorNotification();
3902
- function Signup(_a) {
3903
- var priceListCode = _a.priceListCode, returnUrl = _a.returnUrl;
3904
- // Hooks
3905
- var _b = useContext(BunnyContext), subdomain = _b.subdomain, token = _b.token, window = _b.window;
3906
- useQuery({
3907
- queryKey: QueryKeyFactory.default.currentUserKey,
3908
- queryFn: function () { return getCurrentUserData({ token: token, subdomain: subdomain }); },
3909
- });
3910
- var isMobile = useIsMobile(window);
3911
- var topNavImageUrl = useContext(BrandContext).topNavImageUrl;
3912
- var entityId = useCurrentUserData().entityId;
3913
- var _c = useState(undefined), quote = _c[0], setQuote = _c[1];
3914
- var _d = useState(undefined), accountId = _d[0], setAccountId = _d[1];
3915
- var _e = useState(undefined), quoteId = _e[0], setQuoteId = _e[1];
3916
- var _f = useState(undefined), portalSessionToken = _f[0], setPortalSessionToken = _f[1];
3917
- var _g = useState(undefined), formData = _g[0], setFormData = _g[1];
3918
- var _h = useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
3919
- var _j = useState(false), paying = _j[0], setIsPaying = _j[1];
3920
- var _k = useState(false), purchaseSucceeded = _k[0], setPurchaseSucceeded = _k[1];
3921
- // Queries
3922
- var priceListData = useQuery({
3923
- queryKey: ["priceList", priceListCode],
3924
- queryFn: function () { return getPriceList({ token: token, subdomain: subdomain, code: priceListCode }); },
3925
- }).data;
3926
- function handleSubmit(formData) {
3927
- return __awaiter(this, void 0, void 0, function () {
3928
- var data, portalSessionToken;
3929
- return __generator(this, function (_a) {
3930
- switch (_a.label) {
3931
- case 0:
3932
- setProceedingToPayment(true);
3933
- setFormData(formData);
3934
- return [4 /*yield*/, quoteAccountSignup({
3935
- token: token,
3936
- subdomain: subdomain,
3937
- entityId: entityId,
3938
- priceListCode: priceListCode,
3939
- accountName: formData.accountName,
3940
- billingContact: {
3941
- firstName: formData.firstName,
3942
- lastName: formData.lastName,
3943
- email: formData.email,
3944
- },
3945
- })];
3946
- case 1:
3947
- data = _a.sent();
3948
- setAccountId(data.account.id);
3949
- return [4 /*yield*/, portalSessionCreate({
3950
- token: token,
3951
- subdomain: subdomain,
3952
- tenantCode: data.tenant.code,
3953
- expiry: 24,
3954
- returnUrl: returnUrl || "",
3955
- })];
3956
- case 2:
3957
- portalSessionToken = _a.sent();
3958
- setPortalSessionToken(portalSessionToken);
3959
- setQuoteId(data.quote.id);
3960
- setProceedingToPayment(false);
3961
- setQuote({
3962
- amountDue: data.quote.amountDue,
3963
- currencyId: data.quote.currencyId,
3964
- });
3965
- return [2 /*return*/];
3966
- }
3967
- });
3968
- });
3969
- }
3970
- function handlePaymentSaveSuccess(paymentSuccess) {
3971
- var _a;
3972
- return __awaiter(this, void 0, void 0, function () {
3973
- var response, plugin;
3974
- return __generator(this, function (_b) {
3975
- switch (_b.label) {
3976
- case 0:
3977
- if (!formData) {
3978
- throw new Error("Form data is required");
3979
- }
3980
- response = paymentSuccess.pluginPaymentResponse;
3981
- plugin = response === null || response === void 0 ? void 0 : response.plugin;
3982
- if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
3983
- throw new Error("Plugin ID is required");
3984
- }
3985
- if (!accountId) {
3986
- throw new Error("Account ID is required");
3987
- }
3988
- if (!portalSessionToken) {
3989
- throw new Error("Portal session token is required");
3990
- }
3991
- return [4 /*yield*/, accountSignup({
3992
- token: portalSessionToken,
3993
- subdomain: subdomain,
3994
- entityId: entityId,
3995
- quoteId: quoteId,
3996
- paymentMethodId: (_a = paymentSuccess.savedPaymentMethodResponse) === null || _a === void 0 ? void 0 : _a.paymentMethodId.toString(),
3997
- pluginId: plugin.id.toString(),
3998
- priceListCode: priceListCode,
3999
- accountId: accountId,
4000
- })];
4001
- case 1:
4002
- _b.sent();
4003
- setIsPaying(false);
4004
- setPurchaseSucceeded(true);
4005
- return [2 /*return*/];
4006
- }
4007
- });
4008
- });
4009
- }
4010
- function handlePaymentFail(error) {
4011
- showErrorNotification(error.message);
4012
- setIsPaying(false);
4013
- }
4014
- if (isMobile) {
4015
- return (jsx(Card, __assign({ className: "p-4 flex flex-col" }, { children: purchaseSucceeded ? (jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, 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 items-center" }, { children: jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsx("div", __assign({ className: "mx-8" }, { children: jsx(Divider, { className: "h-full" }) })), jsx("div", __assign({ className: "flex items-center justify-center my-12" }, { children: jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })));
4016
- }
4017
- else {
4018
- return (jsxs(Fragment, { children: [jsx(Card, __assign({ className: "p-4 flex flex-col w-screen h-screen" }, { children: purchaseSucceeded ? (jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, 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 w-1/2 items-center" }, { children: jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsx("div", __assign({ className: "my-4" }, { children: jsx(Divider, { className: "h-full", type: "vertical" }) })), jsx("div", __assign({ className: "flex w-1/2 items-center justify-center my-12" }, { children: jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })), jsx(Footer, {})] }));
4019
- }
4020
- }
4021
-
4022
- var transactionMutation = function (filter) { return "\nquery transactions {\n transactions ".concat(filter ? "(".concat(filter, ")") : "", " {\n nodes {\n amount\n createdAt\n currencyId\n description\n id\n kind\n state\n transactionableId\n transactionable {\n ...on Payment { amount }\n ...on Invoice { amount number }\n }\n }\n }\n}"); };
4023
- var getTransactions = function (filter, token, subdomain, kindsToShow) { return __awaiter(void 0, void 0, void 0, function () {
4024
- var response, _a, data, errors, transactions;
4025
- var _b, _c;
4026
- return __generator(this, function (_d) {
4027
- switch (_d.label) {
4028
- case 0: return [4 /*yield*/, fetch(subdomain + "/graphql", {
4029
- method: "POST",
4030
- headers: {
4031
- "Content-type": "application/json; charset=utf-8",
4032
- Authorization: "Bearer ".concat(token),
4033
- },
4034
- body: JSON.stringify({
4035
- query: transactionMutation(filter),
4036
- }),
4037
- })];
4038
- case 1:
4039
- response = _d.sent();
4040
- return [4 /*yield*/, response.json()];
4041
- case 2:
4042
- _a = _d.sent(), data = _a.data, errors = _a.errors;
4043
- if (errors) {
4044
- throw new Error(errors[0].message);
4045
- }
4046
- transactions = (_c = (_b = data === null || data === void 0 ? void 0 : data.transactions) === null || _b === void 0 ? void 0 : _b.nodes) === null || _c === void 0 ? void 0 : _c.filter(function (transaction) { return kindsToShow.includes(transaction.kind); });
4047
- return [2 /*return*/, transactions === null || transactions === void 0 ? void 0 : transactions.reverse()];
4048
- }
4049
- });
4050
- }); };
4051
-
4052
- var pageContentRefState = atom({
4053
- key: "pageContentRefState",
4054
- default: undefined,
4055
- });
3760
+ var PaymentMethodContext = createContext({});
4056
3761
 
4057
- var PageContent = function (_a) {
3762
+ var Card = function (_a) {
4058
3763
  var children = _a.children, className = _a.className, style = _a.style;
4059
- var pageContentRef = useRef(null);
4060
- var setPageContentRef = useSetRecoilState(pageContentRefState);
4061
- useEffect(function () {
4062
- setPageContentRef(pageContentRef === null || pageContentRef === void 0 ? void 0 : pageContentRef.current);
4063
- }, [pageContentRef, setPageContentRef]);
4064
- return (jsx("div", __assign({ className: className, ref: pageContentRef, style: style }, { children: children })));
4065
- };
4066
-
4067
- var Text$8 = Typography.Text;
4068
- var PageHeaderWithActions = function (_a) {
4069
- var children = _a.children, title = _a.title;
4070
- var isMobile = useIsMobile$1();
4071
- return (jsxs("div", __assign({ className: "flex pb-4 shadow-padding-x ".concat(isMobile ? "flex-col gap-2" : "items-center justify-between h-8") }, { children: [jsx(PageSubTitle, { title: title }), children] })));
4072
- };
4073
- var PageSubTitle = function (_a) {
4074
- var title = _a.title;
4075
- var secondaryColor = useContext(BrandContext).secondaryColor;
4076
3764
  var darkMode = useContext(BunnyContext).darkMode;
4077
- return (jsx(Text$8, __assign({ className: "shrink-0 font-medium", style: { color: darkMode ? undefined : secondaryColor } }, { children: title })));
4078
- };
4079
-
4080
- var StateTag = function (_a) {
4081
- var state = _a.state;
4082
- return jsx(Tag, __assign({ color: getColor(state) }, { children: capitalize(startCase(state)) }));
4083
- };
4084
- var getColor = function (state) {
4085
- switch (state) {
4086
- case FrontendTransaction.TransactionState.not_due:
4087
- return "yellow";
4088
- case FrontendTransaction.TransactionState.voided:
4089
- return "black";
4090
- case FrontendTransaction.TransactionState.ready:
4091
- return "orange";
4092
- case FrontendTransaction.TransactionState.preparing:
4093
- return "purple";
4094
- case FrontendTransaction.TransactionState.unapplied:
4095
- case FrontendTransaction.TransactionState.partially_applied:
4096
- case FrontendTransaction.TransactionState.applied:
4097
- return "blue";
4098
- case FrontendTransaction.TransactionState.due:
4099
- case FrontendTransaction.TransactionState.unpaid:
4100
- return "orange";
4101
- case FrontendTransaction.TransactionState.failed:
4102
- return "red";
4103
- case FrontendTransaction.TransactionState.paid:
4104
- return "green";
4105
- default:
4106
- return "blue";
4107
- }
3765
+ return (jsx("div", __assign({ className: "flex flex-col rounded-md shadow-md ".concat(className), style: __assign(__assign({}, style), { backgroundColor: darkMode
3766
+ ? "var(--row-background-dark)"
3767
+ : "var(--row-background)" }) }, { children: children })));
4108
3768
  };
4109
3769
 
4110
- var TransactionGridCell = styled.div.withConfig({
4111
- shouldForwardProp: function (prop) {
4112
- return !["gridColumn", "padding", "right"].includes(prop);
4113
- },
4114
- })(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);
4115
- var templateObject_1$3;
4116
-
4117
- var Text$7 = Typography.Text;
4118
- var TransactionDate = function (_a) {
4119
- var date = _a.date;
4120
- return jsx(Text$7, __assign({ className: "text-sm" }, { children: Misc.formatDate(date) }));
3770
+ var Text$6 = Typography.Text;
3771
+ var CreditCard = function (_a) {
3772
+ var _b, _c, _d;
3773
+ var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate, paymentMethodData = _a.paymentMethodData;
3774
+ var isExpired = function (paymentMethodData) {
3775
+ // paymentMethodData.expirationDate
3776
+ var expDate = dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate);
3777
+ return expDate.isBefore(dayjs());
3778
+ };
3779
+ var isMobile = useIsMobile$1();
3780
+ var processPublicUrl = useContext(PaymentMethodContext).processPublicUrl;
3781
+ return (jsxs(Card, __assign({ className: "shadow-md 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: [getCardImage((_b = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _b === void 0 ? void 0 : _b.issuer) && (jsx("img", { alt: "Card", width: "24px", src: "".concat(processPublicUrl, "/").concat(getCardImage((_c = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _c === void 0 ? void 0 : _c.issuer)) })), jsx(Text$6, { children: (_d = paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.metadata) === null || _d === void 0 ? void 0 : _d.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: dayjs(paymentMethodData === null || paymentMethodData === void 0 ? void 0 : paymentMethodData.expirationDate).format("MM/YY") }), isMobile && (jsx(CardActions, { onClickRemove: onClickRemove, onClickUpdate: onClickUpdate }))] }))] }))] })));
4121
3782
  };
4122
-
4123
- var isInvoice = function (transaction) {
4124
- return transaction.kind === "INVOICE";
3783
+ var CardAttribute = function (_a) {
3784
+ var title = _a.title, value = _a.value;
3785
+ 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$6, { children: value })] })));
4125
3786
  };
4126
- var isQuote = function (transaction) {
4127
- return transaction.kind === "QUOTE";
3787
+ var CardActions = function (_a) {
3788
+ var onClickRemove = _a.onClickRemove, onClickUpdate = _a.onClickUpdate;
3789
+ var isMobile = useIsMobile$1();
3790
+ return (jsxs("div", __assign({ className: "flex items-center gap-6 ".concat(isMobile ? "justify-center mt-4" : "") }, { children: [jsx(Popconfirm, __assign({ title: "Remove card?", onConfirm: onClickRemove }, { children: jsx(Button, __assign({ className: "font-normal p-0", type: "link" }, { children: "Remove payment method" })) })), jsx(Divider, { style: { height: "24px" }, type: "vertical" }), jsx(Button, __assign({ onClick: onClickUpdate, type: "primary" }, { children: "Update" }))] })));
4128
3791
  };
4129
- var TransactionRowTitle = function (_a) {
4130
- var transaction = _a.transaction;
4131
- if (!isInvoice(transaction) && !isQuote(transaction)) {
4132
- return jsx(Fragment, {});
4133
- }
4134
- return (jsx("span", __assign({ className: "text-slate-400", style: { fontSize: "11px" } }, { children: transaction.transactionable.number })));
3792
+ var EmptyCard = function (_a) {
3793
+ var onClick = _a.onClick;
3794
+ var brandColor = useContext(BrandContext).brandColor;
3795
+ return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center w-full pt-8 px-4 pb-6 cursor-pointer bg-white shadow-md rounded-md", onClick: onClick }, { children: [jsx(LargeCardIcon, {}), jsx("div", __assign({ className: "text-slate-400 pt-4 pb-8" }, { children: "No payment methods" })), jsx(Button, __assign({ type: "link" }, { children: jsxs("div", __assign({ className: "flex items-center gap-1" }, { children: [jsx(PlusIcon, { color: brandColor }), "Add payment method"] })) }))] })));
4135
3796
  };
4136
-
4137
- // TODO: delete
4138
- var ArrowDownToLine = function (_a) {
4139
- var className = _a.className, _b = _a.color, color = _b === void 0 ? SLATE_600 : _b;
4140
- return (jsxs("svg", __assign({ className: className, fill: "none", height: "16", viewBox: "0 0 16 16", width: "16", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsx("path", { d: "M8 11.3333V2", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M4 7.33301L8 11.333L12 7.33301", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }), jsx("path", { d: "M12.6654 14H3.33203", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
3797
+ var getCardImage = function (issuer) {
3798
+ if (issuer === "visa")
3799
+ return "Visa_Brandmark_Blue_RGB_2021.png";
3800
+ else if (issuer === "mastercard")
3801
+ return "mc_symbol_opt_73_3x.png";
4141
3802
  };
4142
3803
 
4143
- var TransactionsListContext = createContext({});
4144
-
4145
- var TransactionDownload = function (_a) {
4146
- var transaction = _a.transaction, token = _a.token, subdomain = _a.subdomain;
4147
- var darkMode = useContext(BunnyContext).darkMode;
4148
- var downloadTransactionLink = useContext(TransactionsListContext).downloadTransactionLink;
4149
- var downloadFile = useDownloadFile();
3804
+ var ActualPaymentMethod = function () {
3805
+ var _a = useContext(BunnyContext), token = _a.token, subdomain = _a.subdomain, graphQLClient = _a.graphQLClient;
3806
+ var accountId = useContext(PaymentContext).accountId;
3807
+ // Hooks
3808
+ var queryClient = useQueryClient();
3809
+ var paymentPlugins = usePaymentPlugins({ subdomain: subdomain, token: token }).paymentPlugins;
3810
+ var showErrorNotification = NotificationUtils.useErrorNotification();
3811
+ var showSuccessNotification = NotificationUtils.useSuccessNotification();
3812
+ var handleAllErrorFormats = NotificationUtils.useAllErrorFormats(function () {
3813
+ console.log("Navigation in PaymentMethod.tsx useAllErrorFormats not implemented");
3814
+ });
4150
3815
  var isMobile = useIsMobile$1();
4151
- var isClickable = transaction.kind === "INVOICE" || downloadTransactionLink !== undefined;
4152
- var downloadLink = downloadTransactionLink
4153
- ? downloadTransactionLink(transaction.transactionableId)
4154
- : "".concat(subdomain, "/api/pdf/invoice/").concat(transaction.transactionableId);
4155
- if (!isClickable)
4156
- return null;
4157
- return (jsx("div", __assign({ onClick: function (e) {
4158
- e.stopPropagation();
4159
- downloadFile(downloadLink, token);
4160
- } }, { children: jsx(ArrowDownToLine, { className: "".concat(isMobile ? "" : "show-on-hover"), color: darkMode ? WHITE : SLATE_600 }) })));
4161
- };
4162
-
4163
- var Text$6 = Typography.Text;
4164
- var TransactionsEmptyState = function () {
4165
- var noTransactionsMessage = useContext(TransactionsListContext).noTransactionsMessage;
4166
- return (jsx(Text$6, __assign({ className: "flex justify-center p-4 text-base" }, { children: noTransactionsMessage || "There are no invoices" })));
4167
- };
4168
-
4169
- function capitalizeFirstLetter(string) {
4170
- return string.charAt(0).toUpperCase() + string.slice(1);
4171
- }
4172
- var WARREN_STATE_LS_KEY = "warrenState";
4173
- var CURRENT_WARREN_ID_LS_KEY = "currentWarrenId";
4174
- var getIsCapacitorApp = function () {
4175
- var isAndroid = window.location.origin === "http://localhost";
4176
- var isIOS = window.location.protocol === "capacitor:";
4177
- return isAndroid || isIOS;
4178
- };
4179
- var getLocalStorageSubdomain = function () {
4180
- var warrenState = JSON.parse(window.localStorage.getItem(WARREN_STATE_LS_KEY) || "{}");
4181
- var subdomain = warrenState[CURRENT_WARREN_ID_LS_KEY];
4182
- if (!subdomain) {
4183
- console.warn("ERROR_MESSAGE_NO_SUBDOMAIN_DEFINED");
4184
- //throw new Error(ERROR_MESSAGE_NO_SUBDOMAIN_DEFINED);
4185
- }
4186
- return subdomain;
4187
- };
4188
- var getApiHost = function (subdomain) {
4189
- var isLocalHost = window.location.href.indexOf(".internal") > 0;
4190
- var sub = subdomain || getLocalStorageSubdomain();
4191
- if (getIsCapacitorApp()) {
4192
- return isLocalHost || process.env.REACT_APP_IS_INTERNAL === "true"
4193
- ? "https://".concat(sub, ".bunny.internal")
4194
- : "https://".concat(sub, ".").concat(process.env.REACT_APP_ROOT_DOMAIN);
4195
- }
4196
- return "";
4197
- };
4198
- var getGraphQLBase = function () {
4199
- if (getIsCapacitorApp()) {
4200
- return "".concat(getApiHost(), "/graphql");
4201
- }
4202
- return "/graphql";
4203
- };
4204
- var createRequestHeaders = function (token) {
4205
- var bearerToken = "Bearer ".concat(token);
4206
- var headers = {
4207
- "Content-type": "application/json; charset=utf-8",
3816
+ var data = usePaymentMethod(graphQLClient).data;
3817
+ // Local state
3818
+ var _b = useState(false), showModal = _b[0], setShowModal = _b[1];
3819
+ var _c = useState(false), isSaving = _c[0], setIsSaving = _c[1];
3820
+ // Queries
3821
+ useQuery({
3822
+ queryKey: QueryKeyFactory.default.currentUserKey,
3823
+ queryFn: function () { return getCurrentUserData({ token: token, subdomain: subdomain }); },
3824
+ });
3825
+ var plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(function (paymentPlugin) { var _a; return String(paymentPlugin.id) === ((_a = data === null || data === void 0 ? void 0 : data.plugin) === null || _a === void 0 ? void 0 : _a.id); });
3826
+ var onClickRemove = function () {
3827
+ if (data && plugin) {
3828
+ invokePlugin({
3829
+ plugin: plugin,
3830
+ method: "remove_payment_method",
3831
+ payload: {
3832
+ payment_method_id: data.id,
3833
+ account_id: accountId,
3834
+ },
3835
+ token: token,
3836
+ subdomain: subdomain,
3837
+ })
3838
+ .then(function () {
3839
+ showSuccessNotification("Payment method was removed", "Success");
3840
+ queryClient.setQueryData(QueryKeyFactory.default.accountPaymentMethodKey, null);
3841
+ })
3842
+ .catch(function (error) {
3843
+ showErrorNotification(error.message, "Error removing Payment Method");
3844
+ });
3845
+ }
4208
3846
  };
4209
- headers["Authorization"] = bearerToken;
4210
- return headers;
3847
+ var onSuccess = function () {
3848
+ queryClient.invalidateQueries({
3849
+ queryKey: QueryKeyFactory.default.accountPaymentMethodKey,
3850
+ });
3851
+ setShowModal(false);
3852
+ showSuccessNotification("Your payment method has been saved");
3853
+ };
3854
+ if (data === undefined)
3855
+ return jsx(Fragment, {});
3856
+ return (jsxs(Fragment, { children: [data ? (jsx(CreditCard, { onClickRemove: onClickRemove, onClickUpdate: function () { return setShowModal(true); }, paymentMethodData: data })) : (jsx(EmptyCard, { onClick: function () { return setShowModal(true); } })), jsx(Drawer, __assign({ closeIcon: null, onClose: function () { return setShowModal(false); }, open: showModal, styles: {
3857
+ body: isMobile
3858
+ ? {
3859
+ padding: "1rem 0 0",
3860
+ }
3861
+ : {},
3862
+ wrapper: isMobile ? { width: "100vw" } : { width: "min-content" },
3863
+ }, title: jsx(DrawerHeader, { onClose: function () { return setShowModal(false); }, title: "New payment method" }) }, { children: jsx(PaymentForm, { isSaving: isSaving, onFail: function (error) {
3864
+ handleAllErrorFormats(error);
3865
+ setIsSaving(false);
3866
+ }, onPaymentSuccess: function () {
3867
+ onSuccess();
3868
+ setIsSaving(false);
3869
+ }, setIsSaving: setIsSaving }) }))] }));
4211
3870
  };
4212
- var useGraphQLRequest = function () { return function (query, token, variables) { return __awaiter(void 0, void 0, void 0, function () {
4213
- var error_1;
4214
- return __generator(this, function (_a) {
4215
- switch (_a.label) {
4216
- case 0:
4217
- _a.trys.push([0, 2, , 3]);
4218
- return [4 /*yield*/, request(getGraphQLBase(), query, variables, createRequestHeaders(token))];
4219
- case 1: return [2 /*return*/, _a.sent()];
4220
- case 2:
4221
- error_1 = _a.sent();
4222
- throw error_1;
4223
- case 3: return [2 /*return*/];
4224
- }
4225
- });
4226
- }); }; };
3871
+ function PaymentMethod(_a) {
3872
+ var footer = _a.footer, processPublicUrl = _a.processPublicUrl;
3873
+ return (jsx(PaymentMethodContext.Provider, __assign({ value: { footer: footer, processPublicUrl: processPublicUrl } }, { children: jsx(ActualPaymentMethod, {}) })));
3874
+ }
4227
3875
 
4228
- var Text$5 = Typography.Text;
4229
- var TransactionsListDesktop = function (_a) {
4230
- var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
4231
- var columns = useContext(TransactionsListContext).columns;
4232
- var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain, darkMode = _b.darkMode;
4233
- var showAmount = columns.includes("amount");
4234
- var showDateAndTitle = columns.includes("date-and-title");
4235
- var showDownload = columns.includes("download");
4236
- var showState = columns.includes("state");
4237
- if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
4238
- return jsx(TransactionsEmptyState, {});
4239
- return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
4240
- var _a;
4241
- var isClickable = onTransactionClick !== undefined;
4242
- return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
4243
- onTransactionClick === null || onTransactionClick === void 0 ? void 0 : onTransactionClick(transaction);
4244
- }, style: {
4245
- backgroundColor: index % 2 === 0
4246
- ? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
4247
- : "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
4248
- } }, { children: [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$5, { children: capitalizeFirstLetter(transaction.kind.toLowerCase()) }), jsx(TransactionRowTitle, { transaction: transaction })] }))] })), showDownload && (jsx(TransactionGridCell, { children: jsx(TransactionDownload, { transaction: transaction, token: token, subdomain: subdomain }) })), showState && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(StateTag, { state: transaction.state }) }))), showAmount && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(Text$5, { children: Misc.formatCurrency(((_a = transaction === null || transaction === void 0 ? void 0 : transaction.transactionable) === null || _a === void 0 ? void 0 : _a.amount) || transaction.amount, transaction.currencyId) }) })))] }), index));
3876
+ var MUTATION$5 = "\nmutation accountUpdate(\n $id: ID!,\n $attributes: AccountAttributes!) {\n accountUpdate(\n id: $id,\n attributes: $attributes\n ) {\n account { id }\n errors\n }\n }\n";
3877
+ var accountUpdate = function (_a) {
3878
+ var accountId = _a.accountId, attributes = _a.attributes, token = _a.token;
3879
+ return __awaiter(void 0, void 0, void 0, function () {
3880
+ var vars, response, errors;
3881
+ var _b;
3882
+ return __generator(this, function (_c) {
3883
+ switch (_c.label) {
3884
+ case 0:
3885
+ vars = { id: accountId, attributes: attributes };
3886
+ return [4 /*yield*/, gqlRequest({ query: MUTATION$5, token: token, vars: vars })];
3887
+ case 1:
3888
+ response = _c.sent();
3889
+ errors = (_b = response === null || response === void 0 ? void 0 : response.accountUpdate) === null || _b === void 0 ? void 0 : _b.errors;
3890
+ if (errors)
3891
+ throw errors;
3892
+ return [2 /*return*/, response.accountUpdate];
3893
+ }
3894
+ });
4249
3895
  });
4250
3896
  };
4251
3897
 
4252
- var Text$4 = Typography.Text;
4253
- var TransactionsListMobile = function (_a) {
4254
- var transactions = _a.transactions, onTransactionClick = _a.onTransactionClick;
4255
- var columns = useContext(TransactionsListContext).columns;
4256
- var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain, darkMode = _b.darkMode;
4257
- var showAmount = columns.includes("amount");
4258
- var showDateAndTitle = columns.includes("date-and-title");
4259
- var showDownload = columns.includes("download");
4260
- var showState = columns.includes("state");
4261
- if ((transactions === null || transactions === void 0 ? void 0 : transactions.length) === 0)
4262
- return jsx(TransactionsEmptyState, {});
4263
- return transactions === null || transactions === void 0 ? void 0 : transactions.map(function (transaction, index) {
4264
- var isClickable = transaction.kind === "INVOICE";
4265
- return (jsxs("div", __assign({ className: "contents ".concat(isClickable && "cursor-pointer", " show-on-hover-container"), onClick: function () {
4266
- onTransactionClick(transaction);
4267
- }, style: {
4268
- backgroundColor: index % 2 === 0
4269
- ? "var(--row-background".concat(darkMode ? "-dark" : "", ")")
4270
- : "var(--row-background-alternate".concat(darkMode ? "-dark" : "", ")"),
4271
- } }, { 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$4, { children: capitalizeFirstLetter(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$4, { children: "\u00B7" }), showAmount && (jsx(Text$4, { children: Misc.formatCurrency(transaction.transactionable.amount || transaction.amount, transaction.currencyId) }))] }))] })) }), showDownload && (jsx(TransactionGridCell, __assign({ right: true }, { children: jsx(TransactionDownload, { transaction: transaction, token: token, subdomain: subdomain }) })))] }), index));
4272
- });
3898
+ var COUNTRIES_REQUIRING_STATE = ["US", "CA"];
3899
+ var TaxationForm = function (_a) {
3900
+ var account = _a.account, quote = _a.quote;
3901
+ // Hooks
3902
+ var queryClient = useQueryClient();
3903
+ var token = useContext(BunnyContext).token;
3904
+ var form = Form.useForm()[0];
3905
+ // Mutations
3906
+ var _b = useMutation({
3907
+ mutationFn: function (changedFormData) { return __awaiter(void 0, void 0, void 0, function () {
3908
+ var account;
3909
+ return __generator(this, function (_a) {
3910
+ switch (_a.label) {
3911
+ case 0: return [4 /*yield*/, accountUpdate({
3912
+ accountId: quote.accountId,
3913
+ attributes: changedFormData,
3914
+ token: token,
3915
+ })];
3916
+ case 1:
3917
+ account = _a.sent();
3918
+ return [2 /*return*/, account];
3919
+ }
3920
+ });
3921
+ }); },
3922
+ onSuccess: function () {
3923
+ queryClient.invalidateQueries({
3924
+ queryKey: ["getTaxationRequiredAccountFields", token],
3925
+ });
3926
+ },
3927
+ }), updateAccount = _b.mutate, isUpdatingAccount = _b.isPending;
3928
+ 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) {
3929
+ var _a, _b;
3930
+ return ((_a = option === null || option === void 0 ? void 0 : option.label) !== null && _a !== void 0 ? _a : "").toLowerCase().includes(input.toLowerCase()) ||
3931
+ ((_b = option === null || option === void 0 ? void 0 : option.value) !== null && _b !== void 0 ? _b : "").toLowerCase().includes(input.toLowerCase());
3932
+ } }) })), jsx(Form.Item, __assign({ label: "Billing zip", name: "billingZip" }, { children: jsx(Input, { placeholder: "Zip" }) })), jsx(Form.Item, { children: jsx(Button, __assign({ className: "w-full", disabled: isUpdatingAccount, htmlType: "submit", type: "primary" }, { children: "Submit" })) })] })));
3933
+ };
3934
+ var FormBillingState = function (_a) {
3935
+ _a.form;
3936
+ var billingCountry = Form.useWatch("billingCountry");
3937
+ var billingStateRequired = COUNTRIES_REQUIRING_STATE.includes(billingCountry);
3938
+ return (jsx(Form.Item, __assign({ label: "Billing state", name: "billingState", rules: [{ required: billingStateRequired }] }, { children: jsx(Input, { placeholder: "State" }) })));
4273
3939
  };
4274
3940
 
4275
- // Create a client
4276
- var queryClient = new QueryClient();
4277
- function Transactions(_a) {
4278
- var transactionComponent = _a.transactionComponent, _b = _a.showSearchBar, showSearchBar = _b === void 0 ? true : _b, _c = _a.showTitle, showTitle = _c === void 0 ? true : _c, _d = _a.columns, columns = _d === void 0 ? ["date-and-title", "state", "amount"] : _d, className = _a.className, _e = _a.shadow, shadow = _e === void 0 ? "md" : _e, searchBarClassName = _a.searchBarClassName, _f = _a.useModal, useModal = _f === void 0 ? false : _f, onTransactionClick = _a.onTransactionClick, _g = _a.suppressTransactionDisplay, suppressTransactionDisplay = _g === void 0 ? false : _g, _h = _a.kindsToShow, kindsToShow = _h === void 0 ? [
4279
- TransactionKind.INVOICE,
4280
- TransactionKind.PAYMENT,
4281
- TransactionKind.REFUND,
4282
- TransactionKind.WRITE_OFF,
4283
- ] : _h, style = _a.style, filter = _a.filter, noTransactionsMessage = _a.noTransactionsMessage;
4284
- var contextValues = {
4285
- showSearchBar: showSearchBar,
4286
- showTitle: showTitle,
4287
- transactionComponent: transactionComponent,
4288
- columns: columns,
4289
- className: className,
4290
- searchBarClassName: searchBarClassName,
4291
- shadow: shadow,
4292
- useModal: useModal,
4293
- onTransactionClick: onTransactionClick,
4294
- suppressTransactionDisplay: suppressTransactionDisplay,
4295
- kindsToShow: kindsToShow,
4296
- style: style,
4297
- filter: filter,
4298
- noTransactionsMessage: noTransactionsMessage,
3941
+ var QuoteCheckout = function (_a) {
3942
+ var account = _a.account, isSaving = _a.isSaving, onSuccess = _a.onSuccess, onFail = _a.onFail, quote = _a.quote, setIsSaving = _a.setIsSaving, taxationRequiredAccountFields = _a.taxationRequiredAccountFields; _a.storedPaymentMethod;
3943
+ // Context
3944
+ var isMobile = useIsMobile$1();
3945
+ var _b = useContext(BunnyContext), subdomain = _b.subdomain, token = _b.token;
3946
+ var paymentRequired = getQuoteAmountDue(quote) > 0;
3947
+ var checkoutMutation = useMutation({
3948
+ mutationFn: function (_a) {
3949
+ var pluginPaymentMethod = _a.pluginPaymentMethod, savedPaymentMethod = _a.storedPaymentMethod;
3950
+ if (!quote)
3951
+ throw new Error("Quote is required");
3952
+ if (!paymentRequired)
3953
+ return checkout({ quoteId: quote.id, token: token, subdomain: subdomain });
3954
+ if (savedPaymentMethod) {
3955
+ var paymentMethodId = savedPaymentMethod.paymentMethodId;
3956
+ return checkout({
3957
+ quoteId: quote.id,
3958
+ paymentMethodId: paymentMethodId,
3959
+ token: token,
3960
+ subdomain: subdomain,
3961
+ });
3962
+ }
3963
+ if (pluginPaymentMethod) {
3964
+ var plugin = pluginPaymentMethod.plugin, savePaymentMethod = pluginPaymentMethod.savePaymentMethod, metadata = pluginPaymentMethod.metadata;
3965
+ var paymentToken = pluginPaymentMethod.token;
3966
+ return checkout({
3967
+ quoteId: quote.id,
3968
+ paymentMethodData: {
3969
+ metadata: metadata,
3970
+ pluginGuid: plugin.guid,
3971
+ savePaymentMethod: savePaymentMethod,
3972
+ token: paymentToken,
3973
+ },
3974
+ token: token,
3975
+ subdomain: subdomain,
3976
+ });
3977
+ }
3978
+ throw new Error("Pay payment method provided");
3979
+ },
3980
+ onSuccess: onSuccess,
3981
+ onError: onFail,
3982
+ });
3983
+ // Handlers
3984
+ var handleCheckout = function (_a) {
3985
+ var pluginPaymentResponse = _a.pluginPaymentResponse, savedPaymentMethodResponse = _a.savedPaymentMethodResponse;
3986
+ return __awaiter(void 0, void 0, void 0, function () {
3987
+ var token_1, plugin, savePaymentMethod, metadata, paymentMethodId;
3988
+ return __generator(this, function (_b) {
3989
+ if (pluginPaymentResponse) {
3990
+ token_1 = pluginPaymentResponse.token, plugin = pluginPaymentResponse.plugin, savePaymentMethod = pluginPaymentResponse.savePaymentMethod, metadata = pluginPaymentResponse.metadata;
3991
+ checkoutMutation.mutate({
3992
+ pluginPaymentMethod: {
3993
+ savePaymentMethod: savePaymentMethod,
3994
+ plugin: plugin,
3995
+ metadata: metadata,
3996
+ token: token_1,
3997
+ },
3998
+ });
3999
+ }
4000
+ else if (savedPaymentMethodResponse) {
4001
+ paymentMethodId = savedPaymentMethodResponse.paymentMethodId;
4002
+ checkoutMutation.mutate({
4003
+ storedPaymentMethod: {
4004
+ paymentMethodId: paymentMethodId,
4005
+ },
4006
+ });
4007
+ }
4008
+ else {
4009
+ checkoutMutation.mutate({});
4010
+ }
4011
+ return [2 /*return*/];
4012
+ });
4013
+ });
4299
4014
  };
4300
- return (jsx(QueryClientProvider, __assign({ client: queryClient }, { children: jsx(TransactionsListContext.Provider, __assign({ value: contextValues }, { children: jsx(TransactionsWrapper, {}) })) })));
4015
+ if (taxationRequiredAccountFields)
4016
+ return (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsx(TaxationForm, { account: account, quote: quote }) })));
4017
+ return (jsx(Fragment, { children: paymentRequired ? (jsx(PaymentForm, { isSaving: isSaving, onFail: onFail, onPaymentSuccess: handleCheckout, quote: quote, setIsSaving: setIsSaving })) : (jsx(PaymentFormWrapper, __assign({ setMaxHeight: false }, { children: jsxs("div", __assign({ className: "flex flex-col gap-2 ".concat(isMobile ? "shadow-padding-x" : "") }, { children: [jsx(Button, __assign({ disabled: isSaving, onClick: function () {
4018
+ setIsSaving(true);
4019
+ handleCheckout({});
4020
+ }, type: "primary" }, { children: isSaving ? "Processing..." : "Complete order" })), jsx("div", __assign({ className: "text-xs text-slate-500" }, { children: "No payment is required" }))] })) }))) }));
4021
+ };
4022
+
4023
+ var useHasTaxPlugin = function (_a) {
4024
+ var subdomain = _a.subdomain, token = _a.token;
4025
+ var plugins = usePlugins({
4026
+ subdomain: subdomain,
4027
+ token: token,
4028
+ }).data;
4029
+ return Boolean(plugins === null || plugins === void 0 ? void 0 : plugins.some(function (plugin) { return plugin.type === "taxation"; }));
4030
+ };
4031
+
4032
+ var QUOTE_FIELDS = "quote {\n formattedQuote {\n html\n }\n acceptedByName\n acceptedByTitle\n accountId\n amount\n amountDue\n applicationDate\n applied\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 invoiceUntil\n isPendingApprovalRequest\n kind\n message\n name\n netPaymentDays\n notes\n ownerId\n periodAmount\n poNumber\n requiresApproval\n startDate\n state\n subtotal\n taxAmount\n updatedAt\n uuid\n amountsByPeriod {\n amount\n id\n name\n }\n endDateOptions {\n endDate\n label\n }\n invoiceUntilOptions {\n endDate\n label\n }\n quoteChanges {\n id\n priceListId\n charges {\n amount\n amountsByPeriod { amount startDate }\n billingPeriod\n billingPeriodAmounts { id amount prorationRate }\n chargeType\n couponId\n createdAt\n currencyId\n discount\n endDate\n feature { id name code isUnit unitName }\n id\n invoiceLineText\n name\n price\n priceDecimals\n priceTiers { starts price }\n pricingModel\n prorationRate\n quantity\n quantityMax\n quantityMin\n startDate\n tieredAveragePrice\n updatedAt\n }\n }\n}";
4033
+
4034
+ var QUOTE_RECALCULATE_TAXES = "\n mutation QuoteRecalculateTaxes($id: ID!) {\n quoteRecalculateTaxes(id: $id) {\n ".concat(QUOTE_FIELDS, "\n errors\n }\n }\n");
4035
+ var quoteRecalculateTaxes = function (_a) {
4036
+ var quoteId = _a.quoteId, token = _a.token;
4037
+ return __awaiter(void 0, void 0, void 0, function () {
4038
+ var vars, response, errors;
4039
+ var _b, _c;
4040
+ return __generator(this, function (_d) {
4041
+ switch (_d.label) {
4042
+ case 0:
4043
+ vars = { id: quoteId };
4044
+ return [4 /*yield*/, gqlRequest({
4045
+ query: QUOTE_RECALCULATE_TAXES,
4046
+ token: token,
4047
+ vars: vars,
4048
+ })];
4049
+ case 1:
4050
+ response = _d.sent();
4051
+ errors = (_b = response === null || response === void 0 ? void 0 : response.quoteRecalculateTaxes) === null || _b === void 0 ? void 0 : _b.errors;
4052
+ if (errors)
4053
+ throw errors;
4054
+ return [2 /*return*/, (_c = response.quoteRecalculateTaxes) === null || _c === void 0 ? void 0 : _c.quote];
4055
+ }
4056
+ });
4057
+ });
4058
+ };
4059
+
4060
+ var planPickerQuoteDataState = atom({
4061
+ key: "planPickerQuoteDataState",
4062
+ default: undefined,
4063
+ });
4064
+
4065
+ var pageWrapperClassName = function (isMobile) {
4066
+ return "flex flex-col grow pt-4 ".concat(isMobile ? "pb-4 overflow-hidden" : "pb-8", " ").concat("content-container");
4067
+ };
4068
+
4069
+ var queryKeyFactory = QueryKeyFactory.default;
4070
+ var Checkout = function (_a) {
4071
+ var _b, _c;
4072
+ var onCancel = _a.onCancel, onSuccess = _a.onSuccess, onFail = _a.onFail, invoice = _a.invoice, open = _a.open, quote = _a.quote, selectedPriceList = _a.selectedPriceList, isMobile = _a.isMobile, token = _a.token, storedPaymentMethod = _a.storedPaymentMethod;
4073
+ var subdomain = useContext(BunnyContext).subdomain;
4074
+ var _d = useState(false), isSaving = _d[0], setIsSaving = _d[1];
4075
+ var hasTaxPlugin = useHasTaxPlugin({ subdomain: subdomain || "", token: token });
4076
+ var queryClient = useQueryClient();
4077
+ var quotePreviewData = useRecoilValue(planPickerQuoteDataState);
4078
+ // Queries
4079
+ var _e = useQuery({
4080
+ queryKey: ["getTaxationRequiredAccountFields", token],
4081
+ queryFn: function () { return getTaxationRequiredAccountFields({ token: token }); },
4082
+ enabled: Boolean(quote),
4083
+ staleTime: 0,
4084
+ }), taxationRequiredAccountFields = _e.data, isLoadingTaxationRequiredAccountFields = _e.isLoading;
4085
+ var _f = useQuery({
4086
+ queryKey: ["account", quote === null || quote === void 0 ? void 0 : quote.accountId],
4087
+ queryFn: function () {
4088
+ return (quote === null || quote === void 0 ? void 0 : quote.accountId) && getAccount({ id: quote.accountId, token: token });
4089
+ },
4090
+ enabled: Boolean(quote === null || quote === void 0 ? void 0 : quote.accountId) &&
4091
+ ((taxationRequiredAccountFields === null || taxationRequiredAccountFields === void 0 ? void 0 : taxationRequiredAccountFields.length) || 0) > 0,
4092
+ }), account = _f.data, isLoadingAccount = _f.isLoading;
4093
+ useQuery({
4094
+ queryKey: queryKeyFactory.createQuoteTaxCalculateKey(quote === null || quote === void 0 ? void 0 : quote.id),
4095
+ queryFn: function () { return __awaiter(void 0, void 0, void 0, function () {
4096
+ var updatedQuote;
4097
+ return __generator(this, function (_a) {
4098
+ switch (_a.label) {
4099
+ case 0:
4100
+ if (!quote) return [3 /*break*/, 2];
4101
+ return [4 /*yield*/, quoteRecalculateTaxes({
4102
+ quoteId: quote.id,
4103
+ token: token,
4104
+ })];
4105
+ case 1:
4106
+ updatedQuote = _a.sent();
4107
+ if (updatedQuote) {
4108
+ queryClient.setQueryData(queryKeyFactory.createObjectKey("editingQuote", updatedQuote.id), updatedQuote);
4109
+ queryClient.setQueryData(queryKeyFactory.calculatedPricesKey((quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.quantity) || 0, selectedPriceList === null || selectedPriceList === void 0 ? void 0 : selectedPriceList.id), updatedQuote);
4110
+ }
4111
+ _a.label = 2;
4112
+ case 2: return [2 /*return*/, {}];
4113
+ }
4114
+ });
4115
+ }); },
4116
+ // Recalculate taxes if the quote is open, has a tax plugin, and the taxation required account fields are not required
4117
+ enabled: Boolean(quote) &&
4118
+ open &&
4119
+ hasTaxPlugin &&
4120
+ !taxationRequiredAccountFields &&
4121
+ !isLoadingTaxationRequiredAccountFields,
4122
+ staleTime: 0,
4123
+ });
4124
+ if (!open || isLoadingTaxationRequiredAccountFields || isLoadingAccount)
4125
+ return null;
4126
+ return (jsx("div", __assign({ className: "flex flex-col fixed top-0 left-0 right-0 bottom-0 bg-slate-50 overflow-auto", style: {
4127
+ zIndex: 1001,
4128
+ } }, { 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: isMobile })), !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, isSaving: isSaving, onFail: function (error) {
4129
+ onFail(error);
4130
+ setIsSaving(false);
4131
+ }, onSuccess: function (_a) {
4132
+ var savePaymentMethod = _a.savePaymentMethod;
4133
+ onSuccess({ savePaymentMethod: savePaymentMethod });
4134
+ setIsSaving(false);
4135
+ }, setIsSaving: setIsSaving })) : quote ? (jsx(QuoteCheckout, { account: account, isSaving: isSaving, onFail: function (error) {
4136
+ onFail(error);
4137
+ setIsSaving(false);
4138
+ }, onSuccess: function (_a) {
4139
+ var savePaymentMethod = _a.savePaymentMethod;
4140
+ onSuccess({ savePaymentMethod: savePaymentMethod });
4141
+ setIsSaving(false);
4142
+ }, quote: quote, setIsSaving: setIsSaving, taxationRequiredAccountFields: taxationRequiredAccountFields, token: token, storedPaymentMethod: storedPaymentMethod })) : (jsx(PaymentForm, { isSaving: isSaving, onFail: function (error) {
4143
+ onFail(error);
4144
+ setIsSaving(false);
4145
+ }, onPaymentSuccess: function (_a) {
4146
+ var pluginPaymentResponse = _a.pluginPaymentResponse;
4147
+ onSuccess({
4148
+ savePaymentMethod: pluginPaymentResponse === null || pluginPaymentResponse === void 0 ? void 0 : pluginPaymentResponse.savePaymentMethod,
4149
+ });
4150
+ setIsSaving(false);
4151
+ }, setIsSaving: setIsSaving }))] }))] })) })));
4152
+ };
4153
+
4154
+ 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}"; };
4155
+ var accountSignup = function (_a) {
4156
+ var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, accountId = _a.accountId, quoteId = _a.quoteId, paymentToken = _a.paymentToken, paymentMethodId = _a.paymentMethodId, pluginId = _a.pluginId, priceListCode = _a.priceListCode;
4157
+ return __awaiter(void 0, void 0, void 0, function () {
4158
+ var vars, response, errors;
4159
+ var _b;
4160
+ return __generator(this, function (_c) {
4161
+ switch (_c.label) {
4162
+ case 0:
4163
+ vars = {
4164
+ entityId: entityId,
4165
+ accountId: accountId,
4166
+ quoteId: quoteId,
4167
+ paymentToken: paymentToken,
4168
+ pluginId: pluginId,
4169
+ paymentMethodId: paymentMethodId,
4170
+ priceListCode: priceListCode,
4171
+ };
4172
+ return [4 /*yield*/, gqlRequest({
4173
+ query: MUTATION$4(),
4174
+ token: token,
4175
+ vars: vars,
4176
+ subdomain: subdomain,
4177
+ })];
4178
+ case 1:
4179
+ response = _c.sent();
4180
+ errors = (_b = response === null || response === void 0 ? void 0 : response.accountSignup) === null || _b === void 0 ? void 0 : _b.errors;
4181
+ if (errors)
4182
+ throw errors;
4183
+ return [2 /*return*/, response === null || response === void 0 ? void 0 : response.accountSignup];
4184
+ }
4185
+ });
4186
+ });
4187
+ };
4188
+
4189
+ var MUTATION$3 = function () { return "\nmutation QuoteAccountSignup (\n $accountName: String!,\n $billingContact: ContactAttributes!,\n $entityId: ID!,\n $priceListCode: String!\n) {\n quoteAccountSignup(\n entityId: $entityId,\n priceListCode: $priceListCode,\n accountName: $accountName,\n billingContact: $billingContact\n ) {\n account {\n id\n }\n amount\n currencyId\n quote {\n id\n }\n tenant {\n code\n }\n errors\n }\n}"; };
4190
+ var quoteAccountSignup = function (_a) {
4191
+ var token = _a.token, subdomain = _a.subdomain, entityId = _a.entityId, priceListCode = _a.priceListCode, accountName = _a.accountName, billingContact = _a.billingContact;
4192
+ return __awaiter(void 0, void 0, void 0, function () {
4193
+ var vars, response, errors;
4194
+ var _b;
4195
+ return __generator(this, function (_c) {
4196
+ switch (_c.label) {
4197
+ case 0:
4198
+ vars = {
4199
+ entityId: entityId,
4200
+ priceListCode: priceListCode,
4201
+ accountName: accountName,
4202
+ billingContact: billingContact,
4203
+ };
4204
+ return [4 /*yield*/, gqlRequest({
4205
+ query: MUTATION$3(),
4206
+ token: token,
4207
+ vars: vars,
4208
+ subdomain: subdomain,
4209
+ })];
4210
+ case 1:
4211
+ response = _c.sent();
4212
+ errors = (_b = response === null || response === void 0 ? void 0 : response.quoteAccountSignup) === null || _b === void 0 ? void 0 : _b.errors;
4213
+ if (errors)
4214
+ throw errors;
4215
+ return [2 /*return*/, response === null || response === void 0 ? void 0 : response.quoteAccountSignup];
4216
+ }
4217
+ });
4218
+ });
4219
+ };
4220
+
4221
+ var MUTATION$2 = function () { return "\nquery PriceList($code: String!) {\n priceList (code: $code) {\n basePrice\n code\n createdAt\n currencyId\n id\n isVisible\n name\n periodMonths\n planId\n priceDescription\n productId\n sku\n trialAllowed\n trialLengthDays\n updatedAt\n }\n}"; };
4222
+ var getPriceList = function (_a) {
4223
+ var token = _a.token, code = _a.code, subdomain = _a.subdomain;
4224
+ return __awaiter(void 0, void 0, void 0, function () {
4225
+ var response;
4226
+ return __generator(this, function (_b) {
4227
+ switch (_b.label) {
4228
+ case 0: return [4 /*yield*/, gqlRequest({
4229
+ query: MUTATION$2(),
4230
+ token: token,
4231
+ vars: { code: code },
4232
+ subdomain: subdomain,
4233
+ })];
4234
+ case 1:
4235
+ response = _b.sent();
4236
+ return [2 /*return*/, response === null || response === void 0 ? void 0 : response.priceList];
4237
+ }
4238
+ });
4239
+ });
4240
+ };
4241
+
4242
+ function PaymentForms(_a) {
4243
+ var quote = _a.quote, paying = _a.paying, setIsPaying = _a.setIsPaying, handlePaymentSaveSuccess = _a.handlePaymentSaveSuccess, handlePaymentFail = _a.handlePaymentFail, handleSubmit = _a.handleSubmit, proceedingToPayment = _a.proceedingToPayment, accountId = _a.accountId;
4244
+ return (jsx(Fragment, { children: quote ? (jsx(Fragment, { children: accountId && (jsx(PaymentContext.Provider, __assign({ value: { accountId: accountId, displayPayButtonNameAnyways: true } }, { children: jsx(PaymentForm, { isSaving: paying, setIsSaving: setIsPaying, onFail: handlePaymentFail, onPaymentSuccess: handlePaymentSaveSuccess }) }))) })) : (jsx(InitialSignupForm, { onSubmit: handleSubmit, submitting: proceedingToPayment })) }));
4245
+ }
4246
+ function InitialSignupForm(_a) {
4247
+ var onSubmit = _a.onSubmit, submitting = _a.submitting;
4248
+ var _b = useState({
4249
+ firstName: "",
4250
+ lastName: "",
4251
+ email: "",
4252
+ accountName: "",
4253
+ }), formData = _b[0], setFormData = _b[1];
4254
+ var handleInputChange = function (e) {
4255
+ var _a;
4256
+ var _b = e.target, name = _b.name, value = _b.value;
4257
+ setFormData(__assign(__assign({}, formData), (_a = {}, _a[name] = value, _a)));
4258
+ };
4259
+ return (jsxs(Form, __assign({ className: "flex w-1/2 flex-col justify-between h-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) {
4260
+ handleInputChange(e);
4261
+ setFormData(__assign(__assign({}, formData), { firstName: e.target.value }));
4262
+ } }) })), 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) {
4263
+ handleInputChange(e);
4264
+ setFormData(__assign(__assign({}, formData), { lastName: e.target.value }));
4265
+ } }) })), jsx(Form.Item, __assign({ rules: [
4266
+ { required: true, message: "Please input your email!" },
4267
+ { type: "email", message: "Please enter a valid email!" },
4268
+ ], initialValue: formData.email }, { children: jsx(Input, { placeholder: "Email", value: formData.email, onChange: function (e) {
4269
+ handleInputChange(e);
4270
+ setFormData(__assign(__assign({}, formData), { email: e.target.value }));
4271
+ } }) })), jsx(Form.Item, __assign({ rules: [
4272
+ { required: true, message: "Please input your account name!" },
4273
+ ], initialValue: formData.accountName }, { children: jsx(Input, { placeholder: "Account name", value: formData.accountName, onChange: function (e) {
4274
+ handleInputChange(e);
4275
+ setFormData(__assign(__assign({}, formData), { accountName: e.target.value }));
4276
+ } }) }))] })), jsx(Form.Item, { children: jsx(Button, __assign({ type: "primary", htmlType: "submit", loading: submitting, className: "w-full mt-4" }, { children: "Proceed to payment" })) })] })));
4277
+ }
4278
+
4279
+ var Title = Typography.Title, Text$5 = Typography.Text;
4280
+ function PaymentSuccessDisplay(_a) {
4281
+ var className = _a.className, amountPaid = _a.amountPaid, style = _a.style, returnUrl = _a.returnUrl;
4282
+ var window = useContext(BunnyContext).window;
4283
+ var companyName = useCurrentUserData().companyName;
4284
+ return (jsxs("div", __assign({ className: "flex flex-col items-center justify-center h-full ".concat(className), style: style }, { children: [jsx(CheckCircleFilled$1, { style: { fontSize: "48px", color: "rgb(52 211 153)" } }), jsxs(Title, __assign({ level: 3, className: "mt-2 m-0" }, { children: ["Payment of ", Misc.formatCurrency(amountPaid, "USD"), " successful"] })), returnUrl && (jsxs(Text$5, __assign({ className: "text-slate-500 cursor-pointer underline", onClick: function () { return (window.location.href = returnUrl); } }, { children: ["Back to ", companyName] })))] })));
4285
+ }
4286
+
4287
+ var Text$4 = Typography.Text;
4288
+ function PriceListDisplay(_a) {
4289
+ var priceListData = _a.priceListData, topNavImageUrl = _a.topNavImageUrl;
4290
+ if (!priceListData)
4291
+ return null;
4292
+ 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$4, __assign({ className: "text-slate-500 font-bold text-lg" }, { children: priceListData.name })), jsxs(Text$4, __assign({ className: "font-bold text-xl" }, { children: [Misc.formatCurrency(priceListData.basePrice, priceListData.currencyId), " ", "/ month"] }))] })), jsxs("div", __assign({ className: "flex flex-col" }, { children: [jsxs(Text$4, __assign({ style: { fontSize: "16px" }, className: "text-slate-500" }, { children: [priceListData.trialLengthDays, " day trial"] })), jsx(Text$4, __assign({ className: "text-slate-500", style: { fontSize: "12px" } }, { children: "You will not be charged until the last day of the trial." }))] }))] })) })) }));
4301
4293
  }
4302
- function TransactionsWrapper() {
4303
- var _a = useContext(TransactionsListContext), kindsToShow = _a.kindsToShow, filterFromContext = _a.filter;
4304
- var _b = useContext(BunnyContext), token = _b.token, subdomain = _b.subdomain;
4305
- // Local state
4306
- var _c = useState(""), search = _c[0], setSearch = _c[1];
4307
- var filter = filterFromContext ||
4308
- (search ? "filter: \"transaction.transactionableId is ".concat(search, "\"") : "");
4294
+
4295
+ var BunnyFooterIcon = function (_a) {
4296
+ var color = _a.color;
4297
+ return (jsxs("svg", __assign({ width: "45", height: "15", viewBox: "0 0 39 13", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, { children: [jsxs("g", __assign({ clipPath: "url(#clip0_6_851)" }, { children: [jsx("path", { className: "icon-path", d: "M14.5898 7.19708C14.5898 9.35053 13.0926 10.325 11.2495 10.325C9.39955 10.325 7.90234 9.35001 7.90234 7.18967V3.26221H10.1125V7.00052C10.1125 7.87719 10.5855 8.27725 11.2495 8.27725C11.9061 8.27725 12.3865 7.87719 12.3865 7.00052V3.26221H14.5898V7.19708Z", fill: color }), jsx("path", { className: "icon-path", d: "M31.8943 12.9625H29.4793L31.8523 8.62816L28.9355 3.26221H31.4708L33.0457 6.35524L34.5924 3.26221H37.0075L31.8943 12.9625Z", fill: color }), jsx("path", { className: "icon-path", d: "M15.1602 5.96827C15.1602 3.8148 16.6574 2.84033 18.5005 2.84033C20.3504 2.84033 21.8476 3.81533 21.8476 5.97568V10.1473H19.6374V6.16483C19.6374 5.28815 19.1645 4.8881 18.5005 4.8881C17.8439 4.8881 17.3634 5.28815 17.3634 6.16483V10.1473H15.1602V5.96827Z", fill: color }), jsx("path", { className: "icon-path", d: "M22.4316 5.96827C22.4316 3.8148 23.9289 2.84033 25.7719 2.84033C27.6219 2.84033 29.1191 3.81533 29.1191 5.97568V10.1473H26.9089V6.16483C26.9089 5.28815 26.4359 4.8881 25.7719 4.8881C25.1154 4.8881 24.6349 5.28815 24.6349 6.16483V10.1473H22.4316V5.96827Z", fill: color }), jsx("path", { className: "icon-path", d: "M7.40511 6.68957C7.40511 8.7236 6.02815 10.3227 4.17816 10.3227C3.23907 10.3227 2.61071 9.94378 2.19358 9.40371V10.1404H0.0605469V0.0405273H2.26381V3.91939C2.68041 3.42158 3.28802 3.07069 4.17763 3.07069C6.02759 3.07069 7.40511 4.66981 7.40511 6.68957ZM2.17229 6.69642C2.17229 7.60802 2.77937 8.2744 3.64823 8.2744C4.53783 8.2744 5.13107 7.59372 5.13107 6.69642C5.13107 5.79912 4.53783 5.11844 3.64823 5.11844C2.77937 5.11844 2.17229 5.78482 2.17229 6.69642Z", fill: color }), jsx("path", { className: "icon-path", d: "M38.966 8.94801C38.966 9.76181 38.2668 10.4631 37.4618 10.4631C36.6499 10.4631 35.9434 9.76181 35.9434 8.94801C35.9434 8.14846 36.6494 7.46094 37.4618 7.46094C38.2668 7.46094 38.966 8.14846 38.966 8.94801Z", fill: color })] })), jsx("defs", { children: jsx("clipPath", __assign({ id: "clip0_6_851" }, { children: jsx("rect", { width: "39", height: "13", fill: "white" }) })) })] })));
4298
+ };
4299
+
4300
+ var Footer = function (_a) {
4301
+ var className = _a.className;
4302
+ var _b = useCurrentUserData(), privacyUrl = _b.privacyUrl, termsUrl = _b.termsUrl;
4303
+ var window = useContext(BunnyContext).window;
4304
+ var isMobile = useIsMobile(window);
4305
+ var quotePreviewData = useRecoilValue(planPickerQuoteDataState);
4306
+ var selectedPriceList = quotePreviewData === null || quotePreviewData === void 0 ? void 0 : quotePreviewData.priceList;
4307
+ if (selectedPriceList && isMobile)
4308
+ return null;
4309
+ return (jsxs("div", __assign({ className: "flex items-center justify-between shrink-0 ".concat(className, " ").concat(isMobile ? "flex-col gap-2 grow" : "") }, { children: [(termsUrl || privacyUrl) && (jsxs("div", __assign({ className: "flex items-center gap-3" }, { children: [termsUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: termsUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Terms" }))), privacyUrl && (jsx(StyedLink, __assign({ className: "text-xs text-slate-400", href: privacyUrl, rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: "Privacy" })))] }))), jsx(BunnyMarketingLink, {})] })));
4310
+ };
4311
+ var BunnyMarketingLink = function () {
4312
+ var _a = useState(false), isHovered = _a[0], setIsHovered = _a[1];
4313
+ var window = useContext(BunnyContext).window;
4314
+ var isMobile = useIsMobile(window);
4315
+ return (jsx("div", __assign({ className: "flex items-end justify-end ".concat(isMobile ? "" : "grow") }, { children: jsx(StyledBunnyLink, __assign({ className: "flex items-end justify-end text-slate-400", href: "https://bunny.com/", rel: "noopener noreferrer", target: "_blank", type: "text" }, { children: jsxs("div", __assign({ className: "flex items-center", onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); } }, { children: ["Powered by\u00A0", jsx("div", __assign({ style: { paddingTop: "5px" } }, { children: jsx(BunnyFooterIcon, { color: isHovered ? PRIMARY_COLOR : SLATE_400 }) }))] })) })) })));
4316
+ };
4317
+ var StyedLink = styled.a(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n"], ["\n color: ", ";\n transition: color 0.3s;\n &:hover {\n color: ", ";\n }\n"])), SLATE_400, SLATE_500);
4318
+ var StyledBunnyLink = styled(StyedLink)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &:hover {\n color: ", " !important;\n }\n"], ["\n &:hover {\n color: ", " !important;\n }\n"])), PRIMARY_COLOR);
4319
+ var templateObject_1$3, templateObject_2;
4320
+
4321
+ var MUTATION$1 = "\n mutation portalSessionCreate ($tenantCode: String!, $expiry: Int!, $returnUrl: String!) {\n portalSessionCreate (tenantCode: $tenantCode, expiry: $expiry, returnUrl: $returnUrl) {\n errors\n token\n }\n }\n";
4322
+ var portalSessionCreate = function (_a) {
4323
+ var tenantCode = _a.tenantCode, expiry = _a.expiry, returnUrl = _a.returnUrl, token = _a.token, subdomain = _a.subdomain;
4324
+ return __awaiter(void 0, void 0, void 0, function () {
4325
+ var response, errors;
4326
+ var _b;
4327
+ return __generator(this, function (_c) {
4328
+ switch (_c.label) {
4329
+ case 0: return [4 /*yield*/, gqlRequest({
4330
+ query: MUTATION$1,
4331
+ token: token,
4332
+ vars: { tenantCode: tenantCode, expiry: expiry, returnUrl: returnUrl },
4333
+ subdomain: subdomain,
4334
+ })];
4335
+ case 1:
4336
+ response = _c.sent();
4337
+ errors = (response === null || response === void 0 ? void 0 : response.portalSessionCreate).errors;
4338
+ if (errors)
4339
+ throw errors;
4340
+ return [2 /*return*/, (_b = response === null || response === void 0 ? void 0 : response.portalSessionCreate) === null || _b === void 0 ? void 0 : _b.token];
4341
+ }
4342
+ });
4343
+ });
4344
+ };
4345
+
4346
+ var showErrorNotification = NotificationUtils.useErrorNotification();
4347
+ function Signup(_a) {
4348
+ var priceListCode = _a.priceListCode, returnUrl = _a.returnUrl;
4349
+ // Hooks
4350
+ var _b = useContext(BunnyContext), subdomain = _b.subdomain, token = _b.token, window = _b.window;
4351
+ useQuery({
4352
+ queryKey: QueryKeyFactory.default.currentUserKey,
4353
+ queryFn: function () { return getCurrentUserData({ token: token, subdomain: subdomain }); },
4354
+ });
4355
+ var isMobile = useIsMobile(window);
4356
+ var topNavImageUrl = useContext(BrandContext).topNavImageUrl;
4357
+ var entityId = useCurrentUserData().entityId;
4358
+ var _c = useState(undefined), quote = _c[0], setQuote = _c[1];
4359
+ var _d = useState(undefined), accountId = _d[0], setAccountId = _d[1];
4360
+ var _e = useState(undefined), quoteId = _e[0], setQuoteId = _e[1];
4361
+ var _f = useState(undefined), portalSessionToken = _f[0], setPortalSessionToken = _f[1];
4362
+ var _g = useState(undefined), formData = _g[0], setFormData = _g[1];
4363
+ var _h = useState(false), proceedingToPayment = _h[0], setProceedingToPayment = _h[1];
4364
+ var _j = useState(false), paying = _j[0], setIsPaying = _j[1];
4365
+ var _k = useState(false), purchaseSucceeded = _k[0], setPurchaseSucceeded = _k[1];
4309
4366
  // Queries
4310
- var data = useQuery({
4311
- queryKey: ["transactions", token, filter],
4312
- queryFn: function () { return getTransactions(filter, token, subdomain, kindsToShow); },
4313
- placeholderData: keepPreviousData,
4367
+ var priceListData = useQuery({
4368
+ queryKey: ["priceList", priceListCode],
4369
+ queryFn: function () { return getPriceList({ token: token, subdomain: subdomain, code: priceListCode }); },
4314
4370
  }).data;
4315
- return (jsx(TransactionsDisplay, { transactions: data, onSearchValueChanged: setSearch, search: search }));
4316
- }
4317
- function TransactionsDisplay(_a) {
4318
- var transactions = _a.transactions, onSearchValueChanged = _a.onSearchValueChanged, search = _a.search, title = _a.title;
4319
- var _b = useContext(TransactionsListContext), showSearchBar = _b.showSearchBar, showTitle = _b.showTitle, transactionComponent = _b.transactionComponent, useModal = _b.useModal, suppressTransactionDisplay = _b.suppressTransactionDisplay, className = _b.className, shadow = _b.shadow, searchBarClassName = _b.searchBarClassName, style = _b.style, onTransactionClick = _b.onTransactionClick;
4320
- var columns = useContext(TransactionsListContext).columns;
4321
- var darkMode = useContext(BunnyContext).darkMode;
4322
- // Local state
4323
- var _c = useState(null), selectedTransaction = _c[0], setSelectedTransaction = _c[1];
4324
- var _d = useState(false), drawerOpen = _d[0], setDrawerOpen = _d[1];
4325
- // Hooks
4326
- var isMobile = useIsMobile$1();
4327
- function handleTransactionClick(transaction) {
4328
- if (onTransactionClick) {
4329
- onTransactionClick(transaction);
4330
- }
4331
- if (!suppressTransactionDisplay) {
4332
- setSelectedTransaction(transaction);
4333
- setDrawerOpen(true);
4334
- }
4371
+ function handleSubmit(formData) {
4372
+ return __awaiter(this, void 0, void 0, function () {
4373
+ var data, portalSessionToken;
4374
+ return __generator(this, function (_a) {
4375
+ switch (_a.label) {
4376
+ case 0:
4377
+ setProceedingToPayment(true);
4378
+ setFormData(formData);
4379
+ return [4 /*yield*/, quoteAccountSignup({
4380
+ token: token,
4381
+ subdomain: subdomain,
4382
+ entityId: entityId,
4383
+ priceListCode: priceListCode,
4384
+ accountName: formData.accountName,
4385
+ billingContact: {
4386
+ firstName: formData.firstName,
4387
+ lastName: formData.lastName,
4388
+ email: formData.email,
4389
+ },
4390
+ })];
4391
+ case 1:
4392
+ data = _a.sent();
4393
+ setAccountId(data.account.id);
4394
+ return [4 /*yield*/, portalSessionCreate({
4395
+ token: token,
4396
+ subdomain: subdomain,
4397
+ tenantCode: data.tenant.code,
4398
+ expiry: 24,
4399
+ returnUrl: returnUrl || "",
4400
+ })];
4401
+ case 2:
4402
+ portalSessionToken = _a.sent();
4403
+ setPortalSessionToken(portalSessionToken);
4404
+ setQuoteId(data.quote.id);
4405
+ setProceedingToPayment(false);
4406
+ setQuote({
4407
+ amountDue: data.quote.amountDue,
4408
+ currencyId: data.quote.currencyId,
4409
+ });
4410
+ return [2 /*return*/];
4411
+ }
4412
+ });
4413
+ });
4414
+ }
4415
+ function handlePaymentSaveSuccess(paymentSuccess) {
4416
+ var _a;
4417
+ return __awaiter(this, void 0, void 0, function () {
4418
+ var response, plugin;
4419
+ return __generator(this, function (_b) {
4420
+ switch (_b.label) {
4421
+ case 0:
4422
+ if (!formData) {
4423
+ throw new Error("Form data is required");
4424
+ }
4425
+ response = paymentSuccess.pluginPaymentResponse;
4426
+ plugin = response === null || response === void 0 ? void 0 : response.plugin;
4427
+ if (!(plugin === null || plugin === void 0 ? void 0 : plugin.id)) {
4428
+ throw new Error("Plugin ID is required");
4429
+ }
4430
+ if (!accountId) {
4431
+ throw new Error("Account ID is required");
4432
+ }
4433
+ if (!portalSessionToken) {
4434
+ throw new Error("Portal session token is required");
4435
+ }
4436
+ return [4 /*yield*/, accountSignup({
4437
+ token: portalSessionToken,
4438
+ subdomain: subdomain,
4439
+ entityId: entityId,
4440
+ quoteId: quoteId,
4441
+ paymentMethodId: (_a = paymentSuccess.savedPaymentMethodResponse) === null || _a === void 0 ? void 0 : _a.paymentMethodId.toString(),
4442
+ pluginId: plugin.id.toString(),
4443
+ priceListCode: priceListCode,
4444
+ accountId: accountId,
4445
+ })];
4446
+ case 1:
4447
+ _b.sent();
4448
+ setIsPaying(false);
4449
+ setPurchaseSucceeded(true);
4450
+ return [2 /*return*/];
4451
+ }
4452
+ });
4453
+ });
4454
+ }
4455
+ function handlePaymentFail(error) {
4456
+ showErrorNotification(error.message);
4457
+ setIsPaying(false);
4458
+ }
4459
+ if (isMobile) {
4460
+ return (jsx(Card, __assign({ className: "p-4 flex flex-col" }, { children: purchaseSucceeded ? (jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, 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 items-center" }, { children: jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsx("div", __assign({ className: "mx-8" }, { children: jsx(Divider, { className: "h-full" }) })), jsx("div", __assign({ className: "flex items-center justify-center my-12" }, { children: jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })));
4461
+ }
4462
+ else {
4463
+ return (jsxs(Fragment, { children: [jsx(Card, __assign({ className: "p-4 flex flex-col w-screen h-screen" }, { children: purchaseSucceeded ? (jsx(PaymentSuccessDisplay, { className: "w-full", amountPaid: (quote === null || quote === void 0 ? void 0 : quote.amountDue) || 0, 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 w-1/2 items-center" }, { children: jsx(PriceListDisplay, { priceListData: priceListData, topNavImageUrl: topNavImageUrl }) })), jsx("div", __assign({ className: "my-4" }, { children: jsx(Divider, { className: "h-full", type: "vertical" }) })), jsx("div", __assign({ className: "flex w-1/2 items-center justify-center my-12" }, { children: jsx(PaymentForms, { quote: quote, paying: paying, setIsPaying: setIsPaying, handlePaymentSaveSuccess: handlePaymentSaveSuccess, handlePaymentFail: handlePaymentFail, handleSubmit: handleSubmit, proceedingToPayment: proceedingToPayment, accountId: accountId || "" }) }))] }))) })), jsx(Footer, {})] }));
4335
4464
  }
4336
- // Since the columns are dynamic, we need to calculate the grid template columns
4337
- var gridTemplateColumns = function () {
4338
- var templateColumns = [];
4339
- if (isMobile) {
4340
- if (columns.includes("date-and-title") ||
4341
- columns.includes("state") ||
4342
- columns.includes("amount")) {
4343
- templateColumns.push("auto");
4344
- }
4345
- if (columns.includes("download")) {
4346
- templateColumns.push("auto");
4347
- }
4348
- }
4349
- else {
4350
- if (columns.includes("date-and-title")) {
4351
- templateColumns.push("auto 3fr");
4352
- }
4353
- if (columns.includes("download")) {
4354
- templateColumns.push("auto");
4355
- }
4356
- if (columns.includes("state")) {
4357
- templateColumns.push("auto");
4358
- }
4359
- if (columns.includes("amount")) {
4360
- templateColumns.push("auto");
4361
- }
4362
- }
4363
- return templateColumns.join(" ");
4364
- };
4365
- var drawerTitle = function () {
4366
- if (!selectedTransaction)
4367
- return "";
4368
- var kind = selectedTransaction.kind.toLowerCase();
4369
- return kind.charAt(0).toUpperCase() + kind.slice(1);
4370
- };
4371
- return (jsxs("div", __assign({ style: style }, { children: [jsx(PageHeaderWithActions, __assign({ title: title || (showTitle ? "Past transactions" : undefined) }, { children: showSearchBar && (jsx("div", { children: jsx(Input, { className: searchBarClassName
4372
- ? searchBarClassName
4373
- : "border border-slate-200", onChange: function (e) {
4374
- if (isNaN(Number(e.target.value))) {
4375
- return;
4376
- }
4377
- onSearchValueChanged(e.target.value);
4378
- }, prefix: jsx(SearchOutlined$1, {}), placeholder: "Search by id #", style: {
4379
- minWidth: "300px",
4380
- }, value: search }) })) })), jsx(PageContent, __assign({ className: "flex w-full shadow-padding-xb ".concat(isMobile ? "overflow-hidden" : "", " ").concat(className) }, { children: jsx("div", __assign({ className: "grid w-full rounded-md overflow-auto ".concat("shadow-".concat(shadow)), style: {
4381
- gridTemplateColumns: gridTemplateColumns(),
4382
- backgroundColor: "var(--row-background".concat(darkMode ? "-dark" : "", ")"),
4383
- } }, { children: isMobile ? (jsx(Fragment, { children: TransactionsListMobile({
4384
- transactions: transactions,
4385
- onTransactionClick: handleTransactionClick,
4386
- }) })) : (jsx(Fragment, { children: TransactionsListDesktop({
4387
- transactions: transactions,
4388
- onTransactionClick: handleTransactionClick,
4389
- }) })) })) })), useModal ? (jsx(Modal, __assign({ title: "Basic Modal", open: drawerOpen, onOk: function () { return setDrawerOpen(false); }, onCancel: function () { return setDrawerOpen(false); }, width: 900, footer: null }, { children: jsx(Invoice, { id: (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId) || "" }) }))) : (jsx(Drawer, __assign({ title: drawerTitle(), onClose: function () { return setDrawerOpen(false); }, open: drawerOpen, width: 900 }, { children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === "INVOICE" ? (jsx(Invoice, { id: selectedTransaction.transactionableId })) : (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: Misc.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 })] })] }))) })))] })));
4390
4465
  }
4391
4466
 
4392
4467
  var updatingChargeQuantityIdState = atom({
@@ -5509,4 +5584,4 @@ var Subscriptions = function (_a) {
5509
5584
  } }, { children: (subscriptions === null || subscriptions === void 0 ? void 0 : subscriptions.length) > 0 ? (jsx(SubscriptionsList, { hideExpired: hideExpired, planChangeOptions: planChangeOptions, setEditingQuoteData: setEditingQuoteData, setPayModalVisible: setPayModalVisible, subscriptions: subscriptions })) : (jsx("div", __assign({ className: "flex flex-col items-center w-full" }, { children: jsx(ErrorView, { message: "You have no subscriptions with ".concat(companyName, " yet") }) }))) })), isMobile && (jsx("div", __assign({ className: "pt-4 pb-2" }, { children: jsx(SubscriptionsNavigation, { hideExpired: hideExpired, setHideExpired: setHideExpired, setQuantityDrawerOpen: setQuantityDrawerOpen, subscriptions: subscriptions }) }))), jsx(Footer, {}), jsx(QuantityChangeDrawerDesktop, { editingQuote: quote, editingQuoteData: editingQuoteData, onClose: onClose, open: quantityDrawerOpen, openCheckout: function () { return setPayModalVisible(true); }, setEditingQuoteData: setEditingQuoteData, subscriptions: subscriptions }), jsx(Checkout, { onCancel: onCancel, onSuccess: onSuccess, onFail: onFail, open: payModalVisible, quote: quote, token: token, isMobile: isMobile })] })));
5510
5585
  };
5511
5586
 
5512
- export { BunnyProvider, Checkout, Invoice, PaymentMethod, Quote, Signup, Subscriptions, Transactions, getQuoteAmountDue, usePaymentMethod };
5587
+ export { BunnyProvider, Checkout, Invoice, PaymentMethod, Quote, Quotes, Signup, Subscriptions, Transactions, getQuoteAmountDue, usePaymentMethod };