@lookiero/checkout 0.1.1 → 0.2.0
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/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.d.ts +4 -4
- package/dist/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.js +3 -2
- package/dist/domain/checkoutBooking/model/checkoutBooking.d.ts +3 -2
- package/dist/domain/checkoutBooking/model/checkoutBooking.js +2 -1
- package/dist/domain/checkoutBooking/model/checkoutBookingBooked.d.ts +4 -4
- package/dist/domain/checkoutBooking/model/checkoutBookingBooked.js +3 -2
- package/dist/domain/checkoutBooking/model/checkoutBookings.d.ts +3 -2
- package/dist/domain/uiSetting/command/updateUiSetting.d.ts +4 -4
- package/dist/domain/uiSetting/command/updateUiSetting.js +3 -2
- package/dist/domain/uiSetting/model/uiSetting.d.ts +3 -2
- package/dist/domain/uiSetting/model/uiSetting.js +2 -1
- package/dist/domain/uiSetting/model/uiSettingUpdated.d.ts +4 -4
- package/dist/domain/uiSetting/model/uiSettingUpdated.js +3 -2
- package/dist/domain/uiSetting/model/uiSettings.d.ts +3 -2
- package/dist/infrastructure/delivery/_mock/bootstrap.mock.js +2 -1
- package/dist/infrastructure/delivery/bootstrap.d.ts +2 -1
- package/dist/infrastructure/delivery/bootstrap.js +3 -2
- package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.d.ts +2 -2
- package/dist/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.js +2 -1
- package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.d.ts +2 -2
- package/dist/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.js +2 -1
- package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.d.ts +13 -0
- package/dist/infrastructure/domain/react/useSetCheckoutIntroShown.js +9 -0
- package/dist/infrastructure/domain/react/useUpdateUiSetting.d.ts +2 -2
- package/dist/infrastructure/domain/react/useUpdateUiSetting.js +2 -1
- package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.d.ts +3 -3
- package/dist/infrastructure/domain/uiSetting/model/storageUiSettings.js +3 -2
- package/dist/infrastructure/persistence/asyncStorageStorage.d.ts +3 -2
- package/dist/infrastructure/persistence/asyncStorageStorage.js +3 -2
- package/dist/infrastructure/persistence/storage.d.ts +3 -2
- package/dist/infrastructure/persistence/uiSettingData.d.ts +2 -1
- package/dist/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.js +2 -1
- package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.d.ts +2 -0
- package/dist/infrastructure/projection/react/useViewCheckoutIntroShown.js +6 -0
- package/dist/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.js +2 -1
- package/dist/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.js +2 -1
- package/dist/infrastructure/projection/react/useViewUiSettingByKey.d.ts +3 -3
- package/dist/infrastructure/projection/react/useViewUiSettingByKey.js +9 -5
- package/dist/infrastructure/projection/storageUiSettingByKeyView.d.ts +2 -2
- package/dist/infrastructure/projection/storageUiSettingByKeyView.js +2 -1
- package/dist/infrastructure/ui/Root.js +8 -10
- package/dist/infrastructure/ui/components/atoms/spinner/Spinner.js +9 -0
- package/dist/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.js +4 -4
- package/dist/infrastructure/ui/routing/CheckoutMiddleware.js +13 -10
- package/dist/infrastructure/ui/routing/Routing.js +11 -14
- package/dist/infrastructure/ui/settings/UISettings.d.ts +4 -0
- package/dist/infrastructure/ui/settings/UISettings.js +5 -0
- package/dist/infrastructure/ui/views/intro/Intro.js +5 -7
- package/dist/infrastructure/ui/views/item/Item.js +6 -8
- package/dist/infrastructure/ui/views/summary/Summary.js +5 -7
- package/dist/projection/uiSetting/viewUiSettingByKey.d.ts +6 -6
- package/dist/projection/uiSetting/viewUiSettingByKey.js +4 -3
- package/package.json +6 -3
- package/.eslintignore +0 -7
- package/.eslintrc +0 -72
- package/.expo-shared/assets.json +0 -4
- package/.github/CODEOWNERS +0 -1
- package/.github/actions/version/action.yaml +0 -32
- package/.github/dependabot.yaml +0 -10
- package/.github/workflows/build.yaml +0 -71
- package/.github/workflows/publish.yaml +0 -52
- package/.husky/pre-commit +0 -4
- package/.husky/prepare-commit-msg +0 -26
- package/.husky/prepush +0 -12
- package/.lintstagedrc.json +0 -4
- package/.nvmrc +0 -1
- package/.prettierignore +0 -2
- package/.prettierrc.json +0 -6
- package/@types/aurora-next.d.ts +0 -1
- package/app.config.js +0 -4
- package/app.json +0 -31
- package/assets/adaptive-icon.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/icon.png +0 -0
- package/assets/splash.png +0 -0
- package/babel.config.js +0 -6
- package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.d.ts +0 -3
- package/dist/infrastructure/projection/react/useViewIsCheckoutIntroVisible.js +0 -3
- package/dist/infrastructure/ui/components/atoms/spiner/Spinner.js +0 -11
- package/dist/infrastructure/ui/test/render.d.ts +0 -19
- package/dist/infrastructure/ui/test/render.js +0 -14
- package/jest.config.js +0 -9
- package/jest.setup.js +0 -3
- package/src/Expo.tsx +0 -59
- package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -26
- package/src/domain/checkoutBooking/command/bookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -27
- package/src/domain/checkoutBooking/model/checkoutBooking.test.ts +0 -30
- package/src/domain/checkoutBooking/model/checkoutBooking.ts +0 -31
- package/src/domain/checkoutBooking/model/checkoutBookingBooked.test.ts +0 -23
- package/src/domain/checkoutBooking/model/checkoutBookingBooked.ts +0 -23
- package/src/domain/checkoutBooking/model/checkoutBookings.ts +0 -6
- package/src/domain/uiSetting/command/updateUiSetting.test.ts +0 -19
- package/src/domain/uiSetting/command/updateUiSetting.ts +0 -23
- package/src/domain/uiSetting/model/uiSetting.test.ts +0 -26
- package/src/domain/uiSetting/model/uiSetting.ts +0 -22
- package/src/domain/uiSetting/model/uiSettingUpdated.test.ts +0 -17
- package/src/domain/uiSetting/model/uiSettingUpdated.ts +0 -19
- package/src/domain/uiSetting/model/uiSettings.ts +0 -6
- package/src/index.ts +0 -44
- package/src/infrastructure/delivery/_mock/bootstrap.mock.ts +0 -38
- package/src/infrastructure/delivery/_mock/checkout.mock.ts +0 -81
- package/src/infrastructure/delivery/bootstrap.ts +0 -42
- package/src/infrastructure/delivery/http/fetchHttpClient.test.ts +0 -51
- package/src/infrastructure/delivery/http/fetchHttpClient.ts +0 -41
- package/src/infrastructure/delivery/http/httpClient.ts +0 -18
- package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.test.ts +0 -45
- package/src/infrastructure/domain/checkoutBooking/model/httpCheckoutBookings.ts +0 -32
- package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -38
- package/src/infrastructure/domain/react/useBookSizeReplaceableProductVariantsForCheckoutItem.ts +0 -44
- package/src/infrastructure/domain/react/useUpdateUiSetting.test.ts +0 -31
- package/src/infrastructure/domain/react/useUpdateUiSetting.ts +0 -43
- package/src/infrastructure/domain/uiSetting/model/storageUiSettings.test.ts +0 -50
- package/src/infrastructure/domain/uiSetting/model/storageUiSettings.ts +0 -50
- package/src/infrastructure/persistence/asyncStorageStorage.ts +0 -12
- package/src/infrastructure/persistence/storage.ts +0 -7
- package/src/infrastructure/persistence/uiSettingData.ts +0 -5
- package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.test.ts +0 -65
- package/src/infrastructure/projection/httpBookedSizeReplaceableProductVariantsForCheckoutItemView.ts +0 -102
- package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.test.ts +0 -99
- package/src/infrastructure/projection/httpFirstAvailableCheckoutByCustomerIdView.ts +0 -128
- package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.test.ts +0 -32
- package/src/infrastructure/projection/httpIsCheckoutEnabledByCustomerIdView.ts +0 -27
- package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -51
- package/src/infrastructure/projection/react/useViewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -25
- package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts +0 -28
- package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.ts +0 -22
- package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.test.ts +0 -44
- package/src/infrastructure/projection/react/useViewIsCheckoutAccessibleByCustomerId.ts +0 -24
- package/src/infrastructure/projection/react/useViewIsCheckoutIntroVisible.ts +0 -5
- package/src/infrastructure/projection/react/useViewUiSettingByKey.test.ts +0 -30
- package/src/infrastructure/projection/react/useViewUiSettingByKey.ts +0 -18
- package/src/infrastructure/projection/storageUiSettingByKeyView.test.ts +0 -32
- package/src/infrastructure/projection/storageUiSettingByKeyView.ts +0 -35
- package/src/infrastructure/ui/Root.tsx +0 -53
- package/src/infrastructure/ui/components/atoms/spiner/Spinner.style.ts +0 -12
- package/src/infrastructure/ui/components/atoms/spiner/Spinner.tsx +0 -35
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.test.tsx +0 -70
- package/src/infrastructure/ui/routing/CheckoutAccessibilityMiddleware.tsx +0 -31
- package/src/infrastructure/ui/routing/CheckoutMiddleware.test.tsx +0 -100
- package/src/infrastructure/ui/routing/CheckoutMiddleware.tsx +0 -52
- package/src/infrastructure/ui/routing/Routing.tsx +0 -64
- package/src/infrastructure/ui/routing/router/Router.native.ts +0 -1
- package/src/infrastructure/ui/routing/router/Router.ts +0 -1
- package/src/infrastructure/ui/routing/routes.ts +0 -6
- package/src/infrastructure/ui/test/render.tsx +0 -47
- package/src/infrastructure/ui/views/intro/Intro.test.tsx +0 -15
- package/src/infrastructure/ui/views/intro/Intro.tsx +0 -27
- package/src/infrastructure/ui/views/item/Item.tsx +0 -31
- package/src/infrastructure/ui/views/summary/Summary.tsx +0 -27
- package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.test.ts +0 -40
- package/src/projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem.ts +0 -85
- package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.test.ts +0 -22
- package/src/projection/checkout/viewFirstAvailableCheckoutByCustomerId.ts +0 -149
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.test.ts +0 -54
- package/src/projection/checkout/viewIsCheckoutAccessibleByCustomerId.ts +0 -46
- package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.test.ts +0 -20
- package/src/projection/checkout/viewIsCheckoutEnabledByCustomerId.ts +0 -51
- package/src/projection/uiSetting/viewUiSettingByKey.test.ts +0 -22
- package/src/projection/uiSetting/viewUiSettingByKey.ts +0 -47
- package/tsconfig.build.json +0 -16
- package/tsconfig.json +0 -19
- package/webpack.config.js +0 -17
- /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.d.ts +0 -0
- /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.style.d.ts +0 -0
- /package/dist/infrastructure/ui/components/atoms/{spiner → spinner}/Spinner.style.js +0 -0
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { v4 as uuid } from "uuid";
|
|
2
|
-
import {
|
|
3
|
-
CheckoutItemStatus,
|
|
4
|
-
CheckoutStatus,
|
|
5
|
-
Currency,
|
|
6
|
-
MediaPerspective,
|
|
7
|
-
} from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
8
|
-
import {
|
|
9
|
-
CheckoutDto,
|
|
10
|
-
httpFirstAvailableCheckoutByCustomerIdView as sut,
|
|
11
|
-
toCheckoutProjection,
|
|
12
|
-
} from "./httpFirstAvailableCheckoutByCustomerIdView";
|
|
13
|
-
|
|
14
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
15
|
-
const checkoutResponse: { result: CheckoutDto } = {
|
|
16
|
-
result: {
|
|
17
|
-
id: uuid(),
|
|
18
|
-
status: CheckoutStatus.STARTED,
|
|
19
|
-
customer_id: uuid(),
|
|
20
|
-
box_id: uuid(),
|
|
21
|
-
booking_id: uuid(),
|
|
22
|
-
expires_on: "2022-09-20",
|
|
23
|
-
items: [
|
|
24
|
-
{
|
|
25
|
-
id: uuid(),
|
|
26
|
-
status: CheckoutItemStatus.KEPT,
|
|
27
|
-
product_variant: {
|
|
28
|
-
id: uuid(),
|
|
29
|
-
media: [
|
|
30
|
-
{
|
|
31
|
-
id: uuid(),
|
|
32
|
-
url: "https://cdn-catalog-back-prod.envs.lookiero.tech/d2/65/d2655b80-7745-4537-bb17-eb38f960a8de.jpg",
|
|
33
|
-
perspective: MediaPerspective.FRONT,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
brand: "CKS",
|
|
37
|
-
name: "Sari Tshirt lines",
|
|
38
|
-
price: {
|
|
39
|
-
amount: 3999,
|
|
40
|
-
currency: Currency.EUR,
|
|
41
|
-
},
|
|
42
|
-
size: {
|
|
43
|
-
id: uuid(),
|
|
44
|
-
lookiero: "M",
|
|
45
|
-
uk: "M",
|
|
46
|
-
it: "M",
|
|
47
|
-
europe: "M",
|
|
48
|
-
unique: false,
|
|
49
|
-
},
|
|
50
|
-
color: {
|
|
51
|
-
id: uuid(),
|
|
52
|
-
label: "black_C2",
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
const checkoutResponseOk: Response = {
|
|
60
|
-
ok: true,
|
|
61
|
-
status: 200,
|
|
62
|
-
json: () => Promise.resolve(checkoutResponse),
|
|
63
|
-
} as Response;
|
|
64
|
-
const checkoutResponseNotFound: Response = {
|
|
65
|
-
ok: false,
|
|
66
|
-
status: 404,
|
|
67
|
-
} as Response;
|
|
68
|
-
const checkoutResponseError: Response = {
|
|
69
|
-
ok: false,
|
|
70
|
-
} as Response;
|
|
71
|
-
|
|
72
|
-
const httpPostMock = jest.fn();
|
|
73
|
-
const view = sut({ httpPost: httpPostMock });
|
|
74
|
-
|
|
75
|
-
describe("httpFirstAvailableCheckoutByCustomerIdView", () => {
|
|
76
|
-
it("returns a Checkout projection for a 200 response", async () => {
|
|
77
|
-
httpPostMock.mockReturnValue(Promise.resolve(checkoutResponseOk));
|
|
78
|
-
|
|
79
|
-
const returnedCheckout = await view({ customerId });
|
|
80
|
-
|
|
81
|
-
expect(returnedCheckout).toStrictEqual(toCheckoutProjection(checkoutResponse.result));
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("returns undefined for a 404 response", async () => {
|
|
85
|
-
httpPostMock.mockReturnValue(Promise.resolve(checkoutResponseNotFound));
|
|
86
|
-
|
|
87
|
-
const returnedCheckout = await view({ customerId });
|
|
88
|
-
|
|
89
|
-
expect(returnedCheckout).toBeUndefined();
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("returns undefined for a non successfull response", async () => {
|
|
93
|
-
httpPostMock.mockReturnValue(Promise.resolve(checkoutResponseError));
|
|
94
|
-
|
|
95
|
-
const returnedCheckout = await view({ customerId });
|
|
96
|
-
|
|
97
|
-
expect(returnedCheckout).toBeUndefined();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CheckoutItemStatus,
|
|
3
|
-
CheckoutProjection,
|
|
4
|
-
CheckoutStatus,
|
|
5
|
-
Currency,
|
|
6
|
-
FirstAvailableCheckoutByCustomerIdView,
|
|
7
|
-
MediaPerspective,
|
|
8
|
-
} from "../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
9
|
-
import { HttpPostFunction } from "../delivery/http/httpClient";
|
|
10
|
-
|
|
11
|
-
interface CheckoutDto {
|
|
12
|
-
readonly id: string;
|
|
13
|
-
readonly customer_id: string;
|
|
14
|
-
readonly box_id: string;
|
|
15
|
-
readonly booking_id: string;
|
|
16
|
-
readonly status: CheckoutStatus;
|
|
17
|
-
readonly expires_on: string;
|
|
18
|
-
readonly items: {
|
|
19
|
-
readonly id: string;
|
|
20
|
-
readonly status: CheckoutItemStatus;
|
|
21
|
-
readonly product_variant: {
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly media: {
|
|
24
|
-
readonly id: string;
|
|
25
|
-
readonly url: string;
|
|
26
|
-
readonly perspective: MediaPerspective;
|
|
27
|
-
}[];
|
|
28
|
-
readonly brand: string;
|
|
29
|
-
readonly name: string;
|
|
30
|
-
readonly price: {
|
|
31
|
-
readonly amount: number;
|
|
32
|
-
readonly currency: Currency;
|
|
33
|
-
readonly discounted_price?: {
|
|
34
|
-
readonly amount: number;
|
|
35
|
-
readonly percentage: number;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
readonly size: {
|
|
39
|
-
readonly id: string;
|
|
40
|
-
readonly lookiero: string;
|
|
41
|
-
readonly uk: string;
|
|
42
|
-
readonly it: string;
|
|
43
|
-
readonly europe: string;
|
|
44
|
-
readonly unique: boolean;
|
|
45
|
-
readonly visual_order?: number;
|
|
46
|
-
};
|
|
47
|
-
readonly color: {
|
|
48
|
-
readonly id: string;
|
|
49
|
-
readonly label: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
readonly replaced_for?: string;
|
|
53
|
-
}[];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
interface ToCheckoutProjectionFunction {
|
|
57
|
-
(checkoutDto: CheckoutDto): CheckoutProjection;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const toCheckoutProjection: ToCheckoutProjectionFunction = (checkoutDto) => ({
|
|
61
|
-
id: checkoutDto.id,
|
|
62
|
-
customerId: checkoutDto.customer_id,
|
|
63
|
-
boxId: checkoutDto.box_id,
|
|
64
|
-
bookingId: checkoutDto.booking_id,
|
|
65
|
-
status: checkoutDto.status,
|
|
66
|
-
expiresOn: new Date(checkoutDto.expires_on),
|
|
67
|
-
items: checkoutDto.items.map((item) => ({
|
|
68
|
-
id: item.id,
|
|
69
|
-
status: item.status,
|
|
70
|
-
replacedFor: item.replaced_for,
|
|
71
|
-
productVariant: {
|
|
72
|
-
id: item.product_variant.id,
|
|
73
|
-
media: item.product_variant.media.map((media) => ({
|
|
74
|
-
id: media.id,
|
|
75
|
-
url: media.url,
|
|
76
|
-
perspective: media.perspective,
|
|
77
|
-
})),
|
|
78
|
-
brand: item.product_variant.brand,
|
|
79
|
-
name: item.product_variant.name,
|
|
80
|
-
price: {
|
|
81
|
-
amount: item.product_variant.price.amount,
|
|
82
|
-
currency: item.product_variant.price.currency,
|
|
83
|
-
discountedPrice: item.product_variant.price.discounted_price
|
|
84
|
-
? {
|
|
85
|
-
amount: item.product_variant.price.discounted_price.amount,
|
|
86
|
-
percentage: item.product_variant.price.discounted_price.percentage,
|
|
87
|
-
}
|
|
88
|
-
: undefined,
|
|
89
|
-
},
|
|
90
|
-
size: {
|
|
91
|
-
id: item.product_variant.size.id,
|
|
92
|
-
lookiero: item.product_variant.size.lookiero,
|
|
93
|
-
uk: item.product_variant.size.uk,
|
|
94
|
-
it: item.product_variant.size.it,
|
|
95
|
-
europe: item.product_variant.size.europe,
|
|
96
|
-
unique: item.product_variant.size.unique,
|
|
97
|
-
visualOrder: item.product_variant.size.visual_order,
|
|
98
|
-
},
|
|
99
|
-
color: {
|
|
100
|
-
id: item.product_variant.color.id,
|
|
101
|
-
label: item.product_variant.color.label,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
})),
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
interface HttpFirstAvailableCheckoutByCustomerIdView extends FirstAvailableCheckoutByCustomerIdView {}
|
|
108
|
-
|
|
109
|
-
interface HttpFirstAvailableCheckoutByCustomerIdViewFunctionArgs {
|
|
110
|
-
readonly httpPost: HttpPostFunction;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
interface HttpFirstAvailableCheckoutByCustomerIdViewFunction {
|
|
114
|
-
(args: HttpFirstAvailableCheckoutByCustomerIdViewFunctionArgs): HttpFirstAvailableCheckoutByCustomerIdView;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const httpFirstAvailableCheckoutByCustomerIdView: HttpFirstAvailableCheckoutByCustomerIdViewFunction =
|
|
118
|
-
({ httpPost }) =>
|
|
119
|
-
async ({ customerId }): Promise<CheckoutProjection | undefined> => {
|
|
120
|
-
const response = await httpPost({
|
|
121
|
-
endpoint: "/view-first-available-checkout-by-customer-id",
|
|
122
|
-
body: { customer_id: customerId },
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
return !response.ok || response.status === 404 ? undefined : toCheckoutProjection((await response.json()).result);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export { CheckoutDto, toCheckoutProjection, httpFirstAvailableCheckoutByCustomerIdView };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { httpIsCheckoutEnabledByCustomerIdView as sut } from "./httpIsCheckoutEnabledByCustomerIdView";
|
|
2
|
-
|
|
3
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
4
|
-
const checkoutResponseOk: Response = {
|
|
5
|
-
ok: true,
|
|
6
|
-
status: 200,
|
|
7
|
-
json: () => Promise.resolve(true),
|
|
8
|
-
} as Response;
|
|
9
|
-
const checkoutResponseError: Response = {
|
|
10
|
-
ok: false,
|
|
11
|
-
} as Response;
|
|
12
|
-
|
|
13
|
-
const httpGetMock = jest.fn();
|
|
14
|
-
const view = sut({ httpGet: httpGetMock });
|
|
15
|
-
|
|
16
|
-
describe("httpIsCheckoutEnabledByCustomerIdView", () => {
|
|
17
|
-
it("returns true/false if enabled/not for a 200 response", async () => {
|
|
18
|
-
httpGetMock.mockReturnValue(Promise.resolve(checkoutResponseOk));
|
|
19
|
-
|
|
20
|
-
const enabled = await view({ customerId });
|
|
21
|
-
|
|
22
|
-
expect(enabled).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("returns false for a non successfull response", async () => {
|
|
26
|
-
httpGetMock.mockReturnValue(Promise.resolve(checkoutResponseError));
|
|
27
|
-
|
|
28
|
-
const enabled = await view({ customerId });
|
|
29
|
-
|
|
30
|
-
expect(enabled).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IsCheckoutEnabledByCustomerIdProjection,
|
|
3
|
-
IsCheckoutEnabledByCustomerIdView,
|
|
4
|
-
} from "../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
5
|
-
import { HttpGetFunction } from "../delivery/http/httpClient";
|
|
6
|
-
|
|
7
|
-
interface HttpIsCheckoutEnabledByCustomerIdView extends IsCheckoutEnabledByCustomerIdView {}
|
|
8
|
-
|
|
9
|
-
interface HttpIsCheckoutEnabledByCustomerIdViewFunctionArgs {
|
|
10
|
-
readonly httpGet: HttpGetFunction;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface HttpIsCheckoutEnabledByCustomerIdViewFunction {
|
|
14
|
-
(args: HttpIsCheckoutEnabledByCustomerIdViewFunctionArgs): HttpIsCheckoutEnabledByCustomerIdView;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const httpIsCheckoutEnabledByCustomerIdView: HttpIsCheckoutEnabledByCustomerIdViewFunction =
|
|
18
|
-
({ httpGet }) =>
|
|
19
|
-
async ({ customerId }): Promise<IsCheckoutEnabledByCustomerIdProjection> => {
|
|
20
|
-
const response = await httpGet({
|
|
21
|
-
endpoint: `/is-new-checkout-enabled/${customerId}`,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return !response.ok ? false : await response.json();
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { httpIsCheckoutEnabledByCustomerIdView };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { bootstrap } from "@lookiero/messaging-react";
|
|
2
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
3
|
-
import {
|
|
4
|
-
BookedSizeReplaceableProductVariantsProjection,
|
|
5
|
-
viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler,
|
|
6
|
-
VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM,
|
|
7
|
-
} from "../../../projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem";
|
|
8
|
-
import { useViewBookedSizeReplaceableProductVariantsForCheckoutItem } from "./useViewBookedSizeReplaceableProductVariantsForCheckoutItem";
|
|
9
|
-
|
|
10
|
-
const checkoutItemId = "6f720954-8039-4bed-9596-34fc5a02131b";
|
|
11
|
-
const bookedSizeReplaceableProductVariants: BookedSizeReplaceableProductVariantsProjection = {
|
|
12
|
-
booking: "b00e2c2d-7d9c-4808-88a4-e1c845ae6889",
|
|
13
|
-
productVariants: [
|
|
14
|
-
{
|
|
15
|
-
id: "383fab95-56eb-4639-bb18-530ab792b4d3",
|
|
16
|
-
size: {
|
|
17
|
-
id: "4f8a26b8-8d2d-4012-b49a-7d2820095598",
|
|
18
|
-
europe: { size: "36", format: "36" },
|
|
19
|
-
lookiero: { size: "S", format: "S" },
|
|
20
|
-
uk: { size: "8", format: "8" },
|
|
21
|
-
it: { size: "M", format: "M" },
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
const view = jest.fn().mockReturnValue(bookedSizeReplaceableProductVariants);
|
|
27
|
-
const { Component: Messaging } = bootstrap({ id: "Checkout" })
|
|
28
|
-
.query(
|
|
29
|
-
VIEW_BOOKED_SIZE_REPLACEABLE_PRODUCT_VARIANTS_FOR_CHECKOUT_ITEM,
|
|
30
|
-
viewBookedSizeReplaceableProductVariantsForCheckoutItemHandler,
|
|
31
|
-
{
|
|
32
|
-
view,
|
|
33
|
-
},
|
|
34
|
-
)
|
|
35
|
-
.build();
|
|
36
|
-
|
|
37
|
-
describe("useViewBookedSizeReplaceableProductVariantsForCheckoutItem integration hook", () => {
|
|
38
|
-
it("returns success as the query status and the result itself after rendering the hook", async () => {
|
|
39
|
-
const { result, waitFor } = renderHook(
|
|
40
|
-
() => useViewBookedSizeReplaceableProductVariantsForCheckoutItem({ checkoutItemId }),
|
|
41
|
-
{ wrapper: Messaging },
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
await waitFor(() => {
|
|
45
|
-
const [projection, status] = result.current;
|
|
46
|
-
|
|
47
|
-
expect(projection).toStrictEqual(bookedSizeReplaceableProductVariants);
|
|
48
|
-
expect(status).toBe("success");
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
-
import {
|
|
3
|
-
BookedSizeReplaceableProductVariantsProjection,
|
|
4
|
-
viewBookedSizeReplaceableProductVariantsForCheckoutItem,
|
|
5
|
-
} from "../../../projection/bookedSizeReplaceableProductVariants/viewBookedSizeReplaceableProductVariantsForCheckoutItem";
|
|
6
|
-
|
|
7
|
-
interface UseViewBookedSizeReplaceableProductVariantsForCheckoutItemFunctionArgs {
|
|
8
|
-
readonly checkoutItemId: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface UseViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction {
|
|
12
|
-
(
|
|
13
|
-
args: UseViewBookedSizeReplaceableProductVariantsForCheckoutItemFunctionArgs,
|
|
14
|
-
): UseQueryFunctionResult<BookedSizeReplaceableProductVariantsProjection>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const useViewBookedSizeReplaceableProductVariantsForCheckoutItem: UseViewBookedSizeReplaceableProductVariantsForCheckoutItemFunction =
|
|
18
|
-
({ checkoutItemId }) =>
|
|
19
|
-
useQuery({
|
|
20
|
-
query: viewBookedSizeReplaceableProductVariantsForCheckoutItem({ checkoutItemId }),
|
|
21
|
-
contextId: "Checkout",
|
|
22
|
-
options: { staleTime: Infinity },
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
export { useViewBookedSizeReplaceableProductVariantsForCheckoutItem };
|
package/src/infrastructure/projection/react/useViewFirstAvailableCheckoutByCustomerId.test.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { bootstrap } from "@lookiero/messaging-react";
|
|
2
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
3
|
-
import {
|
|
4
|
-
CheckoutProjection,
|
|
5
|
-
viewFirstAvailableCheckoutByCustomerIdHandler,
|
|
6
|
-
VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
|
|
7
|
-
} from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
8
|
-
import { useViewFirstAvailableCheckoutByCustomerId as sut } from "./useViewFirstAvailableCheckoutByCustomerId";
|
|
9
|
-
|
|
10
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
11
|
-
const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" };
|
|
12
|
-
const view = jest.fn().mockReturnValue(checkoutProjection);
|
|
13
|
-
const { Component: Messaging } = bootstrap({ id: "Checkout" })
|
|
14
|
-
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, { view })
|
|
15
|
-
.build();
|
|
16
|
-
|
|
17
|
-
describe("useViewFirstAvailableCheckoutByCustomerId integration hook", () => {
|
|
18
|
-
it("returns success as the query status and the result itself after rendering the hook", async () => {
|
|
19
|
-
const { result, waitFor } = renderHook(() => sut({ customerId }), { wrapper: Messaging });
|
|
20
|
-
|
|
21
|
-
await waitFor(() => {
|
|
22
|
-
const [projection, status] = result.current;
|
|
23
|
-
|
|
24
|
-
expect(projection).toStrictEqual(checkoutProjection);
|
|
25
|
-
expect(status).toBe("success");
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
-
import {
|
|
3
|
-
CheckoutProjection,
|
|
4
|
-
viewFirstAvailableCheckoutByCustomerId,
|
|
5
|
-
} from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
6
|
-
|
|
7
|
-
interface UseViewFirstAvailableCheckoutByCustomerIdFunctionArgs {
|
|
8
|
-
readonly customerId: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface UseViewFirstAvailableCheckoutByCustomerIdFunction {
|
|
12
|
-
(args: UseViewFirstAvailableCheckoutByCustomerIdFunctionArgs): UseQueryFunctionResult<CheckoutProjection>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const useViewFirstAvailableCheckoutByCustomerId: UseViewFirstAvailableCheckoutByCustomerIdFunction = ({ customerId }) =>
|
|
16
|
-
useQuery({
|
|
17
|
-
query: viewFirstAvailableCheckoutByCustomerId({ customerId }),
|
|
18
|
-
contextId: "Checkout",
|
|
19
|
-
options: { staleTime: Infinity, retry: false },
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export { useViewFirstAvailableCheckoutByCustomerId };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { bootstrap } from "@lookiero/messaging-react";
|
|
2
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
3
|
-
import {
|
|
4
|
-
CheckoutProjection,
|
|
5
|
-
viewFirstAvailableCheckoutByCustomerIdHandler,
|
|
6
|
-
VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID,
|
|
7
|
-
} from "../../../projection/checkout/viewFirstAvailableCheckoutByCustomerId";
|
|
8
|
-
import {
|
|
9
|
-
viewIsCheckoutAccessibleByCustomerIdHandler,
|
|
10
|
-
VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID,
|
|
11
|
-
} from "../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
12
|
-
import {
|
|
13
|
-
viewIsCheckoutEnabledByCustomerIdHandler,
|
|
14
|
-
VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID,
|
|
15
|
-
} from "../../../projection/checkout/viewIsCheckoutEnabledByCustomerId";
|
|
16
|
-
import { useViewIsCheckoutAccessibleByCustomerId as sut } from "./useViewIsCheckoutAccessibleByCustomerId";
|
|
17
|
-
|
|
18
|
-
const customerId = "29790d24-b139-4ab8-b618-d796d101e974";
|
|
19
|
-
const checkoutProjection: CheckoutProjection = { id: "75574065-5838-42de-9924-c712f7854347" };
|
|
20
|
-
const firstAvailableCheckoutByCustomerIdViewMock = jest.fn().mockReturnValue(checkoutProjection);
|
|
21
|
-
const isCheckoutAccessibleByCustomerIdViewMock = jest.fn().mockReturnValue(checkoutProjection);
|
|
22
|
-
|
|
23
|
-
const { Component: Messaging } = bootstrap({ id: "Checkout" })
|
|
24
|
-
.query(VIEW_FIRST_AVAILABLE_CHECKOUT_BY_CUSTOMER_ID, viewFirstAvailableCheckoutByCustomerIdHandler, {
|
|
25
|
-
view: firstAvailableCheckoutByCustomerIdViewMock,
|
|
26
|
-
})
|
|
27
|
-
.query(VIEW_IS_CHECKOUT_ENABLED_BY_CUSTOMER_ID, viewIsCheckoutEnabledByCustomerIdHandler, {
|
|
28
|
-
view: isCheckoutAccessibleByCustomerIdViewMock,
|
|
29
|
-
})
|
|
30
|
-
.query(VIEW_IS_CHECKOUT_ACCESSIBLE_BY_CUSTOMER_ID, viewIsCheckoutAccessibleByCustomerIdHandler, {})
|
|
31
|
-
.build();
|
|
32
|
-
|
|
33
|
-
describe("useViewIsCheckoutAccessibleByCustomerId integration hook", () => {
|
|
34
|
-
it("returns success as the query status and the result itself after rendering the hook", async () => {
|
|
35
|
-
const { result, waitFor } = renderHook(() => sut({ customerId }), { wrapper: Messaging });
|
|
36
|
-
|
|
37
|
-
await waitFor(() => {
|
|
38
|
-
const [projection, status] = result.current;
|
|
39
|
-
|
|
40
|
-
expect(projection).toBe(true);
|
|
41
|
-
expect(status).toBe("success");
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
-
import {
|
|
3
|
-
IsCheckoutAccessibleByCustomerIdProjection,
|
|
4
|
-
viewIsCheckoutAccessibleByCustomerId,
|
|
5
|
-
} from "../../../projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
6
|
-
|
|
7
|
-
interface UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs {
|
|
8
|
-
readonly customerId: string | undefined;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface UseViewIsCheckoutAccessibleByCustomerIdFunction {
|
|
12
|
-
(
|
|
13
|
-
args: UseViewIsCheckoutAccessibleByCustomerIdFunctionArgs,
|
|
14
|
-
): UseQueryFunctionResult<IsCheckoutAccessibleByCustomerIdProjection>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const useViewIsCheckoutAccessibleByCustomerId: UseViewIsCheckoutAccessibleByCustomerIdFunction = ({ customerId }) =>
|
|
18
|
-
useQuery({
|
|
19
|
-
query: viewIsCheckoutAccessibleByCustomerId({ customerId }),
|
|
20
|
-
contextId: "Checkout",
|
|
21
|
-
options: { staleTime: Infinity },
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export { useViewIsCheckoutAccessibleByCustomerId };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { bootstrap } from "@lookiero/messaging-react";
|
|
2
|
-
import { renderHook } from "@testing-library/react-hooks";
|
|
3
|
-
import {
|
|
4
|
-
UiSettingProjection,
|
|
5
|
-
viewUiSettingByKeyHandler,
|
|
6
|
-
VIEW_UI_SETTING_BY_KEY,
|
|
7
|
-
} from "../../../projection/uiSetting/viewUiSettingByKey";
|
|
8
|
-
import { useViewUiSettingByKey as sut } from "./useViewUiSettingByKey";
|
|
9
|
-
|
|
10
|
-
const uiSettingKey = "ui_setting_key";
|
|
11
|
-
const uiSettingProjection: UiSettingProjection = {
|
|
12
|
-
id: "this-should-be-a-uuid",
|
|
13
|
-
key: uiSettingKey,
|
|
14
|
-
value: "ui_setting_value",
|
|
15
|
-
};
|
|
16
|
-
const view = jest.fn().mockReturnValue(uiSettingProjection);
|
|
17
|
-
const { Component: Messaging } = bootstrap().query(VIEW_UI_SETTING_BY_KEY, viewUiSettingByKeyHandler, { view }).build();
|
|
18
|
-
|
|
19
|
-
describe("useViewUiSettingByKey integration hook", () => {
|
|
20
|
-
it("returns success as the query status and the result itself after rendering the hook", async () => {
|
|
21
|
-
const { result, waitFor } = renderHook(() => sut({ uiSettingKey }), { wrapper: Messaging });
|
|
22
|
-
|
|
23
|
-
await waitFor(() => {
|
|
24
|
-
const [projection, status] = result.current;
|
|
25
|
-
|
|
26
|
-
expect(projection).toStrictEqual(uiSettingProjection);
|
|
27
|
-
expect(status).toBe("success");
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { useQuery, UseQueryFunctionResult } from "@lookiero/messaging-react";
|
|
2
|
-
import { uiSettingUpdated } from "../../../domain/uiSetting/model/uiSettingUpdated";
|
|
3
|
-
import { UiSettingProjection, viewUiSettingByKey } from "../../../projection/uiSetting/viewUiSettingByKey";
|
|
4
|
-
|
|
5
|
-
interface UseViewUiSettingByKeyFunctionArgs {
|
|
6
|
-
readonly uiSettingKey: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface UseViewUiSettingByKeyFunction {
|
|
10
|
-
(args: UseViewUiSettingByKeyFunctionArgs): UseQueryFunctionResult<UiSettingProjection>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const useViewUiSettingByKey: UseViewUiSettingByKeyFunction = ({ uiSettingKey }) =>
|
|
14
|
-
useQuery({
|
|
15
|
-
query: viewUiSettingByKey({ key: uiSettingKey }),
|
|
16
|
-
invalidation: (event) => event instanceof uiSettingUpdated,
|
|
17
|
-
options: { staleTime: Infinity },
|
|
18
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { UiSettingDto } from "../persistence/uiSettingData";
|
|
2
|
-
import { storageUiSettingByKeyView as sut } from "./storageUiSettingByKeyView";
|
|
3
|
-
|
|
4
|
-
const uiSettingKey = "ui_setting_key";
|
|
5
|
-
const uiSetting: UiSettingDto = { id: "this-should-be-a-uuid", key: uiSettingKey, value: "ui_setting_value" };
|
|
6
|
-
|
|
7
|
-
const readMock = jest.fn();
|
|
8
|
-
const view = sut({ read: readMock });
|
|
9
|
-
|
|
10
|
-
describe("storageUiSettingByKeyView", () => {
|
|
11
|
-
it("returns a UiSetting projection", async () => {
|
|
12
|
-
readMock.mockReturnValue(Promise.resolve(uiSetting));
|
|
13
|
-
|
|
14
|
-
const returnedUiSetting = await view({ key: uiSettingKey });
|
|
15
|
-
|
|
16
|
-
expect(returnedUiSetting).toStrictEqual(uiSetting);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it("returns undefined when ui setting key does not exist", async () => {
|
|
20
|
-
readMock.mockReturnValue(Promise.resolve(undefined));
|
|
21
|
-
|
|
22
|
-
const returnedUiSetting = await view({ key: uiSettingKey });
|
|
23
|
-
|
|
24
|
-
expect(returnedUiSetting).toBeUndefined();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("throws for an unsuccessfull response", async () => {
|
|
28
|
-
readMock.mockRejectedValue("error");
|
|
29
|
-
|
|
30
|
-
await expect(view({ key: uiSettingKey })).rejects.toThrow();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { UiSettingByKeyView, UiSettingProjection } from "../../projection/uiSetting/viewUiSettingByKey";
|
|
2
|
-
import { ReadFunction } from "../persistence/storage";
|
|
3
|
-
import { UiSettingDto } from "../persistence/uiSettingData";
|
|
4
|
-
|
|
5
|
-
interface ToUiSettingProjectionFunction {
|
|
6
|
-
(uiSettingDto: UiSettingDto): UiSettingProjection;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const toUiSettingProjection: ToUiSettingProjectionFunction = (uiSettingDto) => ({
|
|
10
|
-
id: uiSettingDto.id,
|
|
11
|
-
key: uiSettingDto.key,
|
|
12
|
-
value: uiSettingDto.value,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
interface StorageUiSettingByKeyView extends UiSettingByKeyView {}
|
|
16
|
-
|
|
17
|
-
interface StorageUiSettingByKeyViewFunctionArgs {
|
|
18
|
-
readonly read: ReadFunction<UiSettingDto>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface StorageUiSettingByKeyViewFunction {
|
|
22
|
-
(args: StorageUiSettingByKeyViewFunctionArgs): StorageUiSettingByKeyView;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const storageUiSettingByKeyView: StorageUiSettingByKeyViewFunction =
|
|
26
|
-
({ read }) =>
|
|
27
|
-
async ({ key }) => {
|
|
28
|
-
try {
|
|
29
|
-
const uiSettingDto = await read(key);
|
|
30
|
-
|
|
31
|
-
return uiSettingDto ? toUiSettingProjection(uiSettingDto) : undefined;
|
|
32
|
-
} catch (ignored) {
|
|
33
|
-
throw new Error("Could not fetch the uiSetting");
|
|
34
|
-
}
|
|
35
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { inMemoryFetchTranslation } from "@lookiero/i18n";
|
|
2
|
-
import { ReactIntl } from "@lookiero/i18n-react";
|
|
3
|
-
import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
4
|
-
import { FC, useCallback } from "react";
|
|
5
|
-
import { Platform } from "react-native";
|
|
6
|
-
import { Spinner } from "./components/atoms/spiner/Spinner";
|
|
7
|
-
import { Router } from "./routing/router/Router";
|
|
8
|
-
import { Routing } from "./routing/Routing";
|
|
9
|
-
|
|
10
|
-
const translationData: Record<string, Record<string, string>> = {
|
|
11
|
-
en: { intro: "Intro view's title" },
|
|
12
|
-
es: { intro: "Título de la vista Intro" },
|
|
13
|
-
};
|
|
14
|
-
const fetchTranslation = inMemoryFetchTranslation({ translationData });
|
|
15
|
-
|
|
16
|
-
interface RootFunctionArgs {
|
|
17
|
-
readonly Messaging: MessagingRoot;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface RootFunction {
|
|
21
|
-
(args: RootFunctionArgs): FC<RootProps>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface RootProps {
|
|
25
|
-
readonly locale?: string;
|
|
26
|
-
readonly customerId: string | undefined;
|
|
27
|
-
readonly onNotAccessible: () => void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const root: RootFunction =
|
|
31
|
-
({ Messaging }) =>
|
|
32
|
-
// eslint-disable-next-line react/display-name, react/prop-types
|
|
33
|
-
({ locale = "en", customerId, onNotAccessible }) => {
|
|
34
|
-
const handleOnI18nError = useCallback(() => void 0, []);
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<ReactIntl.I18n
|
|
38
|
-
locale={locale}
|
|
39
|
-
fetchTranslation={fetchTranslation}
|
|
40
|
-
loader={<Spinner />}
|
|
41
|
-
onError={handleOnI18nError}
|
|
42
|
-
contextId="CheckoutI18n"
|
|
43
|
-
>
|
|
44
|
-
<Messaging includeReactQueryDevTools={Platform.OS === "web"}>
|
|
45
|
-
<Router>
|
|
46
|
-
<Routing customerId={customerId} onNotAccessible={onNotAccessible} />
|
|
47
|
-
</Router>
|
|
48
|
-
</Messaging>
|
|
49
|
-
</ReactIntl.I18n>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export { RootProps, root };
|