@deix/rossini-identity-management 0.1.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.
Files changed (126) hide show
  1. package/README.md +6 -0
  2. package/lib/app/[locale]/groups/page.d.ts +4 -0
  3. package/lib/app/[locale]/groups/page.d.ts.map +1 -0
  4. package/lib/app/[locale]/groups/page.js +9 -0
  5. package/lib/app/[locale]/layout.d.ts +10 -0
  6. package/lib/app/[locale]/layout.d.ts.map +1 -0
  7. package/lib/app/[locale]/layout.js +24 -0
  8. package/lib/app/[locale]/users/page.d.ts +4 -0
  9. package/lib/app/[locale]/users/page.d.ts.map +1 -0
  10. package/lib/app/[locale]/users/page.js +9 -0
  11. package/lib/app/layout.d.ts +13 -0
  12. package/lib/app/layout.d.ts.map +1 -0
  13. package/lib/app/layout.js +20 -0
  14. package/lib/components/AddItemDialog.d.ts +16 -0
  15. package/lib/components/AddItemDialog.d.ts.map +1 -0
  16. package/lib/components/AddItemDialog.js +45 -0
  17. package/lib/components/DeleteConfirmationDialog.d.ts +9 -0
  18. package/lib/components/DeleteConfirmationDialog.d.ts.map +1 -0
  19. package/lib/components/DeleteConfirmationDialog.js +35 -0
  20. package/lib/components/SearchField.d.ts +8 -0
  21. package/lib/components/SearchField.d.ts.map +1 -0
  22. package/lib/components/SearchField.js +16 -0
  23. package/lib/components/groups/CreateGroupDialog.d.ts +8 -0
  24. package/lib/components/groups/CreateGroupDialog.d.ts.map +1 -0
  25. package/lib/components/groups/CreateGroupDialog.js +24 -0
  26. package/lib/components/groups/GroupDetails.d.ts +8 -0
  27. package/lib/components/groups/GroupDetails.d.ts.map +1 -0
  28. package/lib/components/groups/GroupDetails.js +18 -0
  29. package/lib/components/groups/GroupForm.d.ts +11 -0
  30. package/lib/components/groups/GroupForm.d.ts.map +1 -0
  31. package/lib/components/groups/GroupForm.js +38 -0
  32. package/lib/components/groups/GroupTabs.d.ts +16 -0
  33. package/lib/components/groups/GroupTabs.d.ts.map +1 -0
  34. package/lib/components/groups/GroupTabs.js +29 -0
  35. package/lib/components/groups/GroupUsers.d.ts +8 -0
  36. package/lib/components/groups/GroupUsers.d.ts.map +1 -0
  37. package/lib/components/groups/GroupUsers.js +74 -0
  38. package/lib/components/groups/Groups.d.ts +9 -0
  39. package/lib/components/groups/Groups.d.ts.map +1 -0
  40. package/lib/components/groups/Groups.js +78 -0
  41. package/lib/components/groups/GroupsTable.d.ts +11 -0
  42. package/lib/components/groups/GroupsTable.d.ts.map +1 -0
  43. package/lib/components/groups/GroupsTable.js +43 -0
  44. package/lib/components/index.d.ts +3 -0
  45. package/lib/components/index.d.ts.map +1 -0
  46. package/lib/components/index.js +2 -0
  47. package/lib/components/users/CreateUserDialog.d.ts +8 -0
  48. package/lib/components/users/CreateUserDialog.d.ts.map +1 -0
  49. package/lib/components/users/CreateUserDialog.js +24 -0
  50. package/lib/components/users/UserCredentials.d.ts +8 -0
  51. package/lib/components/users/UserCredentials.d.ts.map +1 -0
  52. package/lib/components/users/UserCredentials.js +17 -0
  53. package/lib/components/users/UserDetails.d.ts +8 -0
  54. package/lib/components/users/UserDetails.d.ts.map +1 -0
  55. package/lib/components/users/UserDetails.js +18 -0
  56. package/lib/components/users/UserForm.d.ts +14 -0
  57. package/lib/components/users/UserForm.d.ts.map +1 -0
  58. package/lib/components/users/UserForm.js +62 -0
  59. package/lib/components/users/UserGroups.d.ts +8 -0
  60. package/lib/components/users/UserGroups.d.ts.map +1 -0
  61. package/lib/components/users/UserGroups.js +64 -0
  62. package/lib/components/users/Users.d.ts +9 -0
  63. package/lib/components/users/Users.d.ts.map +1 -0
  64. package/lib/components/users/Users.js +84 -0
  65. package/lib/components/users/UsersTable.d.ts +13 -0
  66. package/lib/components/users/UsersTable.d.ts.map +1 -0
  67. package/lib/components/users/UsersTable.js +62 -0
  68. package/lib/components/users/UsersTabs.d.ts +16 -0
  69. package/lib/components/users/UsersTabs.d.ts.map +1 -0
  70. package/lib/components/users/UsersTabs.js +32 -0
  71. package/lib/config/i18n.d.ts +3 -0
  72. package/lib/config/i18n.d.ts.map +1 -0
  73. package/lib/config/i18n.js +14 -0
  74. package/lib/config/index.d.ts +11 -0
  75. package/lib/config/index.d.ts.map +1 -0
  76. package/lib/config/index.js +18 -0
  77. package/lib/config/palette.d.ts +5 -0
  78. package/lib/config/palette.d.ts.map +1 -0
  79. package/lib/config/palette.js +88 -0
  80. package/lib/index.d.ts +5 -0
  81. package/lib/index.d.ts.map +1 -0
  82. package/lib/index.js +2 -0
  83. package/lib/lang/groups.d.ts +6 -0
  84. package/lib/lang/groups.d.ts.map +1 -0
  85. package/lib/lang/groups.js +71 -0
  86. package/lib/lang/home.d.ts +6 -0
  87. package/lib/lang/home.d.ts.map +1 -0
  88. package/lib/lang/home.js +11 -0
  89. package/lib/lang/users.d.ts +6 -0
  90. package/lib/lang/users.d.ts.map +1 -0
  91. package/lib/lang/users.js +123 -0
  92. package/lib/middleware.d.ts +5 -0
  93. package/lib/middleware.d.ts.map +1 -0
  94. package/lib/middleware.js +9 -0
  95. package/lib/tsconfig.tsbuildinfo +1 -0
  96. package/lib/types/config.d.ts +8 -0
  97. package/lib/types/config.d.ts.map +1 -0
  98. package/lib/types/config.js +1 -0
  99. package/lib/types/groups.d.ts +5 -0
  100. package/lib/types/groups.d.ts.map +1 -0
  101. package/lib/types/groups.js +1 -0
  102. package/lib/types/index.d.ts +1 -0
  103. package/lib/types/index.d.ts.map +1 -0
  104. package/lib/types/index.js +1 -0
  105. package/lib/types/tables.d.ts +12 -0
  106. package/lib/types/tables.d.ts.map +1 -0
  107. package/lib/types/tables.js +1 -0
  108. package/lib/types/users.d.ts +11 -0
  109. package/lib/types/users.d.ts.map +1 -0
  110. package/lib/types/users.js +1 -0
  111. package/lib/utils/helpers/index.d.ts +1 -0
  112. package/lib/utils/helpers/index.d.ts.map +1 -0
  113. package/lib/utils/helpers/index.js +1 -0
  114. package/lib/utils/hooks/groups.d.ts +10 -0
  115. package/lib/utils/hooks/groups.d.ts.map +1 -0
  116. package/lib/utils/hooks/groups.js +133 -0
  117. package/lib/utils/hooks/index.d.ts +1 -0
  118. package/lib/utils/hooks/index.d.ts.map +1 -0
  119. package/lib/utils/hooks/index.js +1 -0
  120. package/lib/utils/hooks/users.d.ts +29 -0
  121. package/lib/utils/hooks/users.d.ts.map +1 -0
  122. package/lib/utils/hooks/users.js +254 -0
  123. package/lib/utils/index.d.ts +1 -0
  124. package/lib/utils/index.d.ts.map +1 -0
  125. package/lib/utils/index.js +1 -0
  126. package/package.json +99 -0
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # Rossini Auth
2
+
3
+ Rossini helps you build UI fast by providing a series of components and utilities featuring the Deix style.
4
+
5
+
6
+ Take a look at the [docs](https://docs.deix.ai/rossini-auth) to see components exported by rossini-auth.
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ declare const GroupsPage: React.FC;
3
+ export default GroupsPage;
4
+ //# sourceMappingURL=page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../src/app/[locale]/groups/page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAGvB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ import { useConfig } from '../../../config';
4
+ import Groups from '../../../components/groups/Groups';
5
+ const GroupsPage = () => {
6
+ const config = useConfig();
7
+ return React.createElement(Groups, { apiUrl: config.generalProperties.apiURL });
8
+ };
9
+ export default GroupsPage;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import '@fontsource/raleway/300.css';
3
+ import '@fontsource/raleway/400.css';
4
+ import '@fontsource/raleway/500.css';
5
+ import '@fontsource/raleway/600.css';
6
+ import '@fontsource/raleway/700.css';
7
+ export default function RootLayout({ children, }: {
8
+ children: React.ReactNode;
9
+ }): React.JSX.Element;
10
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/app/[locale]/layout.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBAiBA"}
@@ -0,0 +1,24 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ import { PageProvider } from '@deix/rossini-core';
4
+ import '@fontsource/raleway/300.css';
5
+ import '@fontsource/raleway/400.css';
6
+ import '@fontsource/raleway/500.css';
7
+ import '@fontsource/raleway/600.css';
8
+ import '@fontsource/raleway/700.css';
9
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
10
+ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
11
+ export default function RootLayout({ children, }) {
12
+ // const config = useConfig();
13
+ const queryClient = new QueryClient({
14
+ defaultOptions: {
15
+ queries: {
16
+ refetchOnWindowFocus: false,
17
+ refetchOnMount: false,
18
+ },
19
+ },
20
+ });
21
+ return (React.createElement(QueryClientProvider, { client: queryClient },
22
+ React.createElement(PageProvider, null, children),
23
+ React.createElement(ReactQueryDevtools, { initialIsOpen: false, buttonPosition: 'bottom-right' })));
24
+ }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ declare const UsersPage: () => React.JSX.Element;
3
+ export default UsersPage;
4
+ //# sourceMappingURL=page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../src/app/[locale]/users/page.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,QAAA,MAAM,SAAS,yBAGd,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ import { useConfig } from '../../../config';
4
+ import Users from '../../../components/users/Users';
5
+ const UsersPage = () => {
6
+ const config = useConfig();
7
+ return React.createElement(Users, { apiUrl: config.generalProperties.apiURL });
8
+ };
9
+ export default UsersPage;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import '@fontsource/raleway/300.css';
3
+ import '@fontsource/raleway/400.css';
4
+ import '@fontsource/raleway/500.css';
5
+ import '@fontsource/raleway/600.css';
6
+ import '@fontsource/raleway/700.css';
7
+ export declare const metadata: {
8
+ title: string;
9
+ };
10
+ export default function RootLayout({ children, }: {
11
+ children: React.ReactNode;
12
+ }): React.JSX.Element;
13
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/app/layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AACrC,OAAO,6BAA6B,CAAC;AAGrC,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,qBAeA"}
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import '@fontsource/raleway/300.css';
3
+ import '@fontsource/raleway/400.css';
4
+ import '@fontsource/raleway/500.css';
5
+ import '@fontsource/raleway/600.css';
6
+ import '@fontsource/raleway/700.css';
7
+ import { ConfigProvider } from '../config';
8
+ export const metadata = {
9
+ title: 'Rossini Authentication',
10
+ };
11
+ export default function RootLayout({ children, }) {
12
+ const publicRuntimeEnv = {
13
+ API_URL: process.env.API_URL || 'http://localhost:5000',
14
+ LOGOUT_URL: process.env.LOGOUT_URL || '',
15
+ ACCOUNT_SETTINGS_URL: process.env.ACCOUNT_SETTINGS_URL || '',
16
+ };
17
+ return (React.createElement("html", { lang: 'en' },
18
+ React.createElement("body", null,
19
+ React.createElement(ConfigProvider, { publicRuntimeEnv: publicRuntimeEnv }, children))));
20
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { StringTranslation } from '@deix/rossini-core';
3
+ interface Option {
4
+ value: string;
5
+ label: string;
6
+ }
7
+ interface AddItemDialogProps {
8
+ title: StringTranslation;
9
+ options?: Option[];
10
+ open: boolean;
11
+ onClose: () => void;
12
+ onConfirm: (value: Option | null) => void;
13
+ }
14
+ declare const AddItemDialog: ({ title, options, open, onClose, onConfirm, }: AddItemDialogProps) => React.JSX.Element;
15
+ export default AddItemDialog;
16
+ //# sourceMappingURL=AddItemDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AddItemDialog.d.ts","sourceRoot":"","sources":["../../src/components/AddItemDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,EAAE,iBAAiB,EAAa,MAAM,oBAAoB,CAAC;AAkBlE,UAAU,MAAM;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,kBAAkB;IAC1B,KAAK,EAAE,iBAAiB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3C;AAED,QAAA,MAAM,aAAa,kDAMhB,kBAAkB,sBAkDpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { Autocomplete, Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField, } from '@mui/material';
3
+ import { useLocale } from '@deix/rossini-core';
4
+ import { useEffect, useState } from 'react';
5
+ const translations = {
6
+ ok: {
7
+ en: 'Add',
8
+ it: 'Aggiungi',
9
+ },
10
+ cancel: {
11
+ en: 'Cancel',
12
+ it: 'Annulla',
13
+ },
14
+ search: {
15
+ en: 'Search...',
16
+ it: 'Cerca...',
17
+ },
18
+ };
19
+ const AddItemDialog = ({ title, options, open, onClose, onConfirm, }) => {
20
+ const locale = useLocale();
21
+ const [value, setValue] = useState(null);
22
+ // Reset the value when the dialog is closed
23
+ useEffect(() => {
24
+ if (!open) {
25
+ setValue(null);
26
+ }
27
+ }, [open]);
28
+ return (React.createElement(Dialog, { open: open, fullWidth: true, maxWidth: 'sm', onClose: onClose },
29
+ React.createElement(DialogTitle, null, title[locale]),
30
+ React.createElement(DialogContent, null,
31
+ React.createElement(Autocomplete
32
+ // multiple
33
+ , {
34
+ // multiple
35
+ options: options ?? [], getOptionLabel: (option) => option.label, getOptionKey: (option) => option.value, isOptionEqualToValue: (option, value) => option.value === value.value, renderInput: (params) => (React.createElement(TextField, { ...params, label: translations.search[locale], placeholder: '' })), onChange: (event, newValue) => {
36
+ setValue(newValue);
37
+ }, value: value })),
38
+ React.createElement(DialogActions, null,
39
+ React.createElement(Button, { size: 'small', variant: 'outlined', onClick: onClose }, translations.cancel[locale]),
40
+ React.createElement(Button, { variant: 'contained', onClick: () => {
41
+ onConfirm(value);
42
+ onClose();
43
+ } }, translations.ok[locale]))));
44
+ };
45
+ export default AddItemDialog;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface DeleteConfirmationDialogProps {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ onConfirm: () => void;
6
+ }
7
+ declare const DeleteConfirmationDialog: ({ open, onClose, onConfirm, }: DeleteConfirmationDialogProps) => React.JSX.Element;
8
+ export default DeleteConfirmationDialog;
9
+ //# sourceMappingURL=DeleteConfirmationDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteConfirmationDialog.d.ts","sourceRoot":"","sources":["../../src/components/DeleteConfirmationDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AA8B1B,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,QAAA,MAAM,wBAAwB,kCAI3B,6BAA6B,sBA2B/B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Typography, } from '@mui/material';
3
+ import { useLocale } from '@deix/rossini-core';
4
+ const translations = {
5
+ title: {
6
+ en: 'Delete item?',
7
+ it: 'Cancellare elemento?',
8
+ },
9
+ message: {
10
+ en: 'This is a permanent action',
11
+ it: "Questa è un'azione permanente",
12
+ },
13
+ yes: {
14
+ en: 'Yes',
15
+ it: 'Si',
16
+ },
17
+ no: {
18
+ en: 'No',
19
+ it: 'No',
20
+ },
21
+ };
22
+ const DeleteConfirmationDialog = ({ open, onClose, onConfirm, }) => {
23
+ const locale = useLocale();
24
+ return (React.createElement(Dialog, { open: open, fullWidth: true, maxWidth: 'sm', onClose: onClose },
25
+ React.createElement(DialogTitle, null, translations.title[locale]),
26
+ React.createElement(DialogContent, null,
27
+ React.createElement(Typography, { variant: 'caption' }, translations.message[locale])),
28
+ React.createElement(DialogActions, null,
29
+ React.createElement(Button, { size: 'small', variant: 'outlined', onClick: onClose }, translations.no[locale]),
30
+ React.createElement(Button, { size: 'small', variant: 'contained', onClick: () => {
31
+ onConfirm();
32
+ onClose();
33
+ } }, translations.yes[locale]))));
34
+ };
35
+ export default DeleteConfirmationDialog;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { TextFieldProps as MuiTextFieldProps } from '@mui/material';
3
+ type SearchFieldProps = MuiTextFieldProps & {
4
+ onSearch: (val: string) => void;
5
+ };
6
+ declare const SearchField: ({ placeholder, onSearch, ...props }: SearchFieldProps) => React.JSX.Element;
7
+ export default SearchField;
8
+ //# sourceMappingURL=SearchField.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchField.d.ts","sourceRoot":"","sources":["../../src/components/SearchField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAEL,cAAc,IAAI,iBAAiB,EAEpC,MAAM,eAAe,CAAC;AAIvB,KAAK,gBAAgB,GAAG,iBAAiB,GAAG;IAC1C,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF,QAAA,MAAM,WAAW,wCAId,gBAAgB,sBAwBlB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import SearchIcon from '@mui/icons-material/Search';
3
+ import { IconButton, TextField, } from '@mui/material';
4
+ import { useState } from 'react';
5
+ const SearchField = ({ placeholder = 'Search...', onSearch, ...props }) => {
6
+ const [value, setValue] = useState('');
7
+ return (React.createElement(React.Fragment, null,
8
+ React.createElement(TextField, { size: 'small', placeholder: placeholder, value: value, onChange: (evt) => {
9
+ setValue(evt.target.value);
10
+ onSearch(evt.target.value);
11
+ }, ...props, InputProps: {
12
+ endAdornment: (React.createElement(IconButton, { size: 'small', onClick: () => onSearch(value) },
13
+ React.createElement(SearchIcon, null))),
14
+ } })));
15
+ };
16
+ export default SearchField;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface CreateGroupDialogProps {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ }
6
+ declare const CreateGroupDialog: ({ open, onClose }: CreateGroupDialogProps) => React.JSX.Element;
7
+ export default CreateGroupDialog;
8
+ //# sourceMappingURL=CreateGroupDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/groups/CreateGroupDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,iBAAiB,sBAAuB,sBAAsB,sBAqBnE,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { useAPI, useLocale } from '@deix/rossini-core';
3
+ import { Dialog, DialogContent, DialogTitle } from '@mui/material';
4
+ import { useQueryClient } from '@tanstack/react-query';
5
+ import { useConfig } from '../../config';
6
+ import groupsTranslations from '../../lang/groups';
7
+ import { useAddGroup } from '../../utils/hooks/groups';
8
+ import GroupForm from './GroupForm';
9
+ const CreateGroupDialog = ({ open, onClose }) => {
10
+ const locale = useLocale();
11
+ const config = useConfig();
12
+ const apiClient = useAPI(config.generalProperties.apiURL);
13
+ const queryClient = useQueryClient();
14
+ const { mutate: addGroup } = useAddGroup(queryClient, apiClient);
15
+ const handleSave = (group) => {
16
+ addGroup(group);
17
+ onClose();
18
+ };
19
+ return (React.createElement(Dialog, { open: open, fullWidth: true, maxWidth: 'sm', onClose: onClose },
20
+ React.createElement(DialogTitle, null, groupsTranslations.create[locale]),
21
+ React.createElement(DialogContent, null,
22
+ React.createElement(GroupForm, { mode: 'create', onSave: handleSave, onCancel: onClose }))));
23
+ };
24
+ export default CreateGroupDialog;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { Group } from '../../types/groups';
3
+ export interface GroupDetailsProps {
4
+ group: Group;
5
+ }
6
+ declare const GroupDetails: ({ group }: GroupDetailsProps) => React.JSX.Element;
7
+ export default GroupDetails;
8
+ //# sourceMappingURL=GroupDetails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupDetails.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupDetails.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;CACd;AAED,QAAA,MAAM,YAAY,cAAe,iBAAiB,sBAoBjD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { useAPI } from '@deix/rossini-core';
3
+ import { useQueryClient } from '@tanstack/react-query';
4
+ import { useConfig } from '../../config';
5
+ import { useUpdateGroup } from '../../utils/hooks/groups';
6
+ import GroupForm from './GroupForm';
7
+ const GroupDetails = ({ group }) => {
8
+ const config = useConfig();
9
+ const apiClient = useAPI(config.generalProperties.apiURL);
10
+ const queryClient = useQueryClient();
11
+ const { mutate: updateGroup } = useUpdateGroup(queryClient, apiClient);
12
+ const handleUpdate = (group) => {
13
+ updateGroup(group);
14
+ };
15
+ return (React.createElement(React.Fragment, null,
16
+ React.createElement(GroupForm, { mode: 'modify', group: group, onSave: handleUpdate, onCancel: () => { } })));
17
+ };
18
+ export default GroupDetails;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Group } from '../../types/groups';
3
+ export interface GroupFormProps {
4
+ onCancel?: () => void;
5
+ onSave: (group: Group) => void;
6
+ group?: Group;
7
+ mode: 'create' | 'modify';
8
+ }
9
+ declare const GroupForm: ({ group, onCancel, onSave, mode }: GroupFormProps) => React.JSX.Element;
10
+ export default GroupForm;
11
+ //# sourceMappingURL=GroupForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupForm.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC3B;AAED,QAAA,MAAM,SAAS,sCAAuC,cAAc,sBAkEnE,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { useLocale } from '@deix/rossini-core';
3
+ import { Button, Grid, TextField } from '@mui/material';
4
+ import { Controller, useForm } from 'react-hook-form';
5
+ import { useEffect } from 'react';
6
+ import groupsTranslations from '../../lang/groups';
7
+ const GroupForm = ({ group, onCancel, onSave, mode }) => {
8
+ const locale = useLocale();
9
+ const { control, handleSubmit, setValue } = useForm({
10
+ defaultValues: {
11
+ id: group?.id,
12
+ name: group?.name,
13
+ },
14
+ });
15
+ useEffect(() => {
16
+ if (group) {
17
+ setValue('id', group?.id);
18
+ setValue('name', group?.name);
19
+ }
20
+ }, [group, setValue]);
21
+ const onSubmit = (data) => {
22
+ onSave(data);
23
+ };
24
+ return (React.createElement("form", { onSubmit: (event) => void handleSubmit(onSubmit)(event) },
25
+ React.createElement(Grid, { container: true, spacing: 2, sx: { mt: 2, maxWidth: 'sm' }, justifyContent: 'stretch' },
26
+ React.createElement(Grid, { item: true, xs: 12 },
27
+ React.createElement(Controller, { name: 'name', control: control, render: ({ field }) => (React.createElement(TextField, { size: 'small', fullWidth: true, label: groupsTranslations.name[locale], sx: { flexShrink: 0 }, ...field })) })),
28
+ React.createElement(Grid, { item: true, sx: {
29
+ mt: 2,
30
+ display: 'flex',
31
+ justifyContent: 'flex-end',
32
+ gap: 2,
33
+ width: '100%',
34
+ } },
35
+ mode === 'create' && (React.createElement(Button, { variant: 'outlined', onClick: onCancel }, groupsTranslations.cancel[locale])),
36
+ React.createElement(Button, { variant: 'contained', type: 'submit' }, groupsTranslations.save[locale])))));
37
+ };
38
+ export default GroupForm;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { StringTranslation } from '@deix/rossini-core';
3
+ import { Group } from '../../types/groups';
4
+ export interface GroupTab {
5
+ title: StringTranslation;
6
+ component: React.FunctionComponent<{
7
+ group: Group;
8
+ }>;
9
+ }
10
+ export interface GroupTabsProps {
11
+ group: Group;
12
+ additionalTabs?: GroupTab[];
13
+ }
14
+ declare const GroupTabs: ({ group, additionalTabs }: GroupTabsProps) => React.JSX.Element;
15
+ export default GroupTabs;
16
+ //# sourceMappingURL=GroupTabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupTabs.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupTabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAE,iBAAiB,EAAa,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAK3C,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,iBAAiB,CAAC;IACzB,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC;CAC7B;AAED,QAAA,MAAM,SAAS,8BAAoC,cAAc,sBAwChE,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,29 @@
1
+ 'use client';
2
+ import React, { useState } from 'react';
3
+ import { Box, Tab, Tabs } from '@mui/material';
4
+ import { useLocale } from '@deix/rossini-core';
5
+ import GroupDetails from './GroupDetails';
6
+ import groupsTranslations from '../../lang/groups';
7
+ import GroupUsers from './GroupUsers';
8
+ const GroupTabs = ({ group, additionalTabs = [] }) => {
9
+ const locale = useLocale();
10
+ const [selectedTab, setSelectedTab] = useState('DETAILS');
11
+ return (React.createElement(Box, { sx: {
12
+ flexGrow: 1,
13
+ maxWidth: '100%',
14
+ overflowX: 'hidden',
15
+ alignSelf: 'stretch',
16
+ } },
17
+ React.createElement(Box, { sx: { borderBottom: 1, borderColor: 'divider' } },
18
+ React.createElement(Tabs, { value: selectedTab, onChange: (_evt, newValue) => {
19
+ setSelectedTab(newValue);
20
+ }, "aria-label": 'basic tabs example' },
21
+ React.createElement(Tab, { label: groupsTranslations.details[locale], value: 'DETAILS' }),
22
+ React.createElement(Tab, { label: groupsTranslations.users[locale], value: 'USERS' }),
23
+ additionalTabs.map((tab, index) => (React.createElement(Tab, { label: tab.title[locale], value: `ADDITIONAL_TAB_${index}` }))))),
24
+ React.createElement(Box, { sx: { p: 1 } },
25
+ selectedTab === 'DETAILS' && React.createElement(GroupDetails, { group: group }),
26
+ selectedTab === 'USERS' && React.createElement(GroupUsers, { group: group }),
27
+ additionalTabs.map((tab, index) => selectedTab === `ADDITIONAL_TAB_${index}` && (React.createElement(tab.component, { group: group }))))));
28
+ };
29
+ export default GroupTabs;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { Group } from '../../types/groups';
3
+ interface GroupUsersProps {
4
+ group: Group;
5
+ }
6
+ declare const GroupUsers: ({ group }: GroupUsersProps) => React.JSX.Element;
7
+ export default GroupUsers;
8
+ //# sourceMappingURL=GroupUsers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupUsers.d.ts","sourceRoot":"","sources":["../../../src/components/groups/GroupUsers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AA+B3C,UAAU,eAAe;IACvB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,QAAA,MAAM,UAAU,cAAe,eAAe,sBA+F7C,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import { Box, Button, IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, } from '@mui/material';
3
+ import AddIcon from '@mui/icons-material/Add';
4
+ import DeleteIcon from '@mui/icons-material/Delete';
5
+ import { isStringTranslation, useAPI, useLocale } from '@deix/rossini-core';
6
+ import { useConfig } from '../../config';
7
+ import { useAddUserToGroup, useRemoveUserFromGroup, useUsers, } from '../../utils/hooks/users';
8
+ import { useState } from 'react';
9
+ import DeleteConfirmationDialog from '../DeleteConfirmationDialog';
10
+ import { useQueryClient } from '@tanstack/react-query';
11
+ import AddItemDialog from '../AddItemDialog';
12
+ import { useGroupUsers } from '../../utils/hooks/groups';
13
+ import groupsTranslations from '../../lang/groups';
14
+ const groupUsersTableColumns = [
15
+ {
16
+ id: 'username',
17
+ label: { en: 'Username', it: 'Username' },
18
+ },
19
+ {
20
+ id: 'firstName',
21
+ label: { en: 'First name', it: 'Nome' },
22
+ },
23
+ {
24
+ id: 'lastName',
25
+ label: { en: 'Last name', it: 'Cognome' },
26
+ },
27
+ ];
28
+ const GroupUsers = ({ group }) => {
29
+ const locale = useLocale();
30
+ const config = useConfig();
31
+ const apiClient = useAPI(config.generalProperties.apiURL);
32
+ const queryClient = useQueryClient();
33
+ const { data: users } = useUsers(apiClient);
34
+ const { data: groupUsers } = useGroupUsers(group?.id, apiClient);
35
+ const { mutate: addUserToGroup } = useAddUserToGroup(queryClient, apiClient);
36
+ const { mutate: removeUserFromGroup } = useRemoveUserFromGroup(queryClient, apiClient);
37
+ const [openAddUserDialog, setOpenAddUserDialog] = useState(false);
38
+ const [openConfirmationDialog, setOpenConfirmationDialog] = useState(false);
39
+ const [deleteId, setDeleteId] = useState();
40
+ return (React.createElement(React.Fragment, null,
41
+ groupUsers && groupUsers.length > 0 && (React.createElement(Box, { maxWidth: 'md' },
42
+ React.createElement(TableContainer, null,
43
+ React.createElement(Table, { size: 'small' },
44
+ React.createElement(TableHead, null,
45
+ React.createElement(TableRow, null,
46
+ groupUsersTableColumns.map((col) => (React.createElement(TableCell, { key: col.id, align: col.align || 'inherit' }, isStringTranslation(col.label)
47
+ ? col.label[locale]
48
+ : col.label))),
49
+ React.createElement(TableCell, { padding: 'none' }, ''))),
50
+ React.createElement(TableBody, null, groupUsers?.map((user, rowIdx) => (React.createElement(TableRow, { key: rowIdx },
51
+ React.createElement(TableCell, null, user.username),
52
+ React.createElement(TableCell, null, user.firstName),
53
+ React.createElement(TableCell, null, user.lastName),
54
+ React.createElement(TableCell, { padding: 'none', align: 'right' },
55
+ React.createElement(IconButton, { size: 'small', onClick: (evt) => {
56
+ evt.stopPropagation();
57
+ setOpenConfirmationDialog(true);
58
+ setDeleteId(user.id);
59
+ } },
60
+ React.createElement(DeleteIcon, null))))))))))),
61
+ React.createElement(Button, { variant: 'outlined', startIcon: React.createElement(AddIcon, null), onClick: () => setOpenAddUserDialog(true), sx: { marginTop: 2 } }, groupsTranslations.addUser[locale]),
62
+ React.createElement(AddItemDialog, { open: openAddUserDialog, onClose: () => setOpenAddUserDialog(false), onConfirm: (value) => {
63
+ if (value) {
64
+ addUserToGroup({ userId: value?.value, groupId: group.id });
65
+ }
66
+ }, title: groupsTranslations.addUser, options: users?.map((user) => ({
67
+ value: user.id,
68
+ label: user.username || '',
69
+ })) }),
70
+ React.createElement(DeleteConfirmationDialog, { open: openConfirmationDialog, onClose: () => setOpenConfirmationDialog(false), onConfirm: () => deleteId
71
+ ? removeUserFromGroup({ userId: deleteId, groupId: group.id })
72
+ : {} })));
73
+ };
74
+ export default GroupUsers;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { GroupTab } from './GroupTabs';
3
+ interface GroupsProps {
4
+ apiUrl: string;
5
+ additionalTabs?: GroupTab[];
6
+ }
7
+ declare const Groups: ({ apiUrl, additionalTabs }: GroupsProps) => React.JSX.Element;
8
+ export default Groups;
9
+ //# sourceMappingURL=Groups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Groups.d.ts","sourceRoot":"","sources":["../../../src/components/groups/Groups.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAanD,OAAkB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGlD,UAAU,WAAW;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,QAAQ,EAAE,CAAC;CAC7B;AAED,QAAA,MAAM,MAAM,+BAAqC,WAAW,sBAqH3D,CAAC;AAEF,eAAe,MAAM,CAAC"}