@open-tender/utils 0.4.35 → 0.4.37
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/LICENSE.md +21 -21
- package/README.md +2 -2
- package/dist/cjs/__tests__/utils/helpers.test.d.ts +1 -1
- package/dist/cjs/__tests__/utils/helpers.test.js +96 -96
- package/dist/cjs/__tests__/utils/theme.test.d.ts +1 -1
- package/dist/cjs/__tests__/utils/theme.test.js +37 -37
- package/dist/cjs/hooks/index.d.ts +35 -35
- package/dist/cjs/hooks/index.js +38 -38
- package/dist/cjs/hooks/types.d.ts +4 -4
- package/dist/cjs/hooks/types.js +2 -2
- package/dist/cjs/hooks/useAccordion.d.ts +22 -22
- package/dist/cjs/hooks/useAccordion.js +56 -56
- package/dist/cjs/hooks/useAddressForm.d.ts +12 -12
- package/dist/cjs/hooks/useAddressForm.js +83 -83
- package/dist/cjs/hooks/useAllergenForm.d.ts +10 -10
- package/dist/cjs/hooks/useAllergenForm.js +58 -58
- package/dist/cjs/hooks/useBuilder.d.ts +14 -14
- package/dist/cjs/hooks/useBuilder.js +144 -144
- package/dist/cjs/hooks/useCartGuestForm.d.ts +12 -12
- package/dist/cjs/hooks/useCartGuestForm.js +58 -58
- package/dist/cjs/hooks/useCartPoints.d.ts +13 -13
- package/dist/cjs/hooks/useCartPoints.js +74 -74
- package/dist/cjs/hooks/useCommunicationPreferences.js +1 -1
- package/dist/cjs/hooks/useCreditCard.d.ts +13 -13
- package/dist/cjs/hooks/useCreditCard.js +63 -63
- package/dist/cjs/hooks/useCreditCardForm.d.ts +10 -10
- package/dist/cjs/hooks/useCreditCardForm.js +71 -71
- package/dist/cjs/hooks/useCurbside.d.ts +9 -9
- package/dist/cjs/hooks/useCurbside.js +39 -39
- package/dist/cjs/hooks/useDineInForm.d.ts +11 -11
- package/dist/cjs/hooks/useDineInForm.js +56 -56
- package/dist/cjs/hooks/useDonationForm.d.ts +28 -28
- package/dist/cjs/hooks/useDonationForm.js +172 -172
- package/dist/cjs/hooks/useFirstTimes.d.ts +18 -18
- package/dist/cjs/hooks/useFirstTimes.js +81 -81
- package/dist/cjs/hooks/useGiftCardAssignForm.d.ts +14 -14
- package/dist/cjs/hooks/useGiftCardAssignForm.js +57 -57
- package/dist/cjs/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
- package/dist/cjs/hooks/useGiftCardAssignOtherForm.js +50 -50
- package/dist/cjs/hooks/useGiftCardForm.d.ts +12 -12
- package/dist/cjs/hooks/useGiftCardForm.js +74 -74
- package/dist/cjs/hooks/useGiftCardsForm.d.ts +31 -31
- package/dist/cjs/hooks/useGiftCardsForm.js +195 -195
- package/dist/cjs/hooks/useGuestCheckoutForm.d.ts +21 -21
- package/dist/cjs/hooks/useGuestCheckoutForm.js +89 -89
- package/dist/cjs/hooks/useGuestForm.d.ts +12 -12
- package/dist/cjs/hooks/useGuestForm.js +60 -60
- package/dist/cjs/hooks/useImage.d.ts +5 -5
- package/dist/cjs/hooks/useImage.js +33 -33
- package/dist/cjs/hooks/useLoginForm.d.ts +12 -12
- package/dist/cjs/hooks/useLoginForm.js +67 -67
- package/dist/cjs/hooks/useMenuItem.d.ts +57 -57
- package/dist/cjs/hooks/useMenuItem.js +67 -67
- package/dist/cjs/hooks/useModifier.d.ts +53 -53
- package/dist/cjs/hooks/useModifier.js +72 -72
- package/dist/cjs/hooks/useModifierGroup.d.ts +15 -15
- package/dist/cjs/hooks/useModifierGroup.js +17 -17
- package/dist/cjs/hooks/useOneTimePasscodeForm.d.ts +16 -16
- package/dist/cjs/hooks/useOneTimePasscodeForm.js +87 -87
- package/dist/cjs/hooks/useOrderFulfillmentForm.d.ts +11 -11
- package/dist/cjs/hooks/useOrderFulfillmentForm.js +65 -65
- package/dist/cjs/hooks/useOrderItem.d.ts +48 -48
- package/dist/cjs/hooks/useOrderItem.js +54 -54
- package/dist/cjs/hooks/useOrderRating.d.ts +10 -10
- package/dist/cjs/hooks/useOrderRating.js +34 -34
- package/dist/cjs/hooks/useOrderRatingForm.d.ts +11 -11
- package/dist/cjs/hooks/useOrderRatingForm.js +35 -35
- package/dist/cjs/hooks/useProfileForm.d.ts +15 -15
- package/dist/cjs/hooks/useProfileForm.js +116 -116
- package/dist/cjs/hooks/useResetPasswordForm.d.ts +12 -12
- package/dist/cjs/hooks/useResetPasswordForm.js +77 -77
- package/dist/cjs/hooks/useSendResetForm.d.ts +14 -14
- package/dist/cjs/hooks/useSendResetForm.js +57 -57
- package/dist/cjs/hooks/useSignUpForm.d.ts +20 -20
- package/dist/cjs/hooks/useSignUpForm.js +157 -157
- package/dist/cjs/hooks/useSignUpGuestForm.d.ts +23 -23
- package/dist/cjs/hooks/useSignUpGuestForm.js +124 -124
- package/dist/cjs/hooks/useSigninForm.d.ts +12 -12
- package/dist/cjs/hooks/useSigninForm.js +66 -66
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/utils/cards.d.ts +20 -20
- package/dist/cjs/utils/cards.js +155 -155
- package/dist/cjs/utils/cart.d.ts +202 -202
- package/dist/cjs/utils/cart.js +909 -909
- package/dist/cjs/utils/checkout.d.ts +55 -55
- package/dist/cjs/utils/checkout.js +125 -125
- package/dist/cjs/utils/constants.d.ts +43 -43
- package/dist/cjs/utils/constants.js +58 -58
- package/dist/cjs/utils/customer.d.ts +4 -4
- package/dist/cjs/utils/customer.js +34 -34
- package/dist/cjs/utils/datetimes.d.ts +99 -99
- package/dist/cjs/utils/datetimes.js +601 -601
- package/dist/cjs/utils/errors.d.ts +51 -51
- package/dist/cjs/utils/errors.js +191 -191
- package/dist/cjs/utils/favorites.d.ts +10 -10
- package/dist/cjs/utils/favorites.js +119 -119
- package/dist/cjs/utils/googleMaps.d.ts +14 -14
- package/dist/cjs/utils/googleMaps.js +30 -30
- package/dist/cjs/utils/helpers.d.ts +63 -63
- package/dist/cjs/utils/helpers.js +244 -244
- package/dist/cjs/utils/index.d.ts +19 -19
- package/dist/cjs/utils/index.js +23 -23
- package/dist/cjs/utils/keypad.d.ts +9 -9
- package/dist/cjs/utils/keypad.js +105 -105
- package/dist/cjs/utils/maps.d.ts +226 -226
- package/dist/cjs/utils/maps.js +334 -334
- package/dist/cjs/utils/menu.d.ts +117 -117
- package/dist/cjs/utils/menu.js +82 -82
- package/dist/cjs/utils/orders.d.ts +21 -21
- package/dist/cjs/utils/orders.js +202 -202
- package/dist/cjs/utils/pizzaBuilder.d.ts +10 -10
- package/dist/cjs/utils/pizzaBuilder.js +43 -43
- package/dist/cjs/utils/refunds.d.ts +35 -35
- package/dist/cjs/utils/refunds.js +98 -98
- package/dist/cjs/utils/revenueCenters.d.ts +11 -11
- package/dist/cjs/utils/revenueCenters.js +125 -125
- package/dist/cjs/utils/rewards.d.ts +4 -4
- package/dist/cjs/utils/rewards.js +100 -100
- package/dist/cjs/utils/theme.d.ts +27 -27
- package/dist/cjs/utils/theme.js +266 -266
- package/dist/cjs/utils/version.d.ts +4 -4
- package/dist/cjs/utils/version.js +38 -38
- package/dist/esm/__tests__/utils/helpers.test.d.ts +1 -1
- package/dist/esm/__tests__/utils/helpers.test.js +94 -94
- package/dist/esm/__tests__/utils/theme.test.d.ts +1 -1
- package/dist/esm/__tests__/utils/theme.test.js +35 -35
- package/dist/esm/hooks/index.d.ts +35 -35
- package/dist/esm/hooks/index.js +35 -35
- package/dist/esm/hooks/types.d.ts +4 -4
- package/dist/esm/hooks/types.js +1 -1
- package/dist/esm/hooks/useAccordion.d.ts +22 -22
- package/dist/esm/hooks/useAccordion.js +52 -52
- package/dist/esm/hooks/useAddressForm.d.ts +12 -12
- package/dist/esm/hooks/useAddressForm.js +79 -79
- package/dist/esm/hooks/useAllergenForm.d.ts +10 -10
- package/dist/esm/hooks/useAllergenForm.js +54 -54
- package/dist/esm/hooks/useBuilder.d.ts +14 -14
- package/dist/esm/hooks/useBuilder.js +140 -140
- package/dist/esm/hooks/useCartGuestForm.d.ts +12 -12
- package/dist/esm/hooks/useCartGuestForm.js +54 -54
- package/dist/esm/hooks/useCartPoints.d.ts +13 -13
- package/dist/esm/hooks/useCartPoints.js +70 -70
- package/dist/esm/hooks/useCommunicationPreferences.js +1 -1
- package/dist/esm/hooks/useCreditCard.d.ts +13 -13
- package/dist/esm/hooks/useCreditCard.js +59 -59
- package/dist/esm/hooks/useCreditCardForm.d.ts +10 -10
- package/dist/esm/hooks/useCreditCardForm.js +67 -67
- package/dist/esm/hooks/useCurbside.d.ts +9 -9
- package/dist/esm/hooks/useCurbside.js +35 -35
- package/dist/esm/hooks/useDineInForm.d.ts +11 -11
- package/dist/esm/hooks/useDineInForm.js +52 -52
- package/dist/esm/hooks/useDonationForm.d.ts +28 -28
- package/dist/esm/hooks/useDonationForm.js +168 -168
- package/dist/esm/hooks/useFirstTimes.d.ts +18 -18
- package/dist/esm/hooks/useFirstTimes.js +77 -77
- package/dist/esm/hooks/useGiftCardAssignForm.d.ts +14 -14
- package/dist/esm/hooks/useGiftCardAssignForm.js +53 -53
- package/dist/esm/hooks/useGiftCardAssignOtherForm.d.ts +14 -14
- package/dist/esm/hooks/useGiftCardAssignOtherForm.js +46 -46
- package/dist/esm/hooks/useGiftCardForm.d.ts +12 -12
- package/dist/esm/hooks/useGiftCardForm.js +70 -70
- package/dist/esm/hooks/useGiftCardsForm.d.ts +31 -31
- package/dist/esm/hooks/useGiftCardsForm.js +191 -191
- package/dist/esm/hooks/useGuestCheckoutForm.d.ts +21 -21
- package/dist/esm/hooks/useGuestCheckoutForm.js +85 -85
- package/dist/esm/hooks/useGuestForm.d.ts +12 -12
- package/dist/esm/hooks/useGuestForm.js +56 -56
- package/dist/esm/hooks/useImage.d.ts +5 -5
- package/dist/esm/hooks/useImage.js +29 -29
- package/dist/esm/hooks/useLoginForm.d.ts +12 -12
- package/dist/esm/hooks/useLoginForm.js +63 -63
- package/dist/esm/hooks/useMenuItem.d.ts +57 -57
- package/dist/esm/hooks/useMenuItem.js +63 -63
- package/dist/esm/hooks/useModifier.d.ts +53 -53
- package/dist/esm/hooks/useModifier.js +68 -68
- package/dist/esm/hooks/useModifierGroup.d.ts +15 -15
- package/dist/esm/hooks/useModifierGroup.js +13 -13
- package/dist/esm/hooks/useOneTimePasscodeForm.d.ts +16 -16
- package/dist/esm/hooks/useOneTimePasscodeForm.js +83 -83
- package/dist/esm/hooks/useOrderFulfillmentForm.d.ts +11 -11
- package/dist/esm/hooks/useOrderFulfillmentForm.js +61 -61
- package/dist/esm/hooks/useOrderItem.d.ts +48 -48
- package/dist/esm/hooks/useOrderItem.js +50 -50
- package/dist/esm/hooks/useOrderRating.d.ts +10 -10
- package/dist/esm/hooks/useOrderRating.js +30 -30
- package/dist/esm/hooks/useOrderRatingForm.d.ts +11 -11
- package/dist/esm/hooks/useOrderRatingForm.js +31 -31
- package/dist/esm/hooks/useProfileForm.d.ts +15 -15
- package/dist/esm/hooks/useProfileForm.js +112 -112
- package/dist/esm/hooks/useResetPasswordForm.d.ts +12 -12
- package/dist/esm/hooks/useResetPasswordForm.js +73 -73
- package/dist/esm/hooks/useSendResetForm.d.ts +14 -14
- package/dist/esm/hooks/useSendResetForm.js +53 -53
- package/dist/esm/hooks/useSignUpForm.d.ts +20 -20
- package/dist/esm/hooks/useSignUpForm.js +153 -153
- package/dist/esm/hooks/useSignUpGuestForm.d.ts +23 -23
- package/dist/esm/hooks/useSignUpGuestForm.js +120 -120
- package/dist/esm/hooks/useSigninForm.d.ts +12 -12
- package/dist/esm/hooks/useSigninForm.js +62 -62
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/cards.d.ts +20 -20
- package/dist/esm/utils/cards.js +146 -146
- package/dist/esm/utils/cart.d.ts +202 -202
- package/dist/esm/utils/cart.js +868 -868
- package/dist/esm/utils/checkout.d.ts +55 -55
- package/dist/esm/utils/checkout.js +117 -117
- package/dist/esm/utils/constants.d.ts +43 -43
- package/dist/esm/utils/constants.js +55 -55
- package/dist/esm/utils/customer.d.ts +4 -4
- package/dist/esm/utils/customer.js +29 -29
- package/dist/esm/utils/datetimes.d.ts +99 -99
- package/dist/esm/utils/datetimes.js +531 -531
- package/dist/esm/utils/errors.d.ts +51 -51
- package/dist/esm/utils/errors.js +180 -180
- package/dist/esm/utils/favorites.d.ts +10 -10
- package/dist/esm/utils/favorites.js +109 -109
- package/dist/esm/utils/googleMaps.d.ts +14 -14
- package/dist/esm/utils/googleMaps.js +26 -26
- package/dist/esm/utils/helpers.d.ts +63 -63
- package/dist/esm/utils/helpers.js +205 -205
- package/dist/esm/utils/index.d.ts +19 -19
- package/dist/esm/utils/index.js +20 -20
- package/dist/esm/utils/keypad.d.ts +9 -9
- package/dist/esm/utils/keypad.js +97 -97
- package/dist/esm/utils/maps.d.ts +226 -226
- package/dist/esm/utils/maps.js +316 -316
- package/dist/esm/utils/menu.d.ts +117 -117
- package/dist/esm/utils/menu.js +74 -74
- package/dist/esm/utils/orders.d.ts +21 -21
- package/dist/esm/utils/orders.js +185 -185
- package/dist/esm/utils/pizzaBuilder.d.ts +10 -10
- package/dist/esm/utils/pizzaBuilder.js +38 -38
- package/dist/esm/utils/refunds.d.ts +35 -35
- package/dist/esm/utils/refunds.js +90 -90
- package/dist/esm/utils/revenueCenters.d.ts +11 -11
- package/dist/esm/utils/revenueCenters.js +115 -115
- package/dist/esm/utils/rewards.d.ts +4 -4
- package/dist/esm/utils/rewards.js +94 -94
- package/dist/esm/utils/theme.d.ts +27 -27
- package/dist/esm/utils/theme.js +254 -254
- package/dist/esm/utils/version.d.ts +4 -4
- package/dist/esm/utils/version.js +34 -34
- 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,117 +1,117 @@
|
|
|
1
|
-
import { isCreditCustomerCheckoutTender, isCreditGuestCheckoutTender, isCreditTender, isGiftCardCheckoutTender, isGiftCardTender, isHouseAccountCheckoutTender, isHouseAccountTender } from '@open-tender/types';
|
|
2
|
-
import { checkAmountRemaining } from './cart';
|
|
3
|
-
export const adjustTenders = (tenders, isPaid, amountRemaining, updateForm) => {
|
|
4
|
-
if (!tenders.length || isPaid)
|
|
5
|
-
return;
|
|
6
|
-
const gift = tenders.filter(i => i.tender_type === 'GIFT_CARD');
|
|
7
|
-
const nonGift = tenders.filter(i => i.tender_type !== 'GIFT_CARD');
|
|
8
|
-
if (amountRemaining > 0) {
|
|
9
|
-
if (!nonGift.length)
|
|
10
|
-
return;
|
|
11
|
-
const newTenders = nonGift.map(i => {
|
|
12
|
-
const newAmount = parseFloat(i.amount) + amountRemaining;
|
|
13
|
-
amountRemaining = 0.0;
|
|
14
|
-
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
15
|
-
});
|
|
16
|
-
updateForm({ tenders: [...gift, ...newTenders] });
|
|
17
|
-
isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
const newTenders = nonGift.map(i => {
|
|
21
|
-
const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
|
|
22
|
-
amountRemaining += parseFloat(i.amount) - newAmount;
|
|
23
|
-
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
24
|
-
});
|
|
25
|
-
isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
|
|
26
|
-
if (isPaid) {
|
|
27
|
-
const nonZero = newTenders.filter(i => i.amount !== '0.00');
|
|
28
|
-
updateForm({ tenders: [...gift, ...nonZero] });
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const newGift = gift.map(i => {
|
|
32
|
-
const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
|
|
33
|
-
amountRemaining += parseFloat(i.amount) - newAmount;
|
|
34
|
-
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
35
|
-
});
|
|
36
|
-
const allNew = [...newGift, ...newTenders].filter(i => i.amount !== '0.00');
|
|
37
|
-
updateForm({ tenders: allNew });
|
|
38
|
-
isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
export const updateTenders = (tenders, total) => {
|
|
43
|
-
if (!total || !tenders || !tenders.length)
|
|
44
|
-
return null;
|
|
45
|
-
let amountRemaining = checkAmountRemaining(total, tenders);
|
|
46
|
-
if (amountRemaining === 0)
|
|
47
|
-
return null;
|
|
48
|
-
const gift = tenders.filter(i => i.tender_type === 'GIFT_CARD');
|
|
49
|
-
const nonGift = tenders.filter(i => i.tender_type !== 'GIFT_CARD');
|
|
50
|
-
if (amountRemaining > 0) {
|
|
51
|
-
if (!nonGift.length)
|
|
52
|
-
return null;
|
|
53
|
-
const newTenders = nonGift.map(i => {
|
|
54
|
-
const newAmount = parseFloat(i.amount) + amountRemaining;
|
|
55
|
-
amountRemaining = 0.0;
|
|
56
|
-
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
57
|
-
});
|
|
58
|
-
return [...gift, ...newTenders];
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
const newTenders = nonGift.map(i => {
|
|
62
|
-
const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
|
|
63
|
-
amountRemaining += parseFloat(i.amount) - newAmount;
|
|
64
|
-
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
65
|
-
});
|
|
66
|
-
const isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
|
|
67
|
-
if (isPaid) {
|
|
68
|
-
const nonZero = newTenders.filter(i => i.amount !== '0.00');
|
|
69
|
-
return [...gift, ...nonZero];
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
const newGift = gift.map(i => {
|
|
73
|
-
const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
|
|
74
|
-
amountRemaining += parseFloat(i.amount) - newAmount;
|
|
75
|
-
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
76
|
-
});
|
|
77
|
-
return [...newGift, ...newTenders].filter(i => i.amount !== '0.00');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
export const makeCreditCardName = (creditCard) => {
|
|
82
|
-
const { card_type_name, last4 } = creditCard;
|
|
83
|
-
return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
|
|
84
|
-
};
|
|
85
|
-
export const makeTenderName = (tender) => {
|
|
86
|
-
if (isCreditTender(tender)) {
|
|
87
|
-
return makeCreditCardName(tender.credit_card);
|
|
88
|
-
}
|
|
89
|
-
else if (isGiftCardTender(tender)) {
|
|
90
|
-
return `Gift Card ${tender.card_number}`;
|
|
91
|
-
}
|
|
92
|
-
else if (isHouseAccountTender(tender)) {
|
|
93
|
-
return `${tender.house_account.name} House Account`;
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
return '';
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
export const makeCheckoutTenderName = (tender) => {
|
|
100
|
-
if (isCreditCustomerCheckoutTender(tender)) {
|
|
101
|
-
const { card_type_name, last4 } = tender;
|
|
102
|
-
return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
|
|
103
|
-
}
|
|
104
|
-
else if (isCreditGuestCheckoutTender(tender)) {
|
|
105
|
-
const { card_type_name, last4 } = tender;
|
|
106
|
-
return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
|
|
107
|
-
}
|
|
108
|
-
else if (isGiftCardCheckoutTender(tender)) {
|
|
109
|
-
return `Gift Card ${tender.card_number}`;
|
|
110
|
-
}
|
|
111
|
-
else if (isHouseAccountCheckoutTender(tender)) {
|
|
112
|
-
return `${tender.name} House Account`;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
return '';
|
|
116
|
-
}
|
|
117
|
-
};
|
|
1
|
+
import { isCreditCustomerCheckoutTender, isCreditGuestCheckoutTender, isCreditTender, isGiftCardCheckoutTender, isGiftCardTender, isHouseAccountCheckoutTender, isHouseAccountTender } from '@open-tender/types';
|
|
2
|
+
import { checkAmountRemaining } from './cart';
|
|
3
|
+
export const adjustTenders = (tenders, isPaid, amountRemaining, updateForm) => {
|
|
4
|
+
if (!tenders.length || isPaid)
|
|
5
|
+
return;
|
|
6
|
+
const gift = tenders.filter(i => i.tender_type === 'GIFT_CARD');
|
|
7
|
+
const nonGift = tenders.filter(i => i.tender_type !== 'GIFT_CARD');
|
|
8
|
+
if (amountRemaining > 0) {
|
|
9
|
+
if (!nonGift.length)
|
|
10
|
+
return;
|
|
11
|
+
const newTenders = nonGift.map(i => {
|
|
12
|
+
const newAmount = parseFloat(i.amount) + amountRemaining;
|
|
13
|
+
amountRemaining = 0.0;
|
|
14
|
+
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
15
|
+
});
|
|
16
|
+
updateForm({ tenders: [...gift, ...newTenders] });
|
|
17
|
+
isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const newTenders = nonGift.map(i => {
|
|
21
|
+
const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
|
|
22
|
+
amountRemaining += parseFloat(i.amount) - newAmount;
|
|
23
|
+
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
24
|
+
});
|
|
25
|
+
isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
|
|
26
|
+
if (isPaid) {
|
|
27
|
+
const nonZero = newTenders.filter(i => i.amount !== '0.00');
|
|
28
|
+
updateForm({ tenders: [...gift, ...nonZero] });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const newGift = gift.map(i => {
|
|
32
|
+
const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
|
|
33
|
+
amountRemaining += parseFloat(i.amount) - newAmount;
|
|
34
|
+
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
35
|
+
});
|
|
36
|
+
const allNew = [...newGift, ...newTenders].filter(i => i.amount !== '0.00');
|
|
37
|
+
updateForm({ tenders: allNew });
|
|
38
|
+
isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
export const updateTenders = (tenders, total) => {
|
|
43
|
+
if (!total || !tenders || !tenders.length)
|
|
44
|
+
return null;
|
|
45
|
+
let amountRemaining = checkAmountRemaining(total, tenders);
|
|
46
|
+
if (amountRemaining === 0)
|
|
47
|
+
return null;
|
|
48
|
+
const gift = tenders.filter(i => i.tender_type === 'GIFT_CARD');
|
|
49
|
+
const nonGift = tenders.filter(i => i.tender_type !== 'GIFT_CARD');
|
|
50
|
+
if (amountRemaining > 0) {
|
|
51
|
+
if (!nonGift.length)
|
|
52
|
+
return null;
|
|
53
|
+
const newTenders = nonGift.map(i => {
|
|
54
|
+
const newAmount = parseFloat(i.amount) + amountRemaining;
|
|
55
|
+
amountRemaining = 0.0;
|
|
56
|
+
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
57
|
+
});
|
|
58
|
+
return [...gift, ...newTenders];
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const newTenders = nonGift.map(i => {
|
|
62
|
+
const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
|
|
63
|
+
amountRemaining += parseFloat(i.amount) - newAmount;
|
|
64
|
+
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
65
|
+
});
|
|
66
|
+
const isPaid = Math.abs(amountRemaining).toFixed(2) === '0.00';
|
|
67
|
+
if (isPaid) {
|
|
68
|
+
const nonZero = newTenders.filter(i => i.amount !== '0.00');
|
|
69
|
+
return [...gift, ...nonZero];
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const newGift = gift.map(i => {
|
|
73
|
+
const newAmount = Math.max(parseFloat(i.amount) + amountRemaining, 0.0);
|
|
74
|
+
amountRemaining += parseFloat(i.amount) - newAmount;
|
|
75
|
+
return Object.assign(Object.assign({}, i), { amount: newAmount.toFixed(2) });
|
|
76
|
+
});
|
|
77
|
+
return [...newGift, ...newTenders].filter(i => i.amount !== '0.00');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export const makeCreditCardName = (creditCard) => {
|
|
82
|
+
const { card_type_name, last4 } = creditCard;
|
|
83
|
+
return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
|
|
84
|
+
};
|
|
85
|
+
export const makeTenderName = (tender) => {
|
|
86
|
+
if (isCreditTender(tender)) {
|
|
87
|
+
return makeCreditCardName(tender.credit_card);
|
|
88
|
+
}
|
|
89
|
+
else if (isGiftCardTender(tender)) {
|
|
90
|
+
return `Gift Card ${tender.card_number}`;
|
|
91
|
+
}
|
|
92
|
+
else if (isHouseAccountTender(tender)) {
|
|
93
|
+
return `${tender.house_account.name} House Account`;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return '';
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
export const makeCheckoutTenderName = (tender) => {
|
|
100
|
+
if (isCreditCustomerCheckoutTender(tender)) {
|
|
101
|
+
const { card_type_name, last4 } = tender;
|
|
102
|
+
return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
|
|
103
|
+
}
|
|
104
|
+
else if (isCreditGuestCheckoutTender(tender)) {
|
|
105
|
+
const { card_type_name, last4 } = tender;
|
|
106
|
+
return last4 ? `${card_type_name} ending in ${last4}` : card_type_name;
|
|
107
|
+
}
|
|
108
|
+
else if (isGiftCardCheckoutTender(tender)) {
|
|
109
|
+
return `Gift Card ${tender.card_number}`;
|
|
110
|
+
}
|
|
111
|
+
else if (isHouseAccountCheckoutTender(tender)) {
|
|
112
|
+
return `${tender.name} House Account`;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
return '';
|
|
116
|
+
}
|
|
117
|
+
};
|
|
@@ -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,55 +1,55 @@
|
|
|
1
|
-
export const serviceTypeNamesMap = {
|
|
2
|
-
WALKIN: 'Dine-In',
|
|
3
|
-
PICKUP: 'Pickup',
|
|
4
|
-
DELIVERY: 'Delivery'
|
|
5
|
-
};
|
|
6
|
-
export const otherServiceTypeNamesMap = {
|
|
7
|
-
WALKIN: 'Delivery',
|
|
8
|
-
PICKUP: 'Delivery',
|
|
9
|
-
DELIVERY: 'Pickup'
|
|
10
|
-
};
|
|
11
|
-
export const orderTypeNamesMap = {
|
|
12
|
-
OLO: 'Regular',
|
|
13
|
-
CATERING: 'Catering',
|
|
14
|
-
MERCH: 'Merch'
|
|
15
|
-
};
|
|
16
|
-
export const otherOrderTypesMap = {
|
|
17
|
-
WALKIN: ['Delivery', 'Catering'],
|
|
18
|
-
PICKUP: ['Delivery', 'Catering'],
|
|
19
|
-
DELIVERY: ['Pickup', 'Catering'],
|
|
20
|
-
CATERING: ['Pickup', 'Delivery'],
|
|
21
|
-
MERCH: ['Pickup', 'Delivery']
|
|
22
|
-
};
|
|
23
|
-
export const tenderTypeNamesMap = {
|
|
24
|
-
CASH: 'Cash',
|
|
25
|
-
CREDIT: 'Credit',
|
|
26
|
-
LEVELUP: 'LevelUp',
|
|
27
|
-
HOUSE_ACCOUNT: 'House Account',
|
|
28
|
-
GIFT_CARD: 'Gift Card',
|
|
29
|
-
COMP: 'Comp',
|
|
30
|
-
APPLE_PAY: 'Apple Pay',
|
|
31
|
-
GOOGLE_PAY: 'Google Pay'
|
|
32
|
-
};
|
|
33
|
-
export const loyaltyType = {
|
|
34
|
-
CREDIT: 'CREDIT',
|
|
35
|
-
PROMO_CODE: 'PROMO_CODE',
|
|
36
|
-
POINTS: 'POINTS'
|
|
37
|
-
};
|
|
38
|
-
export const MAX_DISTANCE = 3000;
|
|
39
|
-
export const prepStatus = {
|
|
40
|
-
TODO: 'TODO',
|
|
41
|
-
IN_PROGRESS: 'IN_PROGRESS',
|
|
42
|
-
DONE: 'DONE',
|
|
43
|
-
COMPLETED: 'COMPLETED',
|
|
44
|
-
FULFILLED: 'FULFILLED'
|
|
45
|
-
};
|
|
46
|
-
export const optionsOrderNotifications = [
|
|
47
|
-
{ name: 'Email Only', value: 'EMAIL' },
|
|
48
|
-
{ name: 'SMS Only', value: 'SMS' },
|
|
49
|
-
{ name: 'Both Email & SMS', value: 'ALL' },
|
|
50
|
-
{ name: 'Neither', value: 'NONE' }
|
|
51
|
-
];
|
|
52
|
-
export const optionsOrderNotificationsTemp = [
|
|
53
|
-
{ name: 'Email', value: 'EMAIL' },
|
|
54
|
-
{ name: 'None', value: 'NONE' }
|
|
55
|
-
];
|
|
1
|
+
export const serviceTypeNamesMap = {
|
|
2
|
+
WALKIN: 'Dine-In',
|
|
3
|
+
PICKUP: 'Pickup',
|
|
4
|
+
DELIVERY: 'Delivery'
|
|
5
|
+
};
|
|
6
|
+
export const otherServiceTypeNamesMap = {
|
|
7
|
+
WALKIN: 'Delivery',
|
|
8
|
+
PICKUP: 'Delivery',
|
|
9
|
+
DELIVERY: 'Pickup'
|
|
10
|
+
};
|
|
11
|
+
export const orderTypeNamesMap = {
|
|
12
|
+
OLO: 'Regular',
|
|
13
|
+
CATERING: 'Catering',
|
|
14
|
+
MERCH: 'Merch'
|
|
15
|
+
};
|
|
16
|
+
export const otherOrderTypesMap = {
|
|
17
|
+
WALKIN: ['Delivery', 'Catering'],
|
|
18
|
+
PICKUP: ['Delivery', 'Catering'],
|
|
19
|
+
DELIVERY: ['Pickup', 'Catering'],
|
|
20
|
+
CATERING: ['Pickup', 'Delivery'],
|
|
21
|
+
MERCH: ['Pickup', 'Delivery']
|
|
22
|
+
};
|
|
23
|
+
export const tenderTypeNamesMap = {
|
|
24
|
+
CASH: 'Cash',
|
|
25
|
+
CREDIT: 'Credit',
|
|
26
|
+
LEVELUP: 'LevelUp',
|
|
27
|
+
HOUSE_ACCOUNT: 'House Account',
|
|
28
|
+
GIFT_CARD: 'Gift Card',
|
|
29
|
+
COMP: 'Comp',
|
|
30
|
+
APPLE_PAY: 'Apple Pay',
|
|
31
|
+
GOOGLE_PAY: 'Google Pay'
|
|
32
|
+
};
|
|
33
|
+
export const loyaltyType = {
|
|
34
|
+
CREDIT: 'CREDIT',
|
|
35
|
+
PROMO_CODE: 'PROMO_CODE',
|
|
36
|
+
POINTS: 'POINTS'
|
|
37
|
+
};
|
|
38
|
+
export const MAX_DISTANCE = 3000;
|
|
39
|
+
export const prepStatus = {
|
|
40
|
+
TODO: 'TODO',
|
|
41
|
+
IN_PROGRESS: 'IN_PROGRESS',
|
|
42
|
+
DONE: 'DONE',
|
|
43
|
+
COMPLETED: 'COMPLETED',
|
|
44
|
+
FULFILLED: 'FULFILLED'
|
|
45
|
+
};
|
|
46
|
+
export const optionsOrderNotifications = [
|
|
47
|
+
{ name: 'Email Only', value: 'EMAIL' },
|
|
48
|
+
{ name: 'SMS Only', value: 'SMS' },
|
|
49
|
+
{ name: 'Both Email & SMS', value: 'ALL' },
|
|
50
|
+
{ name: 'Neither', value: 'NONE' }
|
|
51
|
+
];
|
|
52
|
+
export const optionsOrderNotificationsTemp = [
|
|
53
|
+
{ name: 'Email', value: 'EMAIL' },
|
|
54
|
+
{ name: 'None', value: 'NONE' }
|
|
55
|
+
];
|
|
@@ -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,29 +1,29 @@
|
|
|
1
|
-
import { parseISO } from 'date-fns';
|
|
2
|
-
import { dashesToSlashes } from './helpers';
|
|
3
|
-
export const profileFields = [
|
|
4
|
-
'customer_id',
|
|
5
|
-
'first_name',
|
|
6
|
-
'last_name',
|
|
7
|
-
'email',
|
|
8
|
-
'phone',
|
|
9
|
-
'company',
|
|
10
|
-
'birth_date',
|
|
11
|
-
'gender',
|
|
12
|
-
'is_verified',
|
|
13
|
-
'is_notification_set'
|
|
14
|
-
];
|
|
15
|
-
export const makeCustomerProfile = (customer) => {
|
|
16
|
-
return profileFields.reduce((obj, field) => (Object.assign(Object.assign({}, obj), { [field]: field === 'birth_date'
|
|
17
|
-
? dashesToSlashes(customer[field])
|
|
18
|
-
: customer[field] })), {});
|
|
19
|
-
};
|
|
20
|
-
export const getLastOrder = (orders) => {
|
|
21
|
-
if (!orders || !orders.length)
|
|
22
|
-
return null;
|
|
23
|
-
const withCreated = orders
|
|
24
|
-
.filter(i => i.order_type !== 'MERCH')
|
|
25
|
-
.map(i => (Object.assign(Object.assign({}, i), { createdAt: parseISO(i.created_at) })))
|
|
26
|
-
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime())
|
|
27
|
-
.reverse();
|
|
28
|
-
return withCreated[0];
|
|
29
|
-
};
|
|
1
|
+
import { parseISO } from 'date-fns';
|
|
2
|
+
import { dashesToSlashes } from './helpers';
|
|
3
|
+
export const profileFields = [
|
|
4
|
+
'customer_id',
|
|
5
|
+
'first_name',
|
|
6
|
+
'last_name',
|
|
7
|
+
'email',
|
|
8
|
+
'phone',
|
|
9
|
+
'company',
|
|
10
|
+
'birth_date',
|
|
11
|
+
'gender',
|
|
12
|
+
'is_verified',
|
|
13
|
+
'is_notification_set'
|
|
14
|
+
];
|
|
15
|
+
export const makeCustomerProfile = (customer) => {
|
|
16
|
+
return profileFields.reduce((obj, field) => (Object.assign(Object.assign({}, obj), { [field]: field === 'birth_date'
|
|
17
|
+
? dashesToSlashes(customer[field])
|
|
18
|
+
: customer[field] })), {});
|
|
19
|
+
};
|
|
20
|
+
export const getLastOrder = (orders) => {
|
|
21
|
+
if (!orders || !orders.length)
|
|
22
|
+
return null;
|
|
23
|
+
const withCreated = orders
|
|
24
|
+
.filter(i => i.order_type !== 'MERCH')
|
|
25
|
+
.map(i => (Object.assign(Object.assign({}, i), { createdAt: parseISO(i.created_at) })))
|
|
26
|
+
.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime())
|
|
27
|
+
.reverse();
|
|
28
|
+
return withCreated[0];
|
|
29
|
+
};
|