@hedhog/setting 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/setting/setting.controller.d.ts +27 -3
- package/dist/setting/setting.controller.d.ts.map +1 -1
- package/dist/setting/setting.controller.js +3 -3
- package/dist/setting/setting.controller.js.map +1 -1
- package/dist/setting/setting.service.d.ts +28 -4
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +6 -6
- package/dist/setting/setting.service.js.map +1 -1
- package/hedhog.yaml +285 -285
- package/package.json +39 -37
- package/frontend/setting/components/create-panel.tsx +0 -83
- package/frontend/setting/components/setting.screen.tsx +0 -105
- package/frontend/setting/components/update-panel.tsx +0 -96
- package/frontend/setting/locales/en/setting.setting.json +0 -11
- package/frontend/setting/locales/pt/setting.setting.json +0 -11
- package/frontend/setting/react-query/handlers.ts +0 -28
- package/frontend/setting/react-query/requests.ts +0 -55
- package/frontend/setting-group/components/create-panel.tsx +0 -62
- package/frontend/setting-group/components/setting-group.screen.tsx +0 -107
- package/frontend/setting-group/components/update-panel.tsx +0 -76
- package/frontend/setting-group/locales/en/setting.setting-group.json +0 -11
- package/frontend/setting-group/locales/pt/setting.setting-group.json +0 -11
- package/frontend/setting-group/react-query/handlers.ts +0 -28
- package/frontend/setting-group/react-query/requests.ts +0 -58
- package/frontend/setting-user/components/create-panel.tsx +0 -71
- package/frontend/setting-user/components/setting-user.screen.tsx +0 -107
- package/frontend/setting-user/components/update-panel.tsx +0 -85
- package/frontend/setting-user/locales/en/setting.setting-user.json +0 -11
- package/frontend/setting-user/locales/pt/setting.setting-user.json +0 -11
- package/frontend/setting-user/react-query/handlers.ts +0 -28
- package/frontend/setting-user/react-query/requests.ts +0 -57
@@ -1,28 +0,0 @@
|
|
1
|
-
import { useDefaultMutation } from "@/hooks/use-default-mutation";
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
3
|
-
import { requests } from "./requests";
|
4
|
-
|
5
|
-
const scope = "setting-group";
|
6
|
-
|
7
|
-
export function useSettingGroupCreate() {
|
8
|
-
const { settingGroupCreate } = requests();
|
9
|
-
return useDefaultMutation(scope, "create", settingGroupCreate);
|
10
|
-
}
|
11
|
-
|
12
|
-
export function useSettingGroupDelete() {
|
13
|
-
const { settingGroupDelete } = requests();
|
14
|
-
return useDefaultMutation(scope, "delete", settingGroupDelete);
|
15
|
-
}
|
16
|
-
|
17
|
-
export function useSettingGroupUpdate() {
|
18
|
-
const { settingGroupUpdate } = requests();
|
19
|
-
return useDefaultMutation(scope, "update", settingGroupUpdate);
|
20
|
-
}
|
21
|
-
|
22
|
-
export function useSettingGroupGet(id: number) {
|
23
|
-
const { settingGroupGet } = requests();
|
24
|
-
return useQuery({
|
25
|
-
queryKey: [scope, "get"],
|
26
|
-
queryFn: () => settingGroupGet(id),
|
27
|
-
});
|
28
|
-
}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import { useApp } from "@/hooks/use-app";
|
2
|
-
import { Delete, PaginationParams, PaginationResult } from "@/types";
|
3
|
-
import { SettingGroup } from "@/types/models";
|
4
|
-
import { HttpMethod } from "@/types/http-method";
|
5
|
-
import { formatDataWithLocale } from "@hedhog/utils";
|
6
|
-
|
7
|
-
export function requests() {
|
8
|
-
const { request } = useApp();
|
9
|
-
|
10
|
-
const settingGroupList = async (params: PaginationParams) => {
|
11
|
-
return request<PaginationResult<SettingGroup>>({
|
12
|
-
url: "/setting-group",
|
13
|
-
params,
|
14
|
-
}).then((res) => res.data);
|
15
|
-
};
|
16
|
-
|
17
|
-
const settingGroupGet = async (id: number) => {
|
18
|
-
return request<SettingGroup>({
|
19
|
-
url: `/setting-group/${id}`,
|
20
|
-
}).then((res) => res.data);
|
21
|
-
};
|
22
|
-
|
23
|
-
const settingGroupCreate = async (data: SettingGroup) => {
|
24
|
-
return request<SettingGroup>({
|
25
|
-
url: "/setting-group",
|
26
|
-
method: HttpMethod.POST,
|
27
|
-
data: formatDataWithLocale(data),
|
28
|
-
}).then((res) => res.data);
|
29
|
-
};
|
30
|
-
|
31
|
-
const settingGroupDelete = async (ids: number[]) => {
|
32
|
-
return request<Delete>({
|
33
|
-
url: "/setting-group",
|
34
|
-
data: { ids },
|
35
|
-
method: HttpMethod.DELETE,
|
36
|
-
}).then((res) => res.data);
|
37
|
-
};
|
38
|
-
|
39
|
-
const settingGroupUpdate = async (params: {
|
40
|
-
id: number;
|
41
|
-
data: SettingGroup;
|
42
|
-
}) => {
|
43
|
-
const { id, data } = params;
|
44
|
-
return request<SettingGroup>({
|
45
|
-
url: `/setting-group/${id}`,
|
46
|
-
method: HttpMethod.PATCH,
|
47
|
-
data: formatDataWithLocale(data),
|
48
|
-
}).then((res) => res.data);
|
49
|
-
};
|
50
|
-
|
51
|
-
return {
|
52
|
-
settingGroupCreate,
|
53
|
-
settingGroupUpdate,
|
54
|
-
settingGroupDelete,
|
55
|
-
settingGroupList,
|
56
|
-
settingGroupGet,
|
57
|
-
};
|
58
|
-
}
|
@@ -1,71 +0,0 @@
|
|
1
|
-
import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
|
2
|
-
import { EnumFieldType } from "@/enums/EnumFieldType";
|
3
|
-
import { useSettingUserCreate } from "@/features/blog/setting-user";
|
4
|
-
import { SettingUser } from "@/types/models";
|
5
|
-
import { forwardRef, useImperativeHandle, useRef } from "react";
|
6
|
-
import { useTranslation } from "react-i18next";
|
7
|
-
|
8
|
-
export type SettingUserCreatePanelRef = {
|
9
|
-
submit: () => void;
|
10
|
-
};
|
11
|
-
|
12
|
-
export type SettingUserCreatePanelProps = {
|
13
|
-
onCreated?: (data: SettingUser) => void;
|
14
|
-
};
|
15
|
-
|
16
|
-
const SettingUserCreatePanel = forwardRef(
|
17
|
-
({ onCreated }: SettingUserCreatePanelProps, ref) => {
|
18
|
-
const formRef = useRef<FormPanelRef>(null);
|
19
|
-
const { t } = useTranslation(["actions"]);
|
20
|
-
const { mutateAsync: createSettingUser } = useSettingUserCreate();
|
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
|
-
{
|
37
|
-
name: "user_id",
|
38
|
-
label: { text: t("user_id", { ns: "translation" }) },
|
39
|
-
type: EnumFieldType.TEXT,
|
40
|
-
required: true,
|
41
|
-
},
|
42
|
-
|
43
|
-
{
|
44
|
-
name: "setting_id",
|
45
|
-
label: { text: t("setting_id", { ns: "translation" }) },
|
46
|
-
type: EnumFieldType.TEXT,
|
47
|
-
required: true,
|
48
|
-
},
|
49
|
-
|
50
|
-
{
|
51
|
-
name: "value",
|
52
|
-
label: { text: t("value", { ns: "translation" }) },
|
53
|
-
type: EnumFieldType.TEXT,
|
54
|
-
required: true,
|
55
|
-
},
|
56
|
-
]}
|
57
|
-
button={{ text: t("create", { ns: "actions" }) }}
|
58
|
-
onSubmit={async (data) => {
|
59
|
-
const createdData = await createSettingUser(data);
|
60
|
-
if (typeof onCreated === "function") {
|
61
|
-
onCreated(createdData);
|
62
|
-
}
|
63
|
-
}}
|
64
|
-
/>
|
65
|
-
);
|
66
|
-
},
|
67
|
-
);
|
68
|
-
|
69
|
-
SettingUserCreatePanel.displayName = "SettingUserCreatePanel";
|
70
|
-
|
71
|
-
export default SettingUserCreatePanel;
|
@@ -1,107 +0,0 @@
|
|
1
|
-
import { PageTitle } from "@/components/custom/page-title";
|
2
|
-
import DataPanel from "@/components/panels/data-panel";
|
3
|
-
import { useSettingUserDelete } from "@/features/blog/setting-user";
|
4
|
-
import { useApp } from "@/hooks/use-app";
|
5
|
-
import { isPlural } from "@/lib/utils";
|
6
|
-
import { SettingUser } from "@/types/models";
|
7
|
-
import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
|
8
|
-
import { useState } from "react";
|
9
|
-
import { useTranslation } from "react-i18next";
|
10
|
-
import SettingUserCreatePanel from "./components/setting-user-create-panel";
|
11
|
-
import SettingUserUpdatePanel from "./components/setting-user-update-panel";
|
12
|
-
|
13
|
-
export default function Page() {
|
14
|
-
const [selectedItems, setSelectedItems] = useState<SettingUser[]>([]);
|
15
|
-
const { mutate: deleteSettingUser } = useSettingUserDelete();
|
16
|
-
const { openSheet, confirm, closeSheet } = useApp();
|
17
|
-
const { t } = useTranslation(["setting-user", "modules", "actions"]);
|
18
|
-
|
19
|
-
const openCreate = () => {
|
20
|
-
const id = openSheet({
|
21
|
-
title: t("create", { ns: "actions" }),
|
22
|
-
description: t("createText", { ns: "setting-user" }),
|
23
|
-
children: () => (
|
24
|
-
<SettingUserCreatePanel onCreated={() => closeSheet(id)} />
|
25
|
-
),
|
26
|
-
});
|
27
|
-
|
28
|
-
return id;
|
29
|
-
};
|
30
|
-
|
31
|
-
const openDelete = (items: SettingUser[]) => {
|
32
|
-
return confirm({
|
33
|
-
title: `${t("delete", { ns: "actions" })} ${items.length} ${isPlural(items.length) ? t("items", { ns: "actions" }) : t("item", { ns: "actions" })}`,
|
34
|
-
description: t("deleteText", { ns: "setting-user" }),
|
35
|
-
})
|
36
|
-
.then(() =>
|
37
|
-
deleteSettingUser(
|
38
|
-
items.map((item) => item.id).filter((id) => id !== undefined),
|
39
|
-
),
|
40
|
-
)
|
41
|
-
.catch(() => setSelectedItems(items));
|
42
|
-
};
|
43
|
-
|
44
|
-
const openUpdate = (item: SettingUser) => {
|
45
|
-
const id = openSheet({
|
46
|
-
children: () => (
|
47
|
-
<SettingUserUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
|
48
|
-
),
|
49
|
-
title: t("edit", { ns: "setting-user" }),
|
50
|
-
description: t("editText", { ns: "setting-user" }),
|
51
|
-
});
|
52
|
-
|
53
|
-
return id;
|
54
|
-
};
|
55
|
-
|
56
|
-
return (
|
57
|
-
<>
|
58
|
-
<PageTitle title={t("settingUser", { ns: "modules" })} />
|
59
|
-
<DataPanel
|
60
|
-
url="/setting-user"
|
61
|
-
layout="table"
|
62
|
-
id="setting-user"
|
63
|
-
selectable
|
64
|
-
columns={[
|
65
|
-
{ key: "id", header: "ID", width: 64 },
|
66
|
-
{ key: "name", header: t("name", { ns: "setting-user" }) },
|
67
|
-
]}
|
68
|
-
selected={selectedItems as SettingUser[]}
|
69
|
-
multiple
|
70
|
-
hasSearch
|
71
|
-
sortable
|
72
|
-
onItemDoubleClick={(item) => openUpdate(item)}
|
73
|
-
menuActions={[
|
74
|
-
{
|
75
|
-
icon: <IconEdit className="mr-1 w-8 cursor-pointer" />,
|
76
|
-
label: t("edit", { ns: "actions" }),
|
77
|
-
tooltip: t("editTooltip", { ns: "setting-user" }),
|
78
|
-
handler: (items: SettingUser[]) => {
|
79
|
-
if (items.length === 1) openUpdate(items[0]);
|
80
|
-
},
|
81
|
-
show: "once",
|
82
|
-
},
|
83
|
-
{
|
84
|
-
icon: <IconTrash className="mr-1 w-8 cursor-pointer" />,
|
85
|
-
label: t("delete", { ns: "actions" }),
|
86
|
-
tooltip: t("deleteTooltip", { ns: "setting-user" }),
|
87
|
-
variant: "destructive",
|
88
|
-
handler: (items: SettingUser[]) => {
|
89
|
-
openDelete(items);
|
90
|
-
},
|
91
|
-
show: "some",
|
92
|
-
},
|
93
|
-
{
|
94
|
-
icon: <IconPlus className="mr-1 w-8 cursor-pointer" />,
|
95
|
-
label: t("create", { ns: "actions" }),
|
96
|
-
tooltip: t("createTooltip", { ns: "setting-user" }),
|
97
|
-
variant: "default",
|
98
|
-
handler: () => {
|
99
|
-
openCreate();
|
100
|
-
},
|
101
|
-
show: "none",
|
102
|
-
},
|
103
|
-
]}
|
104
|
-
/>
|
105
|
-
</>
|
106
|
-
);
|
107
|
-
}
|
@@ -1,85 +0,0 @@
|
|
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 { EnumFieldType } from "@/enums/EnumFieldType";
|
5
|
-
import {
|
6
|
-
useSettingUserGet,
|
7
|
-
useSettingUserUpdate,
|
8
|
-
} from "@/features/blog/setting-user";
|
9
|
-
import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
|
10
|
-
import { SettingUser } from "@/types/models";
|
11
|
-
import { forwardRef, useImperativeHandle, useRef } from "react";
|
12
|
-
import { useTranslation } from "react-i18next";
|
13
|
-
|
14
|
-
export type SettingUserUpdatePanelProps = {
|
15
|
-
data: SettingUser;
|
16
|
-
onUpdated?: (data: SettingUser) => void;
|
17
|
-
};
|
18
|
-
|
19
|
-
const SettingUserUpdatePanel = forwardRef(
|
20
|
-
({ data, onUpdated }: SettingUserUpdatePanelProps, ref) => {
|
21
|
-
const { t } = useTranslation(["actions"]);
|
22
|
-
const { data: item, isLoading } = useSettingUserGet(data.id as number);
|
23
|
-
const { mutate: settingUserUpdate } = useSettingUserUpdate();
|
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
|
-
{
|
46
|
-
name: "user_id",
|
47
|
-
label: { text: t("user_id", { ns: "translation" }) },
|
48
|
-
type: EnumFieldType.TEXT,
|
49
|
-
required: true,
|
50
|
-
},
|
51
|
-
|
52
|
-
{
|
53
|
-
name: "setting_id",
|
54
|
-
label: { text: t("setting_id", { ns: "translation" }) },
|
55
|
-
type: EnumFieldType.TEXT,
|
56
|
-
required: true,
|
57
|
-
},
|
58
|
-
|
59
|
-
{
|
60
|
-
name: "value",
|
61
|
-
label: { text: t("value", { ns: "translation" }) },
|
62
|
-
type: EnumFieldType.TEXT,
|
63
|
-
required: true,
|
64
|
-
},
|
65
|
-
]}
|
66
|
-
button={{ text: t("save", { ns: "actions" }) }}
|
67
|
-
onSubmit={(data) => {
|
68
|
-
settingUserUpdate({ id: data.id, data });
|
69
|
-
if (typeof onUpdated === "function") {
|
70
|
-
onUpdated(data);
|
71
|
-
}
|
72
|
-
}}
|
73
|
-
/>
|
74
|
-
</Overlay>
|
75
|
-
),
|
76
|
-
},
|
77
|
-
]}
|
78
|
-
/>
|
79
|
-
);
|
80
|
-
},
|
81
|
-
);
|
82
|
-
|
83
|
-
SettingUserUpdatePanel.displayName = "SettingUserUpdatePanel";
|
84
|
-
|
85
|
-
export default SettingUserUpdatePanel;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"create": "Create setting user",
|
3
|
-
"createText": "Fill the setting user informations.",
|
4
|
-
"createTooltip": "Create new setting user",
|
5
|
-
"delete": "Delete setting user",
|
6
|
-
"deleteText": "Are you sure to delete these setting user?",
|
7
|
-
"deleteTooltip": "Delete the selected setting user",
|
8
|
-
"edit": "Edit setting user",
|
9
|
-
"editText": "View and edit setting user information.",
|
10
|
-
"editTooltip": "Edit the selected setting user"
|
11
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"create": "Criar configuração de usuário",
|
3
|
-
"createText": "Preencha as informações da configuração de usuário.",
|
4
|
-
"createTooltip": "Criar nova configuração de usuário",
|
5
|
-
"delete": "Excluir configuração de usuário",
|
6
|
-
"deleteText": "Tem certeza de que deseja excluir estas configurações de usuário?",
|
7
|
-
"deleteTooltip": "Excluir a configuração de usuário selecionada",
|
8
|
-
"edit": "Editar configuração de usuário",
|
9
|
-
"editText": "Visualizar e editar informações da configuração de usuário.",
|
10
|
-
"editTooltip": "Editar a configuração de usuário selecionada"
|
11
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { useDefaultMutation } from "@/hooks/use-default-mutation";
|
2
|
-
import { useQuery } from "@tanstack/react-query";
|
3
|
-
import { requests } from "./requests";
|
4
|
-
|
5
|
-
const scope = "setting-user";
|
6
|
-
|
7
|
-
export function useSettingUserCreate() {
|
8
|
-
const { settingUserCreate } = requests();
|
9
|
-
return useDefaultMutation(scope, "create", settingUserCreate);
|
10
|
-
}
|
11
|
-
|
12
|
-
export function useSettingUserDelete() {
|
13
|
-
const { settingUserDelete } = requests();
|
14
|
-
return useDefaultMutation(scope, "delete", settingUserDelete);
|
15
|
-
}
|
16
|
-
|
17
|
-
export function useSettingUserUpdate() {
|
18
|
-
const { settingUserUpdate } = requests();
|
19
|
-
return useDefaultMutation(scope, "update", settingUserUpdate);
|
20
|
-
}
|
21
|
-
|
22
|
-
export function useSettingUserGet(id: number) {
|
23
|
-
const { settingUserGet } = requests();
|
24
|
-
return useQuery({
|
25
|
-
queryKey: [scope, "get"],
|
26
|
-
queryFn: () => settingUserGet(id),
|
27
|
-
});
|
28
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import { useApp } from "@/hooks/use-app";
|
2
|
-
import { Delete, PaginationParams, PaginationResult } from "@/types";
|
3
|
-
import { SettingUser } from "@/types/models";
|
4
|
-
import { HttpMethod } from "@/types/http-method";
|
5
|
-
|
6
|
-
export function requests() {
|
7
|
-
const { request } = useApp();
|
8
|
-
|
9
|
-
const settingUserList = async (params: PaginationParams) => {
|
10
|
-
return request<PaginationResult<SettingUser>>({
|
11
|
-
url: "/setting-user",
|
12
|
-
params,
|
13
|
-
}).then((res) => res.data);
|
14
|
-
};
|
15
|
-
|
16
|
-
const settingUserGet = async (id: number) => {
|
17
|
-
return request<SettingUser>({
|
18
|
-
url: `/setting-user/${id}`,
|
19
|
-
}).then((res) => res.data);
|
20
|
-
};
|
21
|
-
|
22
|
-
const settingUserCreate = async (data: SettingUser) => {
|
23
|
-
return request<SettingUser>({
|
24
|
-
url: "/setting-user",
|
25
|
-
method: HttpMethod.POST,
|
26
|
-
data: data,
|
27
|
-
}).then((res) => res.data);
|
28
|
-
};
|
29
|
-
|
30
|
-
const settingUserDelete = async (ids: number[]) => {
|
31
|
-
return request<Delete>({
|
32
|
-
url: "/setting-user",
|
33
|
-
data: { ids },
|
34
|
-
method: HttpMethod.DELETE,
|
35
|
-
}).then((res) => res.data);
|
36
|
-
};
|
37
|
-
|
38
|
-
const settingUserUpdate = async (params: {
|
39
|
-
id: number;
|
40
|
-
data: SettingUser;
|
41
|
-
}) => {
|
42
|
-
const { id, data } = params;
|
43
|
-
return request<SettingUser>({
|
44
|
-
url: `/setting-user/${id}`,
|
45
|
-
method: HttpMethod.PATCH,
|
46
|
-
data: data,
|
47
|
-
}).then((res) => res.data);
|
48
|
-
};
|
49
|
-
|
50
|
-
return {
|
51
|
-
settingUserCreate,
|
52
|
-
settingUserUpdate,
|
53
|
-
settingUserDelete,
|
54
|
-
settingUserList,
|
55
|
-
settingUserGet,
|
56
|
-
};
|
57
|
-
}
|