@sonic-equipment/ui 204.0.0 → 205.0.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/cards/table-card/table-card.d.ts +12 -0
- package/dist/cards/table-card/table-card.js +14 -0
- package/dist/cards/table-card/table-card.module.css.js +3 -0
- package/dist/exports.d.ts +7 -3
- package/dist/filters/pagination/pagination.js +1 -1
- package/dist/forms/fields/search-field/search-field.js +1 -1
- package/dist/forms/fields/text-field/text-field.d.ts +1 -0
- package/dist/forms/fields/text-field/text-field.js +2 -2
- package/dist/icons/solid/solid-edit-icon.js +8 -0
- package/dist/index.js +10 -6
- package/dist/intl/translation-id.d.ts +1 -1
- package/dist/pages/checkout/cart-page/cart-page.js +1 -1
- package/dist/pages/checkout/order-confirmation-page/order-confirmation-page-content.js +1 -1
- package/dist/pages/checkout/payment-page/components/payment.js +2 -2
- package/dist/pages/checkout/shipping-page/hooks/use-patch-shipping-details.js +1 -1
- package/dist/pages/my-sonic/actions/create-ship-to-address/connected-create-ship-to-address-form.js +6 -6
- package/dist/pages/my-sonic/pages/order-history/order-history.js +4 -1
- package/dist/pages/my-sonic/widgets/connected-address-book-widget.d.ts +1 -0
- package/dist/pages/my-sonic/widgets/connected-address-book-widget.js +166 -0
- package/dist/pages/my-sonic/widgets/connected-address-book-widget.module.css.js +3 -0
- package/dist/shared/api/{storefront → bff}/hooks/cart/use-patch-cart.d.ts +2 -2
- package/dist/shared/api/{storefront → bff}/hooks/cart/use-patch-cart.js +1 -1
- package/dist/shared/api/{storefront → bff}/hooks/cart/use-place-order.d.ts +2 -2
- package/dist/shared/api/{storefront → bff}/hooks/cart/use-place-order.js +1 -1
- package/dist/shared/api/{storefront → bff}/hooks/cart/use-save-cart-for-later.d.ts +1 -1
- package/dist/shared/api/{storefront → bff}/hooks/cart/use-save-cart-for-later.js +1 -1
- package/dist/shared/api/bff/services/bff-service.d.ts +12 -0
- package/dist/shared/api/bff/services/bff-service.js +43 -1
- package/dist/shared/api/storefront/hooks/customer/use-fetch-paged-ship-to-addresses.d.ts +8 -0
- package/dist/shared/api/storefront/hooks/customer/use-fetch-paged-ship-to-addresses.js +13 -0
- package/dist/shared/api/storefront/hooks/orders/use-fetch-orders.d.ts +1 -2
- package/dist/shared/api/storefront/model/storefront.model.d.ts +8 -0
- package/dist/shared/api/storefront/services/cart-service.d.ts +1 -12
- package/dist/shared/api/storefront/services/cart-service.js +1 -43
- package/dist/shared/api/storefront/services/customer-service.d.ts +9 -1
- package/dist/shared/api/storefront/services/customer-service.js +19 -1
- package/dist/shared/api/storefront/services/order-service.d.ts +1 -5
- package/dist/shared/utils/children-to-text.d.ts +2 -0
- package/dist/shared/utils/children-to-text.js +18 -0
- package/dist/styles.css +259 -26
- package/dist/table/data-table.d.ts +3 -1
- package/dist/table/data-table.js +2 -2
- package/dist/table/elements/table.module.css.js +1 -1
- package/dist/table/elements/td.js +2 -2
- package/dist/table/elements/th.js +2 -2
- package/dist/table/elements/types.d.ts +1 -0
- package/dist/table/elements/use-td.js +1 -0
- package/dist/text/truncated/truncated.js +3 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CultureCode } from '../../../../intl/types';
|
|
2
2
|
import { ProductListingPageData } from '../../../../pages/product/product-listing-page/product-listing-page-data-types';
|
|
3
3
|
import { AnnouncementObject } from '../../../model/announcement';
|
|
4
|
+
import { CartModel, PatchCartModel } from '../../storefront/model/storefront.model';
|
|
4
5
|
import { NavigationResponse, ProductDetailsPageDataResponse, ProductSummary } from '../model/bff.model';
|
|
5
6
|
export interface FetchAnnouncementsArgs {
|
|
6
7
|
cultureCode: CultureCode;
|
|
@@ -21,3 +22,14 @@ export declare function fetchNavigationLinks({ cultureCode, source, }: FetchNavi
|
|
|
21
22
|
export declare function fetchRecentlyViewedProducts({ cultureCode, }: {
|
|
22
23
|
cultureCode: CultureCode;
|
|
23
24
|
}): Promise<ProductSummary[]>;
|
|
25
|
+
export declare function patchCart({ cart, forceRecalculation, }: {
|
|
26
|
+
cart: PatchCartModel;
|
|
27
|
+
forceRecalculation?: boolean;
|
|
28
|
+
}): Promise<CartModel>;
|
|
29
|
+
export declare function placeOrder({ cart, isPending, }: {
|
|
30
|
+
cart: PatchCartModel;
|
|
31
|
+
isPending?: boolean;
|
|
32
|
+
}): Promise<CartModel>;
|
|
33
|
+
export declare function saveCartForLater({ cart }: {
|
|
34
|
+
cart: CartModel;
|
|
35
|
+
}): Promise<CartModel>;
|
|
@@ -114,5 +114,47 @@ async function fetchRecentlyViewedProducts({ cultureCode, }) {
|
|
|
114
114
|
});
|
|
115
115
|
return body;
|
|
116
116
|
}
|
|
117
|
+
async function patchCart({ cart, forceRecalculation = true, }) {
|
|
118
|
+
const { body } = await request({
|
|
119
|
+
body: cart,
|
|
120
|
+
credentials: 'include',
|
|
121
|
+
headers: {
|
|
122
|
+
'Content-Type': 'application/json',
|
|
123
|
+
},
|
|
124
|
+
method: 'PATCH',
|
|
125
|
+
url: `${config.BFF_API_URL}/api/v1/carts/current${forceRecalculation ? '?forceRecalculation=true' : ''}`,
|
|
126
|
+
});
|
|
127
|
+
return body;
|
|
128
|
+
}
|
|
129
|
+
async function placeOrder({ cart, isPending, }) {
|
|
130
|
+
const newStatus = cart.requiresApproval
|
|
131
|
+
? 'AwaitingApproval'
|
|
132
|
+
: isPending
|
|
133
|
+
? 'PendingPaymentValidation'
|
|
134
|
+
: 'Submitted';
|
|
135
|
+
const { body } = await request({
|
|
136
|
+
body: { ...cart, status: newStatus },
|
|
137
|
+
credentials: 'include',
|
|
138
|
+
headers: {
|
|
139
|
+
'Content-Type': 'application/json',
|
|
140
|
+
},
|
|
141
|
+
method: 'PATCH',
|
|
142
|
+
url: `${config.BFF_API_URL}/api/v1/carts/current?forceRecalculation=false`,
|
|
143
|
+
});
|
|
144
|
+
return body;
|
|
145
|
+
}
|
|
146
|
+
async function saveCartForLater({ cart }) {
|
|
147
|
+
// USER NEEDS TO BE LOGGED IN
|
|
148
|
+
const { body } = await request({
|
|
149
|
+
body: JSON.stringify({ ...cart, status: 'Saved' }),
|
|
150
|
+
credentials: 'include',
|
|
151
|
+
headers: {
|
|
152
|
+
'Content-Type': 'application/json',
|
|
153
|
+
},
|
|
154
|
+
method: 'PATCH',
|
|
155
|
+
url: `${config.BFF_API_URL}/api/v1/carts/current`,
|
|
156
|
+
});
|
|
157
|
+
return body;
|
|
158
|
+
}
|
|
117
159
|
|
|
118
|
-
export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchRecentlyViewedProducts };
|
|
160
|
+
export { fetchAnnouncements, fetchNavigationLinks, fetchProductDetailsPageData, fetchProductListingPageData, fetchRecentlyViewedProducts, patchCart, placeOrder, saveCartForLater };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SortOption } from '../../model/storefront.model';
|
|
2
|
+
export declare function useFetchPagedShipToAddresses({ enabled, page, pageSize, search, sort, }?: {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
page: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
search?: string;
|
|
7
|
+
sort?: SortOption;
|
|
8
|
+
}): import("@tanstack/react-query").UseQueryResult<import("../../model/storefront.model").AddressesCollectionModel, Error>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { fetchPagedShipToAddresses } from '../../services/customer-service.js';
|
|
3
|
+
|
|
4
|
+
function useFetchPagedShipToAddresses({ enabled = true, page = 1, pageSize = 20, search, sort, } = { enabled: true, page: 1, pageSize: 20, search: '' }) {
|
|
5
|
+
return useQuery({
|
|
6
|
+
enabled,
|
|
7
|
+
placeholderData: prev => prev,
|
|
8
|
+
queryFn: () => fetchPagedShipToAddresses({ page, pageSize, search, sort }),
|
|
9
|
+
queryKey: ['addresses', page, pageSize, search, sort],
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { useFetchPagedShipToAddresses };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { OrderStatus } from '../../model/storefront.model';
|
|
2
|
-
import { SortOption } from '../../services/order-service';
|
|
1
|
+
import { OrderStatus, SortOption } from '../../model/storefront.model';
|
|
3
2
|
export declare function useFetchOrders({ enabled, page, pageSize, search, sort, status, }?: {
|
|
4
3
|
enabled?: boolean;
|
|
5
4
|
page: number;
|
|
@@ -2190,6 +2190,10 @@ export interface MobilePageDto {
|
|
|
2190
2190
|
[key: string]: any;
|
|
2191
2191
|
} | null;
|
|
2192
2192
|
}
|
|
2193
|
+
export interface AddressesCollectionModel extends BaseModel {
|
|
2194
|
+
pagination: PaginationModel | null;
|
|
2195
|
+
shipTos: ShipToModel[] | null;
|
|
2196
|
+
}
|
|
2193
2197
|
export interface OrderCollectionModel extends BaseModel {
|
|
2194
2198
|
orders: OrderModel[] | null;
|
|
2195
2199
|
pagination: PaginationModel | null;
|
|
@@ -3092,3 +3096,7 @@ export type OrderStatus = keyof typeof orderStatusMappings;
|
|
|
3092
3096
|
export declare const orderStatuses: OrderStatus[];
|
|
3093
3097
|
export declare function fromApiStatusToOrderStatus(status: string): OrderStatus;
|
|
3094
3098
|
export declare const isValidStatus: (status: string | undefined | null) => status is OrderStatus;
|
|
3099
|
+
export interface SortOption {
|
|
3100
|
+
name: string;
|
|
3101
|
+
order: 'ASC' | 'DESC';
|
|
3102
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdyenPaymentModel, CartLineModel, CartLineModel as ShopCartLineModel, CartModel, CheckoutAtpEntry,
|
|
1
|
+
import { AdyenPaymentModel, CartLineModel, CartLineModel as ShopCartLineModel, CartModel, CheckoutAtpEntry, ProductAtp, PromotionModel } from '../model/storefront.model';
|
|
2
2
|
export declare function fetchCart({ forceRecalculation, id, }: {
|
|
3
3
|
forceRecalculation?: boolean;
|
|
4
4
|
id: string;
|
|
@@ -12,10 +12,6 @@ export declare function patchCartLineById({ cartLine, cartLineId, }: {
|
|
|
12
12
|
cartLine: CartLineModel;
|
|
13
13
|
cartLineId: string;
|
|
14
14
|
}): Promise<CartLineModel>;
|
|
15
|
-
export declare function patchCart({ cart, forceRecalculation, }: {
|
|
16
|
-
cart: PatchCartModel;
|
|
17
|
-
forceRecalculation?: boolean;
|
|
18
|
-
}): Promise<CartModel>;
|
|
19
15
|
export declare function deleteCurrentCart(): Promise<CartModel>;
|
|
20
16
|
export declare function deleteCartLineById({ cartLineId, }: {
|
|
21
17
|
cartLineId: string;
|
|
@@ -28,13 +24,6 @@ export interface AddProductToCurrentCartParams {
|
|
|
28
24
|
export declare function addProductToCurrentCart(productOrderData: AddProductToCurrentCartParams): Promise<ShopCartLineModel>;
|
|
29
25
|
export declare function fetchCurrentCartProductAtp(): Promise<ProductAtp[]>;
|
|
30
26
|
export declare function fetchCurrentCheckoutAtp(): Promise<CheckoutAtpEntry[]>;
|
|
31
|
-
export declare function placeOrder({ cart, isPending, }: {
|
|
32
|
-
cart: PatchCartModel;
|
|
33
|
-
isPending?: boolean;
|
|
34
|
-
}): Promise<CartModel>;
|
|
35
|
-
export declare function saveCartForLater({ cart }: {
|
|
36
|
-
cart: CartModel;
|
|
37
|
-
}): Promise<CartModel>;
|
|
38
27
|
export declare function postAdyenPayment({ currencyCode, data, orderAmount, returnUrl, webOrderNumber, }: {
|
|
39
28
|
currencyCode: string;
|
|
40
29
|
data: any;
|
|
@@ -37,18 +37,6 @@ async function patchCartLineById({ cartLine, cartLineId, }) {
|
|
|
37
37
|
});
|
|
38
38
|
return body;
|
|
39
39
|
}
|
|
40
|
-
async function patchCart({ cart, forceRecalculation = true, }) {
|
|
41
|
-
const { body } = await request({
|
|
42
|
-
body: cart,
|
|
43
|
-
credentials: 'include',
|
|
44
|
-
headers: {
|
|
45
|
-
'Content-Type': 'application/json',
|
|
46
|
-
},
|
|
47
|
-
method: 'PATCH',
|
|
48
|
-
url: `${config.BFF_API_URL}/api/v1/carts/current${forceRecalculation ? '?forceRecalculation=true' : ''}`,
|
|
49
|
-
});
|
|
50
|
-
return body;
|
|
51
|
-
}
|
|
52
40
|
async function deleteCurrentCart() {
|
|
53
41
|
const { body } = await request({
|
|
54
42
|
credentials: 'include',
|
|
@@ -98,36 +86,6 @@ async function fetchCurrentCheckoutAtp() {
|
|
|
98
86
|
});
|
|
99
87
|
return body;
|
|
100
88
|
}
|
|
101
|
-
async function placeOrder({ cart, isPending, }) {
|
|
102
|
-
const newStatus = cart.requiresApproval
|
|
103
|
-
? 'AwaitingApproval'
|
|
104
|
-
: isPending
|
|
105
|
-
? 'PendingPaymentValidation'
|
|
106
|
-
: 'Submitted';
|
|
107
|
-
const { body } = await request({
|
|
108
|
-
body: { ...cart, status: newStatus },
|
|
109
|
-
credentials: 'include',
|
|
110
|
-
headers: {
|
|
111
|
-
'Content-Type': 'application/json',
|
|
112
|
-
},
|
|
113
|
-
method: 'PATCH',
|
|
114
|
-
url: `${config.BFF_API_URL}/api/v1/carts/current?forceRecalculation=false`,
|
|
115
|
-
});
|
|
116
|
-
return body;
|
|
117
|
-
}
|
|
118
|
-
async function saveCartForLater({ cart }) {
|
|
119
|
-
// USER NEEDS TO BE LOGGED IN
|
|
120
|
-
const { body } = await request({
|
|
121
|
-
body: JSON.stringify({ ...cart, status: 'Saved' }),
|
|
122
|
-
credentials: 'include',
|
|
123
|
-
headers: {
|
|
124
|
-
'Content-Type': 'application/json',
|
|
125
|
-
},
|
|
126
|
-
method: 'PATCH',
|
|
127
|
-
url: `${config.BFF_API_URL}/api/v1/carts/current`,
|
|
128
|
-
});
|
|
129
|
-
return body;
|
|
130
|
-
}
|
|
131
89
|
async function postAdyenPayment({ currencyCode, data, orderAmount, returnUrl, webOrderNumber, }) {
|
|
132
90
|
const { body } = await request({
|
|
133
91
|
body: {
|
|
@@ -194,4 +152,4 @@ function convertToMinorUnits(value, currencyCode) {
|
|
|
194
152
|
return Math.round(valueInMinorUnits);
|
|
195
153
|
}
|
|
196
154
|
|
|
197
|
-
export { addProductToCurrentCart, convertToMinorUnits, deleteCartLineById, deleteCurrentCart, fetchCart, fetchCurrentCart, fetchCurrentCartLines, fetchCurrentCartProductAtp, fetchCurrentCartPromotions, fetchCurrentCheckoutAtp, getAdyenPaymentDetails,
|
|
155
|
+
export { addProductToCurrentCart, convertToMinorUnits, deleteCartLineById, deleteCurrentCart, fetchCart, fetchCurrentCart, fetchCurrentCartLines, fetchCurrentCartProductAtp, fetchCurrentCartPromotions, fetchCurrentCheckoutAtp, getAdyenPaymentDetails, patchCartLineById, postAdyenPayment };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BillToCollectionModel, BillToModel, PatchBillToModel, PatchShipToModel, PostShipToModel, ShipToCollectionModel, ShipToModel } from '
|
|
1
|
+
import { AddressesCollectionModel, BillToCollectionModel, BillToModel, PatchBillToModel, PatchShipToModel, PostShipToModel, ShipToCollectionModel, ShipToModel, SortOption } from '../model/storefront.model';
|
|
2
2
|
export declare function fetchCurrentBillToAddress({ includeValidation, }?: {
|
|
3
3
|
includeValidation?: boolean;
|
|
4
4
|
}): Promise<BillToModel>;
|
|
@@ -33,6 +33,14 @@ export declare function postShipToAddress({ billToId, shipTo, }: {
|
|
|
33
33
|
billToId: string;
|
|
34
34
|
shipTo: PostShipToModel;
|
|
35
35
|
}): Promise<ShipToModel>;
|
|
36
|
+
export type exclusionType = 'showAll' | 'createNew' | 'oneTime' | 'billTo';
|
|
37
|
+
export declare function fetchPagedShipToAddresses({ exclude, page, pageSize, search, sort, }?: {
|
|
38
|
+
exclude?: exclusionType[];
|
|
39
|
+
page?: number;
|
|
40
|
+
pageSize?: number;
|
|
41
|
+
search?: string;
|
|
42
|
+
sort?: SortOption;
|
|
43
|
+
}): Promise<AddressesCollectionModel>;
|
|
36
44
|
export declare function fetchFulfillmentMethods({ customerId, }: {
|
|
37
45
|
customerId: string;
|
|
38
46
|
}): Promise<string[]>;
|
|
@@ -75,6 +75,24 @@ async function postShipToAddress({ billToId, shipTo, }) {
|
|
|
75
75
|
});
|
|
76
76
|
return createdShipTo;
|
|
77
77
|
}
|
|
78
|
+
async function fetchPagedShipToAddresses({ exclude = ['showAll', 'oneTime', 'billTo'], page = 1, pageSize = 20, search, sort, } = {}) {
|
|
79
|
+
const searchParams = new URLSearchParams();
|
|
80
|
+
searchParams.set('exclude', exclude.join(','));
|
|
81
|
+
if (page)
|
|
82
|
+
searchParams.set('page', page.toString());
|
|
83
|
+
if (pageSize)
|
|
84
|
+
searchParams.set('pageSize', pageSize.toString());
|
|
85
|
+
if (search)
|
|
86
|
+
searchParams.set('filter', search);
|
|
87
|
+
if (sort)
|
|
88
|
+
searchParams.set('sort', `${sort.name} ${sort.order.toLocaleUpperCase()}`);
|
|
89
|
+
const { body } = await request({
|
|
90
|
+
credentials: 'include',
|
|
91
|
+
params: Object.fromEntries(searchParams),
|
|
92
|
+
url: `${config.SHOP_API_URL}/api/v1/billtos/current/shiptos`,
|
|
93
|
+
});
|
|
94
|
+
return body;
|
|
95
|
+
}
|
|
78
96
|
async function fetchFulfillmentMethods({ customerId, }) {
|
|
79
97
|
const { body: updatedBillTo } = await request({
|
|
80
98
|
credentials: 'include',
|
|
@@ -84,4 +102,4 @@ async function fetchFulfillmentMethods({ customerId, }) {
|
|
|
84
102
|
return updatedBillTo;
|
|
85
103
|
}
|
|
86
104
|
|
|
87
|
-
export { fetchBillToAddress, fetchBillToAddresses, fetchCurrentBillToAddress, fetchCurrentShipToAddress, fetchFulfillmentMethods, fetchShipToAddress, fetchShipToAddresses, patchBillToAddress, patchShipToAddress, postShipToAddress };
|
|
105
|
+
export { fetchBillToAddress, fetchBillToAddresses, fetchCurrentBillToAddress, fetchCurrentShipToAddress, fetchFulfillmentMethods, fetchPagedShipToAddresses, fetchShipToAddress, fetchShipToAddresses, patchBillToAddress, patchShipToAddress, postShipToAddress };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { OrderCollectionModel, OrderStatus } from '../model/storefront.model';
|
|
2
|
-
export interface SortOption {
|
|
3
|
-
name: string;
|
|
4
|
-
order: 'ASC' | 'DESC';
|
|
5
|
-
}
|
|
1
|
+
import { OrderCollectionModel, OrderStatus, SortOption } from '../model/storefront.model';
|
|
6
2
|
export declare function fetchOrders({ page, pageSize, search, sort, status, }?: {
|
|
7
3
|
page?: number;
|
|
8
4
|
pageSize?: number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const childrenToText = (children) => {
|
|
4
|
+
if (typeof children === 'string' || typeof children === 'number') {
|
|
5
|
+
return children.toString();
|
|
6
|
+
}
|
|
7
|
+
if (Array.isArray(children)) {
|
|
8
|
+
return children
|
|
9
|
+
.map(child => childrenToText(child))
|
|
10
|
+
.join(' ');
|
|
11
|
+
}
|
|
12
|
+
if (React.isValidElement(children)) {
|
|
13
|
+
return childrenToText(children.props.children);
|
|
14
|
+
}
|
|
15
|
+
return '';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { childrenToText };
|