@hedhog/admin 0.46.36 → 0.46.39

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 (120) hide show
  1. package/README.md +960 -960
  2. package/dist/auth/auth.service.d.ts.map +1 -1
  3. package/dist/auth/auth.service.js +22 -2
  4. package/dist/auth/auth.service.js.map +1 -1
  5. package/dist/auth/consts/body.js +24 -24
  6. package/dist/emails/index.d.ts +3 -0
  7. package/dist/emails/index.d.ts.map +1 -0
  8. package/dist/emails/index.js +19 -0
  9. package/dist/emails/index.js.map +1 -0
  10. package/dist/emails/lib.d.ts +6 -0
  11. package/dist/emails/lib.d.ts.map +1 -0
  12. package/dist/emails/lib.js +43 -0
  13. package/dist/emails/lib.js.map +1 -0
  14. package/dist/emails/templates.d.ts +13 -0
  15. package/dist/emails/templates.d.ts.map +1 -0
  16. package/dist/emails/templates.js +63 -0
  17. package/dist/emails/templates.js.map +1 -0
  18. package/frontend/menu/components/create-panel.tsx.ejs +55 -55
  19. package/frontend/menu/components/update-panel.tsx.ejs +67 -67
  20. package/frontend/menu/locales/en/admin.menu.json +11 -11
  21. package/frontend/menu/locales/pt/admin.menu.json +11 -11
  22. package/frontend/menu/react-query/handlers.ts.ejs +28 -28
  23. package/frontend/menu/react-query/requests.ts.ejs +56 -56
  24. package/frontend/menu-locale/locales/en/admin.menu-locale.json +11 -11
  25. package/frontend/menu-locale/locales/pt/admin.menu-locale.json +11 -11
  26. package/frontend/menu-screen/locales/en/admin.menu-screen.json +11 -11
  27. package/frontend/menu-screen/locales/pt/admin.menu-screen.json +11 -11
  28. package/frontend/multifactor/components/create-panel.tsx.ejs +55 -55
  29. package/frontend/multifactor/components/update-panel.tsx.ejs +70 -70
  30. package/frontend/multifactor/locales/en/admin.multifactor.json +11 -11
  31. package/frontend/multifactor/locales/pt/admin.multifactor.json +11 -11
  32. package/frontend/multifactor/react-query/handlers.ts.ejs +28 -28
  33. package/frontend/multifactor/react-query/requests.ts.ejs +59 -59
  34. package/frontend/multifactor-locale/locales/en/admin.multifactor-locale.json +11 -11
  35. package/frontend/multifactor-locale/locales/pt/admin.multifactor-locale.json +11 -11
  36. package/frontend/screen/components/create-panel.tsx.ejs +55 -55
  37. package/frontend/screen/components/update-panel.tsx.ejs +67 -67
  38. package/frontend/screen/locales/en/admin.screen.json +11 -11
  39. package/frontend/screen/locales/pt/admin.screen.json +11 -11
  40. package/frontend/screen/react-query/handlers.ts.ejs +28 -28
  41. package/frontend/screen/react-query/requests.ts.ejs +56 -56
  42. package/frontend/screen-locale/locales/en/admin.screen-locale.json +11 -11
  43. package/frontend/screen-locale/locales/pt/admin.screen-locale.json +11 -11
  44. package/frontend/translation/components/create-panel.tsx.ejs +52 -52
  45. package/frontend/translation/components/update-panel.tsx.ejs +67 -67
  46. package/frontend/translation/locales/en/admin.translation.json +11 -11
  47. package/frontend/translation/locales/pt/admin.translation.json +11 -11
  48. package/frontend/translation/react-query/handlers.ts.ejs +28 -28
  49. package/frontend/translation/react-query/requests.ts.ejs +58 -58
  50. package/frontend/translation-namespace/components/create-panel.tsx.ejs +53 -53
  51. package/frontend/translation-namespace/components/update-panel.tsx.ejs +70 -70
  52. package/frontend/translation-namespace/locales/en/admin.translation-namespace.json +11 -11
  53. package/frontend/translation-namespace/locales/pt/admin.translation-namespace.json +11 -11
  54. package/frontend/translation-namespace/react-query/handlers.ts.ejs +28 -28
  55. package/frontend/translation-namespace/react-query/requests.ts.ejs +60 -60
  56. package/frontend/user/components/create-panel.tsx.ejs +52 -52
  57. package/frontend/user/components/update-panel.tsx.ejs +64 -64
  58. package/frontend/user/locales/en/admin.user.json +11 -11
  59. package/frontend/user/locales/pt/admin.user.json +11 -11
  60. package/frontend/user/react-query/handlers.ts.ejs +28 -28
  61. package/frontend/user/react-query/requests.ts.ejs +55 -55
  62. package/hedhog.yaml +783 -783
  63. package/package.json +45 -43
  64. package/src/admin.module.ts +39 -39
  65. package/src/auth/auth.controller.ts +88 -88
  66. package/src/auth/auth.module.ts +41 -41
  67. package/src/auth/auth.service.spec.ts +196 -196
  68. package/src/auth/auth.service.ts +349 -323
  69. package/src/auth/consts/body.ts +27 -27
  70. package/src/auth/dto/change.dto.ts +19 -19
  71. package/src/auth/dto/email.dto.ts +15 -15
  72. package/src/auth/dto/forget.dto.ts +6 -6
  73. package/src/auth/dto/login.dto.ts +21 -21
  74. package/src/auth/dto/otp.dto.ts +11 -11
  75. package/src/auth/dto/reset.dto.ts +14 -14
  76. package/src/auth/enums/multifactor-type.enum.ts +4 -4
  77. package/src/auth/guards/auth.guard.ts +54 -54
  78. package/src/auth/types/user.type.ts +8 -8
  79. package/src/dto/delete.dto.ts +8 -8
  80. package/src/dto/update-ids.dto.ts +9 -9
  81. package/src/emails/index.ts +2 -0
  82. package/src/emails/lib.ts +40 -0
  83. package/src/emails/templates.ts +60 -0
  84. package/src/index.ts +20 -20
  85. package/src/menu/dto/create.dto.ts +25 -25
  86. package/src/menu/dto/order.dto.ts +8 -8
  87. package/src/menu/dto/update.dto.ts +19 -19
  88. package/src/menu/menu.controller.ts +105 -105
  89. package/src/menu/menu.module.ts +18 -18
  90. package/src/menu/menu.service.spec.ts +247 -247
  91. package/src/menu/menu.service.ts +263 -263
  92. package/src/role/dto/create.dto.ts +7 -7
  93. package/src/role/dto/update.dto.ts +4 -4
  94. package/src/role/guards/role.guard.ts +121 -121
  95. package/src/role/role.controller.ts +126 -126
  96. package/src/role/role.module.ts +28 -28
  97. package/src/role/role.service.spec.ts +417 -417
  98. package/src/role/role.service.ts +289 -289
  99. package/src/route/dto/create.dto.ts +13 -13
  100. package/src/route/dto/update.dto.ts +15 -15
  101. package/src/route/route.controller.ts +91 -91
  102. package/src/route/route.module.ts +18 -18
  103. package/src/route/route.service.spec.ts +300 -300
  104. package/src/route/route.service.ts +164 -164
  105. package/src/screen/dto/create.dto.ts +11 -11
  106. package/src/screen/dto/update.dto.ts +19 -19
  107. package/src/screen/screen.controller.ts +93 -93
  108. package/src/screen/screen.module.ts +18 -18
  109. package/src/screen/screen.service.spec.ts +298 -298
  110. package/src/screen/screen.service.ts +179 -179
  111. package/src/types/http-method.ts +8 -8
  112. package/src/user/constants/user.constants.ts +1 -1
  113. package/src/user/dto/create.dto.ts +24 -24
  114. package/src/user/dto/update.dto.ts +41 -41
  115. package/src/user/user.controller.ts +75 -75
  116. package/src/user/user.module.ts +18 -18
  117. package/src/user/user.service.spec.ts +294 -294
  118. package/src/user/user.service.ts +129 -129
  119. package/tsconfig.lib.json +9 -9
  120. package/tsconfig.production.json +20 -20
