@tapcart/mobile-components 0.7.58 → 0.7.59

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.
@@ -0,0 +1,6 @@
1
+ import React from "react"
2
+ export declare function useClickOutside(
3
+ ref: React.RefObject<HTMLElement>,
4
+ callback: () => void
5
+ ): void
6
+ //# sourceMappingURL=use-click-outside.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-click-outside.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-click-outside.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAE,IAAI,CAa5F"}
@@ -0,0 +1,15 @@
1
+ "use client"
2
+ import React from "react"
3
+ export function useClickOutside(ref, callback) {
4
+ React.useEffect(() => {
5
+ const handleClickOutside = (event) => {
6
+ if (ref.current && !ref.current.contains(event.target)) {
7
+ callback()
8
+ }
9
+ }
10
+ document.addEventListener("mousedown", handleClickOutside)
11
+ return () => {
12
+ document.removeEventListener("mousedown", handleClickOutside)
13
+ }
14
+ }, [ref, callback])
15
+ }
@@ -0,0 +1,7 @@
1
+ import React from "react"
2
+ declare const useClickOutside: (
3
+ ref: React.RefObject<HTMLElement>,
4
+ callback: () => void
5
+ ) => void
6
+ export default useClickOutside
7
+ //# sourceMappingURL=use-outside-click.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-outside-click.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-outside-click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,eAAe,QAAS,MAAM,SAAS,CAAC,WAAW,CAAC,YAAY,MAAM,IAAI,SAa/E,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use client"
2
+ import React from "react"
3
+ const useClickOutside = (ref, callback) => {
4
+ React.useEffect(() => {
5
+ const handleClickOutside = (event) => {
6
+ if (ref.current && !ref.current.contains(event.target)) {
7
+ callback()
8
+ }
9
+ }
10
+ document.addEventListener("mousedown", handleClickOutside)
11
+ return () => {
12
+ document.removeEventListener("mousedown", handleClickOutside)
13
+ }
14
+ }, [ref, callback])
15
+ }
16
+ export default useClickOutside
@@ -1,8 +1,8 @@
1
- import React from "react";
1
+ import React from "react"
2
2
  declare const useTap: (tapThreshold?: number) => {
3
- onTap: (handler: (event: any) => void) => (event: any) => void;
4
- isPressed: boolean;
5
- ref: React.MutableRefObject<null>;
6
- };
7
- export { useTap };
8
- //# sourceMappingURL=use-tap.d.ts.map
3
+ onTap: (handler: (event: any) => void) => (event: any) => void
4
+ isPressed: boolean
5
+ ref: React.MutableRefObject<null>
6
+ }
7
+ export { useTap }
8
+ //# sourceMappingURL=use-tap.d.ts.map
@@ -1,100 +1,100 @@
1
- "use client";
2
- import { useState, useEffect, useCallback, useRef } from "react";
1
+ "use client"
2
+ import { useState, useEffect, useCallback, useRef } from "react"
3
3
  // Shared manager for all instances of the hook
