@hedhog/admin 0.46.39 → 0.46.40

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