@open-tender/utils 0.4.35 → 0.4.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +2 -2
  3. package/dist/.DS_Store +0 -0
  4. package/dist/cjs/__tests__/utils/helpers.test.d.ts +1 -1
  5. package/dist/cjs/__tests__/utils/helpers.test.js +96 -96
  6. package/dist/cjs/__tests__/utils/theme.test.d.ts +1 -1
  7. package/dist/cjs/__tests__/utils/theme.test.js +37 -37
  8. package/dist/cjs/hooks/index.d.ts +35 -35
  9. package/dist/cjs/hooks/index.js +38 -38
  10. package/dist/cjs/hooks/types.d.ts +4 -4
  11. package/dist/cjs/hooks/types.js +2 -2
  12. package/dist/cjs/hooks/useAccordion.d.ts +22 -22
  13. package/dist/cjs/hooks/useAccordion.js +56 -56
  14. package/dist/cjs/hooks/useAddressForm.d.ts +12 -12
  15. package/dist/cjs/hooks/useAddressForm.js +83 -83
  16. package/dist/cjs/hooks/useAllergenForm.d.ts +10 -10
  17. package/dist/cjs/hooks/useAllergenForm.js +58 -58
  18. package/dist/cjs/hooks/useBuilder.d.ts +14 -14
  19. package/dist/cjs/hooks/useBuilder.js +144 -144
  20. package/dist/cjs/hooks/useCartGuestForm.d.ts +12 -12
  21. package/dist/cjs/hooks/useCartGuestForm.js +58 -58
  22. package/dist/cjs/hooks/useCartPoints.d.ts +13 -13
  23. package/dist/cjs/hooks/useCartPoints.js +74 -74
  24. package/dist/cjs/hooks/useCommunicationPreferences.js +1 -1
  25. package/dist/cjs/hooks/useCreditCard.d.ts +13 -13
  26. package/dist/cjs/hooks/useCreditCard.js +63 -63
  27. package/dist/cjs/hooks/useCreditCardForm.d.ts +10 -10
  28. package/dist/cjs/hooks/useCreditCardForm.js +71 -71
  29. package/dist/cjs/hooks/useCurbside.d.ts +9 -9
  30. package/dist/cjs/hooks/useCurbside.js +39 -39
  31. package/dist/cjs/hooks/useDineInForm.d.ts +11 -11
  32. package/dist/cjs/hooks/useDineInForm.js +56 -56
  33. package/dist/cjs/hooks/useDonationForm.d.ts +28 -28
  34. package/dist/cjs/hooks/useDonationForm.js +172 -172
  35. package/dist/cjs/hooks/useFirstTimes.d.ts +18 -18
  36. package/dist/cjs/hooks/useFirstTimes.js +81 -81
  37. package/dist/cjs/hooks/useGiftCardAssignForm.d.ts +14 -14
  38. package/dist/cjs/hooks/useGiftCardAssignForm.js +57 -57
  39. package/dist/cjs/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
  40. package/dist/cjs/hooks/useGiftCardAssignOtherForm.js +50 -50
  41. package/dist/cjs/hooks/useGiftCardForm.d.ts +12 -12
  42. package/dist/cjs/hooks/useGiftCardForm.js +74 -74
  43. package/dist/cjs/hooks/useGiftCardsForm.d.ts +31 -31
  44. package/dist/cjs/hooks/useGiftCardsForm.js +195 -195
  45. package/dist/cjs/hooks/useGuestCheckoutForm.d.ts +21 -21
  46. package/dist/cjs/hooks/useGuestCheckoutForm.js +89 -89
  47. package/dist/cjs/hooks/useGuestForm.d.ts +12 -12
  48. package/dist/cjs/hooks/useGuestForm.js +60 -60
  49. package/dist/cjs/hooks/useImage.d.ts +5 -5
  50. package/dist/cjs/hooks/useImage.js +33 -33
  51. package/dist/cjs/hooks/useLoginForm.d.ts +12 -12
  52. package/dist/cjs/hooks/useLoginForm.js +67 -67
  53. package/dist/cjs/hooks/useMenuItem.d.ts +57 -57
  54. package/dist/cjs/hooks/useMenuItem.js +67 -67
  55. package/dist/cjs/hooks/useModifier.d.ts +53 -53
  56. package/dist/cjs/hooks/useModifier.js +72 -72
  57. package/dist/cjs/hooks/useModifierGroup.d.ts +15 -15
  58. package/dist/cjs/hooks/useModifierGroup.js +17 -17
  59. package/dist/cjs/hooks/useOneTimePasscodeForm.d.ts +16 -16
  60. package/dist/cjs/hooks/useOneTimePasscodeForm.js +87 -87
  61. package/dist/cjs/hooks/useOrderFulfillmentForm.d.ts +11 -11
  62. package/dist/cjs/hooks/useOrderFulfillmentForm.js +65 -65
  63. package/dist/cjs/hooks/useOrderItem.d.ts +48 -48
  64. package/dist/cjs/hooks/useOrderItem.js +54 -54
  65. package/dist/cjs/hooks/useOrderRating.d.ts +10 -10
  66. package/dist/cjs/hooks/useOrderRating.js +34 -34
  67. package/dist/cjs/hooks/useOrderRatingForm.d.ts +11 -11
  68. package/dist/cjs/hooks/useOrderRatingForm.js +35 -35
  69. package/dist/cjs/hooks/useProfileForm.d.ts +15 -15
  70. package/dist/cjs/hooks/useProfileForm.js +116 -116
  71. package/dist/cjs/hooks/useResetPasswordForm.d.ts +12 -12
  72. package/dist/cjs/hooks/useResetPasswordForm.js +77 -77
  73. package/dist/cjs/hooks/useSendResetForm.d.ts +14 -14
  74. package/dist/cjs/hooks/useSendResetForm.js +57 -57
  75. package/dist/cjs/hooks/useSignUpForm.d.ts +20 -20
  76. package/dist/cjs/hooks/useSignUpForm.js +151 -157
  77. package/dist/cjs/hooks/useSignUpGuestForm.d.ts +23 -23
  78. package/dist/cjs/hooks/useSignUpGuestForm.js +113 -124
  79. package/dist/cjs/hooks/useSigninForm.d.ts +12 -12
  80. package/dist/cjs/hooks/useSigninForm.js +66 -66
  81. package/dist/cjs/index.d.ts +2 -2
  82. package/dist/cjs/index.js +5 -5
  83. package/dist/cjs/utils/cards.d.ts +20 -20
  84. package/dist/cjs/utils/cards.js +155 -155
  85. package/dist/cjs/utils/cart.d.ts +202 -202
  86. package/dist/cjs/utils/cart.js +909 -909
  87. package/dist/cjs/utils/checkout.d.ts +55 -55
  88. package/dist/cjs/utils/checkout.js +125 -125
  89. package/dist/cjs/utils/constants.d.ts +43 -43
  90. package/dist/cjs/utils/constants.js +58 -58
  91. package/dist/cjs/utils/customer.d.ts +4 -4
  92. package/dist/cjs/utils/customer.js +34 -34
  93. package/dist/cjs/utils/datetimes.d.ts +99 -99
  94. package/dist/cjs/utils/datetimes.js +601 -601
  95. package/dist/cjs/utils/errors.d.ts +51 -51
  96. package/dist/cjs/utils/errors.js +191 -191
  97. package/dist/cjs/utils/favorites.d.ts +10 -10
  98. package/dist/cjs/utils/favorites.js +119 -119
  99. package/dist/cjs/utils/googleMaps.d.ts +14 -14
  100. package/dist/cjs/utils/googleMaps.js +30 -30
  101. package/dist/cjs/utils/helpers.d.ts +63 -63
  102. package/dist/cjs/utils/helpers.js +244 -244
  103. package/dist/cjs/utils/index.d.ts +19 -19
  104. package/dist/cjs/utils/index.js +23 -23
  105. package/dist/cjs/utils/keypad.d.ts +9 -9
  106. package/dist/cjs/utils/keypad.js +105 -105
  107. package/dist/cjs/utils/maps.d.ts +226 -226
  108. package/dist/cjs/utils/maps.js +334 -334
  109. package/dist/cjs/utils/menu.d.ts +117 -117
  110. package/dist/cjs/utils/menu.js +82 -82
  111. package/dist/cjs/utils/orders.d.ts +21 -21
  112. package/dist/cjs/utils/orders.js +202 -202
  113. package/dist/cjs/utils/pizzaBuilder.d.ts +10 -10
  114. package/dist/cjs/utils/pizzaBuilder.js +43 -43
  115. package/dist/cjs/utils/refunds.d.ts +35 -35
  116. package/dist/cjs/utils/refunds.js +98 -98
  117. package/dist/cjs/utils/revenueCenters.d.ts +11 -11
  118. package/dist/cjs/utils/revenueCenters.js +125 -125
  119. package/dist/cjs/utils/rewards.d.ts +4 -4
  120. package/dist/cjs/utils/rewards.js +100 -100
  121. package/dist/cjs/utils/theme.d.ts +27 -27
  122. package/dist/cjs/utils/theme.js +266 -266
  123. package/dist/cjs/utils/version.d.ts +4 -4
  124. package/dist/cjs/utils/version.js +38 -38
  125. package/dist/esm/__tests__/utils/helpers.test.d.ts +1 -1
  126. package/dist/esm/__tests__/utils/helpers.test.js +94 -94
  127. package/dist/esm/__tests__/utils/theme.test.d.ts +1 -1
  128. package/dist/esm/__tests__/utils/theme.test.js +35 -35
  129. package/dist/esm/hooks/index.d.ts +35 -35
  130. package/dist/esm/hooks/index.js +35 -35
  131. package/dist/esm/hooks/types.d.ts +4 -4
  132. package/dist/esm/hooks/types.js +1 -1
  133. package/dist/esm/hooks/useAccordion.d.ts +22 -22
  134. package/dist/esm/hooks/useAccordion.js +52 -52
  135. package/dist/esm/hooks/useAddressForm.d.ts +12 -12
  136. package/dist/esm/hooks/useAddressForm.js +79 -79
  137. package/dist/esm/hooks/useAllergenForm.d.ts +10 -10
  138. package/dist/esm/hooks/useAllergenForm.js +54 -54
  139. package/dist/esm/hooks/useBuilder.d.ts +14 -14
  140. package/dist/esm/hooks/useBuilder.js +140 -140
  141. package/dist/esm/hooks/useCartGuestForm.d.ts +12 -12
  142. package/dist/esm/hooks/useCartGuestForm.js +54 -54
  143. package/dist/esm/hooks/useCartPoints.d.ts +13 -13
  144. package/dist/esm/hooks/useCartPoints.js +70 -70
  145. package/dist/esm/hooks/useCommunicationPreferences.js +1 -1
  146. package/dist/esm/hooks/useCreditCard.d.ts +13 -13
  147. package/dist/esm/hooks/useCreditCard.js +59 -59
  148. package/dist/esm/hooks/useCreditCardForm.d.ts +10 -10
  149. package/dist/esm/hooks/useCreditCardForm.js +67 -67
  150. package/dist/esm/hooks/useCurbside.d.ts +9 -9
  151. package/dist/esm/hooks/useCurbside.js +35 -35
  152. package/dist/esm/hooks/useDineInForm.d.ts +11 -11
  153. package/dist/esm/hooks/useDineInForm.js +52 -52
  154. package/dist/esm/hooks/useDonationForm.d.ts +28 -28
  155. package/dist/esm/hooks/useDonationForm.js +168 -168
  156. package/dist/esm/hooks/useFirstTimes.d.ts +18 -18
  157. package/dist/esm/hooks/useFirstTimes.js +77 -77
  158. package/dist/esm/hooks/useGiftCardAssignForm.d.ts +14 -14
  159. package/dist/esm/hooks/useGiftCardAssignForm.js +53 -53
  160. package/dist/esm/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
  161. package/dist/esm/hooks/useGiftCardAssignOtherForm.js +46 -46
  162. package/dist/esm/hooks/useGiftCardForm.d.ts +12 -12
  163. package/dist/esm/hooks/useGiftCardForm.js +70 -70
  164. package/dist/esm/hooks/useGiftCardsForm.d.ts +31 -31
  165. package/dist/esm/hooks/useGiftCardsForm.js +191 -191
  166. package/dist/esm/hooks/useGuestCheckoutForm.d.ts +21 -21
  167. package/dist/esm/hooks/useGuestCheckoutForm.js +85 -85
  168. package/dist/esm/hooks/useGuestForm.d.ts +12 -12
  169. package/dist/esm/hooks/useGuestForm.js +56 -56
  170. package/dist/esm/hooks/useImage.d.ts +5 -5
  171. package/dist/esm/hooks/useImage.js +29 -29
  172. package/dist/esm/hooks/useLoginForm.d.ts +12 -12
  173. package/dist/esm/hooks/useLoginForm.js +63 -63
  174. package/dist/esm/hooks/useMenuItem.d.ts +57 -57
  175. package/dist/esm/hooks/useMenuItem.js +63 -63
  176. package/dist/esm/hooks/useModifier.d.ts +53 -53
  177. package/dist/esm/hooks/useModifier.js +68 -68
  178. package/dist/esm/hooks/useModifierGroup.d.ts +15 -15
  179. package/dist/esm/hooks/useModifierGroup.js +13 -13
  180. package/dist/esm/hooks/useOneTimePasscodeForm.d.ts +16 -16
  181. package/dist/esm/hooks/useOneTimePasscodeForm.js +83 -83
  182. package/dist/esm/hooks/useOrderFulfillmentForm.d.ts +11 -11
  183. package/dist/esm/hooks/useOrderFulfillmentForm.js +61 -61
  184. package/dist/esm/hooks/useOrderItem.d.ts +48 -48
  185. package/dist/esm/hooks/useOrderItem.js +50 -50
  186. package/dist/esm/hooks/useOrderRating.d.ts +10 -10
  187. package/dist/esm/hooks/useOrderRating.js +30 -30
  188. package/dist/esm/hooks/useOrderRatingForm.d.ts +11 -11
  189. package/dist/esm/hooks/useOrderRatingForm.js +31 -31
  190. package/dist/esm/hooks/useProfileForm.d.ts +15 -15
  191. package/dist/esm/hooks/useProfileForm.js +112 -112
  192. package/dist/esm/hooks/useResetPasswordForm.d.ts +12 -12
  193. package/dist/esm/hooks/useResetPasswordForm.js +73 -73
  194. package/dist/esm/hooks/useSendResetForm.d.ts +14 -14
  195. package/dist/esm/hooks/useSendResetForm.js +53 -53
  196. package/dist/esm/hooks/useSignUpForm.d.ts +20 -20
  197. package/dist/esm/hooks/useSignUpForm.js +147 -153
  198. package/dist/esm/hooks/useSignUpGuestForm.d.ts +23 -23
  199. package/dist/esm/hooks/useSignUpGuestForm.js +109 -120
  200. package/dist/esm/hooks/useSigninForm.d.ts +12 -12
  201. package/dist/esm/hooks/useSigninForm.js +62 -62
  202. package/dist/esm/index.d.ts +2 -2
  203. package/dist/esm/index.js +2 -2
  204. package/dist/esm/utils/cards.d.ts +20 -20
  205. package/dist/esm/utils/cards.js +146 -146
  206. package/dist/esm/utils/cart.d.ts +202 -202
  207. package/dist/esm/utils/cart.js +868 -868
  208. package/dist/esm/utils/checkout.d.ts +55 -55
  209. package/dist/esm/utils/checkout.js +117 -117
  210. package/dist/esm/utils/constants.d.ts +43 -43
  211. package/dist/esm/utils/constants.js +55 -55
  212. package/dist/esm/utils/customer.d.ts +4 -4
  213. package/dist/esm/utils/customer.js +29 -29
  214. package/dist/esm/utils/datetimes.d.ts +99 -99
  215. package/dist/esm/utils/datetimes.js +531 -531
  216. package/dist/esm/utils/errors.d.ts +51 -51
  217. package/dist/esm/utils/errors.js +180 -180
  218. package/dist/esm/utils/favorites.d.ts +10 -10
  219. package/dist/esm/utils/favorites.js +109 -109
  220. package/dist/esm/utils/googleMaps.d.ts +14 -14
  221. package/dist/esm/utils/googleMaps.js +26 -26
  222. package/dist/esm/utils/helpers.d.ts +63 -63
  223. package/dist/esm/utils/helpers.js +205 -205
  224. package/dist/esm/utils/index.d.ts +19 -19
  225. package/dist/esm/utils/index.js +20 -20
  226. package/dist/esm/utils/keypad.d.ts +9 -9
  227. package/dist/esm/utils/keypad.js +97 -97
  228. package/dist/esm/utils/maps.d.ts +226 -226
  229. package/dist/esm/utils/maps.js +316 -316
  230. package/dist/esm/utils/menu.d.ts +117 -117
  231. package/dist/esm/utils/menu.js +74 -74
  232. package/dist/esm/utils/orders.d.ts +21 -21
  233. package/dist/esm/utils/orders.js +185 -185
  234. package/dist/esm/utils/pizzaBuilder.d.ts +10 -10
  235. package/dist/esm/utils/pizzaBuilder.js +38 -38
  236. package/dist/esm/utils/refunds.d.ts +35 -35
  237. package/dist/esm/utils/refunds.js +90 -90
  238. package/dist/esm/utils/revenueCenters.d.ts +11 -11
  239. package/dist/esm/utils/revenueCenters.js +115 -115
  240. package/dist/esm/utils/rewards.d.ts +4 -4
  241. package/dist/esm/utils/rewards.js +94 -94
  242. package/dist/esm/utils/theme.d.ts +27 -27
  243. package/dist/esm/utils/theme.js +254 -254
  244. package/dist/esm/utils/version.d.ts +4 -4
  245. package/dist/esm/utils/version.js +34 -34
  246. package/package.json +69 -69
