@inceptionbg/iui 2.0.6 → 2.0.7

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.
@@ -5,40 +5,48 @@ import { Tooltip } from '../../Tooltip/Tooltip';
5
5
  import { Menu } from '../../Menu/Menu';
6
6
  import { IHeaderUserMenuProps } from '../../../types/IHeader';
7
7
 
8
- interface Props {
9
- useHeaderUserContext: () => IHeaderUserMenuProps;
10
- }
8
+ export const UserMenu: FC<IHeaderUserMenuProps> = ({
9
+ isOpen,
10
+ setIsOpen,
11
+ userName,
12
+ organizationName,
13
+ menuItems,
14
+ showBadge,
11
15
 
12
- export const UserMenu: FC<Props> = ({ useHeaderUserContext }) => {
13
- const { isOpen, setIsOpen, userName, organizationName, menuItems, showBadge } =
14
- useHeaderUserContext();
15
-
16
- return (
17
- <>
18
- <Menu
19
- isOpen={isOpen}
20
- onClose={() => setIsOpen(false)}
21
- placement="bottom-right"
22
- size="m"
23
- items={menuItems}
24
- renderButton={ref => (
25
- <button ref={ref} className="user-box" onClick={() => setIsOpen(true)}>
26
- {showBadge && <div className="user-badge" />}
27
- <FontAwesomeIcon icon={faCircleUser} className="user-icon" />
28
- <div className="user-info">
29
- {userName && <p className="user-name">{userName}</p>}
30
- {organizationName && (
31
- <Tooltip
32
- label={(organizationName?.length || 0) > 20 ? organizationName : ''}
33
- position="bottom"
34
- >
35
- <p className="org-name">{organizationName}</p>
36
- </Tooltip>
37
- )}
38
- </div>
39
- </button>
40
- )}
41
- />
42
- </>
43
- );
44
- };
16
+ HeaderUserMenuDialogs,
17
+ openedDialog,
18
+ setOpenedDialog,
19
+ refetchOrganizationInvites,
20
+ }) => (
21
+ <>
22
+ <Menu
23
+ isOpen={isOpen}
24
+ onClose={() => setIsOpen(false)}
25
+ placement="bottom-right"
26
+ size="m"
27
+ items={menuItems}
28
+ renderButton={ref => (
29
+ <button ref={ref} className="user-box" onClick={() => setIsOpen(true)}>
30
+ {showBadge && <div className="user-badge" />}
31
+ <FontAwesomeIcon icon={faCircleUser} className="user-icon" />
32
+ <div className="user-info">
33
+ {userName && <p className="user-name">{userName}</p>}
34
+ {organizationName && (
35
+ <Tooltip
36
+ label={(organizationName?.length || 0) > 20 ? organizationName : ''}
37
+ position="bottom"
38
+ >
39
+ <p className="org-name">{organizationName}</p>
40
+ </Tooltip>
41
+ )}
42
+ </div>
43
+ </button>
44
+ )}
45
+ />
46
+ <HeaderUserMenuDialogs
47
+ openedDialog={openedDialog}
48
+ setOpenedDialog={setOpenedDialog}
49
+ refetchOrganizationInvites={refetchOrganizationInvites}
50
+ />
51
+ </>
52
+ );
@@ -9,17 +9,14 @@ interface Props {
9
9
  // actions: {
10
10
  // icon: IconDefinition;
11
11
  // };
12
- userMenuProps: {
13
- HeaderUserProvider: ({ children }: { children: ReactNode }) => React.JSX.Element;
14
- useHeaderUserContext: () => IHeaderUserMenuProps;
15
- };
12
+ userMenuProps: IHeaderUserMenuProps;
16
13
  children?: ReactNode;
17
14
  }
18
15
 
19
16
  export const Header: FC<Props> = ({
20
17
  customTitle,
21
18
  modulesProps,
22
- userMenuProps: { HeaderUserProvider, useHeaderUserContext },
19
+ userMenuProps,
23
20
  children,
24
21
  }) => (
25
22
  <div className="iui-header">
@@ -28,9 +25,7 @@ export const Header: FC<Props> = ({
28
25
  <div className="flex gap-2 align-center">
29
26
  {children}
30
27
  {/* {!hideNotifications && <Notifications />} */}
31
- <HeaderUserProvider>
32
- <UserMenu useHeaderUserContext={useHeaderUserContext} />
33
- </HeaderUserProvider>
28
+ <UserMenu {...userMenuProps} />
34
29
  </div>
35
30
  </div>
36
31
  );
@@ -7,8 +7,8 @@ import { DatePartInput } from './components/DatePartInput';
7
7
  import { faCalendarPlus } from '../../../assets/icons/light/faCalendarPlus';
8
8
  import dayjs from 'dayjs';
9
9
  import { IMenuPlacement } from '../../../types/IMenu';
10
- import i18next from 'i18next';
11
10
  import { formatDateYMD } from '../../../utils/DateUtils';
11
+ import { useTranslation } from 'react-i18next';
12
12
 
13
13
  export interface IDateInputProps {
14
14
  label?: string;
@@ -42,6 +42,7 @@ export const DateInput: FC<IDateInputProps> = ({
42
42
  const [day, setDay] = useState(date?.split('-')[2] ?? '');
43
43
  const [month, setMonth] = useState(date?.split('-')[1] ?? '');
44
44
  const [year, setYear] = useState(date?.split('-')[0] ?? '');
45
+ const { i18n } = useTranslation();
45
46
 
46
47
  const [isCalendarOpen, setIsCalendarOpen] = useState(false);
47
48
 
@@ -116,11 +117,11 @@ export const DateInput: FC<IDateInputProps> = ({
116
117
  setIsCalendarOpen(false);
117
118
  }}
118
119
  locale={
119
- i18next.language === 'sr_RS_Latn'
120
+ i18n.language === 'sr_RS_Latn'
120
121
  ? 'sr-Latn-RS'
121
- : i18next.language === 'sr_RS_Cyrl'
122
+ : i18n.language === 'sr_RS_Cyrl'
122
123
  ? 'sr-RS'
123
- : i18next.language
124
+ : i18n.language
124
125
  }
125
126
  formatShortWeekday={(locale, date) =>
126
127
  new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date)
@@ -1,6 +1,7 @@
1
1
  import { IconDefinition, RotateProp } from '@fortawesome/fontawesome-svg-core';
2
2
  import { IButtonColor } from '../components/Button/Button';
3
3
  import { IMenuItem } from './IMenu';
4
+ import { FC } from 'react';
4
5
 
5
6
  export interface IHeaderAction {
6
7
  label: string;
@@ -21,4 +22,13 @@ export type IHeaderUserMenuProps = {
21
22
  organizationName?: string;
22
23
  showBadge?: boolean;
23
24
  menuItems?: IMenuItem[];
25
+
26
+ HeaderUserMenuDialogs: FC<{
27
+ openedDialog: string | null;
28
+ setOpenedDialog: (dialog: string | null) => void;
29
+ refetchOrganizationInvites?: () => void;
30
+ }>;
31
+ openedDialog: string | null;
32
+ setOpenedDialog: (dialog: string | null) => void;
33
+ refetchOrganizationInvites?: () => void;
24
34
  };