@@ -1,70 +1,70 @@
1
- import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
- import { Overlay } from "@/components/custom/overlay";
3
- import { TabPanel } from "@/components/panels/tab-panel";
4
- import {
5
- useTranslationNamespaceGet,
6
- useTranslationNamespaceUpdate,
7
- } from "@/features/admin/translation-namespace";
8
- import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
9
- import { TranslationNamespace } from "@/types/models";
10
- import { useState, forwardRef, useImperativeHandle, useRef } from "react";
11
- import { useTranslation } from "react-i18next";
12
- import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
13
-
14
- export type TranslationNamespaceUpdatePanelProps = {
15
- data: TranslationNamespace;
16
- onUpdated?: (data: TranslationNamespace) => void;
17
- };
18
-
19
- const TranslationNamespaceUpdatePanel = forwardRef(
20
- ({ data, onUpdated }: TranslationNamespaceUpdatePanelProps, ref) => {
21
- const { t } = useTranslation(["actions", "fields", "translations"]);
22
- const { data: item, isLoading } = useTranslationNamespaceGet(
23
- data.id as number,
24
- );
25
- const { mutate: translationNamespaceUpdate } =
26
- useTranslationNamespaceUpdate();
27
- const formRef = useRef<FormPanelRef>(null);
28
-
29
- useEffectAfterFirstUpdate(() => {
30
- if (item && formRef.current) {
31
- formRef.current.setValuesFromItem(item);
32
- }
33
- }, [item]);
34
-
35
- useImperativeHandle(ref, () => ({}));
36
-
37
- return (
38
- <TabPanel
39
- activeTabIndex={0}
40
- tabs={[
41
- {
42
- title: t("details", { ns: "actions" }),
43
- children: (
44
- <Overlay loading={isLoading}>
45
- <FormPanel
46
- ref={formRef}
47
- fields={[]}
48
- button={{ text: t("save", { ns: "actions" }) }}
49
- onSubmit={(data) => {
50
- translationNamespaceUpdate({
51
- id: data.id,
52
- data,
53
- });
54
- if (typeof onUpdated === "function") {
55
- onUpdated(data);
56
- }
57
- }}
58
- />
59
- </Overlay>
60
- ),
61
- },
62
- ]}
63
- />
64
- );
65
- },
66
- );
67
-
68
- TranslationNamespaceUpdatePanel.displayName = "TranslationNamespaceUpdatePanel";
69
-
70
- export default TranslationNamespaceUpdatePanel;
1
+ import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
+ import { Overlay } from "@/components/custom/overlay";
3
+ import { TabPanel } from "@/components/panels/tab-panel";
4
+ import {
5
+ useTranslationNamespaceGet,
6
+ useTranslationNamespaceUpdate,
7
+ } from "@/features/admin/translation-namespace";
8
+ import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
9
+ import { TranslationNamespace } from "@/types/models";
10
+ import { useState, forwardRef, useImperativeHandle, useRef } from "react";
11
+ import { useTranslation } from "react-i18next";
12
+ import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
13
+
14
+ export type TranslationNamespaceUpdatePanelProps = {
15
+ data: TranslationNamespace;
16
+ onUpdated?: (data: TranslationNamespace) => void;
17
+ };
18
+
19
+ const TranslationNamespaceUpdatePanel = forwardRef(
20
+ ({ data, onUpdated }: TranslationNamespaceUpdatePanelProps, ref) => {
21
+ const { t } = useTranslation(["actions", "fields", "translations"]);
22
+ const { data: item, isLoading } = useTranslationNamespaceGet(
23
+ data.id as number,
24
+ );
25
+ const { mutate: translationNamespaceUpdate } =
26
+ useTranslationNamespaceUpdate();
27
+ const formRef = useRef<FormPanelRef>(null);
28
+
29
+ useEffectAfterFirstUpdate(() => {
30
+ if (item && formRef.current) {
31
+ formRef.current.setValuesFromItem(item);
32
+ }
33
+ }, [item]);
34
+
35
+ useImperativeHandle(ref, () => ({}));
36
+
37
+ return (
38
+ <TabPanel
39
+ activeTabIndex={0}
40
+ tabs={[
41
+ {
42
+ title: t("details", { ns: "actions" }),
43
+ children: (
44
+ <Overlay loading={isLoading}>
45
+ <FormPanel
46
+ ref={formRef}
47
+ fields={[]}
48
+ button={{ text: t("save", { ns: "actions" }) }}
49
+ onSubmit={(data) => {
50
+ translationNamespaceUpdate({
51
+ id: data.id,
52
+ data,
53
+ });
54
+ if (typeof onUpdated === "function") {
55
+ onUpdated(data);
56
+ }
57
+ }}
58
+ />
59
+ </Overlay>
60
+ ),
61
+ },
62
+ ]}
63
+ />
64
+ );
65
+ },
66
+ );
67
+
68
+ TranslationNamespaceUpdatePanel.displayName = "TranslationNamespaceUpdatePanel";
69
+
70
+ export default TranslationNamespaceUpdatePanel;
@@ -1,11 +1,11 @@
1
- {
2
- "create": "Create translation namespace",
3
- "createText": "Fill the translation namespace informations.",
4
- "createTooltip": "Create new translation namespace",
5
- "delete": "Delete translation namespace",
6
- "deleteText": "Are you sure to delete these translation namespace?",
7
- "deleteTooltip": "Delete the selected translation namespace",
8
- "edit": "Edit translation namespace",
9
- "editText": "View and edit translation namespace information.",
10
- "editTooltip": "Edit the selected translation namespace"
11
- }
1
+ {
2
+ "create": "Create translation namespace",
3
+ "createText": "Fill the translation namespace informations.",
4
+ "createTooltip": "Create new translation namespace",
5
+ "delete": "Delete translation namespace",
6
+ "deleteText": "Are you sure to delete these translation namespace?",
7
+ "deleteTooltip": "Delete the selected translation namespace",
8
+ "edit": "Edit translation namespace",
9
+ "editText": "View and edit translation namespace information.",
10
+ "editTooltip": "Edit the selected translation namespace"
11
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "create": "Criar translation namespace",
3
- "createText": "Preencha as informações do translation namespace.",
4
- "createTooltip": "Criar novo translation namespace",
5
- "delete": "Excluir translation namespace",
6
- "deleteText": "Você tem certeza de que deseja excluir estes translation namespace?",
7
- "deleteTooltip": "Excluir o translation namespace selecionado",
8
- "edit": "Editar translation namespace",
9
- "editText": "Visualizar e editar informações do translation namespace.",
10
- "editTooltip": "Editar o translation namespace selecionado"
11
- }
1
+ {
2
+ "create": "Criar translation namespace",
3
+ "createText": "Preencha as informações do translation namespace.",
4
+ "createTooltip": "Criar novo translation namespace",
5
+ "delete": "Excluir translation namespace",
6
+ "deleteText": "Você tem certeza de que deseja excluir estes translation namespace?",
7
+ "deleteTooltip": "Excluir o translation namespace selecionado",
8
+ "edit": "Editar translation namespace",
9
+ "editText": "Visualizar e editar informações do translation namespace.",
10
+ "editTooltip": "Editar o translation namespace selecionado"
11
+ }
@@ -1,28 +1,28 @@
1
- import { useDefaultMutation } from "@/hooks/use-default-mutation";
2
- import { useQuery } from "@tanstack/react-query";
3
- import { requests } from "./requests";
4
-
5
- const scope = "translation-namespace";
6
-
7
- export function useTranslationNamespaceCreate() {
8
- const { translationNamespaceCreate } = requests();
9
- return useDefaultMutation(scope, "create", translationNamespaceCreate);
10
- }
11
-
12
- export function useTranslationNamespaceDelete() {
13
- const { translationNamespaceDelete } = requests();
14
- return useDefaultMutation(scope, "delete", translationNamespaceDelete);
15
- }
16
-
17
- export function useTranslationNamespaceUpdate() {
18
- const { translationNamespaceUpdate } = requests();
19
- return useDefaultMutation(scope, "update", translationNamespaceUpdate);
20
- }
21
-
22
- export function useTranslationNamespaceGet(id: number) {
23
- const { translationNamespaceGet } = requests();
24
- return useQuery({
25
- queryKey: [scope, "get"],
26
- queryFn: () => translationNamespaceGet(id),
27
- });
28
- }
1
+ import { useDefaultMutation } from "@/hooks/use-default-mutation";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { requests } from "./requests";
4
+
5
+ const scope = "translation-namespace";
6
+
7
+ export function useTranslationNamespaceCreate() {
8
+ const { translationNamespaceCreate } = requests();
9
+ return useDefaultMutation(scope, "create", translationNamespaceCreate);
10
+ }
11
+
12
+ export function useTranslationNamespaceDelete() {
13
+ const { translationNamespaceDelete } = requests();
14
+ return useDefaultMutation(scope, "delete", translationNamespaceDelete);
15
+ }
16
+
17
+ export function useTranslationNamespaceUpdate() {
18
+ const { translationNamespaceUpdate } = requests();
19
+ return useDefaultMutation(scope, "update", translationNamespaceUpdate);
20
+ }
21
+
22
+ export function useTranslationNamespaceGet(id: number) {
23
+ const { translationNamespaceGet } = requests();
24
+ return useQuery({
25
+ queryKey: [scope, "get"],
26
+ queryFn: () => translationNamespaceGet(id),
27
+ });
28
+ }
@@ -1,60 +1,60 @@
1
- import { useApp } from "@/hooks/use-app";
2
- import { Delete, PaginationParams, PaginationResult } from "@/types";
3
- import { TranslationNamespace } from "@/types/models";
4
- import { HttpMethod } from "@/types/http-method";
5
-
6
- export function requests() {
7
- const { request } = useApp();
8
-
9
- const translationNamespaceList = async (params: PaginationParams) => {
10
- return request<PaginationResult<TranslationNamespace>>({
11
- url: "/translation-namespace",
12
- params,
13
- }).then((res) => res.data);
14
- };
15
-
16
- const translationNamespaceGet = async (id: number) => {
17
- return request<TranslationNamespace>({
18
- url: `/translation-namespace/${id}`,
19
- }).then((res) => res.data);
20
- };
21
-
22
- const translationNamespaceCreate = async (params: {
23
- data: TranslationNamespace;
24
- }) => {
25
- const { data } = params;
26
- return request<TranslationNamespace>({
27
- url: "/translation-namespace",
28
- method: HttpMethod.POST,
29
- data: data,
30
- }).then((res) => res.data);
31
- };
32
-
33
- const translationNamespaceDelete = async (ids: number[]) => {
34
- return request<Delete>({
35
- url: "/translation-namespace",
36
- data: { ids },
37
- method: HttpMethod.DELETE,
38
- }).then((res) => res.data);
39
- };
40
-
41
- const translationNamespaceUpdate = async (params: {
42
- id: number;
43
- data: TranslationNamespace;
44
- }) => {
45
- const { id, data } = params;
46
- return request<TranslationNamespace>({
47
- url: `/translation-namespace/${id}`,
48
- method: HttpMethod.PATCH,
49
- data: data,
50
- }).then((res) => res.data);
51
- };
52
-
53
- return {
54
- translationNamespaceCreate,
55
- translationNamespaceUpdate,
56
- translationNamespaceDelete,
57
- translationNamespaceList,
58
- translationNamespaceGet,
59
- };
60
- }
1
+ import { useApp } from "@/hooks/use-app";
2
+ import { Delete, PaginationParams, PaginationResult } from "@/types";
3
+ import { TranslationNamespace } from "@/types/models";
4
+ import { HttpMethod } from "@/types/http-method";
5
+
6
+ export function requests() {
7
+ const { request } = useApp();
8
+
9
+ const translationNamespaceList = async (params: PaginationParams) => {
10
+ return request<PaginationResult<TranslationNamespace>>({
11
+ url: "/translation-namespace",
12
+ params,
13
+ }).then((res) => res.data);
14
+ };
15
+
16
+ const translationNamespaceGet = async (id: number) => {
17
+ return request<TranslationNamespace>({
18
+ url: `/translation-namespace/${id}`,
19
+ }).then((res) => res.data);
20
+ };
21
+
22
+ const translationNamespaceCreate = async (params: {
23
+ data: TranslationNamespace;
24
+ }) => {
25
+ const { data } = params;
26
+ return request<TranslationNamespace>({
27
+ url: "/translation-namespace",
28
+ method: HttpMethod.POST,
29
+ data: data,
30
+ }).then((res) => res.data);
31
+ };
32
+
33
+ const translationNamespaceDelete = async (ids: number[]) => {
34
+ return request<Delete>({
35
+ url: "/translation-namespace",
36
+ data: { ids },
37
+ method: HttpMethod.DELETE,
38
+ }).then((res) => res.data);
39
+ };
40
+
41
+ const translationNamespaceUpdate = async (params: {
42
+ id: number;
43
+ data: TranslationNamespace;
44
+ }) => {
45
+ const { id, data } = params;
46
+ return request<TranslationNamespace>({
47
+ url: `/translation-namespace/${id}`,
48
+ method: HttpMethod.PATCH,
49
+ data: data,
50
+ }).then((res) => res.data);
51
+ };
52
+
53
+ return {
54
+ translationNamespaceCreate,
55
+ translationNamespaceUpdate,
56
+ translationNamespaceDelete,
57
+ translationNamespaceList,
58
+ translationNamespaceGet,
59
+ };
60
+ }
@@ -1,52 +1,52 @@
1
- import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
-
3
- import { useUserCreate } from "@/features/admin/user";
4
- import { User } from "@/types/models";
5
- import { forwardRef, useImperativeHandle, useRef } from "react";
6
- import { useTranslation } from "react-i18next";
7
-
8
- export type UserCreatePanelRef = {
9
- submit: () => void;
10
- };
11
-
12
- export type UserCreatePanelProps = {
13
- onCreated?: (data: User) => void;
14
- };
15
-
16
- const UserCreatePanel = forwardRef(
17
- ({ onCreated }: UserCreatePanelProps, ref) => {
18
- const formRef = useRef<FormPanelRef>(null);
19
- const { t } = useTranslation(["actions", "fields", "translations"]);
20
- const { mutateAsync: createUser } = useUserCreate();
21
-
22
- useImperativeHandle(
23
- ref,
24
- () => ({
25
- submit: () => {
26
- formRef.current?.submit();
27
- },
28
- }),
29
- [formRef],
30
- );
31
-
32
- return (
33
- <FormPanel
34
- ref={formRef}
35
- fields={[]}
36
- button={{ text: t("create", { ns: "actions" }) }}
37
- onSubmit={async (data) => {
38
- const createdData = await createUser({
39
- data,
40
- });
41
- if (typeof onCreated === "function") {
42
- onCreated(createdData as any);
43
- }
44
- }}
45
- />
46
- );
47
- },
48
- );
49
-
50
- UserCreatePanel.displayName = "UserCreatePanel";
51
-
52
- export default UserCreatePanel;
1
+ import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
+
3
+ import { useUserCreate } from "@/features/admin/user";
4
+ import { User } from "@/types/models";
5
+ import { forwardRef, useImperativeHandle, useRef } from "react";
6
+ import { useTranslation } from "react-i18next";
7
+
8
+ export type UserCreatePanelRef = {
9
+ submit: () => void;
10
+ };
11
+
12
+ export type UserCreatePanelProps = {
13
+ onCreated?: (data: User) => void;
14
+ };
15
+
16
+ const UserCreatePanel = forwardRef(
17
+ ({ onCreated }: UserCreatePanelProps, ref) => {
18
+ const formRef = useRef<FormPanelRef>(null);
19
+ const { t } = useTranslation(["actions", "fields", "translations"]);
20
+ const { mutateAsync: createUser } = useUserCreate();
21
+
22
+ useImperativeHandle(
23
+ ref,
24
+ () => ({
25
+ submit: () => {
26
+ formRef.current?.submit();
27
+ },
28
+ }),
29
+ [formRef],
30
+ );
31
+
32
+ return (
33
+ <FormPanel
34
+ ref={formRef}
35
+ fields={[]}
36
+ button={{ text: t("create", { ns: "actions" }) }}
37
+ onSubmit={async (data) => {
38
+ const createdData = await createUser({
39
+ data,
40
+ });
41
+ if (typeof onCreated === "function") {
42
+ onCreated(createdData as any);
43
+ }
44
+ }}
45
+ />
46
+ );
47
+ },
48
+ );
49
+
50
+ UserCreatePanel.displayName = "UserCreatePanel";
51
+
52
+ export default UserCreatePanel;
@@ -1,64 +1,64 @@
1
- import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
- import { Overlay } from "@/components/custom/overlay";
3
- import { TabPanel } from "@/components/panels/tab-panel";
4
- import { useUserGet, useUserUpdate } from "@/features/admin/user";
5
- import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
6
- import { User } from "@/types/models";
7
- import { useState, forwardRef, useImperativeHandle, useRef } from "react";
8
- import { useTranslation } from "react-i18next";
9
- import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
10
-
11
- export type UserUpdatePanelProps = {
12
- data: User;
13
- onUpdated?: (data: User) => void;
14
- };
15
-
16
- const UserUpdatePanel = forwardRef(
17
- ({ data, onUpdated }: UserUpdatePanelProps, ref) => {
18
- const { t } = useTranslation(["actions", "fields", "translations"]);
19
- const { data: item, isLoading } = useUserGet(data.id as number);
20
- const { mutate: userUpdate } = useUserUpdate();
21
- const formRef = useRef<FormPanelRef>(null);
22
-
23
- useEffectAfterFirstUpdate(() => {
24
- if (item && formRef.current) {
25
- formRef.current.setValuesFromItem(item);
26
- }
27
- }, [item]);
28
-
29
- useImperativeHandle(ref, () => ({}));
30
-
31
- return (
32
- <TabPanel
33
- activeTabIndex={0}
34
- tabs={[
35
- {
36
- title: t("details", { ns: "actions" }),
37
- children: (
38
- <Overlay loading={isLoading}>
39
- <FormPanel
40
- ref={formRef}
41
- fields={[]}
42
- button={{ text: t("save", { ns: "actions" }) }}
43
- onSubmit={(data) => {
44
- userUpdate({
45
- id: data.id,
46
- data,
47
- });
48
- if (typeof onUpdated === "function") {
49
- onUpdated(data);
50
- }
51
- }}
52
- />
53
- </Overlay>
54
- ),
55
- },
56
- ]}
57
- />
58
- );
59
- },
60
- );
61
-
62
- UserUpdatePanel.displayName = "UserUpdatePanel";
63
-
64
- export default UserUpdatePanel;
1
+ import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
+ import { Overlay } from "@/components/custom/overlay";
3
+ import { TabPanel } from "@/components/panels/tab-panel";
4
+ import { useUserGet, useUserUpdate } from "@/features/admin/user";
5
+ import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
6
+ import { User } from "@/types/models";
7
+ import { useState, forwardRef, useImperativeHandle, useRef } from "react";
8
+ import { useTranslation } from "react-i18next";
9
+ import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
10
+
11
+ export type UserUpdatePanelProps = {
12
+ data: User;
13
+ onUpdated?: (data: User) => void;
14
+ };
15
+
16
+ const UserUpdatePanel = forwardRef(
17
+ ({ data, onUpdated }: UserUpdatePanelProps, ref) => {
18
+ const { t } = useTranslation(["actions", "fields", "translations"]);
19
+ const { data: item, isLoading } = useUserGet(data.id as number);
20
+ const { mutate: userUpdate } = useUserUpdate();
21
+ const formRef = useRef<FormPanelRef>(null);
22
+
23
+ useEffectAfterFirstUpdate(() => {
24
+ if (item && formRef.current) {
25
+ formRef.current.setValuesFromItem(item);
26
+ }
27
+ }, [item]);
28
+
29
+ useImperativeHandle(ref, () => ({}));
30
+
31
+ return (
32
+ <TabPanel
33
+ activeTabIndex={0}
34
+ tabs={[
35
+ {
36
+ title: t("details", { ns: "actions" }),
37
+ children: (
38
+ <Overlay loading={isLoading}>
39
+ <FormPanel
40
+ ref={formRef}
41
+ fields={[]}
42
+ button={{ text: t("save", { ns: "actions" }) }}
43
+ onSubmit={(data) => {
44
+ userUpdate({
45
+ id: data.id,
46
+ data,
47
+ });
48
+ if (typeof onUpdated === "function") {
49
+ onUpdated(data);
50
+ }
51
+ }}
52
+ />
53
+ </Overlay>
54
+ ),
55
+ },
56
+ ]}
57
+ />
58
+ );
59
+ },
60
+ );
61
+
62
+ UserUpdatePanel.displayName = "UserUpdatePanel";
63
+
64
+ export default UserUpdatePanel;
@@ -1,11 +1,11 @@
1
- {
2
- "create": "Create user",
3
- "createText": "Fill the user informations.",
4
- "createTooltip": "Create new user",
5
- "delete": "Delete user",
6
- "deleteText": "Are you sure to delete these user?",
7
- "deleteTooltip": "Delete the selected user",
8
- "edit": "Edit user",
9
- "editText": "View and edit user information.",
10
- "editTooltip": "Edit the selected user"
11
- }
1
+ {
2
+ "create": "Create user",
3
+ "createText": "Fill the user informations.",
4
+ "createTooltip": "Create new user",
5
+ "delete": "Delete user",
6
+ "deleteText": "Are you sure to delete these user?",
7
+ "deleteTooltip": "Delete the selected user",
8
+ "edit": "Edit user",
9
+ "editText": "View and edit user information.",
10
+ "editTooltip": "Edit the selected user"
11
+ }
@@ -1,11 +1,11 @@
1
- {
2
- "create": "Criar usuário",
3
- "createText": "Preencha as informações do usuário.",
4
- "createTooltip": "Criar novo usuário",
5
- "delete": "Excluir usuário",
6
- "deleteText": "Você tem certeza que deseja excluir esses usuários?",
7
- "deleteTooltip": "Excluir o usuário selecionado",
8
- "edit": "Editar usuário",
9
- "editText": "Visualizar e editar informações do usuário.",
10
- "editTooltip": "Editar o usuário selecionado"
11
- }
1
+ {
2
+ "create": "Criar usuário",
3
+ "createText": "Preencha as informações do usuário.",
4
+ "createTooltip": "Criar novo usuário",
5
+ "delete": "Excluir usuário",
6
+ "deleteText": "Você tem certeza que deseja excluir esses usuários?",
7
+ "deleteTooltip": "Excluir o usuário selecionado",
8
+ "edit": "Editar usuário",
9
+ "editText": "Visualizar e editar informações do usuário.",
10
+ "editTooltip": "Editar o usuário selecionado"
11
+ }