@@ -1,55 +1,55 @@
1
- import { CheckoutTender, CheckoutTenders, CreditCard, Money, OrderTender } from '@open-tender/types';
2
- export declare const adjustTenders: (tenders: CheckoutTenders, isPaid: boolean, amountRemaining: number, updateForm: (form: {
3
- tenders: any;
4
- }) => void) => void;
5
- export declare const updateTenders: (tenders: CheckoutTenders, total: Money) => ({
6
- amount: string;
7
- acct: string;
8
- addr?: string | undefined;
9
- card_type_name: import("@open-tender/types").CardTypeName;
10
- cvv: string;
11
- exp: string;
12
- is_default: boolean;
13
- last4: string;
14
- masked: string;
15
- tender_status?: import("@open-tender/types").TenderStatus | undefined;
16
- tender_type: import("@open-tender/types").TenderType;
17
- zip: string;
18
- } | {
19
- amount: string;
20
- card_type?: import("@open-tender/types").CardType | undefined;
21
- card_type_name?: import("@open-tender/types").CardTypeName | undefined;
22
- customer_card_id: number;
23
- is_default?: boolean | undefined;
24
- last4?: string | undefined;
25
- masked?: string | undefined;
26
- tender_status?: import("@open-tender/types").TenderStatus | undefined;
27
- tender_type: import("@open-tender/types").TenderType;
28
- } | {
29
- amount: string;
30
- balance?: `${number}.${number}` | undefined;
31
- card_number: string;
32
- pin?: string | undefined;
33
- tender_status?: import("@open-tender/types").TenderStatus | undefined;
34
- tender_type: import("@open-tender/types").TenderType;
35
- } | {
36
- amount: string;
37
- approved_contact?: boolean | undefined;
38
- domain?: string | null | undefined;
39
- house_account_id: number;
40
- name: string;
41
- order_type?: import("@open-tender/types").OrderType | null | undefined;
42
- pin?: string | undefined;
43
- revenue_centers?: number[] | undefined;
44
- service_type?: import("@open-tender/types").ServiceType | null | undefined;
45
- tender_status?: import("@open-tender/types").TenderStatus | undefined;
46
- tender_type?: import("@open-tender/types").TenderType | undefined;
47
- } | {
48
- amount: string;
49
- tender_status?: import("@open-tender/types").TenderStatus | undefined;
50
- tender_type: import("@open-tender/types").TenderType;
51
- token: any;
52
- })[] | null;
53
- export declare const makeCreditCardName: (creditCard: CreditCard) => string;
54
- export declare const makeTenderName: (tender: OrderTender) => string;
55
- export declare const makeCheckoutTenderName: (tender: CheckoutTender) => string | undefined;
1
+ import { CheckoutTender, CheckoutTenders, CreditCard, Money, OrderTender } from '@open-tender/types';
2
+ export declare const adjustTenders: (tenders: CheckoutTenders, isPaid: boolean, amountRemaining: number, updateForm: (form: {
3
+ tenders: any;
4
+ }) => void) => void;
5
+ export declare const updateTenders: (tenders: CheckoutTenders, total: Money) => ({
6
+ amount: string;
7
+ acct: string;
8
+ addr?: string | undefined;
9
+ card_type_name: import("@open-tender/types").CardTypeName;
10
+ cvv: string;
11
+ exp: string;
12
+ is_default: boolean;
13
+ last4: string;
14
+ masked: string;
15
+ tender_status?: import("@open-tender/types").TenderStatus | undefined;
16
+ tender_type: import("@open-tender/types").TenderType;
17
+ zip: string;
18
+ } | {
19
+ amount: string;
20
+ card_type?: import("@open-tender/types").CardType | undefined;
21
+ card_type_name?: import("@open-tender/types").CardTypeName | undefined;
22
+ customer_card_id: number;
23
+ is_default?: boolean | undefined;
24
+ last4?: string | undefined;
25
+ masked?: string | undefined;
26
+ tender_status?: import("@open-tender/types").TenderStatus | undefined;
27
+ tender_type: import("@open-tender/types").TenderType;
28
+ } | {
29
+ amount: string;
30
+ balance?: `${number}.${number}` | undefined;
31
+ card_number: string;
32
+ pin?: string | undefined;
33
+ tender_status?: import("@open-tender/types").TenderStatus | undefined;
34
+ tender_type: import("@open-tender/types").TenderType;
35
+ } | {
36
+ amount: string;
37
+ approved_contact?: boolean | undefined;
38
+ domain?: string | null | undefined;
39
+ house_account_id: number;
40
+ name: string;
41
+ order_type?: import("@open-tender/types").OrderType | null | undefined;
42
+ pin?: string | undefined;
43
+ revenue_centers?: number[] | undefined;
44
+ service_type?: import("@open-tender/types").ServiceType | null | undefined;
45
+ tender_status?: import("@open-tender/types").TenderStatus | undefined;
46
+ tender_type?: import("@open-tender/types").TenderType | undefined;
47
+ } | {
48
+ amount: string;
49
+ tender_status?: import("@open-tender/types").TenderStatus | undefined;
50
+ tender_type: import("@open-tender/types").TenderType;
51
+ token: any;
52
+ })[] | null;
53
+ export declare const makeCreditCardName: (creditCard: CreditCard) => string;
54
+ export declare const makeTenderName: (tender: OrderTender) => string;
55
+ export declare const makeCheckoutTenderName: (tender: CheckoutTender) => string | undefined;
@@ -1,125 +1,125 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeCheckoutTenderName = exports.makeTenderName = exports.makeCreditCardName = exports.updateTenders = exports.adjustTenders = void 0;
4
- const types_1 = require("@open-tender/types");
5
- const cart_1 = require("./cart");
6
- const adjustTenders = (tenders, isPaid, amountRemaining, updateForm) => {
7
- if (!tenders.length || isPaid)
8
- return;
9
- const gift = tenders.filter(i => i.tender_type === 'GIFT_CARD');
10
- const nonGift = tenders.filter(i => i.tender_type !== 'GIFT_CARD');
11
- if (amountRemaining > 0) {
12
- if (!nonGift.length)
13
- return;
14
- const newTenders = nonGift.map(i => {
15
- const newAmount = parseFloat(i.amount) + amountRemaining;
16
- amountRemaining = 0.0;
17
- return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
18
- });
19
- updateForm({ tenders: [...gift, ...newTenders] });
20
- isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
21
- }
22
- else {
23
- const newTenders = nonGift.map(i => {
24
- const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
25
- amountRemaining += parseFloat(i.amount) - newAmount;
26
- return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
27
- });
28
- isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
29
- if (isPaid) {
30
- const nonZero = newTenders.filter(i => i.amount !== '0.00');
31
- updateForm({ tenders: [...gift, ...nonZero] });
32
- }
33
- else {
34
- const newGift = gift.map(i => {
35
- const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
36
- amountRemaining += parseFloat(i.amount) - newAmount;
37
- return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
38
- });
39
- const allNew = [...newGift, ...newTenders].filter(i => i.amount !== '0.00');
40
- updateForm({ tenders: allNew });
41
- isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
42
- }
43
- }
44
- };
45
- exports.adjustTenders = adjustTenders;
46
- const updateTenders = (tenders, total) => {
47
- if (!total || !tenders || !tenders.length)
48
- return null;
49
- let amountRemaining = (0, cart_1.checkAmountRemaining)(total, tenders);
50
- if (amountRemaining === 0)
51
- return null;
52
- const gift = tenders.filter(i => i.tender_type === 'GIFT_CARD');
53
- const nonGift = tenders.filter(i => i.tender_type !== 'GIFT_CARD');
54
- if (amountRemaining > 0) {
55
- if (!nonGift.length)
56
- return null;
57
- const newTenders = nonGift.map(i => {
58
- const newAmount = parseFloat(i.amount) + amountRemaining;
59
- amountRemaining = 0.0;
60
- return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
61
- });
62
- return [...gift, ...newTenders];
63
- }
64
- else {
65
- const newTenders = nonGift.map(i => {
66
- const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
67
- amountRemaining += parseFloat(i.amount) - newAmount;
68
- return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
69
- });
70
- const isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
71
- if (isPaid) {
72
- const nonZero = newTenders.filter(i => i.amount !== '0.00');
73
- return [...gift, ...nonZero];
74
- }
75
- else {
76
- const newGift = gift.map(i => {
77
- const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
78
- amountRemaining += parseFloat(i.amount) - newAmount;
79
- return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
80
- });
81
- return [...newGift, ...newTenders].filter(i => i.amount !== '0.00');
82
- }
83
- }
84
- };
85
- exports.updateTenders = updateTenders;
86
- const makeCreditCardName = (creditCard) => {
87
- const { card_type_name, last4 } = creditCard;
88
- return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
89
- };
90
- exports.makeCreditCardName = makeCreditCardName;
91
- const makeTenderName = (tender) => {
92
- if ((0, types_1.isCreditTender)(tender)) {
93
- return (0, exports.makeCreditCardName)(tender.credit_card);
94
- }
95
- else if ((0, types_1.isGiftCardTender)(tender)) {
96
- return `Gift Card ${tender.card_number}`;
97
- }
98
- else if ((0, types_1.isHouseAccountTender)(tender)) {
99
- return `${tender.house_account.name} House Account`;
100
- }
101
- else {
102
- return '';
103
- }
104
- };
105
- exports.makeTenderName = makeTenderName;
106
- const makeCheckoutTenderName = (tender) => {
107
- if ((0, types_1.isCreditCustomerCheckoutTender)(tender)) {
108
- const { card_type_name, last4 } = tender;
109
- return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
110
- }
111
- else if ((0, types_1.isCreditGuestCheckoutTender)(tender)) {
112
- const { card_type_name, last4 } = tender;
113
- return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
114
- }
115
- else if ((0, types_1.isGiftCardCheckoutTender)(tender)) {
116
- return `Gift Card ${tender.card_number}`;
117
- }
118
- else if ((0, types_1.isHouseAccountCheckoutTender)(tender)) {
119
- return `${tender.name} House Account`;
120
- }
121
- else {
122
- return '';
123
- }
124
- };
125
- exports.makeCheckoutTenderName = makeCheckoutTenderName;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeCheckoutTenderName = exports.makeTenderName = exports.makeCreditCardName = exports.updateTenders = exports.adjustTenders = void 0;
4
+ const types_1 = require("@open-tender/types");
5
+ const cart_1 = require("./cart");
6
+ const adjustTenders = (tenders, isPaid, amountRemaining, updateForm) => {
7
+ if (!tenders.length || isPaid)
8
+ return;
9
+ const gift = tenders.filter(i => i.tender_type === 'GIFT_CARD');
10
+ const nonGift = tenders.filter(i => i.tender_type !== 'GIFT_CARD');
11
+ if (amountRemaining > 0) {
12
+ if (!nonGift.length)
13
+ return;
14
+ const newTenders = nonGift.map(i => {
15
+ const newAmount = parseFloat(i.amount) + amountRemaining;
16
+ amountRemaining = 0.0;
17
+ return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
18
+ });
19
+ updateForm({ tenders: [...gift, ...newTenders] });
20
+ isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
21
+ }
22
+ else {
23
+ const newTenders = nonGift.map(i => {
24
+ const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
25
+ amountRemaining += parseFloat(i.amount) - newAmount;
26
+ return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
27
+ });
28
+ isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
29
+ if (isPaid) {
30
+ const nonZero = newTenders.filter(i => i.amount !== '0.00');
31
+ updateForm({ tenders: [...gift, ...nonZero] });
32
+ }
33
+ else {
34
+ const newGift = gift.map(i => {
35
+ const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
36
+ amountRemaining += parseFloat(i.amount) - newAmount;
37
+ return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
38
+ });
39
+ const allNew = [...newGift, ...newTenders].filter(i => i.amount !== '0.00');
40
+ updateForm({ tenders: allNew });
41
+ isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
42
+ }
43
+ }
44
+ };
45
+ exports.adjustTenders = adjustTenders;
46
+ const updateTenders = (tenders, total) => {
47
+ if (!total || !tenders || !tenders.length)
48
+ return null;
49
+ let amountRemaining = (0, cart_1.checkAmountRemaining)(total, tenders);
50
+ if (amountRemaining === 0)
51
+ return null;
52
+ const gift = tenders.filter(i => i.tender_type === 'GIFT_CARD');
53
+ const nonGift = tenders.filter(i => i.tender_type !== 'GIFT_CARD');
54
+ if (amountRemaining > 0) {
55
+ if (!nonGift.length)
56
+ return null;
57
+ const newTenders = nonGift.map(i => {
58
+ const newAmount = parseFloat(i.amount) + amountRemaining;
59
+ amountRemaining = 0.0;
60
+ return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
61
+ });
62
+ return [...gift, ...newTenders];
63
+ }
64
+ else {
65
+ const newTenders = nonGift.map(i => {
66
+ const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
67
+ amountRemaining += parseFloat(i.amount) - newAmount;
68
+ return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
69
+ });
70
+ const isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
71
+ if (isPaid) {
72
+ const nonZero = newTenders.filter(i => i.amount !== '0.00');
73
+ return [...gift, ...nonZero];
74
+ }
75
+ else {
76
+ const newGift = gift.map(i => {
77
+ const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
78
+ amountRemaining += parseFloat(i.amount) - newAmount;
79
+ return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
80
+ });
81
+ return [...newGift, ...newTenders].filter(i => i.amount !== '0.00');
82
+ }
83
+ }
84
+ };
85
+ exports.updateTenders = updateTenders;
86
+ const makeCreditCardName = (creditCard) => {
87
+ const { card_type_name, last4 } = creditCard;
88
+ return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
89
+ };
90
+ exports.makeCreditCardName = makeCreditCardName;
91
+ const makeTenderName = (tender) => {
92
+ if ((0, types_1.isCreditTender)(tender)) {
93
+ return (0, exports.makeCreditCardName)(tender.credit_card);
94
+ }
95
+ else if ((0, types_1.isGiftCardTender)(tender)) {
96
+ return `Gift Card ${tender.card_number}`;
97
+ }
98
+ else if ((0, types_1.isHouseAccountTender)(tender)) {
99
+ return `${tender.house_account.name} House Account`;
100
+ }
101
+ else {
102
+ return '';
103
+ }
104
+ };
105
+ exports.makeTenderName = makeTenderName;
106
+ const makeCheckoutTenderName = (tender) => {
107
+ if ((0, types_1.isCreditCustomerCheckoutTender)(tender)) {
108
+ const { card_type_name, last4 } = tender;
109
+ return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
110
+ }
111
+ else if ((0, types_1.isCreditGuestCheckoutTender)(tender)) {
112
+ const { card_type_name, last4 } = tender;
113
+ return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
114
+ }
115
+ else if ((0, types_1.isGiftCardCheckoutTender)(tender)) {
116
+ return `Gift Card ${tender.card_number}`;
117
+ }
118
+ else if ((0, types_1.isHouseAccountCheckoutTender)(tender)) {
119
+ return `${tender.name} House Account`;
120
+ }
121
+ else {
122
+ return '';
123
+ }
124
+ };
125
+ exports.makeCheckoutTenderName = makeCheckoutTenderName;
@@ -1,43 +1,43 @@
1
- import { ServiceType, TenderType } from '@open-tender/types';
2
- export declare const serviceTypeNamesMap: {
3
- [keys in ServiceType]?: string;
4
- };
5
- export declare const otherServiceTypeNamesMap: {
6
- WALKIN: string;
7
- PICKUP: string;
8
- DELIVERY: string;
9
- };
10
- export declare const orderTypeNamesMap: {
11
- OLO: string;
12
- CATERING: string;
13
- MERCH: string;
14
- };
15
- export declare const otherOrderTypesMap: {
16
- WALKIN: string[];
17
- PICKUP: string[];
18
- DELIVERY: string[];
19
- CATERING: string[];
20
- MERCH: string[];
21
- };
22
- export declare const tenderTypeNamesMap: Record<TenderType, string>;
23
- export declare const loyaltyType: {
24
- CREDIT: string;
25
- PROMO_CODE: string;
26
- POINTS: string;
27
- };
28
- export declare const MAX_DISTANCE = 3000;
29
- export declare const prepStatus: {
30
- TODO: string;
31
- IN_PROGRESS: string;
32
- DONE: string;
33
- COMPLETED: string;
34
- FULFILLED: string;
35
- };
36
- export declare const optionsOrderNotifications: {
37
- name: string;
38
- value: string;
39
- }[];
40
- export declare const optionsOrderNotificationsTemp: {
41
- name: string;
42
- value: string;
43
- }[];
1
+ import { ServiceType, TenderType } from '@open-tender/types';
2
+ export declare const serviceTypeNamesMap: {
3
+ [keys in ServiceType]?: string;
4
+ };
5
+ export declare const otherServiceTypeNamesMap: {
6
+ WALKIN: string;
7
+ PICKUP: string;
8
+ DELIVERY: string;
9
+ };
10
+ export declare const orderTypeNamesMap: {
11
+ OLO: string;
12
+ CATERING: string;
13
+ MERCH: string;
14
+ };
15
+ export declare const otherOrderTypesMap: {
16
+ WALKIN: string[];
17
+ PICKUP: string[];
18
+ DELIVERY: string[];
19
+ CATERING: string[];
20
+ MERCH: string[];
21
+ };
22
+ export declare const tenderTypeNamesMap: Record<TenderType, string>;
23
+ export declare const loyaltyType: {
24
+ CREDIT: string;
25
+ PROMO_CODE: string;
26
+ POINTS: string;
27
+ };
28
+ export declare const MAX_DISTANCE = 3000;
29
+ export declare const prepStatus: {
30
+ TODO: string;
31
+ IN_PROGRESS: string;
32
+ DONE: string;
33
+ COMPLETED: string;
34
+ FULFILLED: string;
35
+ };
36
+ export declare const optionsOrderNotifications: {
37
+ name: string;
38
+ value: string;
39
+ }[];
40
+ export declare const optionsOrderNotificationsTemp: {
41
+ name: string;
42
+ value: string;
43
+ }[];
@@ -1,58 +1,58 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optionsOrderNotificationsTemp = exports.optionsOrderNotifications = exports.prepStatus = exports.MAX_DISTANCE = exports.loyaltyType = exports.tenderTypeNamesMap = exports.otherOrderTypesMap = exports.orderTypeNamesMap = exports.otherServiceTypeNamesMap = exports.serviceTypeNamesMap = void 0;
4
- exports.serviceTypeNamesMap = {
5
- WALKIN: 'Dine-In',
6
- PICKUP: 'Pickup',
7
- DELIVERY: 'Delivery'
8
- };
9
- exports.otherServiceTypeNamesMap = {
10
- WALKIN: 'Delivery',
11
- PICKUP: 'Delivery',
12
- DELIVERY: 'Pickup'
13
- };
14
- exports.orderTypeNamesMap = {
15
- OLO: 'Regular',
16
- CATERING: 'Catering',
17
- MERCH: 'Merch'
18
- };
19
- exports.otherOrderTypesMap = {
20
- WALKIN: ['Delivery', 'Catering'],
21
- PICKUP: ['Delivery', 'Catering'],
22
- DELIVERY: ['Pickup', 'Catering'],
23
- CATERING: ['Pickup', 'Delivery'],
24
- MERCH: ['Pickup', 'Delivery']
25
- };
26
- exports.tenderTypeNamesMap = {
27
- CASH: 'Cash',
28
- CREDIT: 'Credit',
29
- LEVELUP: 'LevelUp',
30
- HOUSE_ACCOUNT: 'House Account',
31
- GIFT_CARD: 'Gift Card',
32
- COMP: 'Comp',
33
- APPLE_PAY: 'Apple Pay',
34
- GOOGLE_PAY: 'Google Pay'
35
- };
36
- exports.loyaltyType = {
37
- CREDIT: 'CREDIT',
38
- PROMO_CODE: 'PROMO_CODE',
39
- POINTS: 'POINTS'
40
- };
41
- exports.MAX_DISTANCE = 3000;
42
- exports.prepStatus = {
43
- TODO: 'TODO',
44
- IN_PROGRESS: 'IN_PROGRESS',
45
- DONE: 'DONE',
46
- COMPLETED: 'COMPLETED',
47
- FULFILLED: 'FULFILLED'
48
- };
49
- exports.optionsOrderNotifications = [
50
- { name: 'Email Only', value: 'EMAIL' },
51
- { name: 'SMS Only', value: 'SMS' },
52
- { name: 'Both Email & SMS', value: 'ALL' },
53
- { name: 'Neither', value: 'NONE' }
54
- ];
55
- exports.optionsOrderNotificationsTemp = [
56
- { name: 'Email', value: 'EMAIL' },
57
- { name: 'None', value: 'NONE' }
58
- ];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.optionsOrderNotificationsTemp = exports.optionsOrderNotifications = exports.prepStatus = exports.MAX_DISTANCE = exports.loyaltyType = exports.tenderTypeNamesMap = exports.otherOrderTypesMap = exports.orderTypeNamesMap = exports.otherServiceTypeNamesMap = exports.serviceTypeNamesMap = void 0;
4
+ exports.serviceTypeNamesMap = {
5
+ WALKIN: 'Dine-In',
6
+ PICKUP: 'Pickup',
7
+ DELIVERY: 'Delivery'
8
+ };
9
+ exports.otherServiceTypeNamesMap = {
10
+ WALKIN: 'Delivery',
11
+ PICKUP: 'Delivery',
12
+ DELIVERY: 'Pickup'
13
+ };
14
+ exports.orderTypeNamesMap = {
15
+ OLO: 'Regular',
16
+ CATERING: 'Catering',
17
+ MERCH: 'Merch'
18
+ };
19
+ exports.otherOrderTypesMap = {
20
+ WALKIN: ['Delivery', 'Catering'],
21
+ PICKUP: ['Delivery', 'Catering'],
22
+ DELIVERY: ['Pickup', 'Catering'],
23
+ CATERING: ['Pickup', 'Delivery'],
24
+ MERCH: ['Pickup', 'Delivery']
25
+ };
26
+ exports.tenderTypeNamesMap = {
27
+ CASH: 'Cash',
28
+ CREDIT: 'Credit',
29
+ LEVELUP: 'LevelUp',
30
+ HOUSE_ACCOUNT: 'House Account',
31
+ GIFT_CARD: 'Gift Card',
32
+ COMP: 'Comp',
33
+ APPLE_PAY: 'Apple Pay',
34
+ GOOGLE_PAY: 'Google Pay'
35
+ };
36
+ exports.loyaltyType = {
37
+ CREDIT: 'CREDIT',
38
+ PROMO_CODE: 'PROMO_CODE',
39
+ POINTS: 'POINTS'
40
+ };
41
+ exports.MAX_DISTANCE = 3000;
42
+ exports.prepStatus = {
43
+ TODO: 'TODO',
44
+ IN_PROGRESS: 'IN_PROGRESS',
45
+ DONE: 'DONE',
46
+ COMPLETED: 'COMPLETED',
47
+ FULFILLED: 'FULFILLED'
48
+ };
49
+ exports.optionsOrderNotifications = [
50
+ { name: 'Email Only', value: 'EMAIL' },
51
+ { name: 'SMS Only', value: 'SMS' },
52
+ { name: 'Both Email & SMS', value: 'ALL' },
53
+ { name: 'Neither', value: 'NONE' }
54
+ ];
55
+ exports.optionsOrderNotificationsTemp = [
56
+ { name: 'Email', value: 'EMAIL' },
57
+ { name: 'None', value: 'NONE' }
58
+ ];
@@ -1,4 +1,4 @@
1
- import { Customer, Order, Orders } from '@open-tender/types';
2
- export declare const profileFields: string[];
3
- export declare const makeCustomerProfile: (customer: Partial<Customer>) => Partial<Customer>;
4
- export declare const getLastOrder: (orders: Orders) => Order | null;
1
+ import { Customer, Order, Orders } from '@open-tender/types';
2
+ export declare const profileFields: string[];
3
+ export declare const makeCustomerProfile: (customer: Partial<Customer>) => Partial<Customer>;
4
+ export declare const getLastOrder: (orders: Orders) => Order | null;
@@ -1,34 +1,34 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLastOrder = exports.makeCustomerProfile = exports.profileFields = void 0;
4
- const date_fns_1 = require("date-fns");
5
- const helpers_1 = require("./helpers");
6
- exports.profileFields = [
7
- 'customer_id',
8
- 'first_name',
9
- 'last_name',
10
- 'email',
11
- 'phone',
12
- 'company',
13
- 'birth_date',
14
- 'gender',
15
- 'is_verified',
16
- 'is_notification_set'
17
- ];
18
- const makeCustomerProfile = (customer) => {
19
- return exports.profileFields.reduce((obj, field) => (Object.assign(Object.assign({}, obj), { [field]: field === 'birth_date'
20
- ? (0, helpers_1.dashesToSlashes)(customer[field])
21
- : customer[field] })), {});
22
- };
23
- exports.makeCustomerProfile = makeCustomerProfile;
24
- const getLastOrder = (orders) => {
25
- if (!orders || !orders.length)
26
- return null;
27
- const withCreated = orders
28
- .filter(i => i.order_type !== 'MERCH')
29
- .map(i => (Object.assign(Object.assign({}, i), { createdAt: (0, date_fns_1.parseISO)(i.created_at) })))
30
- .sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime())
31
- .reverse();
32
- return withCreated[0];
33
- };
34
- exports.getLastOrder = getLastOrder;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLastOrder = exports.makeCustomerProfile = exports.profileFields = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ const helpers_1 = require("./helpers");
6
+ exports.profileFields = [
7
+ 'customer_id',
8
+ 'first_name',
9
+ 'last_name',
10
+ 'email',
11
+ 'phone',
12
+ 'company',
13
+ 'birth_date',
14
+ 'gender',
15
+ 'is_verified',
16
+ 'is_notification_set'
17
+ ];
18
+ const makeCustomerProfile = (customer) => {
19
+ return exports.profileFields.reduce((obj, field) => (Object.assign(Object.assign({}, obj), { [field]: field === 'birth_date'
20
+ ? (0, helpers_1.dashesToSlashes)(customer[field])
21
+ : customer[field] })), {});
22
+ };
23
+ exports.makeCustomerProfile = makeCustomerProfile;
24
+ const getLastOrder = (orders) => {
25
+ if (!orders || !orders.length)
26
+ return null;
27
+ const withCreated = orders
28
+ .filter(i => i.order_type !== 'MERCH')
29
+ .map(i => (Object.assign(Object.assign({}, i), { createdAt: (0, date_fns_1.parseISO)(i.created_at) })))
30
+ .sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime())
31
+ .reverse();
32
+ return withCreated[0];
33
+ };
34
+ exports.getLastOrder = getLastOrder;