@sonic-equipment/ui 206.0.0 → 207.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.
|
@@ -4,6 +4,7 @@ export interface TableCardProps {
|
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
className?: string;
|
|
6
6
|
'data-test-selector'?: string;
|
|
7
|
+
id?: string;
|
|
7
8
|
isLoading?: boolean;
|
|
8
9
|
paging?: React.ReactNode;
|
|
9
10
|
results?: number;
|
|
@@ -11,4 +12,4 @@ export interface TableCardProps {
|
|
|
11
12
|
stickyHeader?: boolean;
|
|
12
13
|
title?: TranslationId;
|
|
13
14
|
}
|
|
14
|
-
export declare function TableCard({ actions, children, className, 'data-test-selector': dataTestSelector, isLoading, paging, results, showError, stickyHeader, title, }: TableCardProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function TableCard({ actions, children, className, 'data-test-selector': dataTestSelector, id, isLoading, paging, results, showError, stickyHeader, title, }: TableCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,8 +5,8 @@ import { UnauthorizedRequestError } from '../../shared/fetch/request.js';
|
|
|
5
5
|
import { Heading } from '../../typography/heading/heading.js';
|
|
6
6
|
import styles from './table-card.module.css.js';
|
|
7
7
|
|
|
8
|
-
function TableCard({ actions, children, className, 'data-test-selector': dataTestSelector, isLoading, paging, results = 0, showError = false, stickyHeader = false, title, }) {
|
|
9
|
-
return (jsxs("section", { className: clsx(styles['table-card-container'], stickyHeader && styles['sticky-header'], className), "data-test-selector": dataTestSelector, children: [title && (jsx(Heading, { className: styles.title, size: "xxs", tag: "h3", children: jsx(FormattedMessage, { id: title }) })), jsx("div", { className: styles['table-card'], children: showError ? (jsx("div", { className: styles['error-container'], children: showError instanceof UnauthorizedRequestError ? (jsx(FormattedMessage, { id: "You are not authorized to access this information." })) : typeof showError === 'string' ? (jsx(FormattedMessage, { id: showError })) : (jsx(FormattedMessage, { id: "An unexpected error occured" })) })) : (jsxs(Fragment, { children: [Boolean(actions?.length) && (jsx("div", { className: styles['actions'], children: actions })), results === 0 && !isLoading && (jsx("div", { className: clsx(styles['no-data-container']), children: jsx(FormattedMessage, { id: "There is no information to display" }) })), jsx("div", { className: styles['data'], children: children }), paging && jsx("div", { className: styles['paging'], children: paging })] })) }), jsx("div", { className: styles['sticky-bar'], role: "presentation" })] }));
|
|
8
|
+
function TableCard({ actions, children, className, 'data-test-selector': dataTestSelector, id, isLoading, paging, results = 0, showError = false, stickyHeader = false, title, }) {
|
|
9
|
+
return (jsxs("section", { className: clsx(styles['table-card-container'], stickyHeader && styles['sticky-header'], className), "data-test-selector": dataTestSelector, id: id, children: [title && (jsx(Heading, { className: styles.title, size: "xxs", tag: "h3", children: jsx(FormattedMessage, { id: title }) })), jsx("div", { className: styles['table-card'], children: showError ? (jsx("div", { className: styles['error-container'], children: showError instanceof UnauthorizedRequestError ? (jsx(FormattedMessage, { id: "You are not authorized to access this information." })) : typeof showError === 'string' ? (jsx(FormattedMessage, { id: showError })) : (jsx(FormattedMessage, { id: "An unexpected error occured" })) })) : (jsxs(Fragment, { children: [Boolean(actions?.length) && (jsx("div", { className: styles['actions'], children: actions })), results === 0 && !isLoading && (jsx("div", { className: clsx(styles['no-data-container']), children: jsx(FormattedMessage, { id: "There is no information to display" }) })), jsx("div", { className: styles['data'], children: children }), paging && jsx("div", { className: styles['paging'], children: paging })] })) }), jsx("div", { className: styles['sticky-bar'], role: "presentation" })] }));
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export { TableCard };
|
|
@@ -21,6 +21,7 @@ function ConnectedAddressBookWidget() {
|
|
|
21
21
|
const { pathname, search: searchParams } = useLocation();
|
|
22
22
|
const href = `${pathname}${searchParams}`;
|
|
23
23
|
const paths = usePaths();
|
|
24
|
+
const addressBookId = 'address-book';
|
|
24
25
|
const [sort, setSort] = useState({
|
|
25
26
|
name: 'companyName',
|
|
26
27
|
order: 'ASC',
|
|
@@ -49,11 +50,11 @@ function ConnectedAddressBookWidget() {
|
|
|
49
50
|
};
|
|
50
51
|
return (jsx(TableCard, { stickyHeader: true, actions: [
|
|
51
52
|
jsx(SearchField, { isDebounced: true, className: styles['search-field'], label: t('Search'), onChange: searchAddresses, placeholder: t('Search'), showLabel: false, size: "md", variant: "outline" }, "searchAddresses"),
|
|
52
|
-
jsx(Button, { color: "secondary", href: `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/current${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/new?returnUrl=${encodeURIComponent(href)}`, size: "sm", variant: "outline", children: t('Add address') }, "addAddress"),
|
|
53
|
-
], className: styles['address-book-widget'], "data-test-selector": "address-book-widget", isLoading: isFetching, paging: addresses &&
|
|
53
|
+
jsx(Button, { color: "secondary", href: `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/current${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/new?returnUrl=${encodeURIComponent(`${href}#${addressBookId}`)}`, size: "sm", variant: "outline", children: t('Add address') }, "addAddress"),
|
|
54
|
+
], className: styles['address-book-widget'], "data-test-selector": "address-book-widget", id: addressBookId, isLoading: isFetching, paging: addresses &&
|
|
54
55
|
addresses.length > 0 && (jsx("nav", { className: styles['paging'], children: jsx(Pagination, { currentPage: pagination?.currentPage || 1, onChange: page => setPage(page), totalPages: pagination?.numberOfPages || 1 }) })), results: addresses ? addresses.length : 0, showError: error, title: "Address book", children: jsx("div", { ref: addressBookRef, "aria-label": "Results", "aria-live": "polite", className: styles['results'], children: jsx(DynamicLoadingOverlay, { isLoading: isFetching, children: jsx(DataTable, { actions: [
|
|
55
56
|
{
|
|
56
|
-
href: address => `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/current${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${address.id}?returnUrl=${encodeURIComponent(href)}`,
|
|
57
|
+
href: address => `${paths.ACCOUNT_EDIT_BILL_TO_ADDRESS}/current${paths.ACCOUNT_EDIT_SHIP_TO_ADDRESS}/${address.id}?returnUrl=${encodeURIComponent(`${href}#${addressBookId}`)}`,
|
|
57
58
|
key: 'edit',
|
|
58
59
|
label: 'Edit',
|
|
59
60
|
},
|