@lookiero/checkout 9.7.0 → 9.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback.d.ts +0 -1
- package/dist/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback.js +3 -4
- package/dist/src/infrastructure/ui/views/feedback/Feedback.js +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx +1 -1
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback.test.ts +2 -32
- package/src/infrastructure/ui/components/organisms/checkoutQuestions/behaviors/useCheckoutQuestionFeedback.tsx +2 -6
- package/src/infrastructure/ui/views/feedback/Feedback.tsx +1 -1
- package/src/infrastructure/ui/views/feedback/components/checkoutQuestionsForm/CheckoutQuestionsForm.test.tsx +1 -1
- package/src/infrastructure/ui/views/item/components/getOutOfCheckoutModal/__snapshots__/GetOutOfCheckoutModal.test.tsx.snap +0 -1
- package/src/infrastructure/ui/views/item/components/itemActions/__snapshots__/ItemActions.test.tsx.snap +1 -2
- package/src/infrastructure/ui/views/item/components/selectModal/__snapshots__/SelecModal.test.tsx.snap +0 -1
- package/src/infrastructure/ui/views/item/components/sizeWithoutStockModal/__snapshots__/SizeWithoutStockModal.test.tsx.snap +0 -1
|
@@ -9,7 +9,6 @@ interface OnChangeCheckoutQuestionFeedbackFunction {
|
|
|
9
9
|
(args: OnChangeCheckoutQuestionFeedbackFunctionArgs): void;
|
|
10
10
|
}
|
|
11
11
|
interface CheckoutQuestionFeedbackContextProviderProps {
|
|
12
|
-
readonly feedback: CheckoutFeedbackProjection | undefined;
|
|
13
12
|
readonly onChanged?: OnChangeCheckoutQuestionFeedbackFunction;
|
|
14
13
|
readonly children: ReactNode;
|
|
15
14
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { createContext, useCallback, useContext,
|
|
1
|
+
import React, { createContext, useCallback, useContext, useMemo, useState } from "react";
|
|
2
2
|
import invariant from "tiny-invariant";
|
|
3
3
|
const CheckoutQuestionFeedbackContext = createContext(null);
|
|
4
|
-
const CheckoutQuestionFeedbackProvider = ({
|
|
5
|
-
const [contextFeedback, setContextFeedback] = useState(
|
|
4
|
+
const CheckoutQuestionFeedbackProvider = ({ onChanged, children, }) => {
|
|
5
|
+
const [contextFeedback, setContextFeedback] = useState({});
|
|
6
6
|
const onChange = useCallback(({ checkoutQuestionId, checkoutQuestionFeedback }) => {
|
|
7
7
|
setContextFeedback((feedback) => checkoutQuestionFeedback
|
|
8
8
|
? { ...feedback, [checkoutQuestionId]: checkoutQuestionFeedback }
|
|
@@ -13,7 +13,6 @@ const CheckoutQuestionFeedbackProvider = ({ feedback = {}, onChanged, children,
|
|
|
13
13
|
hasFeedback: Boolean(contextFeedback[checkoutQuestionId]),
|
|
14
14
|
});
|
|
15
15
|
}, [contextFeedback, onChanged]);
|
|
16
|
-
useEffect(() => setContextFeedback(feedback), [feedback]);
|
|
17
16
|
const value = useMemo(() => ({
|
|
18
17
|
feedback: contextFeedback,
|
|
19
18
|
onChange,
|
|
@@ -80,7 +80,7 @@ const Feedback = ({ layout: Layout }) => {
|
|
|
80
80
|
const dependenciesLoaded = dependenciesLoadedStatuses.includes(checkoutStatus) && dependenciesLoadedStatuses.includes(checkoutQuestionsStatus);
|
|
81
81
|
if (!dependenciesLoaded)
|
|
82
82
|
return React.createElement(Spinner, null);
|
|
83
|
-
return (React.createElement(CheckoutQuestionFeedbackProvider, {
|
|
83
|
+
return (React.createElement(CheckoutQuestionFeedbackProvider, { onChanged: handleOnChangedFeedback },
|
|
84
84
|
React.createElement(Layout, null,
|
|
85
85
|
React.createElement(Body, { style: { row: [style.container, isDesktop && style.containerDesktop] } },
|
|
86
86
|
React.createElement(CheckoutQuestionsForm, { checkoutQuestions: checkoutQuestions || [], submitButtonDisabled: giveCheckoutFeedbackStatus === CommandStatus.LOADING, onSubmit: handleOnSubmit })))));
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "9.
|
|
1
|
+
export declare const VERSION = "9.8.1";
|
package/dist/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "9.
|
|
1
|
+
export const VERSION = "9.8.1";
|
package/package.json
CHANGED
package/src/infrastructure/ui/components/organisms/checkoutQuestions/CheckoutQuestions.test.tsx
CHANGED
|
@@ -48,7 +48,7 @@ const checkoutQuestionItems: CheckoutQuestionItems = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const Wrapper = ({ children }: { children: ReactNode }) => (
|
|
51
|
-
<CheckoutQuestionFeedbackProvider
|
|
51
|
+
<CheckoutQuestionFeedbackProvider>
|
|
52
52
|
<CheckoutQuestionItemProvider checkoutQuestionItems={checkoutQuestionItems}>
|
|
53
53
|
{children}
|
|
54
54
|
</CheckoutQuestionItemProvider>
|
|
@@ -1,50 +1,20 @@
|
|
|
1
1
|
import { act, renderHook } from "@testing-library/react-native";
|
|
2
|
-
import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
3
2
|
import { createWrapper } from "../../../../test/createWrapper";
|
|
4
3
|
import {
|
|
5
4
|
CheckoutQuestionFeedbackProvider,
|
|
6
|
-
useCheckoutQuestionFeedback as sut,
|
|
7
5
|
useCheckoutQuestionFeedbackForId as sutForId,
|
|
8
6
|
} from "./useCheckoutQuestionFeedback";
|
|
9
7
|
|
|
10
|
-
const initialFeedback: CheckoutFeedbackProjection = {
|
|
11
|
-
["0ad1dba8-b02c-4121-a1e3-981f1c30800d"]: "9251dc2c-d76a-484d-9299-346929af932f",
|
|
12
|
-
["542c4d24-e1da-484f-8c3a-7d89ee135adc"]: "68c0bb98-b00a-4b86-af43-528fe903cb69",
|
|
13
|
-
};
|
|
14
8
|
const checkoutQuestionId = "542c4d24-e1da-484f-8c3a-7d89ee135adc";
|
|
15
9
|
const mockOnChanged = jest.fn();
|
|
16
10
|
|
|
17
11
|
describe("useCheckoutQuestionFeedback hook", () => {
|
|
18
|
-
it("returns the customer's feedback from the context's local state", () => {
|
|
19
|
-
const { result } = renderHook(() => sut(), {
|
|
20
|
-
wrapper: createWrapper({
|
|
21
|
-
wrapper: CheckoutQuestionFeedbackProvider,
|
|
22
|
-
initialProps: { feedback: initialFeedback, children: null, onChanged: mockOnChanged },
|
|
23
|
-
}),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
expect(result.current).toStrictEqual(initialFeedback);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("returns the customer's feedback for the checkoutQuestion from the context's local state", async () => {
|
|
30
|
-
const { result } = renderHook(() => sutForId({ id: checkoutQuestionId }), {
|
|
31
|
-
wrapper: createWrapper({
|
|
32
|
-
wrapper: CheckoutQuestionFeedbackProvider,
|
|
33
|
-
initialProps: { feedback: initialFeedback, children: null, onChanged: mockOnChanged },
|
|
34
|
-
}),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const { feedback: initialCheckoutQuestionFeedback } = result.current;
|
|
38
|
-
|
|
39
|
-
expect(initialCheckoutQuestionFeedback).toEqual(initialFeedback[checkoutQuestionId]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
12
|
it("returns the customer's feedback for the checkoutQuestion from the context's local state after updating it", async () => {
|
|
43
13
|
const feedbackToUpdate = "f3742fa1-e6e9-4321-baea-9622b57416f4";
|
|
44
14
|
const { result } = renderHook(() => sutForId({ id: checkoutQuestionId }), {
|
|
45
15
|
wrapper: createWrapper({
|
|
46
16
|
wrapper: CheckoutQuestionFeedbackProvider,
|
|
47
|
-
initialProps: {
|
|
17
|
+
initialProps: { children: null, onChanged: mockOnChanged },
|
|
48
18
|
}),
|
|
49
19
|
});
|
|
50
20
|
|
|
@@ -55,7 +25,7 @@ describe("useCheckoutQuestionFeedback hook", () => {
|
|
|
55
25
|
expect(mockOnChanged).toHaveBeenCalledWith({
|
|
56
26
|
checkoutQuestionId,
|
|
57
27
|
checkoutQuestionFeedback: feedbackToUpdate,
|
|
58
|
-
hasFeedback:
|
|
28
|
+
hasFeedback: false,
|
|
59
29
|
});
|
|
60
30
|
|
|
61
31
|
const { feedback: updatedCheckoutQuestionFeedback } = result.current;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, FC, ReactNode, useCallback, useContext,
|
|
1
|
+
import React, { createContext, FC, ReactNode, useCallback, useContext, useMemo, useState } from "react";
|
|
2
2
|
import invariant from "tiny-invariant";
|
|
3
3
|
import { CheckoutFeedbackProjection } from "../../../../../../projection/checkoutFeedback/checkoutFeedback";
|
|
4
4
|
|
|
@@ -22,17 +22,15 @@ const CheckoutQuestionFeedbackContext = createContext<CheckoutQuestionFeedbackCo
|
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
interface CheckoutQuestionFeedbackContextProviderProps {
|
|
25
|
-
readonly feedback: CheckoutFeedbackProjection | undefined;
|
|
26
25
|
readonly onChanged?: OnChangeCheckoutQuestionFeedbackFunction;
|
|
27
26
|
readonly children: ReactNode;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
const CheckoutQuestionFeedbackProvider: FC<CheckoutQuestionFeedbackContextProviderProps> = ({
|
|
31
|
-
feedback = {},
|
|
32
30
|
onChanged,
|
|
33
31
|
children,
|
|
34
32
|
}) => {
|
|
35
|
-
const [contextFeedback, setContextFeedback] = useState<CheckoutFeedbackProjection>(
|
|
33
|
+
const [contextFeedback, setContextFeedback] = useState<CheckoutFeedbackProjection>({});
|
|
36
34
|
const onChange = useCallback<OnChangeCheckoutQuestionFeedbackFunction>(
|
|
37
35
|
({ checkoutQuestionId, checkoutQuestionFeedback }) => {
|
|
38
36
|
setContextFeedback((feedback) =>
|
|
@@ -52,8 +50,6 @@ const CheckoutQuestionFeedbackProvider: FC<CheckoutQuestionFeedbackContextProvid
|
|
|
52
50
|
[contextFeedback, onChanged],
|
|
53
51
|
);
|
|
54
52
|
|
|
55
|
-
useEffect(() => setContextFeedback(feedback), [feedback]);
|
|
56
|
-
|
|
57
53
|
const value = useMemo(
|
|
58
54
|
() => ({
|
|
59
55
|
feedback: contextFeedback,
|
|
@@ -115,7 +115,7 @@ const Feedback: FC<FeedbackProps> = ({ layout: Layout }) => {
|
|
|
115
115
|
if (!dependenciesLoaded) return <Spinner />;
|
|
116
116
|
|
|
117
117
|
return (
|
|
118
|
-
<CheckoutQuestionFeedbackProvider
|
|
118
|
+
<CheckoutQuestionFeedbackProvider onChanged={handleOnChangedFeedback}>
|
|
119
119
|
<Layout>
|
|
120
120
|
<Body style={{ row: [style.container, isDesktop && style.containerDesktop] }}>
|
|
121
121
|
<CheckoutQuestionsForm
|
|
@@ -9,7 +9,7 @@ import { CheckoutQuestionsForm } from "./CheckoutQuestionsForm";
|
|
|
9
9
|
const mockOnSubmit = jest.fn();
|
|
10
10
|
|
|
11
11
|
const Wrapper = ({ children }: { children: ReactNode }) => (
|
|
12
|
-
<CheckoutQuestionFeedbackProvider
|
|
12
|
+
<CheckoutQuestionFeedbackProvider>{children}</CheckoutQuestionFeedbackProvider>
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
describe("CheckoutQuestionsForm component)", () => {
|
|
@@ -490,7 +490,7 @@ exports[`ItemActions component matches the snapshot 1`] = `
|
|
|
490
490
|
<View
|
|
491
491
|
accessibilityState={
|
|
492
492
|
{
|
|
493
|
-
"expanded":
|
|
493
|
+
"expanded": false,
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
496
|
pointerEvents="none"
|
|
@@ -590,7 +590,6 @@ exports[`ItemActions component matches the snapshot 1`] = `
|
|
|
590
590
|
},
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
|
-
onLayout={[Function]}
|
|
594
593
|
pointerEvents="none"
|
|
595
594
|
style={
|
|
596
595
|
{
|