@bunnyapp/components 1.6.0-beta.21 → 1.6.0-beta.23

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/cjs/index.js CHANGED
@@ -143,7 +143,7 @@ const useAllErrorFormats = () => {
143
143
  };
144
144
 
145
145
  // This will be replaced at build time by rollup-plugin-replace
146
- const PACKAGE_VERSION = '1.6.0-beta.20';
146
+ const PACKAGE_VERSION = '1.6.0-beta.22';
147
147
  const createRequestHeaders = (token) => {
148
148
  const headers = createClientDevHeaders({ token });
149
149
  // Add the components version header
@@ -18916,6 +18916,37 @@ function Content({ children, accountId }) {
18916
18916
  return jsxRuntime.jsx(SelectedPluginDataProvider, { value: selectedPlugin, children: children });
18917
18917
  }
18918
18918
 
18919
+ const invokePlugin = async ({ method, payload, plugin, token, apiHost, componentsVersion, }) => {
18920
+ var _a, _b, _c, _d;
18921
+ const backendComponent = (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.backend) === null || _b === void 0 ? void 0 : _b[0];
18922
+ if (!((_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.backend) === null || _d === void 0 ? void 0 : _d.length))
18923
+ throw new Error('The provided plugin is not invokable');
18924
+ if (!(backendComponent === null || backendComponent === void 0 ? void 0 : backendComponent.access.includes(method)))
18925
+ throw new Error(`Method ${method} is not invokable`);
18926
+ const body = JSON.stringify({
18927
+ guid: plugin.guid,
18928
+ class: backendComponent === null || backendComponent === void 0 ? void 0 : backendComponent.name,
18929
+ method,
18930
+ payload,
18931
+ });
18932
+ const headers = createClientDevHeaders({
18933
+ token,
18934
+ componentsVersion: componentsVersion || PACKAGE_VERSION,
18935
+ });
18936
+ const response = await common.request({
18937
+ method: 'POST',
18938
+ apiHost,
18939
+ endpoint: `/plugins/invoke`,
18940
+ body,
18941
+ token,
18942
+ headers,
18943
+ });
18944
+ if (response.ok)
18945
+ return response.json();
18946
+ const error = await response.json();
18947
+ throw new Error(error.message);
18948
+ };
18949
+
18919
18950
  const DIGIT_REGEX = /\d/;
18920
18951
  const isDigit = (char) => DIGIT_REGEX.test(char);
18921
18952
  const isDeletion = (char) => [8, 46].includes(char); // Backspace or Delete
@@ -18950,7 +18981,7 @@ const unformatCardNumber = (cardNumber) => {
18950
18981
  };
18951
18982
  const storePayment = async (options, plugin, apiHost, accountId) => {
18952
18983
  const { testCreditCardNumber, testCreditCardCvc, testCreditCardExpirationDate, token } = options;
18953
- const response = await common.invokePlugin({
18984
+ const response = await invokePlugin({
18954
18985
  method: 'store_payment_method',
18955
18986
  plugin,
18956
18987
  payload: {
@@ -19075,7 +19106,7 @@ const getQuoteAmountDue = (quote) => {
19075
19106
 
19076
19107
  const { useToken: useAntdToken } = antd.theme;
19077
19108
  const createPaymentMethod = async ({ paymentMethodId, plugin, token, apiHost, accountId, }) => {
19078
- const response = await common.invokePlugin({
19109
+ const response = await invokePlugin({
19079
19110
  plugin,
19080
19111
  method: 'store_payment_method',
19081
19112
  payload: {
@@ -19090,7 +19121,7 @@ const createPaymentMethod = async ({ paymentMethodId, plugin, token, apiHost, ac
19090
19121
  return response;
19091
19122
  };
19092
19123
  const createSetupIntent = (plugin, apiHost, token, accountId) => {
19093
- return common.invokePlugin({
19124
+ return invokePlugin({
19094
19125
  plugin,
19095
19126
  method: 'create_setup_intent',
19096
19127
  token,
@@ -19106,7 +19137,7 @@ const createPaymentHold = async ({ quote, plugin, token, apiHost, paymentMethodI
19106
19137
  amount: quote.amount,
19107
19138
  payment_method_id: paymentMethodId,
19108
19139
  };
19109
- const response = await common.invokePlugin({
19140
+ const response = await invokePlugin({
19110
19141
  plugin,
19111
19142
  method: 'create_payment_hold',
19112
19143
  payload,
@@ -19118,7 +19149,7 @@ const createPaymentHold = async ({ quote, plugin, token, apiHost, paymentMethodI
19118
19149
  return response;
19119
19150
  };
19120
19151
  const fetchStripeKey = async (plugin, apiHost, token, accountId) => {
19121
- const response = await common.invokePlugin({
19152
+ const response = await invokePlugin({
19122
19153
  plugin,
19123
19154
  method: 'retrieve_config',
19124
19155
  token,
@@ -20000,7 +20031,7 @@ function useRemovePaymentMethod(onRemovePaymentMethod, onError) {
20000
20031
  const removePaymentMethod = react.useCallback(async (data) => {
20001
20032
  const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(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); });
20002
20033
  if (data && plugin) {
20003
- await common.invokePlugin({
20034
+ await invokePlugin({
20004
20035
  plugin: plugin, // TODO: type the plugin
20005
20036
  method: 'remove_payment_method',
20006
20037
  payload: {
@@ -20054,7 +20085,7 @@ function useSetDefaultPaymentMethod(onError, onSuccess) {
20054
20085
  const plugin = paymentPlugins === null || paymentPlugins === void 0 ? void 0 : paymentPlugins.find(paymentPlugin => { var _a; return String(paymentPlugin.id) === ((_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.plugin) === null || _a === void 0 ? void 0 : _a.id); }); // TODO: type the response to PluginData
20055
20086
  if (plugin) {
20056
20087
  setLoading(true);
20057
- await common.invokePlugin({
20088
+ await invokePlugin({
20058
20089
  plugin: plugin,
20059
20090
  method: 'assign_default_payment_method',
20060
20091
  payload: {
@@ -20383,10 +20414,18 @@ const usePlugins = ({ apiHost, token }) => {
20383
20414
  return response;
20384
20415
  };
20385
20416
  const getPlugins = async ({ token, apiHost }) => {
20417
+ const baseHeaders = createClientDevHeaders({
20418
+ token,
20419
+ componentsVersion: PACKAGE_VERSION,
20420
+ });
20421
+ const requestHeaders = {
20422
+ ...baseHeaders,
20423
+ };
20386
20424
  const response = await common.request({
20387
20425
  endpoint: `/plugins`,
20388
20426
  token,
20389
20427
  apiHost,
20428
+ headers: requestHeaders,
20390
20429
  });
20391
20430
  if (response.ok) {
20392
20431
  const plugins = await response.json();
@@ -20858,6 +20897,8 @@ function PaymentHoldDisplay({ paymentHold, currency, amount, }) {
20858
20897
  return (jsxRuntime.jsx(antd.Tooltip, { title: `${formattedAmount} will be charged to ${paymentMethod} once the quote is accepted. Hold will be released on ${expirationDate} if not accepted.`, children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(CustomizedTag, { color: 'orange', className: "rounded-md", style: { padding: 6 }, children: ["Hold of ", formattedAmount, " on ****", paymentMethod] }) }) }));
20859
20898
  }
20860
20899
 
20900
+ const TransactionsListContext = react.createContext({});
20901
+
20861
20902
  const QUOTES_QUERY = (filter) => `
20862
20903
  query quotes {
20863
20904
  quotes ${filter ? `(${filter})` : ''} {
@@ -20894,8 +20935,6 @@ const getQuotes = async ({ token, apiHost, filter, }) => {
20894
20935
  return response === null || response === void 0 ? void 0 : response.quotes;
20895
20936
  };
20896
20937
 
20897
- const TransactionsListContext = react.createContext({});
20898
-
20899
20938
  const transactionMutation = (filter) => `
20900
20939
  query transactions {
20901
20940
  transactions ${filter ? `(${filter})` : ''} {
@@ -21219,7 +21258,7 @@ function TransactionsDisplay({ transactions, onSearchValueChanged, search, }) {
21219
21258
  }, children: isMobile ? (jsxRuntime.jsx(TransactionsListMobile, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) : (jsxRuntime.jsx(TransactionsListDesktop, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) })] }), useModal ? (jsxRuntime.jsx(antd.Modal, { title: drawerTitle(), open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null, children: jsxRuntime.jsx(Invoice, { id: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId, hidePaymentForm: hidePaymentForm }) })) : (jsxRuntime.jsx(antd.Drawer, { title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH, children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === 'INVOICE' ? (jsxRuntime.jsx(Invoice, { id: selectedTransaction.transactionableId, hidePaymentForm: hidePaymentForm })) : (jsxRuntime.jsxs(antd.Card, { className: "bunny-shadow-md", children: [jsxRuntime.jsx(antd.Typography.Title, { level: 2, className: "bunny-mb-4", children: "Transaction Details" }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Amount:" }), ' ', jsxRuntime.jsx(antd.Typography.Text, { children: common.formatCurrency((selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.amount) || 0, (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.currencyId) || 'USD') })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Description:" }), ' ', jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.description })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "Kind:" }), ' ', jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind })] }), jsxRuntime.jsxs(antd.Typography.Paragraph, { children: [jsxRuntime.jsx("strong", { children: "State:" }), ' ', jsxRuntime.jsx(antd.Typography.Text, { children: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.state })] })] })) }))] }));
21220
21259
  }
21221
21260
 
21222
- function Quotes({ className, columns = ['date', 'title', 'amount', 'download', 'state'], filter, filterQuotes, sort = (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), noQuotesMessage = 'There are no quotes', onQuoteClick, quoteComponent, searchBarClassName, shadow = 'shadow-md', showSearchBar = true, showTitle = true, title = 'Past quotes', style, suppressQuoteDisplay = false, useModal = false, }) {
21261
+ function Quotes({ className, columns = ['date', 'title', 'amount', 'download', 'state'], filter, filterQuotes, sort = (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), noQuotesMessage = 'There are no quotes', onQuoteClick, renderQuote, searchBarClassName, shadow = 'shadow-md', showSearchBar = true, showTitle = true, title = 'Past quotes', style, suppressQuoteDisplay = false, useModal = false, }) {
21223
21262
  const { apiHost } = react.useContext(BunnyContext);
21224
21263
  const [component, setComponent] = react.useState(null);
21225
21264
  const contextValues = {
@@ -21269,8 +21308,8 @@ function Quotes({ className, columns = ['date', 'title', 'amount', 'download', '
21269
21308
  }
21270
21309
  function handleQuoteClick(quote) {
21271
21310
  onQuoteClick === null || onQuoteClick === void 0 ? void 0 : onQuoteClick(quote);
21272
- if (quoteComponent) {
21273
- setComponent(quoteComponent);
21311
+ if (renderQuote !== undefined) {
21312
+ setComponent(renderQuote(quote));
21274
21313
  }
21275
21314
  else {
21276
21315
  setComponent(jsxRuntime.jsx(Quote, { id: quote === null || quote === void 0 ? void 0 : quote.transactionableId }));
@@ -1,9 +1,9 @@
1
1
  import { Transaction } from '@bunnyapp/common';
2
2
  import { ShadowType } from '../../types/shadowType';
3
3
  import { TransactionListColumnType } from '../Transactions/transactionsList/TransactionsListDesktop';
4
- declare function Quotes({ className, columns, filter, filterQuotes, sort, noQuotesMessage, onQuoteClick, quoteComponent, searchBarClassName, shadow, showSearchBar, showTitle, title, style, suppressQuoteDisplay, useModal, }: {
5
- /** A custom component to render instead of the default invoice component */
6
- quoteComponent?: React.ReactNode;
4
+ declare function Quotes({ className, columns, filter, filterQuotes, sort, noQuotesMessage, onQuoteClick, renderQuote, searchBarClassName, shadow, showSearchBar, showTitle, title, style, suppressQuoteDisplay, useModal, }: {
5
+ /** Render a custom quote component. Receives the quoteId as a parameter. */
6
+ renderQuote?: (quote: Transaction) => React.ReactNode;
7
7
  /** Whether to show the search bar */
8
8
  showSearchBar?: boolean;
9
9
  /** Whether to show the title */
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { isValidElement, createContext, useContext, useMemo, useState, useEffect, useRef, createElement, useCallback, Fragment as Fragment$1 } from 'react';
3
3
  import { DownloadOutlined, CreditCardOutlined, EllipsisOutlined, BankOutlined, SearchOutlined, CloseOutlined, CheckCircleFilled, InfoCircleOutlined } from '@ant-design/icons';
4
- import { useErrorNotification, DEFAULT_CONFIG, createClientDevHeaders as createClientDevHeaders$1, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory as QueryKeyFactory$1, useIsMobile as useIsMobile$1, DEFAULT_BRAND_COLOR, isColorTooDark, DEFAULT_TOP_NAV_IMAGE_URL, DEFAULT_ACCENT_COLOR, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, DEFAULT_SECONDARY_COLOR, request as request$1, invokePlugin, useAllErrorFormats as useAllErrorFormats$1, formatCurrency as formatCurrency$1, GRAY_500, GRAY_200, useSuccessNotification, PAYABLE_INVOICE_STATES, BreakpointNumbers as BreakpointNumbers$1, useGraphQLmutation, useInfoNotification, formatDate, TransactionState, SLATE_600, WHITE, TransactionKind, QuoteChangeKind, SLATE_500, PRIMARY_COLOR, Lists, getAccount, ChargeType, PERIOD_LABELS, MODAL_MAX_HEIGHT, DataInterval, SLATE_100 } from '@bunnyapp/common';
4
+ import { useErrorNotification, DEFAULT_CONFIG, createClientDevHeaders as createClientDevHeaders$1, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory as QueryKeyFactory$1, useIsMobile as useIsMobile$1, DEFAULT_BRAND_COLOR, isColorTooDark, DEFAULT_TOP_NAV_IMAGE_URL, DEFAULT_ACCENT_COLOR, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, DEFAULT_SECONDARY_COLOR, request as request$1, useAllErrorFormats as useAllErrorFormats$1, formatCurrency as formatCurrency$1, GRAY_500, GRAY_200, useSuccessNotification, PAYABLE_INVOICE_STATES, BreakpointNumbers as BreakpointNumbers$1, useGraphQLmutation, useInfoNotification, formatDate, TransactionState, SLATE_600, WHITE, TransactionKind, QuoteChangeKind, SLATE_500, PRIMARY_COLOR, Lists, getAccount, ChargeType, PERIOD_LABELS, MODAL_MAX_HEIGHT, DataInterval, SLATE_100 } from '@bunnyapp/common';
5
5
  import { ConfigProvider, Spin, Typography, Button, theme as theme$1, Tag, Dropdown, Input, Modal, Checkbox, Skeleton, Collapse, Form, Tooltip, Drawer, Card as Card$1, Select, Divider, Popconfirm, Table, Radio, Space, Switch } from 'antd';
6
6
  import { Markup } from 'interweave';
7
7
  import request from 'graphql-request';
@@ -141,7 +141,7 @@ const useAllErrorFormats = () => {
141
141
  };
142
142
 
143
143
  // This will be replaced at build time by rollup-plugin-replace
144
- const PACKAGE_VERSION = '1.6.0-beta.20';
144
+ const PACKAGE_VERSION = '1.6.0-beta.22';
145
145
  const createRequestHeaders = (token) => {
146
146
  const headers = createClientDevHeaders({ token });
147
147
  // Add the components version header
@@ -18914,6 +18914,37 @@ function Content({ children, accountId }) {
18914
18914
  return jsx(SelectedPluginDataProvider, { value: selectedPlugin, children: children });
18915
18915
  }
18916
18916
 
18917
+ const invokePlugin = async ({ method, payload, plugin, token, apiHost, componentsVersion, }) => {
18918
+ var _a, _b, _c, _d;
18919
+ const backendComponent = (_b = (_a = plugin.components) === null || _a === void 0 ? void 0 : _a.backend) === null || _b === void 0 ? void 0 : _b[0];
18920
+ if (!((_d = (_c = plugin.components) === null || _c === void 0 ? void 0 : _c.backend) === null || _d === void 0 ? void 0 : _d.length))
18921
+ throw new Error('The provided plugin is not invokable');
18922
+ if (!(backendComponent === null || backendComponent === void 0 ? void 0 : backendComponent.access.includes(method)))
18923
+ throw new Error(`Method ${method} is not invokable`);
18924
+ const body = JSON.stringify({
18925
+ guid: plugin.guid,
18926
+ class: backendComponent === null || backendComponent === void 0 ? void 0 : backendComponent.name,
18927
+ method,
18928
+ payload,
18929
+ });
18930
+ const headers = createClientDevHeaders({
18931
+ token,
18932
+ componentsVersion: componentsVersion || PACKAGE_VERSION,
18933
+ });
18934
+ const response = await request$1({
18935
+ method: 'POST',
18936
+ apiHost,
18937
+ endpoint: `/plugins/invoke`,
18938
+ body,
18939
+ token,
18940
+ headers,
18941
+ });
18942
+ if (response.ok)
18943
+ return response.json();
18944
+ const error = await response.json();
18945
+ throw new Error(error.message);
18946
+ };
18947
+
18917
18948
  const DIGIT_REGEX = /\d/;
18918
18949
  const isDigit = (char) => DIGIT_REGEX.test(char);
18919
18950
  const isDeletion = (char) => [8, 46].includes(char); // Backspace or Delete
@@ -20381,10 +20412,18 @@ const usePlugins = ({ apiHost, token }) => {
20381
20412
  return response;
20382
20413
  };
20383
20414
  const getPlugins = async ({ token, apiHost }) => {
20415
+ const baseHeaders = createClientDevHeaders({
20416
+ token,
20417
+ componentsVersion: PACKAGE_VERSION,
20418
+ });
20419
+ const requestHeaders = {
20420
+ ...baseHeaders,
20421
+ };
20384
20422
  const response = await request$1({
20385
20423
  endpoint: `/plugins`,
20386
20424
  token,
20387
20425
  apiHost,
20426
+ headers: requestHeaders,
20388
20427
  });
20389
20428
  if (response.ok) {
20390
20429
  const plugins = await response.json();
@@ -20856,6 +20895,8 @@ function PaymentHoldDisplay({ paymentHold, currency, amount, }) {
20856
20895
  return (jsx(Tooltip, { title: `${formattedAmount} will be charged to ${paymentMethod} once the quote is accepted. Hold will be released on ${expirationDate} if not accepted.`, children: jsx(Fragment, { children: jsxs(CustomizedTag, { color: 'orange', className: "rounded-md", style: { padding: 6 }, children: ["Hold of ", formattedAmount, " on ****", paymentMethod] }) }) }));
20857
20896
  }
20858
20897
 
20898
+ const TransactionsListContext = createContext({});
20899
+
20859
20900
  const QUOTES_QUERY = (filter) => `
20860
20901
  query quotes {
20861
20902
  quotes ${filter ? `(${filter})` : ''} {
@@ -20892,8 +20933,6 @@ const getQuotes = async ({ token, apiHost, filter, }) => {
20892
20933
  return response === null || response === void 0 ? void 0 : response.quotes;
20893
20934
  };
20894
20935
 
20895
- const TransactionsListContext = createContext({});
20896
-
20897
20936
  const transactionMutation = (filter) => `
20898
20937
  query transactions {
20899
20938
  transactions ${filter ? `(${filter})` : ''} {
@@ -21217,7 +21256,7 @@ function TransactionsDisplay({ transactions, onSearchValueChanged, search, }) {
21217
21256
  }, children: isMobile ? (jsx(TransactionsListMobile, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) : (jsx(TransactionsListDesktop, { transactions: updatedTransactions, onTransactionClick: handleTransactionClick })) })] }), useModal ? (jsx(Modal, { title: drawerTitle(), open: drawerOpen, onOk: handleDisplayClose, onCancel: handleDisplayClose, width: DISPLAY_WIDTH, footer: null, children: jsx(Invoice, { id: selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.transactionableId, hidePaymentForm: hidePaymentForm }) })) : (jsx(Drawer, { title: drawerTitle(), onClose: handleDisplayClose, open: drawerOpen, width: DISPLAY_WIDTH, children: transactionComponent ? (transactionComponent) : (selectedTransaction === null || selectedTransaction === void 0 ? void 0 : selectedTransaction.kind) === 'INVOICE' ? (jsx(Invoice, { id: selectedTransaction.transactionableId, hidePaymentForm: hidePaymentForm })) : (jsxs(Card$1, { className: "bunny-shadow-md", children: [jsx(Typography.Title, { level: 2, className: "bunny-mb-4", children: "Transaction Details" }), jsxs(Typography.Paragraph, { children: [jsx("strong", { children: "Amount:" }), ' ', jsx(Typography.Text, { children: formatCurrency$1((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 })] })] })) }))] }));
21218
21257
  }
21219
21258
 
21220
- function Quotes({ className, columns = ['date', 'title', 'amount', 'download', 'state'], filter, filterQuotes, sort = (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), noQuotesMessage = 'There are no quotes', onQuoteClick, quoteComponent, searchBarClassName, shadow = 'shadow-md', showSearchBar = true, showTitle = true, title = 'Past quotes', style, suppressQuoteDisplay = false, useModal = false, }) {
21259
+ function Quotes({ className, columns = ['date', 'title', 'amount', 'download', 'state'], filter, filterQuotes, sort = (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), noQuotesMessage = 'There are no quotes', onQuoteClick, renderQuote, searchBarClassName, shadow = 'shadow-md', showSearchBar = true, showTitle = true, title = 'Past quotes', style, suppressQuoteDisplay = false, useModal = false, }) {
21221
21260
  const { apiHost } = useContext(BunnyContext);
21222
21261
  const [component, setComponent] = useState(null);
21223
21262
  const contextValues = {
@@ -21267,8 +21306,8 @@ function Quotes({ className, columns = ['date', 'title', 'amount', 'download', '
21267
21306
  }
21268
21307
  function handleQuoteClick(quote) {
21269
21308
  onQuoteClick === null || onQuoteClick === void 0 ? void 0 : onQuoteClick(quote);
21270
- if (quoteComponent) {
21271
- setComponent(quoteComponent);
21309
+ if (renderQuote !== undefined) {
21310
+ setComponent(renderQuote(quote));
21272
21311
  }
21273
21312
  else {
21274
21313
  setComponent(jsx(Quote, { id: quote === null || quote === void 0 ? void 0 : quote.transactionableId }));
@@ -1,9 +1,9 @@
1
1
  import { Transaction } from '@bunnyapp/common';
2
2
  import { ShadowType } from '../../types/shadowType';
3
3
  import { TransactionListColumnType } from '../Transactions/transactionsList/TransactionsListDesktop';
4
- declare function Quotes({ className, columns, filter, filterQuotes, sort, noQuotesMessage, onQuoteClick, quoteComponent, searchBarClassName, shadow, showSearchBar, showTitle, title, style, suppressQuoteDisplay, useModal, }: {
5
- /** A custom component to render instead of the default invoice component */
6
- quoteComponent?: React.ReactNode;
4
+ declare function Quotes({ className, columns, filter, filterQuotes, sort, noQuotesMessage, onQuoteClick, renderQuote, searchBarClassName, shadow, showSearchBar, showTitle, title, style, suppressQuoteDisplay, useModal, }: {
5
+ /** Render a custom quote component. Receives the quoteId as a parameter. */
6
+ renderQuote?: (quote: Transaction) => React.ReactNode;
7
7
  /** Whether to show the search bar */
8
8
  showSearchBar?: boolean;
9
9
  /** Whether to show the title */
package/dist/index.d.ts CHANGED
@@ -41,9 +41,9 @@ declare function Quote({ id, invoiceQuoteViewComponent, onInvoiceDownloadError,
41
41
 
42
42
  type TransactionListColumnType = 'date' | 'title' | 'state' | 'amount' | 'download' | 'accountName';
43
43
 
44
- declare function Quotes({ className, columns, filter, filterQuotes, sort, noQuotesMessage, onQuoteClick, quoteComponent, searchBarClassName, shadow, showSearchBar, showTitle, title, style, suppressQuoteDisplay, useModal, }: {
45
- /** A custom component to render instead of the default invoice component */
46
- quoteComponent?: React.ReactNode;
44
+ declare function Quotes({ className, columns, filter, filterQuotes, sort, noQuotesMessage, onQuoteClick, renderQuote, searchBarClassName, shadow, showSearchBar, showTitle, title, style, suppressQuoteDisplay, useModal, }: {
45
+ /** Render a custom quote component. Receives the quoteId as a parameter. */
46
+ renderQuote?: (quote: Transaction) => React.ReactNode;
47
47
  /** Whether to show the search bar */
48
48
  showSearchBar?: boolean;
49
49
  /** Whether to show the title */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.6.0-beta.21",
3
+ "version": "1.6.0-beta.23",
4
4
  "description": "Components from the Bunny portal to embed Bunny UI functionality into your application.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",