@hedhog/blog 0.0.13 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/author/author.controller.d.ts +13 -5
- package/dist/author/author.controller.d.ts.map +1 -1
- package/dist/author/author.controller.js +7 -7
- package/dist/author/author.controller.js.map +1 -1
- package/dist/author/author.service.d.ts +9 -1
- package/dist/author/author.service.d.ts.map +1 -1
- package/dist/category/category.controller.d.ts +13 -5
- package/dist/category/category.controller.d.ts.map +1 -1
- package/dist/category/category.controller.js +9 -9
- package/dist/category/category.controller.js.map +1 -1
- package/dist/category/category.service.d.ts +9 -1
- package/dist/category/category.service.d.ts.map +1 -1
- package/dist/category/dto/create.dto.d.ts +1 -1
- package/dist/category/dto/create.dto.d.ts.map +1 -1
- package/dist/category/dto/create.dto.js +2 -2
- package/dist/category/dto/create.dto.js.map +1 -1
- package/dist/post/post.controller.d.ts +13 -5
- package/dist/post/post.controller.d.ts.map +1 -1
- package/dist/post/post.controller.js +7 -7
- package/dist/post/post.controller.js.map +1 -1
- package/dist/post/post.service.d.ts +9 -1
- package/dist/post/post.service.d.ts.map +1 -1
- package/hedhog.yaml +133 -133
- package/package.json +9 -5
- package/frontend/author/components/author.screen.ts +0 -105
- package/frontend/author/components/author.screen.tsx +0 -105
- package/frontend/author/components/create-panel.tsx +0 -64
- package/frontend/author/components/update-panel.tsx +0 -75
- package/frontend/author/locales/en/blog.author.json +0 -11
- package/frontend/author/locales/pt/blog.author.json +0 -11
- package/frontend/author/react-query/handlers.ts +0 -28
- package/frontend/author/react-query/requests.ts +0 -54
- package/frontend/category/components/category.screen.ts +0 -105
- package/frontend/category/components/category.screen.tsx +0 -105
- package/frontend/category/components/create-panel.tsx +0 -53
- package/frontend/category/components/update-panel.tsx +0 -64
- package/frontend/category/locales/en/blog.category.json +0 -11
- package/frontend/category/locales/pt/blog.category.json +0 -11
- package/frontend/category/react-query/handlers.ts +0 -28
- package/frontend/category/react-query/requests.ts +0 -55
- package/frontend/post/components/create-panel.tsx +0 -78
- package/frontend/post/components/post.screen.ts +0 -105
- package/frontend/post/components/post.screen.tsx +0 -105
- package/frontend/post/components/update-panel.tsx +0 -89
- package/frontend/post/locales/en/blog.post.json +0 -11
- package/frontend/post/locales/pt/blog.post.json +0 -11
- package/frontend/post/react-query/handlers.ts +0 -28
- package/frontend/post/react-query/requests.ts +0 -54
@@ -1,89 +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 { usePostGet, usePostUpdate } from "@/features/blog/post";
|
6
|
-
import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
|
7
|
-
import { Post } from "@/types/models";
|
8
|
-
import { forwardRef, useImperativeHandle, useRef } from "react";
|
9
|
-
import { useTranslation } from "react-i18next";
|
10
|
-
|
11
|
-
export type PostUpdatePanelProps = {
|
12
|
-
data: Post;
|
13
|
-
onUpdated?: (data: Post) => void;
|
14
|
-
};
|
15
|
-
|
16
|
-
const PostUpdatePanel = forwardRef(
|
17
|
-
({ data, onUpdated }: PostUpdatePanelProps, ref) => {
|
18
|
-
const { t } = useTranslation(["actions"]);
|
19
|
-
const { data: item, isLoading } = usePostGet(data.id as number);
|
20
|
-
const { mutate: postUpdate } = usePostUpdate();
|
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
|
-
{
|
43
|
-
name: "title",
|
44
|
-
label: { text: t("title", { ns: "translation" }) },
|
45
|
-
type: EnumFieldType.TEXT,
|
46
|
-
required: true,
|
47
|
-
},
|
48
|
-
|
49
|
-
{
|
50
|
-
name: "content",
|
51
|
-
label: { text: t("content", { ns: "translation" }) },
|
52
|
-
type: EnumFieldType.TEXT,
|
53
|
-
required: true,
|
54
|
-
},
|
55
|
-
|
56
|
-
{
|
57
|
-
name: "author_id",
|
58
|
-
label: { text: t("author_id", { ns: "translation" }) },
|
59
|
-
type: EnumFieldType.TEXT,
|
60
|
-
required: true,
|
61
|
-
},
|
62
|
-
|
63
|
-
{
|
64
|
-
name: "category_id",
|
65
|
-
label: { text: t("category_id", { ns: "translation" }) },
|
66
|
-
type: EnumFieldType.TEXT,
|
67
|
-
required: true,
|
68
|
-
},
|
69
|
-
]}
|
70
|
-
button={{ text: t("save", { ns: "actions" }) }}
|
71
|
-
onSubmit={(data) => {
|
72
|
-
postUpdate({ id: data.id, data });
|
73
|
-
if (typeof onUpdated === "function") {
|
74
|
-
onUpdated(data);
|
75
|
-
}
|
76
|
-
}}
|
77
|
-
/>
|
78
|
-
</Overlay>
|
79
|
-
),
|
80
|
-
},
|
81
|
-
]}
|
82
|
-
/>
|
83
|
-
);
|
84
|
-
},
|
85
|
-
);
|
86
|
-
|
87
|
-
PostUpdatePanel.displayName = "PostUpdatePanel";
|
88
|
-
|
89
|
-
export default PostUpdatePanel;
|
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"create": "Create post",
|
3
|
-
"createText": "Fill the post informations.",
|
4
|
-
"createTooltip": "Create new post",
|
5
|
-
"delete": "Delete post",
|
6
|
-
"deleteText": "Are you sure to delete these post?",
|
7
|
-
"deleteTooltip": "Delete the selected post",
|
8
|
-
"edit": "Edit post",
|
9
|
-
"editText": "View and edit post information.",
|
10
|
-
"editTooltip": "Edit the selected post"
|
11
|
-
}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"create": "Criar post",
|
3
|
-
"createText": "Preencha as informações do post.",
|
4
|
-
"createTooltip": "Criar novo post",
|
5
|
-
"delete": "Excluir post",
|
6
|
-
"deleteText": "Tem certeza de que deseja excluir estes posts?",
|
7
|
-
"deleteTooltip": "Excluir o post selecionado",
|
8
|
-
"edit": "Editar post",
|
9
|
-
"editText": "Visualizar e editar informações do post.",
|
10
|
-
"editTooltip": "Editar o post selecionado"
|
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 = "post";
|
6
|
-
|
7
|
-
export function usePostCreate() {
|
8
|
-
const { postCreate } = requests();
|
9
|
-
return useDefaultMutation(scope, "create", postCreate);
|
10
|
-
}
|
11
|
-
|
12
|
-
export function usePostDelete() {
|
13
|
-
const { postDelete } = requests();
|
14
|
-
return useDefaultMutation(scope, "delete", postDelete);
|
15
|
-
}
|
16
|
-
|
17
|
-
export function usePostUpdate() {
|
18
|
-
const { postUpdate } = requests();
|
19
|
-
return useDefaultMutation(scope, "update", postUpdate);
|
20
|
-
}
|
21
|
-
|
22
|
-
export function usePostGet(id: number) {
|
23
|
-
const { postGet } = requests();
|
24
|
-
return useQuery({
|
25
|
-
queryKey: [scope, "get"],
|
26
|
-
queryFn: () => postGet(id),
|
27
|
-
});
|
28
|
-
}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import { useApp } from "@/hooks/use-app";
|
2
|
-
import { Delete, PaginationParams, PaginationResult } from "@/types";
|
3
|
-
import { Post } from "@/types/models";
|
4
|
-
import { HttpMethod } from "@/types/http-method";
|
5
|
-
|
6
|
-
export function requests() {
|
7
|
-
const { request } = useApp();
|
8
|
-
|
9
|
-
const postList = async (params: PaginationParams) => {
|
10
|
-
return request<PaginationResult<Post>>({
|
11
|
-
url: "/post",
|
12
|
-
params,
|
13
|
-
}).then((res) => res.data);
|
14
|
-
};
|
15
|
-
|
16
|
-
const postGet = async (id: number) => {
|
17
|
-
return request<Post>({
|
18
|
-
url: `/post/${id}`,
|
19
|
-
}).then((res) => res.data);
|
20
|
-
};
|
21
|
-
|
22
|
-
const postCreate = async (data: Post) => {
|
23
|
-
return request<Post>({
|
24
|
-
url: "/post",
|
25
|
-
method: HttpMethod.POST,
|
26
|
-
data: data,
|
27
|
-
}).then((res) => res.data);
|
28
|
-
};
|
29
|
-
|
30
|
-
const postDelete = async (ids: number[]) => {
|
31
|
-
return request<Delete>({
|
32
|
-
url: "/post",
|
33
|
-
data: { ids },
|
34
|
-
method: HttpMethod.DELETE,
|
35
|
-
}).then((res) => res.data);
|
36
|
-
};
|
37
|
-
|
38
|
-
const postUpdate = async (params: { id: number; data: Post }) => {
|
39
|
-
const { id, data } = params;
|
40
|
-
return request<Post>({
|
41
|
-
url: `/post/${id}`,
|
42
|
-
method: HttpMethod.PATCH,
|
43
|
-
data: data,
|
44
|
-
}).then((res) => res.data);
|
45
|
-
};
|
46
|
-
|
47
|
-
return {
|
48
|
-
postCreate,
|
49
|
-
postUpdate,
|
50
|
-
postDelete,
|
51
|
-
postList,
|
52
|
-
postGet,
|
53
|
-
};
|
54
|
-
}
|