@bunnyapp/components 1.0.62-beta.5 → 1.0.62-beta.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/cjs/index.js CHANGED
@@ -173,18 +173,11 @@ var BrandContext = react.createContext({
173
173
  });
174
174
 
175
175
  // This will be replaced at build time by rollup-plugin-replace
176
- var PACKAGE_VERSION = '1.0.62-beta.5';
176
+ var PACKAGE_VERSION = '1.0.62-beta.7';
177
177
  var createRequestHeaders = function (token) {
178
- var _a;
179
- var bearerToken = token ? "Bearer ".concat(token) : null;
180
- var headers = (_a = {
181
- 'Content-type': 'application/json; charset=utf-8'
182
- },
183
- _a[common.X_BUNNY_COMPONENTS_VERSION_HEADER_NAME] = PACKAGE_VERSION,
184
- _a);
185
- if (bearerToken) {
186
- headers['Authorization'] = bearerToken;
187
- }
178
+ var headers = common.createClientDevHeaders(token);
179
+ // Add the components version header
180
+ headers[common.X_BUNNY_COMPONENTS_VERSION_HEADER_NAME] = PACKAGE_VERSION;
188
181
  return headers;
189
182
  };
190
183
  var getGraphQLBaseURL = function (apiHost) {
@@ -352,18 +345,15 @@ var useAjax = function (onError) {
352
345
  case 0: return [4 /*yield*/, fetch(url, {
353
346
  method: method,
354
347
  body: bodyData,
355
- headers: {
356
- "Content-type": "application/json; charset=utf-8",
357
- Authorization: "Bearer ".concat(token),
358
- },
348
+ headers: common.createClientDevHeaders(token),
359
349
  })];
360
350
  case 1:
361
351
  response = _a.sent();
362
352
  if (response.status !== 200 && response.status !== 201) {
363
353
  return [2 /*return*/, response.json().then(function (data) {
364
354
  if (response.status === 401) {
365
- console.error("expired token");
366
- onError === null || onError === void 0 ? void 0 : onError("expired token");
355
+ console.error('expired token');
356
+ onError === null || onError === void 0 ? void 0 : onError('expired token');
367
357
  }
368
358
  else {
369
359
  throw new Error(data === null || data === void 0 ? void 0 : data.message);
@@ -379,7 +369,7 @@ var useAjax = function (onError) {
379
369
  var useDownloadFile = function (id, onError) {
380
370
  var ajax = useAjax(onError);
381
371
  return function (url, token) {
382
- return ajax(url + (id ? "?id=".concat(id) : ""), "GET", function (rsp) { return __awaiter(void 0, void 0, void 0, function () {
372
+ return ajax(url + (id ? "?id=".concat(id) : ''), 'GET', function (rsp) { return __awaiter(void 0, void 0, void 0, function () {
383
373
  var blob, file, contentDisposition, anchor, filenameRegex, matches;
384
374
  return __generator(this, function (_a) {
385
375
  switch (_a.label) {
@@ -387,15 +377,14 @@ var useDownloadFile = function (id, onError) {
387
377
  case 1:
388
378
  blob = _a.sent();
389
379
  file = window.URL.createObjectURL(blob);
390
- contentDisposition = rsp.headers.get("content-disposition");
391
- anchor = document.createElement("a");
380
+ contentDisposition = rsp.headers.get('content-disposition');
381
+ anchor = document.createElement('a');
392
382
  anchor.href = file;
393
- if (contentDisposition &&
394
- contentDisposition.indexOf("attachment") !== -1) {
383
+ if (contentDisposition && contentDisposition.indexOf('attachment') !== -1) {
395
384
  filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
396
385
  matches = filenameRegex.exec(contentDisposition);
397
386
  if (matches != null && matches[1]) {
398
- anchor.setAttribute("download", matches[1].replace(/['"]/g, ""));
387
+ anchor.setAttribute('download', matches[1].replace(/['"]/g, ''));
399
388
  }
400
389
  }
401
390
  anchor.click();
@@ -497,9 +486,7 @@ var fetchPDF = function (apiHost, documentUuid, documentType, token) { return __
497
486
  throw new Error('Invoice ID is required to fetch PDF');
498
487
  }
499
488
  return [4 /*yield*/, fetch("".concat(apiHost, "/api/legacy_documents/").concat(documentUuid, "?type=").concat(documentType), {
500
- headers: {
501
- Authorization: "Bearer ".concat(token),
502
- },
489
+ headers: common.createClientDevHeaders(token),
503
490
  })];
504
491
  case 1:
505
492
  response = _a.sent();
@@ -19589,7 +19576,7 @@ var PaymentHoldModal = function (_a) {
19589
19576
  }, footer: null, open: visible, width: 600 }, { children: [jsxRuntime.jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsxRuntime.jsx("div", __assign({ className: "mb-4" }, { children: jsxRuntime.jsx(PaymentForm, { quote: {
19590
19577
  amount: quote.amount,
19591
19578
  currencyId: quote.currency,
19592
- id: quote.object.id,
19579
+ id: quote.quote.id,
19593
19580
  }, paymentHoldOptions: {
19594
19581
  payToAccept: true,
19595
19582
  amountToHold: quote.amount,
@@ -19627,8 +19614,8 @@ function Quote(_a) {
19627
19614
  // TODO: dissolve this hook
19628
19615
  var useQuotePaymentHold = function (formattedQuote) {
19629
19616
  var _a = react.useState(false), paymentHoldModalVisible = _a[0], setPaymentHoldModalVisible = _a[1];
19630
- var shouldDoPaymentHold = (formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.object.payToAccept) == true;
19631
- var currentPaymentHold = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.object.currentPaymentHold;
19617
+ var shouldDoPaymentHold = (formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.quote.payToAccept) == true;
19618
+ var currentPaymentHold = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.quote.currentPaymentHold;
19632
19619
  return {
19633
19620
  paymentHold: currentPaymentHold,
19634
19621
  paymentHoldModalVisible: paymentHoldModalVisible,
@@ -19666,7 +19653,6 @@ function ActualQuote() {
19666
19653
  placeholderData: reactQuery.keepPreviousData,
19667
19654
  }), data = _g.data, isLoading = _g.isLoading;
19668
19655
  var formattedQuote = data;
19669
- console.log(data);
19670
19656
  // Hooks
19671
19657
  var _h = useSendAcceptQuote({
19672
19658
  token: token,
@@ -19697,11 +19683,13 @@ function ActualQuote() {
19697
19683
  }
19698
19684
  // Derived state
19699
19685
  var isAccepted = formattedQuote.state === 'ACCEPTED';
19700
- var firstInvoice = (_a = formattedQuote.object) === null || _a === void 0 ? void 0 : _a.firstInvoice;
19686
+ var firstInvoice = (_a = formattedQuote.quote) === null || _a === void 0 ? void 0 : _a.firstInvoice;
19701
19687
  if ((firstInvoice === null || firstInvoice === void 0 ? void 0 : firstInvoice.state) === 'PAID' && paymentHoldCompleted) {
19702
19688
  return jsxRuntime.jsx(Invoice, { id: firstInvoice.id });
19703
19689
  }
19704
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 ".concat(isMobile ? 'bunny-w-full bunny-overflow-hidden' : '', " ").concat(className) }, { children: [jsxRuntime.jsx(QuoteButtons, { isAccepted: isAccepted, formattedQuote: formattedQuote, isMobile: isMobile, hideDownloadButton: hideDownloadButton, id: id, isAccepting: isAccepting, handleClickAccept: handleClickAccept, setPaymentHoldModalVisible: setPaymentHoldModalVisible, shouldDoPaymentHold: shouldDoPaymentHold, paymentHoldCompleted: paymentHoldCompleted, paymentHold: paymentHold }), jsxRuntime.jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html, targetUrl: ((_b = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.object) === null || _b === void 0 ? void 0 : _b.documentTemplateId) ? "".concat(apiHost, "/api/pdf/quote") : undefined }, { children: ((_d = (_c = formattedQuote.object) === null || _c === void 0 ? void 0 : _c.documents) === null || _d === void 0 ? void 0 : _d.length) > 0 ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: formattedQuote.object.documents.map(function (doc, index) {
19690
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 ".concat(isMobile ? 'bunny-w-full bunny-overflow-hidden' : '', " ").concat(className) }, { children: [jsxRuntime.jsx(QuoteButtons, { isAccepted: isAccepted, formattedQuote: formattedQuote, isMobile: isMobile, hideDownloadButton: hideDownloadButton, id: id, isAccepting: isAccepting, handleClickAccept: handleClickAccept, setPaymentHoldModalVisible: setPaymentHoldModalVisible, shouldDoPaymentHold: shouldDoPaymentHold, paymentHoldCompleted: paymentHoldCompleted, paymentHold: paymentHold }), jsxRuntime.jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html, targetUrl: ((_b = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.quote) === null || _b === void 0 ? void 0 : _b.documentTemplateId)
19691
+ ? "".concat(apiHost, "/api/pdf/quote/").concat(formattedQuote.id)
19692
+ : undefined }, { children: ((_d = (_c = formattedQuote.quote) === null || _c === void 0 ? void 0 : _c.documents) === null || _d === void 0 ? void 0 : _d.length) > 0 ? (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: formattedQuote.quote.documents.map(function (doc, index) {
19705
19693
  return (jsxRuntime.jsx(antd.Button, __assign({ download: doc.filename, href: doc.url, type: "link" }, { children: doc.filename }), index));
19706
19694
  }) }))) : null }))] })), jsxRuntime.jsx(AcceptQuoteModal, { acceptBoxVisible: acceptBoxVisible, formattedQuote: formattedQuote, setAcceptBoxVisible: setAcceptBoxVisible, setIsAccepting: setIsAccepting, sendAccept: sendAccept, isSendAcceptPending: isSendAcceptPending }), jsxRuntime.jsx(PaymentHoldModal, { visible: paymentHoldModalVisible, setVisible: setPaymentHoldModalVisible, quote: formattedQuote }), jsxRuntime.jsx(PandadocPollingModal, { isVisible: pandadocPollingModalVisible, setVisible: setPandadocPollingModalVisible, id: id })] }));
19707
19695
  }
@@ -19750,17 +19738,14 @@ var getQuotes = function (_a) {
19750
19738
  });
19751
19739
  };
19752
19740
 
19753
- 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 dueAt issuedAt isLegacy }\n ...on CreditNote { amount number issuedAt }\n }\n account {\n name\n id\n }\n }\n }\n}"); };
19741
+ 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 dueAt issuedAt isLegacy }\n ...on CreditNote { amount number issuedAt }\n }\n account {\n name\n id\n }\n }\n }\n}"); };
19754
19742
  var getTransactions = function (filter, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19755
19743
  var response, _a, data, errors;
19756
19744
  return __generator(this, function (_b) {
19757
19745
  switch (_b.label) {
19758
- case 0: return [4 /*yield*/, fetch(apiHost + "/graphql", {
19759
- method: "POST",
19760
- headers: {
19761
- "Content-type": "application/json; charset=utf-8",
19762
- Authorization: "Bearer ".concat(token),
19763
- },
19746
+ case 0: return [4 /*yield*/, fetch(apiHost + '/graphql', {
19747
+ method: 'POST',
19748
+ headers: common.createClientDevHeaders(token),
19764
19749
  body: JSON.stringify({
19765
19750
  query: transactionMutation(filter),
19766
19751
  }),
@@ -21577,7 +21562,7 @@ var PriceListGridMobile = function (_a) {
21577
21562
 
21578
21563
  var NextPriceListButton = function (_a) {
21579
21564
  var availablePriceLists = _a.availablePriceLists, priceListStart = _a.priceListStart, setPriceListStart = _a.setPriceListStart, numberOfPlansToDisplay = _a.numberOfPlansToDisplay;
21580
- return (jsxRuntime.jsxs("div", __assign({ className: "bunny-absolute bunny-flex bunny-gap-1", style: { top: "12px", right: "8px", zIndex: 10 } }, { children: [priceListStart > 0 && (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-center bunny-rounded-full bunny-shadow bunny-p-1 bunny-cursor-pointer", onClick: function () {
21565
+ return (jsxRuntime.jsxs("div", __assign({ className: "bunny-absolute bunny-flex bunny-gap-1", style: { top: '12px', right: '8px' } }, { children: [priceListStart > 0 && (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-center bunny-rounded-full bunny-shadow bunny-p-1 bunny-cursor-pointer", onClick: function () {
21581
21566
  setPriceListStart(function (prev) {
21582
21567
  var newValue = prev - 1;
21583
21568
  if (newValue < 0) {
@@ -21585,7 +21570,7 @@ var NextPriceListButton = function (_a) {
21585
21570
  }
21586
21571
  return newValue;
21587
21572
  });
21588
- }, style: { width: "22px", height: "22px" } }, { children: jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faChevronLeft }) }))), priceListStart < availablePriceLists.length - numberOfPlansToDisplay && (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-center bunny-rounded-full bunny-shadow bunny-p-1 bunny-cursor-pointer", onClick: function () {
21573
+ }, style: { width: '22px', height: '22px' } }, { children: jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faChevronLeft }) }))), priceListStart < availablePriceLists.length - numberOfPlansToDisplay && (jsxRuntime.jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-center bunny-rounded-full bunny-shadow bunny-p-1 bunny-cursor-pointer", onClick: function () {
21589
21574
  return setPriceListStart(function (prev) {
21590
21575
  var newValue = prev + 1;
21591
21576
  if (newValue >= availablePriceLists.length) {
@@ -21593,7 +21578,7 @@ var NextPriceListButton = function (_a) {
21593
21578
  }
21594
21579
  return newValue;
21595
21580
  });
21596
- }, style: { width: "22px", height: "22px" } }, { children: jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faChevronRight }) })))] })));
21581
+ }, style: { width: '22px', height: '22px' } }, { children: jsxRuntime.jsx(reactFontawesome.FontAwesomeIcon, { icon: freeSolidSvgIcons.faChevronRight }) })))] })));
21597
21582
  };
21598
21583
 
21599
21584
  var filterUniqueFeatures = function (_a) {
@@ -1,5 +1,5 @@
1
- import { Dispatch, SetStateAction } from "react";
2
- import { PriceList } from "@bunnyapp/common";
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { PriceList } from '@bunnyapp/common';
3
3
  declare const NextPriceListButton: ({ availablePriceLists, priceListStart, setPriceListStart, numberOfPlansToDisplay, }: {
4
4
  availablePriceLists: PriceList[];
5
5
  numberOfPlansToDisplay: number;
@@ -1,3 +1,3 @@
1
- import { FrontendTransaction as T } from "@bunnyapp/common";
1
+ import { FrontendTransaction as T } from '@bunnyapp/common';
2
2
  declare const getTransactions: (filter: string, apiHost: string, token?: string) => Promise<T.Transaction[]>;
3
3
  export default getTransactions;
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ import { Markup } from 'interweave';
4
4
  import { ConfigProvider, Spin, Button, Tag, Typography, Dropdown, Input, Checkbox, Skeleton, Collapse, Modal, Form, Tooltip, Drawer, Card as Card$1, Image, Divider, Select, Radio, Space, Popconfirm, Table } from 'antd';
5
5
  import { DownloadOutlined, CreditCardOutlined, EllipsisOutlined, BankOutlined, SearchOutlined, CheckCircleFilled, CloseOutlined, ArrowLeftOutlined } from '@ant-design/icons';
6
6
  import styled from 'styled-components';
7
- import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory, useIsMobile, isColorTooDark, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, useErrorNotification, invokePlugin, useAllErrorFormats, formatCurrency, GRAY_500, GRAY_200, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, request as request$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, SLATE_500, PRIMARY_COLOR as PRIMARY_COLOR$1, sortSubscriptionCharges, Lists, getAccount, StringUtils, BillingPeriod, ChargeType, SubscriptionState as SubscriptionState$2, PERIOD_LABELS, PricingStyle, PricingModel, SLATE_100, useInfoNotification, MODAL_MAX_HEIGHT, DataInterval, QuoteChangeKind, TAG_COLORS } from '@bunnyapp/common';
7
+ import { DEFAULT_ACCENT_COLOR, DEFAULT_BRAND_COLOR, DEFAULT_SECONDARY_COLOR, DEFAULT_TOP_NAV_IMAGE_URL, gqlRequest as gqlRequest$1, createClientDevHeaders, X_BUNNY_COMPONENTS_VERSION_HEADER_NAME, QueryKeyFactory, useIsMobile, isColorTooDark, INPUT_BORDER_COLOR, SLATE_50, SLATE_400, SLATE_200, useErrorNotification, invokePlugin, useAllErrorFormats, formatCurrency, GRAY_500, GRAY_200, useSuccessNotification, getFormattedInvoice, PAYABLE_INVOICE_STATES, BreakpointNumbers, request as request$1, useGraphQLmutation, formatDate, FrontendTransaction, SLATE_600, WHITE, TransactionKind, SLATE_500, PRIMARY_COLOR as PRIMARY_COLOR$1, sortSubscriptionCharges, Lists, getAccount, StringUtils, BillingPeriod, ChargeType, SubscriptionState as SubscriptionState$2, PERIOD_LABELS, PricingStyle, PricingModel, SLATE_100, useInfoNotification, MODAL_MAX_HEIGHT, DataInterval, QuoteChangeKind, TAG_COLORS } from '@bunnyapp/common';
8
8
  import { QueryClient, QueryClientProvider, useQuery, useQueryClient, useMutation, keepPreviousData } from '@tanstack/react-query';
9
9
  import theme from 'antd/lib/theme/index.js';
10
10
  import { RecoilRoot } from 'recoil';
@@ -143,18 +143,11 @@ var BrandContext = createContext({
143
143
  });
144
144
 
145
145
  // This will be replaced at build time by rollup-plugin-replace
146
- var PACKAGE_VERSION = '1.0.62-beta.5';
146
+ var PACKAGE_VERSION = '1.0.62-beta.7';
147
147
  var createRequestHeaders = function (token) {
148
- var _a;
149
- var bearerToken = token ? "Bearer ".concat(token) : null;
150
- var headers = (_a = {
151
- 'Content-type': 'application/json; charset=utf-8'
152
- },
153
- _a[X_BUNNY_COMPONENTS_VERSION_HEADER_NAME] = PACKAGE_VERSION,
154
- _a);
155
- if (bearerToken) {
156
- headers['Authorization'] = bearerToken;
157
- }
148
+ var headers = createClientDevHeaders(token);
149
+ // Add the components version header
150
+ headers[X_BUNNY_COMPONENTS_VERSION_HEADER_NAME] = PACKAGE_VERSION;
158
151
  return headers;
159
152
  };
160
153
  var getGraphQLBaseURL = function (apiHost) {
@@ -322,18 +315,15 @@ var useAjax = function (onError) {
322
315
  case 0: return [4 /*yield*/, fetch(url, {
323
316
  method: method,
324
317
  body: bodyData,
325
- headers: {
326
- "Content-type": "application/json; charset=utf-8",
327
- Authorization: "Bearer ".concat(token),
328
- },
318
+ headers: createClientDevHeaders(token),
329
319
  })];
330
320
  case 1:
331
321
  response = _a.sent();
332
322
  if (response.status !== 200 && response.status !== 201) {
333
323
  return [2 /*return*/, response.json().then(function (data) {
334
324
  if (response.status === 401) {
335
- console.error("expired token");
336
- onError === null || onError === void 0 ? void 0 : onError("expired token");
325
+ console.error('expired token');
326
+ onError === null || onError === void 0 ? void 0 : onError('expired token');
337
327
  }
338
328
  else {
339
329
  throw new Error(data === null || data === void 0 ? void 0 : data.message);
@@ -349,7 +339,7 @@ var useAjax = function (onError) {
349
339
  var useDownloadFile = function (id, onError) {
350
340
  var ajax = useAjax(onError);
351
341
  return function (url, token) {
352
- return ajax(url + (id ? "?id=".concat(id) : ""), "GET", function (rsp) { return __awaiter(void 0, void 0, void 0, function () {
342
+ return ajax(url + (id ? "?id=".concat(id) : ''), 'GET', function (rsp) { return __awaiter(void 0, void 0, void 0, function () {
353
343
  var blob, file, contentDisposition, anchor, filenameRegex, matches;
354
344
  return __generator(this, function (_a) {
355
345
  switch (_a.label) {
@@ -357,15 +347,14 @@ var useDownloadFile = function (id, onError) {
357
347
  case 1:
358
348
  blob = _a.sent();
359
349
  file = window.URL.createObjectURL(blob);
360
- contentDisposition = rsp.headers.get("content-disposition");
361
- anchor = document.createElement("a");
350
+ contentDisposition = rsp.headers.get('content-disposition');
351
+ anchor = document.createElement('a');
362
352
  anchor.href = file;
363
- if (contentDisposition &&
364
- contentDisposition.indexOf("attachment") !== -1) {
353
+ if (contentDisposition && contentDisposition.indexOf('attachment') !== -1) {
365
354
  filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
366
355
  matches = filenameRegex.exec(contentDisposition);
367
356
  if (matches != null && matches[1]) {
368
- anchor.setAttribute("download", matches[1].replace(/['"]/g, ""));
357
+ anchor.setAttribute('download', matches[1].replace(/['"]/g, ''));
369
358
  }
370
359
  }
371
360
  anchor.click();
@@ -467,9 +456,7 @@ var fetchPDF = function (apiHost, documentUuid, documentType, token) { return __
467
456
  throw new Error('Invoice ID is required to fetch PDF');
468
457
  }
469
458
  return [4 /*yield*/, fetch("".concat(apiHost, "/api/legacy_documents/").concat(documentUuid, "?type=").concat(documentType), {
470
- headers: {
471
- Authorization: "Bearer ".concat(token),
472
- },
459
+ headers: createClientDevHeaders(token),
473
460
  })];
474
461
  case 1:
475
462
  response = _a.sent();
@@ -19559,7 +19546,7 @@ var PaymentHoldModal = function (_a) {
19559
19546
  }, footer: null, open: visible, width: 600 }, { children: [jsx(Title$2, __assign({ className: "mt-4 pb-4 mx-4", level: 5 }, { children: "Pay to accept" })), jsx("div", __assign({ className: "mb-4" }, { children: jsx(PaymentForm, { quote: {
19560
19547
  amount: quote.amount,
19561
19548
  currencyId: quote.currency,
19562
- id: quote.object.id,
19549
+ id: quote.quote.id,
19563
19550
  }, paymentHoldOptions: {
19564
19551
  payToAccept: true,
19565
19552
  amountToHold: quote.amount,
@@ -19597,8 +19584,8 @@ function Quote(_a) {
19597
19584
  // TODO: dissolve this hook
19598
19585
  var useQuotePaymentHold = function (formattedQuote) {
19599
19586
  var _a = useState(false), paymentHoldModalVisible = _a[0], setPaymentHoldModalVisible = _a[1];
19600
- var shouldDoPaymentHold = (formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.object.payToAccept) == true;
19601
- var currentPaymentHold = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.object.currentPaymentHold;
19587
+ var shouldDoPaymentHold = (formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.quote.payToAccept) == true;
19588
+ var currentPaymentHold = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.quote.currentPaymentHold;
19602
19589
  return {
19603
19590
  paymentHold: currentPaymentHold,
19604
19591
  paymentHoldModalVisible: paymentHoldModalVisible,
@@ -19636,7 +19623,6 @@ function ActualQuote() {
19636
19623
  placeholderData: keepPreviousData,
19637
19624
  }), data = _g.data, isLoading = _g.isLoading;
19638
19625
  var formattedQuote = data;
19639
- console.log(data);
19640
19626
  // Hooks
19641
19627
  var _h = useSendAcceptQuote({
19642
19628
  token: token,
@@ -19667,11 +19653,13 @@ function ActualQuote() {
19667
19653
  }
19668
19654
  // Derived state
19669
19655
  var isAccepted = formattedQuote.state === 'ACCEPTED';
19670
- var firstInvoice = (_a = formattedQuote.object) === null || _a === void 0 ? void 0 : _a.firstInvoice;
19656
+ var firstInvoice = (_a = formattedQuote.quote) === null || _a === void 0 ? void 0 : _a.firstInvoice;
19671
19657
  if ((firstInvoice === null || firstInvoice === void 0 ? void 0 : firstInvoice.state) === 'PAID' && paymentHoldCompleted) {
19672
19658
  return jsx(Invoice, { id: firstInvoice.id });
19673
19659
  }
19674
- return (jsxs(Fragment, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 ".concat(isMobile ? 'bunny-w-full bunny-overflow-hidden' : '', " ").concat(className) }, { children: [jsx(QuoteButtons, { isAccepted: isAccepted, formattedQuote: formattedQuote, isMobile: isMobile, hideDownloadButton: hideDownloadButton, id: id, isAccepting: isAccepting, handleClickAccept: handleClickAccept, setPaymentHoldModalVisible: setPaymentHoldModalVisible, shouldDoPaymentHold: shouldDoPaymentHold, paymentHoldCompleted: paymentHoldCompleted, paymentHold: paymentHold }), jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html, targetUrl: ((_b = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.object) === null || _b === void 0 ? void 0 : _b.documentTemplateId) ? "".concat(apiHost, "/api/pdf/quote") : undefined }, { children: ((_d = (_c = formattedQuote.object) === null || _c === void 0 ? void 0 : _c.documents) === null || _d === void 0 ? void 0 : _d.length) > 0 ? (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: formattedQuote.object.documents.map(function (doc, index) {
19660
+ return (jsxs(Fragment, { children: [jsxs("div", __assign({ className: "bunny-flex bunny-flex-col bunny-gap-4 ".concat(isMobile ? 'bunny-w-full bunny-overflow-hidden' : '', " ").concat(className) }, { children: [jsx(QuoteButtons, { isAccepted: isAccepted, formattedQuote: formattedQuote, isMobile: isMobile, hideDownloadButton: hideDownloadButton, id: id, isAccepting: isAccepting, handleClickAccept: handleClickAccept, setPaymentHoldModalVisible: setPaymentHoldModalVisible, shouldDoPaymentHold: shouldDoPaymentHold, paymentHoldCompleted: paymentHoldCompleted, paymentHold: paymentHold }), jsx(InvoiceQuoteView, __assign({ html: formattedQuote.html, targetUrl: ((_b = formattedQuote === null || formattedQuote === void 0 ? void 0 : formattedQuote.quote) === null || _b === void 0 ? void 0 : _b.documentTemplateId)
19661
+ ? "".concat(apiHost, "/api/pdf/quote/").concat(formattedQuote.id)
19662
+ : undefined }, { children: ((_d = (_c = formattedQuote.quote) === null || _c === void 0 ? void 0 : _c.documents) === null || _d === void 0 ? void 0 : _d.length) > 0 ? (jsx("div", __assign({ className: "bunny-flex bunny-flex-col bunny-items-end" }, { children: formattedQuote.quote.documents.map(function (doc, index) {
19675
19663
  return (jsx(Button, __assign({ download: doc.filename, href: doc.url, type: "link" }, { children: doc.filename }), index));
19676
19664
  }) }))) : null }))] })), jsx(AcceptQuoteModal, { acceptBoxVisible: acceptBoxVisible, formattedQuote: formattedQuote, setAcceptBoxVisible: setAcceptBoxVisible, setIsAccepting: setIsAccepting, sendAccept: sendAccept, isSendAcceptPending: isSendAcceptPending }), jsx(PaymentHoldModal, { visible: paymentHoldModalVisible, setVisible: setPaymentHoldModalVisible, quote: formattedQuote }), jsx(PandadocPollingModal, { isVisible: pandadocPollingModalVisible, setVisible: setPandadocPollingModalVisible, id: id })] }));
19677
19665
  }
@@ -19720,17 +19708,14 @@ var getQuotes = function (_a) {
19720
19708
  });
19721
19709
  };
19722
19710
 
19723
- 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 dueAt issuedAt isLegacy }\n ...on CreditNote { amount number issuedAt }\n }\n account {\n name\n id\n }\n }\n }\n}"); };
19711
+ 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 dueAt issuedAt isLegacy }\n ...on CreditNote { amount number issuedAt }\n }\n account {\n name\n id\n }\n }\n }\n}"); };
19724
19712
  var getTransactions = function (filter, apiHost, token) { return __awaiter(void 0, void 0, void 0, function () {
19725
19713
  var response, _a, data, errors;
19726
19714
  return __generator(this, function (_b) {
19727
19715
  switch (_b.label) {
19728
- case 0: return [4 /*yield*/, fetch(apiHost + "/graphql", {
19729
- method: "POST",
19730
- headers: {
19731
- "Content-type": "application/json; charset=utf-8",
19732
- Authorization: "Bearer ".concat(token),
19733
- },
19716
+ case 0: return [4 /*yield*/, fetch(apiHost + '/graphql', {
19717
+ method: 'POST',
19718
+ headers: createClientDevHeaders(token),
19734
19719
  body: JSON.stringify({
19735
19720
  query: transactionMutation(filter),
19736
19721
  }),
@@ -21547,7 +21532,7 @@ var PriceListGridMobile = function (_a) {
21547
21532
 
21548
21533
  var NextPriceListButton = function (_a) {
21549
21534
  var availablePriceLists = _a.availablePriceLists, priceListStart = _a.priceListStart, setPriceListStart = _a.setPriceListStart, numberOfPlansToDisplay = _a.numberOfPlansToDisplay;
21550
- return (jsxs("div", __assign({ className: "bunny-absolute bunny-flex bunny-gap-1", style: { top: "12px", right: "8px", zIndex: 10 } }, { children: [priceListStart > 0 && (jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-center bunny-rounded-full bunny-shadow bunny-p-1 bunny-cursor-pointer", onClick: function () {
21535
+ return (jsxs("div", __assign({ className: "bunny-absolute bunny-flex bunny-gap-1", style: { top: '12px', right: '8px' } }, { children: [priceListStart > 0 && (jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-center bunny-rounded-full bunny-shadow bunny-p-1 bunny-cursor-pointer", onClick: function () {
21551
21536
  setPriceListStart(function (prev) {
21552
21537
  var newValue = prev - 1;
21553
21538
  if (newValue < 0) {
@@ -21555,7 +21540,7 @@ var NextPriceListButton = function (_a) {
21555
21540
  }
21556
21541
  return newValue;
21557
21542
  });
21558
- }, style: { width: "22px", height: "22px" } }, { children: jsx(FontAwesomeIcon, { icon: faChevronLeft }) }))), priceListStart < availablePriceLists.length - numberOfPlansToDisplay && (jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-center bunny-rounded-full bunny-shadow bunny-p-1 bunny-cursor-pointer", onClick: function () {
21543
+ }, style: { width: '22px', height: '22px' } }, { children: jsx(FontAwesomeIcon, { icon: faChevronLeft }) }))), priceListStart < availablePriceLists.length - numberOfPlansToDisplay && (jsx("div", __assign({ className: "bunny-flex bunny-items-center bunny-justify-center bunny-rounded-full bunny-shadow bunny-p-1 bunny-cursor-pointer", onClick: function () {
21559
21544
  return setPriceListStart(function (prev) {
21560
21545
  var newValue = prev + 1;
21561
21546
  if (newValue >= availablePriceLists.length) {
@@ -21563,7 +21548,7 @@ var NextPriceListButton = function (_a) {
21563
21548
  }
21564
21549
  return newValue;
21565
21550
  });
21566
- }, style: { width: "22px", height: "22px" } }, { children: jsx(FontAwesomeIcon, { icon: faChevronRight }) })))] })));
21551
+ }, style: { width: '22px', height: '22px' } }, { children: jsx(FontAwesomeIcon, { icon: faChevronRight }) })))] })));
21567
21552
  };
21568
21553
 
21569
21554
  var filterUniqueFeatures = function (_a) {
@@ -1,5 +1,5 @@
1
- import { Dispatch, SetStateAction } from "react";
2
- import { PriceList } from "@bunnyapp/common";
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { PriceList } from '@bunnyapp/common';
3
3
  declare const NextPriceListButton: ({ availablePriceLists, priceListStart, setPriceListStart, numberOfPlansToDisplay, }: {
4
4
  availablePriceLists: PriceList[];
5
5
  numberOfPlansToDisplay: number;
@@ -1,3 +1,3 @@
1
- import { FrontendTransaction as T } from "@bunnyapp/common";
1
+ import { FrontendTransaction as T } from '@bunnyapp/common';
2
2
  declare const getTransactions: (filter: string, apiHost: string, token?: string) => Promise<T.Transaction[]>;
3
3
  export default getTransactions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunnyapp/components",
3
- "version": "1.0.62-beta.5",
3
+ "version": "1.0.62-beta.7",
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",
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@ant-design/icons": "^5.6.1",
68
- "@bunnyapp/common": "^1.0.62-beta.6",
68
+ "@bunnyapp/common": "^1.0.62-beta.7",
69
69
  "@fortawesome/fontawesome-svg-core": "^6.7.2",
70
70
  "@fortawesome/free-brands-svg-icons": "^6.7.2",
71
71
  "@fortawesome/free-regular-svg-icons": "^6.7.2",