@omniumretail/component-library 1.2.51 → 1.2.53
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/bundle.js +1 -1
- package/dist/types/components/Header/Header.types.d.ts +1 -0
- package/dist/types/components/Header/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Footer2/index.tsx +17 -16
- package/src/components/Header/Header.types.ts +1 -0
- package/src/components/Header/index.tsx +15 -4
|
@@ -3,5 +3,5 @@ import { HeaderProps } from './Header.types';
|
|
|
3
3
|
* Header component to display navigation bar with dropdown menus and action button.
|
|
4
4
|
* @param {HeaderProps} props - Properties passed to the component.
|
|
5
5
|
*/
|
|
6
|
-
export declare const Header: ({ menuList, actionButton, logout, homeUrl, profileUrl, onLeavingPage, userName, pageTitle, onFilterChange, notifications, onNotificationClick, handleMarkAllAsRead }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const Header: ({ menuList, actionButton, logout, homeUrl, profileUrl, onLeavingPage, userName, pageTitle, onFilterChange, notifications, onNotificationClick, handleMarkAllAsRead, shouldConfirmNavigation }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default Header;
|
package/package.json
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
ExportOutlined,
|
|
10
10
|
PrinterOutlined
|
|
11
11
|
} from '@ant-design/icons';
|
|
12
|
-
import { t } from 'i18next';
|
|
13
12
|
import moment from 'moment';
|
|
14
13
|
import React, { useEffect, useRef, useState } from 'react';
|
|
15
14
|
import omniumLogo from '../../assets/images/omnium-retail-logo-white.png';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
16
|
|
|
17
17
|
interface Action {
|
|
18
18
|
key: string;
|
|
@@ -68,16 +68,6 @@ export interface Footer2Props {
|
|
|
68
68
|
disableNotifications?: boolean;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// Mapeamento de tipos de ações para seus ícones e labels padrão
|
|
72
|
-
const defaultActionProps: Record<string, { icon: React.ReactNode; label: string }> = {
|
|
73
|
-
[ActionType.DELETE]: { icon: <DeleteOutlined />, label: t('navigation.delete') },
|
|
74
|
-
[ActionType.UPDATE]: { icon: <ReloadOutlined />, label: t('navigation.update') },
|
|
75
|
-
[ActionType.CREATE]: { icon: <PlusOutlined />, label: t('navigation.create') },
|
|
76
|
-
[ActionType.EDIT]: { icon: <EditOutlined />, label: t('navigation.edit') },
|
|
77
|
-
[ActionType.EXPORT]: { icon: <ExportOutlined />, label: t('navigation.export') },
|
|
78
|
-
[ActionType.PRINT]: { icon: <PrinterOutlined />, label: t('navigation.print') },
|
|
79
|
-
};
|
|
80
|
-
|
|
81
71
|
export const Footer2 = (props: Footer2Props) => {
|
|
82
72
|
const {
|
|
83
73
|
onBackClick,
|
|
@@ -96,6 +86,17 @@ export const Footer2 = (props: Footer2Props) => {
|
|
|
96
86
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
97
87
|
const menuRef = useRef<HTMLDivElement>(null);
|
|
98
88
|
const [isMobile, setIsMobile] = useState(window.innerWidth < 768);
|
|
89
|
+
const { t } = useTranslation();
|
|
90
|
+
|
|
91
|
+
// Mapeamento de tipos de ações para seus ícones e labels padrão
|
|
92
|
+
const defaultActionProps: Record<string, { icon: React.ReactNode; label: string }> = {
|
|
93
|
+
[ActionType.DELETE]: { icon: <DeleteOutlined />, label: t('navigation.delete') },
|
|
94
|
+
[ActionType.UPDATE]: { icon: <ReloadOutlined />, label: t('navigation.update') },
|
|
95
|
+
[ActionType.CREATE]: { icon: <PlusOutlined />, label: t('navigation.create') },
|
|
96
|
+
[ActionType.EDIT]: { icon: <EditOutlined />, label: t('navigation.edit') },
|
|
97
|
+
[ActionType.EXPORT]: { icon: <ExportOutlined />, label: t('navigation.export') },
|
|
98
|
+
[ActionType.PRINT]: { icon: <PrinterOutlined />, label: t('navigation.print') },
|
|
99
|
+
};
|
|
99
100
|
|
|
100
101
|
useEffect(() => {
|
|
101
102
|
const time = (function updateDate() {
|
|
@@ -124,11 +125,11 @@ export const Footer2 = (props: Footer2Props) => {
|
|
|
124
125
|
// Converter ActionConfig para Action
|
|
125
126
|
const standardActions = actions.map(actionConfig => {
|
|
126
127
|
const actionType = actionConfig.type;
|
|
127
|
-
const defaultProps = defaultActionProps[actionType] || {
|
|
128
|
+
const defaultProps = defaultActionProps[actionType] || {
|
|
128
129
|
label: String(actionType),
|
|
129
130
|
icon: <PlusOutlined />
|
|
130
131
|
};
|
|
131
|
-
|
|
132
|
+
|
|
132
133
|
return {
|
|
133
134
|
key: actionType,
|
|
134
135
|
label: defaultProps.label,
|
|
@@ -140,7 +141,7 @@ export const Footer2 = (props: Footer2Props) => {
|
|
|
140
141
|
|
|
141
142
|
// Combinar com ações personalizadas
|
|
142
143
|
const combinedActions = [...standardActions, ...customActions];
|
|
143
|
-
|
|
144
|
+
|
|
144
145
|
// Ordenar por label
|
|
145
146
|
return combinedActions.sort((a, b) => a.label.localeCompare(b.label));
|
|
146
147
|
};
|
|
@@ -185,8 +186,8 @@ export const Footer2 = (props: Footer2Props) => {
|
|
|
185
186
|
|
|
186
187
|
<div className={styles.navigation}>
|
|
187
188
|
{onBackClick && (
|
|
188
|
-
<div
|
|
189
|
-
className={`${styles.navItem} ${disableBackButton ? styles.disabled : ''}`}
|
|
189
|
+
<div
|
|
190
|
+
className={`${styles.navItem} ${disableBackButton ? styles.disabled : ''}`}
|
|
190
191
|
onClick={disableBackButton ? undefined : onBackClick}
|
|
191
192
|
>
|
|
192
193
|
<ArrowLeftOutlined className={styles.navIcon} />
|
|
@@ -24,7 +24,8 @@ export const Header = ({
|
|
|
24
24
|
onFilterChange,
|
|
25
25
|
notifications,
|
|
26
26
|
onNotificationClick,
|
|
27
|
-
handleMarkAllAsRead
|
|
27
|
+
handleMarkAllAsRead,
|
|
28
|
+
shouldConfirmNavigation
|
|
28
29
|
}: HeaderProps) => {
|
|
29
30
|
|
|
30
31
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
|
@@ -36,7 +37,9 @@ export const Header = ({
|
|
|
36
37
|
* Handle the logout action. If no logout function is provided, redirect to home as discussed in a meet
|
|
37
38
|
*/
|
|
38
39
|
const onLogout = () => {
|
|
39
|
-
if (
|
|
40
|
+
if (shouldConfirmNavigation) {
|
|
41
|
+
onLeavingPage!('/logout');
|
|
42
|
+
} else if (logout) {
|
|
40
43
|
logout();
|
|
41
44
|
} else {
|
|
42
45
|
onHome();
|
|
@@ -47,14 +50,22 @@ export const Header = ({
|
|
|
47
50
|
* Navigate to the profile URL.
|
|
48
51
|
*/
|
|
49
52
|
const onProfile = () => {
|
|
50
|
-
|
|
53
|
+
if (shouldConfirmNavigation) {
|
|
54
|
+
onLeavingPage!('/profile');
|
|
55
|
+
} else {
|
|
56
|
+
window.location.href = profileUrl;
|
|
57
|
+
}
|
|
51
58
|
};
|
|
52
59
|
|
|
53
60
|
/**
|
|
54
61
|
* Navigate to the home URL.
|
|
55
62
|
*/
|
|
56
63
|
const onHome = () => {
|
|
57
|
-
|
|
64
|
+
if (shouldConfirmNavigation) {
|
|
65
|
+
onLeavingPage!('/home');
|
|
66
|
+
} else {
|
|
67
|
+
window.location.href = homeUrl;
|
|
68
|
+
}
|
|
58
69
|
};
|
|
59
70
|
|
|
60
71
|
const menuTopList = getMenuTopList(
|