@lookiero/checkout 0.8.14-beta.0 → 0.8.14-patch.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/domain/checkout/event/createModalNotificationWhenCheckoutSubmitted.d.ts +7 -0
- package/dist/domain/checkout/event/createModalNotificationWhenCheckoutSubmitted.js +12 -0
- package/dist/domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired.d.ts +7 -0
- package/dist/domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired.js +13 -0
- package/dist/domain/checkoutItem/event/createModalNotificationWhenCheckoutItemReplaced.d.ts +7 -0
- package/dist/domain/checkoutItem/event/createModalNotificationWhenCheckoutItemReplaced.js +12 -0
- package/dist/index.d.ts +3 -3
- package/dist/infrastructure/delivery/bootstrap.d.ts +1 -1
- package/dist/infrastructure/delivery/http/fetchHttpClient.d.ts +1 -1
- package/dist/infrastructure/delivery/http/fetchHttpClient.js +2 -2
- package/dist/infrastructure/ui/Root.d.ts +2 -2
- package/dist/projection/shared/locale.d.ts +11 -0
- package/dist/projection/shared/locale.js +12 -0
- package/dist/shared/logging/SentryLogger.d.ts +5 -2
- package/dist/shared/logging/SentryLogger.js +3 -2
- package/dist/shared/notifications/domain/notification/command/createModalNotification.d.ts +18 -0
- package/dist/shared/notifications/domain/notification/command/createModalNotification.js +9 -0
- package/dist/shared/notifications/domain/notification/command/createToastNotification.d.ts +18 -0
- package/dist/shared/notifications/domain/notification/command/createToastNotification.js +9 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateModalNotification.d.ts +20 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateModalNotification.js +22 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateToastNotification.d.ts +21 -0
- package/dist/shared/notifications/infrastructure/domain/notification/react/useCreateToastNotification.js +22 -0
- package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.d.ts +10 -0
- package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.js +26 -0
- package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.style.d.ts +16 -0
- package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotificationItem.style.js +19 -0
- package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.d.ts +8 -0
- package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.js +6 -0
- package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.style.d.ts +25 -0
- package/dist/shared/notifications/infrastructure/ui/components/modalNotifications/ModalNotifications.style.js +18 -0
- package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotificationItem.d.ts +12 -0
- package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotificationItem.js +24 -0
- package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.d.ts +9 -0
- package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.js +20 -0
- package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.style.d.ts +36 -0
- package/dist/shared/notifications/infrastructure/ui/components/toastNotifications/ToastNotifications.style.js +31 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProcessManagerFunction } from "@lookiero/messaging";
|
|
2
|
+
import { CheckoutSubmitted } from "../model/checkoutSubmitted";
|
|
3
|
+
declare const CHECKOUT_SUCCESS_NOTIFICATION_ID = "fa25dcdd-9f5d-4760-9e6f-27174205b1fa";
|
|
4
|
+
interface CreateModalNotificationWhenCheckoutSubmittedFunction extends ProcessManagerFunction<CheckoutSubmitted> {
|
|
5
|
+
}
|
|
6
|
+
declare const createModalNotificationWhenCheckoutSubmitted: CreateModalNotificationWhenCheckoutSubmittedFunction;
|
|
7
|
+
export { createModalNotificationWhenCheckoutSubmitted, CHECKOUT_SUCCESS_NOTIFICATION_ID };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { I18nMessages } from "../../../infrastructure/ui/i18n/i18n";
|
|
2
|
+
import { createModalNotification } from "../../../shared/notifications/domain/notification/command/createModalNotification";
|
|
3
|
+
const CHECKOUT_SUCCESS_NOTIFICATION_ID = "fa25dcdd-9f5d-4760-9e6f-27174205b1fa";
|
|
4
|
+
const createModalNotificationWhenCheckoutSubmitted = ({ commandBus }) => async () => {
|
|
5
|
+
await commandBus(createModalNotification({
|
|
6
|
+
aggregateId: CHECKOUT_SUCCESS_NOTIFICATION_ID,
|
|
7
|
+
titleI18nKey: I18nMessages.CHECKOUT_SUCCESS_MODAL_TITLE,
|
|
8
|
+
bodyI18nKey: I18nMessages.CHECKOUT_SUCCESS_MODAL_DESCRIPTION,
|
|
9
|
+
acceptI18nKey: I18nMessages.CHECKOUT_SUCCESS_MODAL_BUTTON,
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
export { createModalNotificationWhenCheckoutSubmitted, CHECKOUT_SUCCESS_NOTIFICATION_ID };
|
package/dist/domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProcessManagerFunction } from "@lookiero/messaging";
|
|
2
|
+
import { CheckoutBookingExpired } from "../model/checkoutBookingExpired";
|
|
3
|
+
declare const CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID = "d423934e-2499-46ab-8cfb-39e1e398237e";
|
|
4
|
+
interface CreateToastNotificationWhenCheckoutBookingExpiredFunction extends ProcessManagerFunction<CheckoutBookingExpired> {
|
|
5
|
+
}
|
|
6
|
+
declare const createToastNotificationWhenCheckoutBookingExpired: CreateToastNotificationWhenCheckoutBookingExpiredFunction;
|
|
7
|
+
export { createToastNotificationWhenCheckoutBookingExpired, CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID };
|
package/dist/domain/checkoutBooking/event/createToastNotificationWhenCheckoutBookingExpired.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { I18nMessages } from "../../../infrastructure/ui/i18n/i18n";
|
|
2
|
+
import { createToastNotification } from "../../../shared/notifications/domain/notification/command/createToastNotification";
|
|
3
|
+
import { NotificationLevel } from "../../../shared/notifications/domain/notification/model/notification";
|
|
4
|
+
const CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID = "d423934e-2499-46ab-8cfb-39e1e398237e";
|
|
5
|
+
const createToastNotificationWhenCheckoutBookingExpired = ({ commandBus }) => async () => {
|
|
6
|
+
await commandBus(createToastNotification({
|
|
7
|
+
aggregateId: CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID,
|
|
8
|
+
level: NotificationLevel.ERROR,
|
|
9
|
+
titleI18nKey: undefined,
|
|
10
|
+
bodyI18nKey: I18nMessages.CHECKOUT_TOAST_BOOKING_EXPIRED,
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
export { createToastNotificationWhenCheckoutBookingExpired, CHECKOUT_BOOKING_EXPIRED_NOTIFICATION_ID };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProcessManagerFunction } from "@lookiero/messaging";
|
|
2
|
+
import { CheckoutItemReplaced } from "../model/checkoutItemReplaced";
|
|
3
|
+
declare const SIZE_CHANGE_NOTIFICATION_ID = "ce89b8b2-e025-4b54-8cdc-52520dc3dd23";
|
|
4
|
+
interface CreateModalNotificationWhenCheckoutItemReplacedFunction extends ProcessManagerFunction<CheckoutItemReplaced> {
|
|
5
|
+
}
|
|
6
|
+
declare const createModalNotificationWhenCheckoutItemReplaced: CreateModalNotificationWhenCheckoutItemReplacedFunction;
|
|
7
|
+
export { createModalNotificationWhenCheckoutItemReplaced, SIZE_CHANGE_NOTIFICATION_ID };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { I18nMessages } from "../../../infrastructure/ui/i18n/i18n";
|
|
2
|
+
import { createModalNotification } from "../../../shared/notifications/domain/notification/command/createModalNotification";
|
|
3
|
+
const SIZE_CHANGE_NOTIFICATION_ID = "ce89b8b2-e025-4b54-8cdc-52520dc3dd23";
|
|
4
|
+
const createModalNotificationWhenCheckoutItemReplaced = ({ commandBus }) => async () => {
|
|
5
|
+
await commandBus(createModalNotification({
|
|
6
|
+
aggregateId: SIZE_CHANGE_NOTIFICATION_ID,
|
|
7
|
+
titleI18nKey: I18nMessages.SIZE_CHANGE_MODAL_TITLE,
|
|
8
|
+
bodyI18nKey: I18nMessages.SIZE_CHANGE_MODAL_DESCRIPTION,
|
|
9
|
+
acceptI18nKey: I18nMessages.SIZE_CHANGE_MODAL_BUTTON,
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
12
|
+
export { createModalNotificationWhenCheckoutItemReplaced, SIZE_CHANGE_NOTIFICATION_ID };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CheckoutStatus } from "./domain/checkout/model/checkout";
|
|
|
4
4
|
import { RootProps } from "./infrastructure/ui/Root";
|
|
5
5
|
import { CheckoutProjection } from "./projection/checkout/checkout";
|
|
6
6
|
import { IsCheckoutAccessibleByCustomerIdProjection } from "./projection/checkout/viewIsCheckoutAccessibleByCustomerId";
|
|
7
|
-
import {
|
|
7
|
+
import { SentryEnvironment } from "./shared/logging/SentryLogger";
|
|
8
8
|
interface IsCheckoutAccessibleFunctionArgs {
|
|
9
9
|
readonly customerId: string | undefined;
|
|
10
10
|
}
|
|
@@ -19,8 +19,8 @@ interface FirstAvailableCheckoutByCustomerIdFunction {
|
|
|
19
19
|
}
|
|
20
20
|
interface BootstrapFunctionArgs {
|
|
21
21
|
readonly getAuthToken: () => Promise<string>;
|
|
22
|
-
readonly apiUrl: string;
|
|
23
|
-
readonly sentry:
|
|
22
|
+
readonly apiUrl: () => string;
|
|
23
|
+
readonly sentry: () => SentryEnvironment;
|
|
24
24
|
readonly translations: EndpointFunction[];
|
|
25
25
|
}
|
|
26
26
|
interface BootstrapFunctionReturn {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BuildBootstrapFunctionReturn } from "@lookiero/messaging-react";
|
|
2
2
|
interface BootstrapFunctionArgs {
|
|
3
3
|
readonly getAuthToken: () => Promise<string>;
|
|
4
|
-
readonly apiUrl: string;
|
|
4
|
+
readonly apiUrl: () => string;
|
|
5
5
|
}
|
|
6
6
|
interface BootstrapFunction {
|
|
7
7
|
(args: BootstrapFunctionArgs): BuildBootstrapFunctionReturn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body, signal, result }) => {
|
|
2
|
-
const response = await fetch(`${apiUrl}${endpoint}`, {
|
|
2
|
+
const response = await fetch(`${apiUrl()}${endpoint}`, {
|
|
3
3
|
method: "POST",
|
|
4
4
|
headers: {
|
|
5
5
|
["Content-Type"]: "application/json",
|
|
@@ -11,7 +11,7 @@ const fetchHttpPost = ({ apiUrl, getAuthToken }) => async ({ endpoint, body, sig
|
|
|
11
11
|
return await processResponse({ response, result });
|
|
12
12
|
};
|
|
13
13
|
const fetchHttpGet = ({ apiUrl, getAuthToken }) => async ({ endpoint, signal, result }) => {
|
|
14
|
-
const response = await fetch(`${apiUrl}${endpoint}`, {
|
|
14
|
+
const response = await fetch(`${apiUrl()}${endpoint}`, {
|
|
15
15
|
method: "GET",
|
|
16
16
|
credentials: "include",
|
|
17
17
|
headers: {
|
|
@@ -3,13 +3,13 @@ import { MessagingRoot } from "@lookiero/messaging-react/bootstrap";
|
|
|
3
3
|
import { ComponentType } from "react";
|
|
4
4
|
import { useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
5
5
|
import { Customer } from "../../projection/shared/customer";
|
|
6
|
-
import {
|
|
6
|
+
import { SentryEnvironment } from "../../shared/logging/SentryLogger";
|
|
7
7
|
import { Menu, TabBar } from "./views/navigation/Navigation";
|
|
8
8
|
interface RootFunctionArgs {
|
|
9
9
|
readonly Messaging: MessagingRoot;
|
|
10
10
|
readonly I18n: I18n;
|
|
11
11
|
readonly development?: boolean;
|
|
12
|
-
readonly sentry:
|
|
12
|
+
readonly sentry: () => SentryEnvironment;
|
|
13
13
|
readonly getAuthToken: () => Promise<string>;
|
|
14
14
|
}
|
|
15
15
|
interface RootFunction {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var Locale;
|
|
2
|
+
(function (Locale) {
|
|
3
|
+
Locale["ES"] = "es";
|
|
4
|
+
Locale["FR"] = "fr";
|
|
5
|
+
Locale["EN"] = "en";
|
|
6
|
+
Locale["IT"] = "it";
|
|
7
|
+
Locale["PT"] = "pt";
|
|
8
|
+
Locale["DE"] = "de";
|
|
9
|
+
Locale["AT"] = "at";
|
|
10
|
+
Locale["NL"] = "nl";
|
|
11
|
+
})(Locale || (Locale = {}));
|
|
12
|
+
export { Locale };
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Platform } from "react-native";
|
|
2
2
|
import { Logger } from "./Logger";
|
|
3
|
-
interface
|
|
3
|
+
interface SentryEnvironment {
|
|
4
4
|
readonly publicKey: string;
|
|
5
5
|
readonly environment: `${typeof Platform.OS}-${"DEV" | "PROD" | "EXPO"}`;
|
|
6
6
|
readonly release: string;
|
|
7
7
|
readonly project: string;
|
|
8
8
|
}
|
|
9
|
+
interface SentryLoggerFunctionArgs {
|
|
10
|
+
(): SentryEnvironment;
|
|
11
|
+
}
|
|
9
12
|
interface SentryLoggerFunction {
|
|
10
13
|
(args: SentryLoggerFunctionArgs): Logger;
|
|
11
14
|
}
|
|
12
15
|
declare const sentryLogger: SentryLoggerFunction;
|
|
13
|
-
export type {
|
|
16
|
+
export type { SentryEnvironment };
|
|
14
17
|
export { sentryLogger };
|
|
@@ -49,12 +49,13 @@ const DENIED_URLS = [
|
|
|
49
49
|
/webappstoolbarba\.texthelp\.com\//i,
|
|
50
50
|
/metrics\.itunes\.apple\.com\.edgesuite\.net\//i,
|
|
51
51
|
];
|
|
52
|
-
const sentryLogger = (
|
|
52
|
+
const sentryLogger = (environment) => {
|
|
53
53
|
let globalHub;
|
|
54
54
|
let currentHub;
|
|
55
55
|
const createHub = () => {
|
|
56
|
+
const { environment: clientEnvironment, release, publicKey, project } = environment();
|
|
56
57
|
const client = new Client({
|
|
57
|
-
environment,
|
|
58
|
+
environment: clientEnvironment,
|
|
58
59
|
release,
|
|
59
60
|
dsn: `https://${publicKey}@o179049.ingest.sentry.io/${project}`,
|
|
60
61
|
integrations: integrations(),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from "@lookiero/messaging";
|
|
2
|
+
import { NotificationType } from "../model/notification";
|
|
3
|
+
declare const CREATE_MODAL_NOTIFICATION = "create_modal_notification";
|
|
4
|
+
interface CreateModalNotificationPayload {
|
|
5
|
+
readonly aggregateId: string;
|
|
6
|
+
readonly bodyI18nKey: string;
|
|
7
|
+
readonly titleI18nKey: string;
|
|
8
|
+
readonly acceptI18nKey: string;
|
|
9
|
+
}
|
|
10
|
+
interface CreateModalNotification extends Command<typeof CREATE_MODAL_NOTIFICATION>, CreateModalNotificationPayload {
|
|
11
|
+
readonly type: NotificationType.MODAL;
|
|
12
|
+
}
|
|
13
|
+
interface CreateModalNotificationFunction {
|
|
14
|
+
(payload: CreateModalNotificationPayload): CreateModalNotification;
|
|
15
|
+
}
|
|
16
|
+
declare const createModalNotification: CreateModalNotificationFunction;
|
|
17
|
+
export type { CreateModalNotification };
|
|
18
|
+
export { CREATE_MODAL_NOTIFICATION, createModalNotification };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { command } from "@lookiero/messaging";
|
|
2
|
+
import { NotificationType } from "../model/notification";
|
|
3
|
+
const CREATE_MODAL_NOTIFICATION = "create_modal_notification";
|
|
4
|
+
const createModalNotification = ({ aggregateId, ...payload }) => ({
|
|
5
|
+
...command({ aggregateId, name: CREATE_MODAL_NOTIFICATION }),
|
|
6
|
+
...payload,
|
|
7
|
+
type: NotificationType.MODAL,
|
|
8
|
+
});
|
|
9
|
+
export { CREATE_MODAL_NOTIFICATION, createModalNotification };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from "@lookiero/messaging";
|
|
2
|
+
import { NotificationLevel, NotificationType } from "../model/notification";
|
|
3
|
+
declare const CREATE_TOAST_NOTIFICATION = "create_toast_notification";
|
|
4
|
+
interface CreateToastNotificationPayload {
|
|
5
|
+
readonly aggregateId: string;
|
|
6
|
+
readonly level: NotificationLevel;
|
|
7
|
+
readonly bodyI18nKey: string;
|
|
8
|
+
readonly titleI18nKey: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
interface CreateToastNotification extends Command<typeof CREATE_TOAST_NOTIFICATION>, CreateToastNotificationPayload {
|
|
11
|
+
readonly type: NotificationType.TOAST;
|
|
12
|
+
}
|
|
13
|
+
interface CreateToastNotificationFunction {
|
|
14
|
+
(payload: CreateToastNotificationPayload): CreateToastNotification;
|
|
15
|
+
}
|
|
16
|
+
declare const createToastNotification: CreateToastNotificationFunction;
|
|
17
|
+
export type { CreateToastNotification };
|
|
18
|
+
export { CREATE_TOAST_NOTIFICATION, createToastNotification };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { command } from "@lookiero/messaging";
|
|
2
|
+
import { NotificationType } from "../model/notification";
|
|
3
|
+
const CREATE_TOAST_NOTIFICATION = "create_toast_notification";
|
|
4
|
+
const createToastNotification = ({ aggregateId, ...payload }) => ({
|
|
5
|
+
...command({ aggregateId, name: CREATE_TOAST_NOTIFICATION }),
|
|
6
|
+
...payload,
|
|
7
|
+
type: NotificationType.TOAST,
|
|
8
|
+
});
|
|
9
|
+
export { CREATE_TOAST_NOTIFICATION, createToastNotification };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../../logging/Logger";
|
|
3
|
+
interface CreateModalNotificationFunctionArgs {
|
|
4
|
+
readonly aggregateId?: string;
|
|
5
|
+
readonly bodyI18nKey: string;
|
|
6
|
+
readonly titleI18nKey: string;
|
|
7
|
+
readonly acceptI18nKey: string;
|
|
8
|
+
}
|
|
9
|
+
interface CreateModalNotificationFunction {
|
|
10
|
+
(args: CreateModalNotificationFunctionArgs): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
interface UseCreateModalNotificationFunctionArgs {
|
|
13
|
+
readonly contextId: string;
|
|
14
|
+
readonly logger: Logger;
|
|
15
|
+
}
|
|
16
|
+
interface UseCreateModalNotificationFunction {
|
|
17
|
+
(args: UseCreateModalNotificationFunctionArgs): [create: CreateModalNotificationFunction, status: CommandStatus];
|
|
18
|
+
}
|
|
19
|
+
declare const useCreateModalNotification: UseCreateModalNotificationFunction;
|
|
20
|
+
export { useCreateModalNotification };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCommand } from "@lookiero/messaging-react";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { v4 as uuid } from "uuid";
|
|
4
|
+
import { createModalNotification } from "../../../../domain/notification/command/createModalNotification";
|
|
5
|
+
const useCreateModalNotification = ({ contextId, logger }) => {
|
|
6
|
+
const [commandBus, status] = useCommand({ contextId });
|
|
7
|
+
const create = useCallback(async ({ aggregateId, titleI18nKey, bodyI18nKey, acceptI18nKey }) => {
|
|
8
|
+
try {
|
|
9
|
+
await commandBus(createModalNotification({
|
|
10
|
+
aggregateId: aggregateId || uuid(),
|
|
11
|
+
titleI18nKey,
|
|
12
|
+
bodyI18nKey,
|
|
13
|
+
acceptI18nKey,
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
logger.captureException(error);
|
|
18
|
+
}
|
|
19
|
+
}, [commandBus, logger]);
|
|
20
|
+
return [create, status];
|
|
21
|
+
};
|
|
22
|
+
export { useCreateModalNotification };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CommandStatus } from "@lookiero/messaging-react";
|
|
2
|
+
import { Logger } from "../../../../../logging/Logger";
|
|
3
|
+
import { NotificationLevel } from "../../../../domain/notification/model/notification";
|
|
4
|
+
interface CreateToastNotificationFunctionArgs {
|
|
5
|
+
readonly aggregateId?: string;
|
|
6
|
+
readonly level: NotificationLevel;
|
|
7
|
+
readonly bodyI18nKey: string;
|
|
8
|
+
readonly titleI18nKey?: string;
|
|
9
|
+
}
|
|
10
|
+
interface CreateToastNotificationFunction {
|
|
11
|
+
(args: CreateToastNotificationFunctionArgs): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
interface UseCreateToastNotificationFunctionArgs {
|
|
14
|
+
readonly contextId: string;
|
|
15
|
+
readonly logger: Logger;
|
|
16
|
+
}
|
|
17
|
+
interface UseCreateToastNotificationFunction {
|
|
18
|
+
(args: UseCreateToastNotificationFunctionArgs): [create: CreateToastNotificationFunction, status: CommandStatus];
|
|
19
|
+
}
|
|
20
|
+
declare const useCreateToastNotification: UseCreateToastNotificationFunction;
|
|
21
|
+
export { useCreateToastNotification };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCommand } from "@lookiero/messaging-react";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { v4 as uuid } from "uuid";
|
|
4
|
+
import { createToastNotification } from "../../../../domain/notification/command/createToastNotification";
|
|
5
|
+
const useCreateToastNotification = ({ contextId, logger }) => {
|
|
6
|
+
const [commandBus, status] = useCommand({ contextId });
|
|
7
|
+
const create = useCallback(async ({ aggregateId, level, titleI18nKey, bodyI18nKey }) => {
|
|
8
|
+
try {
|
|
9
|
+
await commandBus(createToastNotification({
|
|
10
|
+
aggregateId: aggregateId || uuid(),
|
|
11
|
+
level,
|
|
12
|
+
titleI18nKey,
|
|
13
|
+
bodyI18nKey,
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
logger.captureException(error);
|
|
18
|
+
}
|
|
19
|
+
}, [commandBus, logger]);
|
|
20
|
+
return [create, status];
|
|
21
|
+
};
|
|
22
|
+
export { useCreateToastNotification };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ModalNotificationProjection } from "../../../../projection/notification/notification";
|
|
3
|
+
interface ModalNotificationItemProps {
|
|
4
|
+
readonly visible: boolean;
|
|
5
|
+
readonly notification: ModalNotificationProjection;
|
|
6
|
+
readonly onRemove: (notificationId: string) => void;
|
|
7
|
+
readonly testID?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const ModalNotificationItem: FC<ModalNotificationItemProps>;
|
|
10
|
+
export { ModalNotificationItem };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Button } from "@lookiero/aurora-next/build/components/atoms/Button/Button";
|
|
2
|
+
import { Text } from "@lookiero/aurora-next/build/components/primitives/Text/Text";
|
|
3
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { useCallback } from "react";
|
|
6
|
+
import { View } from "react-native";
|
|
7
|
+
import { Modal } from "../../../../../ui/components/layouts/modal/Modal";
|
|
8
|
+
import { style } from "./ModalNotificationItem.style";
|
|
9
|
+
const ModalNotificationItem = ({ visible, notification, onRemove, testID = "modal-notification-item", }) => {
|
|
10
|
+
const titleText = useI18nMessage({ id: notification.titleI18nKey });
|
|
11
|
+
const bodyText = useI18nMessage({ id: notification.bodyI18nKey });
|
|
12
|
+
const acceptText = useI18nMessage({ id: notification.acceptI18nKey });
|
|
13
|
+
const handleOnClose = useCallback(() => onRemove(notification.id), [notification.id, onRemove]);
|
|
14
|
+
return (React.createElement(Modal, { testID: testID, visible: visible, onClose: handleOnClose },
|
|
15
|
+
React.createElement(View, { style: style.modal },
|
|
16
|
+
React.createElement(Text, { level: 1, style: style.modalTitle, body: true }, titleText),
|
|
17
|
+
React.createElement(Text, { level: 3, style: style.modalDescription, body: true }, bodyText),
|
|
18
|
+
React.createElement(Button
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
, {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
style: style.button, onPress: handleOnClose }, acceptText))));
|
|
25
|
+
};
|
|
26
|
+
export { ModalNotificationItem };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../../../infrastructure/ui/theme/theme";
|
|
3
|
+
const { spaceXL } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
button: {
|
|
6
|
+
flex: 0,
|
|
7
|
+
},
|
|
8
|
+
modal: {
|
|
9
|
+
padding: spaceXL,
|
|
10
|
+
},
|
|
11
|
+
modalDescription: {
|
|
12
|
+
marginVertical: spaceXL,
|
|
13
|
+
textAlign: "center",
|
|
14
|
+
},
|
|
15
|
+
modalTitle: {
|
|
16
|
+
textAlign: "center",
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
export { style };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ModalNotificationProjection } from "../../../../projection/notification/notification";
|
|
3
|
+
interface ModalNotificationsProps {
|
|
4
|
+
readonly notifications?: ModalNotificationProjection[];
|
|
5
|
+
readonly onRemove: (notificationId: string) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const ModalNotifications: FC<ModalNotificationsProps>;
|
|
8
|
+
export { ModalNotifications };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { style } from "../toastNotifications/ToastNotifications.style";
|
|
4
|
+
import { ModalNotificationItem } from "./ModalNotificationItem";
|
|
5
|
+
const ModalNotifications = ({ notifications = [], onRemove }) => (React.createElement(View, { pointerEvents: "box-none", style: style.notifications, testID: "modal-notifications" }, notifications.map((notification) => (React.createElement(ModalNotificationItem, { key: notification.id, notification: notification, testID: notification.id, visible: true, onRemove: onRemove })))));
|
|
6
|
+
export { ModalNotifications };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
declare const style: StyleSheet.NamedStyles<any> | StyleSheet.NamedStyles<{
|
|
3
|
+
notifications: {
|
|
4
|
+
flexDirection: "column";
|
|
5
|
+
top: number;
|
|
6
|
+
width: string;
|
|
7
|
+
zIndex: number;
|
|
8
|
+
left: number;
|
|
9
|
+
} | {
|
|
10
|
+
flexDirection: "column";
|
|
11
|
+
top: number;
|
|
12
|
+
width: string;
|
|
13
|
+
zIndex: number;
|
|
14
|
+
position: "fixed";
|
|
15
|
+
left: number;
|
|
16
|
+
} | {
|
|
17
|
+
flexDirection: "column";
|
|
18
|
+
top: number;
|
|
19
|
+
width: string;
|
|
20
|
+
zIndex: number;
|
|
21
|
+
position: "absolute";
|
|
22
|
+
left: number;
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
export { style };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Platform, StyleSheet } from "react-native";
|
|
2
|
+
const style = StyleSheet.create({
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
notifications: {
|
|
6
|
+
left: 0,
|
|
7
|
+
...Platform.select({
|
|
8
|
+
web: { position: "fixed" },
|
|
9
|
+
ios: { position: "absolute" },
|
|
10
|
+
android: { position: "absolute" },
|
|
11
|
+
}),
|
|
12
|
+
flexDirection: "column",
|
|
13
|
+
top: 0,
|
|
14
|
+
width: "100%",
|
|
15
|
+
zIndex: 20,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export { style };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ToastStyle } from "../../../../../ui/components/molecules/toast/Toast";
|
|
3
|
+
import { ToastNotificationProjection } from "../../../../projection/notification/notification";
|
|
4
|
+
interface ToastNotificationItemProps {
|
|
5
|
+
readonly notification: ToastNotificationProjection;
|
|
6
|
+
readonly onRemove: (notificationId: string) => void;
|
|
7
|
+
readonly autoHideTimeout?: number;
|
|
8
|
+
readonly testID?: string;
|
|
9
|
+
readonly style?: ToastStyle;
|
|
10
|
+
}
|
|
11
|
+
declare const ToastNotificationItem: FC<ToastNotificationItemProps>;
|
|
12
|
+
export { ToastNotificationItem };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { useCallback, useEffect } from "react";
|
|
4
|
+
import { Toast, ToastVariant } from "../../../../../ui/components/molecules/toast/Toast";
|
|
5
|
+
import { NotificationLevel } from "../../../../domain/notification/model/notification";
|
|
6
|
+
const toastVariantForNotificationLevel = {
|
|
7
|
+
[NotificationLevel.INFO]: ToastVariant.INFO,
|
|
8
|
+
[NotificationLevel.ERROR]: ToastVariant.ERROR,
|
|
9
|
+
[NotificationLevel.SUCCESS]: ToastVariant.SUCCESS,
|
|
10
|
+
};
|
|
11
|
+
const ToastNotificationItem = ({ notification, onRemove, autoHideTimeout, testID = "toast-notification-item", style: customStyle, }) => {
|
|
12
|
+
const title = useI18nMessage({ id: notification.titleI18nKey }) || undefined;
|
|
13
|
+
const body = useI18nMessage({ id: notification.bodyI18nKey || "" });
|
|
14
|
+
const handleOnClose = useCallback(() => onRemove(notification.id), [notification.id, onRemove]);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!autoHideTimeout) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const hideTimeout = setTimeout(handleOnClose, autoHideTimeout);
|
|
20
|
+
return () => clearTimeout(hideTimeout);
|
|
21
|
+
}, [autoHideTimeout, handleOnClose]);
|
|
22
|
+
return (React.createElement(Toast, { body: body, style: customStyle, testID: testID, title: title, variant: toastVariantForNotificationLevel[notification.level], onClose: handleOnClose }));
|
|
23
|
+
};
|
|
24
|
+
export { ToastNotificationItem };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC } from "react";
|
|
2
|
+
import { ToastNotificationProjection } from "../../../../projection/notification/notification";
|
|
3
|
+
interface ToastNotificationsProps {
|
|
4
|
+
readonly notifications?: ToastNotificationProjection[];
|
|
5
|
+
readonly onRemove: (notificationId: string) => void;
|
|
6
|
+
readonly autoHideTimeout?: number;
|
|
7
|
+
}
|
|
8
|
+
declare const ToastNotifications: FC<ToastNotificationsProps>;
|
|
9
|
+
export { ToastNotifications };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import { Column } from "../../../../../ui/components/layouts/column/Column";
|
|
5
|
+
import { Row } from "../../../../../ui/components/layouts/row/Row";
|
|
6
|
+
import { Stack } from "../../../../../ui/components/layouts/stack/Stack";
|
|
7
|
+
import { useScreenSize } from "../../../../../ui/hooks/useScreenSize";
|
|
8
|
+
import { ToastNotificationItem } from "./ToastNotificationItem";
|
|
9
|
+
import { style } from "./ToastNotifications.style";
|
|
10
|
+
const NOTIFICATIONS_AUTOHIDE_TIMEOUT = 10000;
|
|
11
|
+
const ToastNotifications = ({ notifications = [], onRemove, autoHideTimeout = NOTIFICATIONS_AUTOHIDE_TIMEOUT, }) => {
|
|
12
|
+
const { top: safeAreaInsetTop } = useSafeAreaInsets();
|
|
13
|
+
const screenSize = useScreenSize();
|
|
14
|
+
const isSmallDevice = screenSize === "S";
|
|
15
|
+
return (React.createElement(View, { pointerEvents: "box-none", style: style.notifications, testID: "toast-notifications" },
|
|
16
|
+
React.createElement(Row, { style: [style.row, isSmallDevice && style.rowSmall, { paddingTop: safeAreaInsetTop }] },
|
|
17
|
+
React.createElement(Column, null,
|
|
18
|
+
React.createElement(Stack, null, notifications.map((notification) => (React.createElement(ToastNotificationItem, { key: notification.id, autoHideTimeout: autoHideTimeout, notification: notification, style: { toast: style.toast }, testID: notification.id, onRemove: onRemove }))))))));
|
|
19
|
+
};
|
|
20
|
+
export { ToastNotifications };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
declare const style: StyleSheet.NamedStyles<any> | StyleSheet.NamedStyles<{
|
|
3
|
+
notifications: {
|
|
4
|
+
flexDirection: "column";
|
|
5
|
+
top: number;
|
|
6
|
+
width: string;
|
|
7
|
+
zIndex: number;
|
|
8
|
+
left: number;
|
|
9
|
+
} | {
|
|
10
|
+
flexDirection: "column";
|
|
11
|
+
top: number;
|
|
12
|
+
width: string;
|
|
13
|
+
zIndex: number;
|
|
14
|
+
position: "fixed";
|
|
15
|
+
left: number;
|
|
16
|
+
} | {
|
|
17
|
+
flexDirection: "column";
|
|
18
|
+
top: number;
|
|
19
|
+
width: string;
|
|
20
|
+
zIndex: number;
|
|
21
|
+
position: "absolute";
|
|
22
|
+
left: number;
|
|
23
|
+
};
|
|
24
|
+
row: {
|
|
25
|
+
flex: number;
|
|
26
|
+
justifyContent: "center";
|
|
27
|
+
};
|
|
28
|
+
rowSmall: {
|
|
29
|
+
paddingLeft: number;
|
|
30
|
+
paddingRight: number;
|
|
31
|
+
};
|
|
32
|
+
toast: {
|
|
33
|
+
marginTop: number;
|
|
34
|
+
};
|
|
35
|
+
}>;
|
|
36
|
+
export { style };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Platform, StyleSheet } from "react-native";
|
|
2
|
+
import { theme } from "../../../../../../infrastructure/ui/theme/theme";
|
|
3
|
+
const { spaceM } = theme();
|
|
4
|
+
const style = StyleSheet.create({
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
notifications: {
|
|
8
|
+
left: 0,
|
|
9
|
+
...Platform.select({
|
|
10
|
+
web: { position: "fixed" },
|
|
11
|
+
ios: { position: "absolute" },
|
|
12
|
+
android: { position: "absolute" },
|
|
13
|
+
}),
|
|
14
|
+
flexDirection: "column",
|
|
15
|
+
top: 0,
|
|
16
|
+
width: "100%",
|
|
17
|
+
zIndex: 20,
|
|
18
|
+
},
|
|
19
|
+
row: {
|
|
20
|
+
flex: 1,
|
|
21
|
+
justifyContent: "center",
|
|
22
|
+
},
|
|
23
|
+
rowSmall: {
|
|
24
|
+
paddingLeft: spaceM,
|
|
25
|
+
paddingRight: spaceM,
|
|
26
|
+
},
|
|
27
|
+
toast: {
|
|
28
|
+
marginTop: spaceM,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
export { style };
|