4
4
  const tapManager = (() => {
5
- const elements = new Map();
6
- let isListening = false;
7
- const startListening = () => {
8
- if (isListening)
9
- return;
10
- const handleTouchStart = (e) => {
11
- const touch = e.touches[0];
12
- elements.forEach((data, el) => {
13
- if (el.contains(touch.target)) {
14
- data.touchStarted = true;
15
- data.touchMoved = false;
16
- data.startPosition = { x: touch.clientX, y: touch.clientY };
17
- // Don't set isPressed here, wait to determine if it's a tap or drag
18
- }
19
- });
20
- };
21
- const handleTouchMove = (e) => {
22
- const touch = e.touches[0];
23
- elements.forEach((data, el) => {
24
- if (data.touchStarted) {
25
- const deltaX = Math.abs(touch.clientX - data.startPosition.x);
26
- const deltaY = Math.abs(touch.clientY - data.startPosition.y);
27
- if (deltaX > data.tapThreshold || deltaY > data.tapThreshold) {
28
- data.touchMoved = true;
29
- data.setIsPressed(false);
30
- }
31
- }
32
- });
33
- };
34
- const handleTouchEnd = () => {
35
- elements.forEach((data) => {
36
- if (data.touchStarted) {
37
- data.touchStarted = false;
38
- if (!data.touchMoved) {
39
- // It's a tap, set isPressed briefly
40
- data.setIsPressed(true);
41
- setTimeout(() => data.setIsPressed(false), 100);
42
- }
43
- }
44
- });
45
- };
46
- document.addEventListener("touchstart", (e) => handleTouchStart(e), { passive: true });
47
- document.addEventListener("touchmove", (e) => handleTouchMove(e), { passive: true });
48
- document.addEventListener("touchend", () => handleTouchEnd(), {
49
- passive: true,
50
- });
51
- isListening = true;
52
- };
53
- return {
54
- register: (el, data) => {
55
- elements.set(el, data);
56
- startListening();
57
- },
58
- unregister: (el) => {
59
- elements.delete(el);
60
- },
61
- elements,
62
- };
63
- })();
5
+ const elements = new Map()
6
+ let isListening = false
7
+ const startListening = () => {
8
+ if (isListening) return
9
+ const handleTouchStart = (e) => {
10
+ const touch = e.touches[0]
11
+ elements.forEach((data, el) => {
12
+ if (el.contains(touch.target)) {
13
+ data.touchStarted = true
14
+ data.touchMoved = false
15
+ data.startPosition = { x: touch.clientX, y: touch.clientY }
16
+ // Don't set isPressed here, wait to determine if it's a tap or drag
17
+ }
18
+ })
19
+ }
20
+ const handleTouchMove = (e) => {
21
+ const touch = e.touches[0]
22
+ elements.forEach((data, el) => {
23
+ if (data.touchStarted) {
24
+ const deltaX = Math.abs(touch.clientX - data.startPosition.x)
25
+ const deltaY = Math.abs(touch.clientY - data.startPosition.y)
26
+ if (deltaX > data.tapThreshold || deltaY > data.tapThreshold) {
27
+ data.touchMoved = true
28
+ data.setIsPressed(false)
29
+ }
30
+ }
31
+ })
32
+ }
33
+ const handleTouchEnd = () => {
34
+ elements.forEach((data) => {
35
+ if (data.touchStarted) {
36
+ data.touchStarted = false
37
+ if (!data.touchMoved) {
38
+ // It's a tap, set isPressed briefly
39
+ data.setIsPressed(true)
40
+ setTimeout(() => data.setIsPressed(false), 100)
41
+ }
42
+ }
43
+ })
44
+ }
45
+ document.addEventListener("touchstart", (e) => handleTouchStart(e), {
46
+ passive: true,
47
+ })
48
+ document.addEventListener("touchmove", (e) => handleTouchMove(e), {
49
+ passive: true,
50
+ })
51
+ document.addEventListener("touchend", () => handleTouchEnd(), {
52
+ passive: true,
53
+ })
54
+ isListening = true
55
+ }
56
+ return {
57
+ register: (el, data) => {
58
+ elements.set(el, data)
59
+ startListening()
60
+ },
61
+ unregister: (el) => {
62
+ elements.delete(el)
63
+ },
64
+ elements,
65
+ }
66
+ })()
64
67
  const useTap = (tapThreshold = 10) => {
65
- const [isPressed, setIsPressed] = useState(false);
66
- const elementRef = useRef(null);
67
- useEffect(() => {
68
- const element = elementRef.current;
69
- if (!element)
70
- return;
71
- const data = {
72
- touchStarted: false,
73
- touchMoved: false,
74
- startPosition: { x: 0, y: 0 },
75
- setIsPressed,
76
- tapThreshold,
77
- };
78
- tapManager.register(element, data);
79
- return () => {
80
- tapManager.unregister(element);
81
- };
82
- }, [tapThreshold]);
83
- const onTap = useCallback((handler) => {
84
- return (event) => {
85
- const data = tapManager.elements.get(elementRef.current);
86
- if (!data)
87
- return;
88
- if (event.type === "touchend" && !data.touchMoved) {
89
- handler(event);
90
- }
91
- else if (event.type === "click" && !data.touchStarted) {
92
- handler(event);
93
- setIsPressed(true);
94
- setTimeout(() => setIsPressed(false), 100);
95
- }
96
- };
97
- }, []);
98
- return { onTap, isPressed, ref: elementRef };
99
- };
100
- export { useTap };
68
+ const [isPressed, setIsPressed] = useState(false)
69
+ const elementRef = useRef(null)
70
+ useEffect(() => {
71
+ const element = elementRef.current
72
+ if (!element) return
73
+ const data = {
74
+ touchStarted: false,
75
+ touchMoved: false,
76
+ startPosition: { x: 0, y: 0 },
77
+ setIsPressed,
78
+ tapThreshold,
79
+ }
80
+ tapManager.register(element, data)
81
+ return () => {
82
+ tapManager.unregister(element)
83
+ }
84
+ }, [tapThreshold])
85
+ const onTap = useCallback((handler) => {
86
+ return (event) => {
87
+ const data = tapManager.elements.get(elementRef.current)
88
+ if (!data) return
89
+ if (event.type === "touchend" && !data.touchMoved) {
90
+ handler(event)
91
+ } else if (event.type === "click" && !data.touchStarted) {
92
+ handler(event)
93
+ setIsPressed(true)
94
+ setTimeout(() => setIsPressed(false), 100)
95
+ }
96
+ }
97
+ }, [])
98
+ return { onTap, isPressed, ref: elementRef }
99
+ }
100
+ export { useTap }
@@ -17,7 +17,7 @@ export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButt
17
17
  supportedNetworks?: string[];
18
18
  buttonType?: ApplePayButtonType;
19
19
  buttonStyle?: ApplePayButtonStyle;
20
- onPaymentAuthorized?: (paymentData: ApplePayJS.ApplePayPayment) => Promise<void>;
20
+ onPaymentAuthorized?: (paymentData: ApplePayJS.ApplePayPayment) => Promise<boolean>;
21
21
  onShippingContactSelected?: (shippingContact: ApplePayJS.ApplePayPaymentContact) => Promise<ApplePayJS.ApplePayShippingMethodUpdate>;
22
22
  onShippingMethodSelected?: (shippingMethod: ApplePayJS.ApplePayShippingMethod) => Promise<ApplePayJS.ApplePayShippingMethodUpdate>;
23
23
  onPaymentCancelled?: (event?: ApplePayJS.Event) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"apple-pay-button.d.ts","sourceRoot":"","sources":["../../../components/ui/apple-pay-button.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,MAAM,kBAAkB,GAC1B,OAAO,GACP,WAAW,GACX,MAAM,GACN,KAAK,GACL,WAAW,GACX,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,WAAW,GACX,SAAS,GACT,KAAK,GACL,QAAQ,CAAA;AAEZ,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,CAAA;AAErE,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,WAAW,EAAE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AAE,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,KAAK,KAAK,IAAI,CAAA;CACxD;AAED,QAAA,MAAM,cAAc;oVAmBjB,mBAAmB;;CAyKrB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -101,18 +101,14 @@ const ApplePayButton = ({ displayName, amount, requiredBillingContactFields = ["
101
101
  const paymentData = event.payment;
102
102
  try {
103
103
  if (onPaymentAuthorized) {
104
- yield onPaymentAuthorized(paymentData);
105
- }
106
- if (paymentData.token) {
107
- const result = {
108
- status: ApplePaySession.STATUS_SUCCESS,
109
- };
110
- session.completePayment(result);
111
- }
112
- else {
113
- const result = {
114
- status: ApplePaySession.STATUS_FAILURE,
115
- };
104
+ const isPaymentAuthorized = yield onPaymentAuthorized(paymentData);
105
+ const result = isPaymentAuthorized
106
+ ? {
107
+ status: ApplePaySession.STATUS_SUCCESS,
108
+ }
109
+ : {
110
+ status: ApplePaySession.STATUS_FAILURE,
111
+ };
116
112
  session.completePayment(result);
117
113
  }
118
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"quantity-picker.d.ts","sourceRoot":"","sources":["../../../components/ui/quantity-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAChC,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAoBD,QAAA,MAAM,cAAc,4FAmFnB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
1
+ {"version":3,"file":"quantity-picker.d.ts","sourceRoot":"","sources":["../../../components/ui/quantity-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAChC,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAiCD,QAAA,MAAM,cAAc,4FAmFnB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -14,7 +14,13 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
14
14
  import * as React from "react";
15
15
  import { cn } from "../../lib/utils";
16
16
  import { Icon } from "./icon";
17
- const IconButton = ({ iconUrl, iconColor, handler, className, style }) => (_jsx("button", Object.assign({ onClick: handler, className: cn("flex items-center justify-center h-7 w-7 bg-stateColors-skeleton border border-coreColors-dividingLines", className), style: style }, { children: _jsx(Icon, { url: iconUrl, size: "sm", strokeColor: iconColor, strokeWidth: 4 }) })));
17
+ import { useTap } from "./tap";
18
+ const IconButton = ({ iconUrl, iconColor, handler, className, style }) => {
19
+ const { onTap, isPressed, ref: tapRef } = useTap();
20
+ return (_jsx("button", Object.assign({ onClick: onTap(handler), ref: tapRef, className: cn("flex items-center justify-center h-7 w-7 bg-stateColors-skeleton border border-coreColors-dividingLines", className), style: style }, { children: _jsx(Icon, { url: iconUrl, size: "sm", strokeColor: iconColor, strokeWidth: 4, style: {
21
+ opacity: isPressed ? 0.7 : 1,
22
+ } }) })));
23
+ };
18
24
  const QuantityPicker = React.forwardRef((_a, ref) => {
19
25
  var { className, decreaseIconUrl, increaseIconUrl, deleteIconUrl, isDeleteOnly = false, iconColor, onDecreaseClick, onIncreaseClick, value, setValue, inputStyle, buttonStyle, buttonCornerRadius = 4 } = _a, props = __rest(_a, ["className", "decreaseIconUrl", "increaseIconUrl", "deleteIconUrl", "isDeleteOnly", "iconColor", "onDecreaseClick", "onIncreaseClick", "value", "setValue", "inputStyle", "buttonStyle", "buttonCornerRadius"]);
20
26
  const leftButtonStyle = Object.assign(Object.assign({}, buttonStyle), { borderTopLeftRadius: buttonCornerRadius
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.58",
3
+ "version": "0.7.59",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -11,20 +11,6 @@
11
11
  "license": "SEE LICENSE IN LICENSE.md",
12
12
  "author": "Tapcart Inc.",
13
13
  "homepage": "https://tapcart.com",
14
- "scripts": {
15
- "clean": "rm -rf dist node_modules",
16
- "lint": "eslint \"**/*.ts*\"",
17
- "ui:add": "pnpm dlx shadcn-ui@latest add",
18
- "build:styles": "postcss styles/globals.css -o dist/styles.css",
19
- "build:ts": "tsc -p tsconfig.json && tsc-alias",
20
- "build": "pnpm run build:ts && pnpm run build:styles",
21
- "dev:ts": "tsc -w -p tsconfig.json",
22
- "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
23
- "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
24
- "test": "jest",
25
- "test:silent": "jest --silent",
26
- "test:watch": "jest --watch"
27
- },
28
14
  "peerDependencies": {
29
15
  "react": "^17.0.2 || ^18.0.0",
30
16
  "react-dom": "^17.0.2 || ^18.0.0"
@@ -37,20 +23,20 @@
37
23
  "@types/pluralize": "^0.0.33",
38
24
  "@types/react": "^18.2.0",
39
25
  "@types/react-dom": "^18.2.0",
40
- "app-studio-types": "workspace:*",
41
26
  "autoprefixer": "^10.4.14",
42
27
  "chokidar-cli": "^3.0.0",
43
28
  "concurrently": "^8.2.2",
44
29
  "eslint": "^7.32.0",
45
- "eslint-config-custom": "workspace:*",
46
30
  "jest": "^29.7.0",
47
31
  "jest-environment-jsdom": "^29.7.0",
48
32
  "postcss": "^8.4.24",
49
33
  "tailwindcss": "^3.3.2",
50
34
  "ts-jest": "^29.2.5",
51
35
  "tsc-alias": "^1.8.10",
52
- "tsconfig": "workspace:*",
53
- "typescript": "^4.5.2"
36
+ "typescript": "^4.5.2",
37
+ "app-studio-types": "0.0.6",
38
+ "eslint-config-custom": "0.0.0",
39
+ "tsconfig": "0.0.0"
54
40
  },
55
41
  "dependencies": {
56
42
  "@radix-ui/react-accordion": "^1.1.2",
@@ -90,5 +76,19 @@
90
76
  "tailwind-merge": "^1.13.2",
91
77
  "tailwindcss-animate": "^1.0.6",
92
78
  "vaul": "0.9.1"
79
+ },
80
+ "scripts": {
81
+ "clean": "rm -rf dist node_modules",
82
+ "lint": "eslint \"**/*.ts*\"",
83
+ "ui:add": "pnpm dlx shadcn-ui@latest add",
84
+ "build:styles": "postcss styles/globals.css -o dist/styles.css",
85
+ "build:ts": "tsc -p tsconfig.json && tsc-alias",
86
+ "build": "pnpm run build:ts && pnpm run build:styles",
87
+ "dev:ts": "tsc -w -p tsconfig.json",
88
+ "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
89
+ "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
90
+ "test": "jest",
91
+ "test:silent": "jest --silent",
92
+ "test:watch": "jest --watch"
93
93
  }
94
- }
94
+ }
@@ -1,10 +0,0 @@
1
- type Customer = {
2
- isAuthenticated: boolean;
3
- };
4
- type UseCustomerProps = {};
5
- type UseCustomerReturn = {
6
- customer: Customer;
7
- };
8
- export declare const useCustomer: (props: UseCustomerProps | null) => UseCustomerReturn;
9
- export {};
10
- //# sourceMappingURL=use-customer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-customer.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-customer.ts"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAGD,KAAK,gBAAgB,GAAG,EAAE,CAAA;AAE1B,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,WAAW,UACf,gBAAgB,GAAG,IAAI,KAC7B,iBAuBF,CAAA"}
@@ -1,24 +0,0 @@
1
- "use client";
2
- import { useState, useEffect } from "react";
3
- // @ts-ignore -- webbridge-react is not typed (yet)
4
- import { useActions } from "@tapcart/webbridge-react";
5
- export const useCustomer = (props) => {
6
- const [isAuthenticated, setIsAuthenticated] = useState(false);
7
- const [customer, setCustomer] = useState({});
8
- const actions = useActions();
9
- // verify customer
10
- useEffect(() => {
11
- try {
12
- // webbridge method to get customerIdentity
13
- actions.getCustomerIdentity(null, {
14
- onSuccess: (user) => setIsAuthenticated(!!(user === null || user === void 0 ? void 0 : user.email)),
15
- });
16
- }
17
- catch (e) {
18
- console.log("unable to get customer identity ", e);
19
- }
20
- }, [actions]);
21
- return {
22
- customer: Object.assign({ isAuthenticated }, customer),
23
- };
24
- };