@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.
Files changed (48) hide show
  1. package/dist/author/author.controller.d.ts +13 -5
  2. package/dist/author/author.controller.d.ts.map +1 -1
  3. package/dist/author/author.controller.js +7 -7
  4. package/dist/author/author.controller.js.map +1 -1
  5. package/dist/author/author.service.d.ts +9 -1
  6. package/dist/author/author.service.d.ts.map +1 -1
  7. package/dist/category/category.controller.d.ts +13 -5
  8. package/dist/category/category.controller.d.ts.map +1 -1
  9. package/dist/category/category.controller.js +9 -9
  10. package/dist/category/category.controller.js.map +1 -1
  11. package/dist/category/category.service.d.ts +9 -1
  12. package/dist/category/category.service.d.ts.map +1 -1
  13. package/dist/category/dto/create.dto.d.ts +1 -1
  14. package/dist/category/dto/create.dto.d.ts.map +1 -1
  15. package/dist/category/dto/create.dto.js +2 -2
  16. package/dist/category/dto/create.dto.js.map +1 -1
  17. package/dist/post/post.controller.d.ts +13 -5
  18. package/dist/post/post.controller.d.ts.map +1 -1
  19. package/dist/post/post.controller.js +7 -7
  20. package/dist/post/post.controller.js.map +1 -1
  21. package/dist/post/post.service.d.ts +9 -1
  22. package/dist/post/post.service.d.ts.map +1 -1
  23. package/hedhog.yaml +133 -133
  24. package/package.json +9 -5
  25. package/frontend/author/components/author.screen.ts +0 -105
  26. package/frontend/author/components/author.screen.tsx +0 -105
  27. package/frontend/author/components/create-panel.tsx +0 -64
  28. package/frontend/author/components/update-panel.tsx +0 -75
  29. package/frontend/author/locales/en/blog.author.json +0 -11
  30. package/frontend/author/locales/pt/blog.author.json +0 -11
  31. package/frontend/author/react-query/handlers.ts +0 -28
  32. package/frontend/author/react-query/requests.ts +0 -54
  33. package/frontend/category/components/category.screen.ts +0 -105
  34. package/frontend/category/components/category.screen.tsx +0 -105
  35. package/frontend/category/components/create-panel.tsx +0 -53
  36. package/frontend/category/components/update-panel.tsx +0 -64
  37. package/frontend/category/locales/en/blog.category.json +0 -11
  38. package/frontend/category/locales/pt/blog.category.json +0 -11
  39. package/frontend/category/react-query/handlers.ts +0 -28
  40. package/frontend/category/react-query/requests.ts +0 -55
  41. package/frontend/post/components/create-panel.tsx +0 -78
  42. package/frontend/post/components/post.screen.ts +0 -105
  43. package/frontend/post/components/post.screen.tsx +0 -105
  44. package/frontend/post/components/update-panel.tsx +0 -89
  45. package/frontend/post/locales/en/blog.post.json +0 -11
  46. package/frontend/post/locales/pt/blog.post.json +0 -11
  47. package/frontend/post/react-query/handlers.ts +0 -28
  48. package/frontend/post/react-query/requests.ts +0 -54
@@ -1,105 +0,0 @@
1
- import { PageTitle } from "@/components/custom/page-title";
2
- import DataPanel from "@/components/panels/data-panel";
3
- import { useCategoryDelete } from "@/features/blog/category";
4
- import { useApp } from "@/hooks/use-app";
5
- import { isPlural } from "@/lib/utils";
6
- import { Category } 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 CategoryCreatePanel from "./components/category-create-panel";
11
- import CategoryUpdatePanel from "./components/category-update-panel";
12
-
13
- export default function Page() {
14
- const [selectedItems, setSelectedItems] = useState<Category[]>([]);
15
- const { mutate: deleteCategory } = useCategoryDelete();
16
- const { openSheet, confirm, closeSheet } = useApp();
17
- const { t } = useTranslation(["category", "modules", "actions"]);
18
-
19
- const openCreate = () => {
20
- const id = openSheet({
21
- title: t("create", { ns: "actions" }),
22
- description: t("createText", { ns: "category" }),
23
- children: () => <CategoryCreatePanel onCreated={() => closeSheet(id)} />,
24
- });
25
-
26
- return id;
27
- };
28
-
29
- const openDelete = (items: Category[]) => {
30
- return confirm({
31
- title: `${t("delete", { ns: "actions" })} ${items.length} ${isPlural(items.length) ? t("items", { ns: "actions" }) : t("item", { ns: "actions" })}`,
32
- description: t("deleteText", { ns: "category" }),
33
- })
34
- .then(() =>
35
- deleteCategory(
36
- items.map((item) => item.id).filter((id) => id !== undefined),
37
- ),
38
- )
39
- .catch(() => setSelectedItems(items));
40
- };
41
-
42
- const openUpdate = (item: Category) => {
43
- const id = openSheet({
44
- children: () => (
45
- <CategoryUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
46
- ),
47
- title: t("edit", { ns: "category" }),
48
- description: t("editText", { ns: "category" }),
49
- });
50
-
51
- return id;
52
- };
53
-
54
- return (
55
- <>
56
- <PageTitle title={t("category", { ns: "modules" })} />
57
- <DataPanel
58
- url="/category"
59
- layout="table"
60
- id="category"
61
- selectable
62
- columns={[
63
- { key: "id", header: "ID", width: 64 },
64
- { key: "name", header: t("name", { ns: "category" }) },
65
- ]}
66
- selected={selectedItems as Category[]}
67
- multiple
68
- hasSearch
69
- sortable
70
- onItemDoubleClick={(item) => openUpdate(item)}
71
- menuActions={[
72
- {
73
- icon: <IconEdit className="mr-1 w-8 cursor-pointer" />,
74
- label: t("edit", { ns: "actions" }),
75
- tooltip: t("editTooltip", { ns: "category" }),
76
- handler: (items: Category[]) => {
77
- if (items.length === 1) openUpdate(items[0]);
78
- },
79
- show: "once",
80
- },
81
- {
82
- icon: <IconTrash className="mr-1 w-8 cursor-pointer" />,
83
- label: t("delete", { ns: "actions" }),
84
- tooltip: t("deleteTooltip", { ns: "category" }),
85
- variant: "destructive",
86
- handler: (items: Category[]) => {
87
- openDelete(items);
88
- },
89
- show: "some",
90
- },
91
- {
92
- icon: <IconPlus className="mr-1 w-8 cursor-pointer" />,
93
- label: t("create", { ns: "actions" }),
94
- tooltip: t("createTooltip", { ns: "category" }),
95
- variant: "default",
96
- handler: () => {
97
- openCreate();
98
- },
99
- show: "none",
100
- },
101
- ]}
102
- />
103
- </>
104
- );
105
- }
@@ -1,53 +0,0 @@
1
- import FormPanel, {
2
- FormPanelRef,
3
- getFieldsLocale,
4
- } from "@/components/panels/form-panel";
5
-
6
- import { useCategoryCreate } from "@/features/blog/category";
7
- import { Category } from "@/types/models";
8
- import { forwardRef, useImperativeHandle, useRef } from "react";
9
- import { useTranslation } from "react-i18next";
10
-
11
- export type CategoryCreatePanelRef = {
12
- submit: () => void;
13
- };
14
-
15
- export type CategoryCreatePanelProps = {
16
- onCreated?: (data: Category) => void;
17
- };
18
-
19
- const CategoryCreatePanel = forwardRef(
20
- ({ onCreated }: CategoryCreatePanelProps, ref) => {
21
- const formRef = useRef<FormPanelRef>(null);
22
- const { t } = useTranslation(["actions"]);
23
- const { mutateAsync: createCategory } = useCategoryCreate();
24
-
25
- useImperativeHandle(
26
- ref,
27
- () => ({
28
- submit: () => {
29
- formRef.current?.submit();
30
- },
31
- }),
32
- [formRef],
33
- );
34
-
35
- return (
36
- <FormPanel
37
- ref={formRef}
38
- fields={[...getFieldsLocale([{ name: "name" }])]}
39
- button={{ text: t("create", { ns: "actions" }) }}
40
- onSubmit={async (data) => {
41
- const createdData = await createCategory(data);
42
- if (typeof onCreated === "function") {
43
- onCreated(createdData);
44
- }
45
- }}
46
- />
47
- );
48
- },
49
- );
50
-
51
- CategoryCreatePanel.displayName = "CategoryCreatePanel";
52
-
53
- export default CategoryCreatePanel;
@@ -1,64 +0,0 @@
1
- import FormPanel, {
2
- FormPanelRef,
3
- getFieldsLocale,
4
- } from "@/components/panels/form-panel";
5
- import { Overlay } from "@/components/custom/overlay";
6
- import { TabPanel } from "@/components/panels/tab-panel";
7
-
8
- import { useCategoryGet, useCategoryUpdate } from "@/features/blog/category";
9
- import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
10
- import { Category } from "@/types/models";
11
- import { forwardRef, useImperativeHandle, useRef } from "react";
12
- import { useTranslation } from "react-i18next";
13
-
14
- export type CategoryUpdatePanelProps = {
15
- data: Category;
16
- onUpdated?: (data: Category) => void;
17
- };
18
-
19
- const CategoryUpdatePanel = forwardRef(
20
- ({ data, onUpdated }: CategoryUpdatePanelProps, ref) => {
21
- const { t } = useTranslation(["actions"]);
22
- const { data: item, isLoading } = useCategoryGet(data.id as number);
23
- const { mutate: categoryUpdate } = useCategoryUpdate();
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={[...getFieldsLocale([{ name: "name" }])]}
45
- button={{ text: t("save", { ns: "actions" }) }}
46
- onSubmit={(data) => {
47
- categoryUpdate({ id: data.id, data });
48
- if (typeof onUpdated === "function") {
49
- onUpdated(data);
50
- }
51
- }}
52
- />
53
- </Overlay>
54
- ),
55
- },
56
- ]}
57
- />
58
- );
59
- },
60
- );
61
-
62
- CategoryUpdatePanel.displayName = "CategoryUpdatePanel";
63
-
64
- export default CategoryUpdatePanel;
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Create category",
3
- "createText": "Fill the category informations.",
4
- "createTooltip": "Create new category",
5
- "delete": "Delete category",
6
- "deleteText": "Are you sure to delete these category?",
7
- "deleteTooltip": "Delete the selected category",
8
- "edit": "Edit category",
9
- "editText": "View and edit category information.",
10
- "editTooltip": "Edit the selected category"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "create": "Criar categoria",
3
- "createText": "Preencha as informações da categoria.",
4
- "createTooltip": "Criar nova categoria",
5
- "delete": "Excluir categoria",
6
- "deleteText": "Você tem certeza de que deseja excluir estas categorias?",
7
- "deleteTooltip": "Excluir a categoria selecionada",
8
- "edit": "Editar categoria",
9
- "editText": "Ver e editar informações da categoria.",
10
- "editTooltip": "Editar a categoria 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 = "category";
6
-
7
- export function useCategoryCreate() {
8
- const { categoryCreate } = requests();
9
- return useDefaultMutation(scope, "create", categoryCreate);
10
- }
11
-
12
- export function useCategoryDelete() {
13
- const { categoryDelete } = requests();
14
- return useDefaultMutation(scope, "delete", categoryDelete);
15
- }
16
-
17
- export function useCategoryUpdate() {
18
- const { categoryUpdate } = requests();
19
- return useDefaultMutation(scope, "update", categoryUpdate);
20
- }
21
-
22
- export function useCategoryGet(id: number) {
23
- const { categoryGet } = requests();
24
- return useQuery({
25
- queryKey: [scope, "get"],
26
- queryFn: () => categoryGet(id),
27
- });
28
- }
@@ -1,55 +0,0 @@
1
- import { useApp } from "@/hooks/use-app";
2
- import { Delete, PaginationParams, PaginationResult } from "@/types";
3
- import { Category } 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 categoryList = async (params: PaginationParams) => {
11
- return request<PaginationResult<Category>>({
12
- url: "/category",
13
- params,
14
- }).then((res) => res.data);
15
- };
16
-
17
- const categoryGet = async (id: number) => {
18
- return request<Category>({
19
- url: `/category/${id}`,
20
- }).then((res) => res.data);
21
- };
22
-
23
- const categoryCreate = async (data: Category) => {
24
- return request<Category>({
25
- url: "/category",
26
- method: HttpMethod.POST,
27
- data: formatDataWithLocale(data),
28
- }).then((res) => res.data);
29
- };
30
-
31
- const categoryDelete = async (ids: number[]) => {
32
- return request<Delete>({
33
- url: "/category",
34
- data: { ids },
35
- method: HttpMethod.DELETE,
36
- }).then((res) => res.data);
37
- };
38
-
39
- const categoryUpdate = async (params: { id: number; data: Category }) => {
40
- const { id, data } = params;
41
- return request<Category>({
42
- url: `/category/${id}`,
43
- method: HttpMethod.PATCH,
44
- data: formatDataWithLocale(data),
45
- }).then((res) => res.data);
46
- };
47
-
48
- return {
49
- categoryCreate,
50
- categoryUpdate,
51
- categoryDelete,
52
- categoryList,
53
- categoryGet,
54
- };
55
- }
@@ -1,78 +0,0 @@
1
- import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
- import { EnumFieldType } from "@/enums/EnumFieldType";
3
- import { usePostCreate } from "@/features/blog/post";
4
- import { Post } from "@/types/models";
5
- import { forwardRef, useImperativeHandle, useRef } from "react";
6
- import { useTranslation } from "react-i18next";
7
-
8
- export type PostCreatePanelRef = {
9
- submit: () => void;
10
- };
11
-
12
- export type PostCreatePanelProps = {
13
- onCreated?: (data: Post) => void;
14
- };
15
-
16
- const PostCreatePanel = forwardRef(
17
- ({ onCreated }: PostCreatePanelProps, ref) => {
18
- const formRef = useRef<FormPanelRef>(null);
19
- const { t } = useTranslation(["actions"]);
20
- const { mutateAsync: createPost } = usePostCreate();
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: "title",
38
- label: { text: t("title", { ns: "translation" }) },
39
- type: EnumFieldType.TEXT,
40
- required: true,
41
- },
42
-
43
- {
44
- name: "content",
45
- label: { text: t("content", { ns: "translation" }) },
46
- type: EnumFieldType.TEXT,
47
- required: true,
48
- },
49
-
50
- {
51
- name: "author_id",
52
- label: { text: t("author_id", { ns: "translation" }) },
53
- type: EnumFieldType.TEXT,
54
- required: true,
55
- },
56
-
57
- {
58
- name: "category_id",
59
- label: { text: t("category_id", { ns: "translation" }) },
60
- type: EnumFieldType.TEXT,
61
- required: true,
62
- },
63
- ]}
64
- button={{ text: t("create", { ns: "actions" }) }}
65
- onSubmit={async (data) => {
66
- const createdData = await createPost(data);
67
- if (typeof onCreated === "function") {
68
- onCreated(createdData);
69
- }
70
- }}
71
- />
72
- );
73
- },
74
- );
75
-
76
- PostCreatePanel.displayName = "PostCreatePanel";
77
-
78
- export default PostCreatePanel;
@@ -1,105 +0,0 @@
1
- import { PageTitle } from "@/components/custom/page-title";
2
- import DataPanel from "@/components/panels/data-panel";
3
- import { usePostDelete } from "@/features/blog/post";
4
- import { useApp } from "@/hooks/use-app";
5
- import { isPlural } from "@/lib/utils";
6
- import { Post } 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 PostCreatePanel from "./components/post-create-panel";
11
- import PostUpdatePanel from "./components/post-update-panel";
12
-
13
- export default function Page() {
14
- const [selectedItems, setSelectedItems] = useState<Post[]>([]);
15
- const { mutate: deletePost } = usePostDelete();
16
- const { openSheet, confirm, closeSheet } = useApp();
17
- const { t } = useTranslation(["post", "modules", "actions"]);
18
-
19
- const openCreate = () => {
20
- const id = openSheet({
21
- title: t("create", { ns: "actions" }),
22
- description: t("createText", { ns: "post" }),
23
- children: () => <PostCreatePanel onCreated={() => closeSheet(id)} />,
24
- });
25
-
26
- return id;
27
- };
28
-
29
- const openDelete = (items: Post[]) => {
30
- return confirm({
31
- title: `${t("delete", { ns: "actions" })} ${items.length} ${isPlural(items.length) ? t("items", { ns: "actions" }) : t("item", { ns: "actions" })}`,
32
- description: t("deleteText", { ns: "post" }),
33
- })
34
- .then(() =>
35
- deletePost(
36
- items.map((item) => item.id).filter((id) => id !== undefined),
37
- ),
38
- )
39
- .catch(() => setSelectedItems(items));
40
- };
41
-
42
- const openUpdate = (item: Post) => {
43
- const id = openSheet({
44
- children: () => (
45
- <PostUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
46
- ),
47
- title: t("edit", { ns: "post" }),
48
- description: t("editText", { ns: "post" }),
49
- });
50
-
51
- return id;
52
- };
53
-
54
- return (
55
- <>
56
- <PageTitle title={t("post", { ns: "modules" })} />
57
- <DataPanel
58
- url="/post"
59
- layout="table"
60
- id="post"
61
- selectable
62
- columns={[
63
- { key: "id", header: "ID", width: 64 },
64
- { key: "name", header: t("name", { ns: "post" }) },
65
- ]}
66
- selected={selectedItems as Post[]}
67
- multiple
68
- hasSearch
69
- sortable
70
- onItemDoubleClick={(item) => openUpdate(item)}
71
- menuActions={[
72
- {
73
- icon: <IconEdit className="mr-1 w-8 cursor-pointer" />,
74
- label: t("edit", { ns: "actions" }),
75
- tooltip: t("editTooltip", { ns: "post" }),
76
- handler: (items: Post[]) => {
77
- if (items.length === 1) openUpdate(items[0]);
78
- },
79
- show: "once",
80
- },
81
- {
82
- icon: <IconTrash className="mr-1 w-8 cursor-pointer" />,
83
- label: t("delete", { ns: "actions" }),
84
- tooltip: t("deleteTooltip", { ns: "post" }),
85
- variant: "destructive",
86
- handler: (items: Post[]) => {
87
- openDelete(items);
88
- },
89
- show: "some",
90
- },
91
- {
92
- icon: <IconPlus className="mr-1 w-8 cursor-pointer" />,
93
- label: t("create", { ns: "actions" }),
94
- tooltip: t("createTooltip", { ns: "post" }),
95
- variant: "default",
96
- handler: () => {
97
- openCreate();
98
- },
99
- show: "none",
100
- },
101
- ]}
102
- />
103
- </>
104
- );
105
- }
@@ -1,105 +0,0 @@
1
- import { PageTitle } from "@/components/custom/page-title";
2
- import DataPanel from "@/components/panels/data-panel";
3
- import { usePostDelete } from "@/features/blog/post";
4
- import { useApp } from "@/hooks/use-app";
5
- import { isPlural } from "@/lib/utils";
6
- import { Post } 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 PostCreatePanel from "./components/post-create-panel";
11
- import PostUpdatePanel from "./components/post-update-panel";
12
-
13
- export default function Page() {
14
- const [selectedItems, setSelectedItems] = useState<Post[]>([]);
15
- const { mutate: deletePost } = usePostDelete();
16
- const { openSheet, confirm, closeSheet } = useApp();
17
- const { t } = useTranslation(["post", "modules", "actions"]);
18
-
19
- const openCreate = () => {
20
- const id = openSheet({
21
- title: t("create", { ns: "actions" }),
22
- description: t("createText", { ns: "post" }),
23
- children: () => <PostCreatePanel onCreated={() => closeSheet(id)} />,
24
- });
25
-
26
- return id;
27
- };
28
-
29
- const openDelete = (items: Post[]) => {
30
- return confirm({
31
- title: `${t("delete", { ns: "actions" })} ${items.length} ${isPlural(items.length) ? t("items", { ns: "actions" }) : t("item", { ns: "actions" })}`,
32
- description: t("deleteText", { ns: "post" }),
33
- })
34
- .then(() =>
35
- deletePost(
36
- items.map((item) => item.id).filter((id) => id !== undefined),
37
- ),
38
- )
39
- .catch(() => setSelectedItems(items));
40
- };
41
-
42
- const openUpdate = (item: Post) => {
43
- const id = openSheet({
44
- children: () => (
45
- <PostUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
46
- ),
47
- title: t("edit", { ns: "post" }),
48
- description: t("editText", { ns: "post" }),
49
- });
50
-
51
- return id;
52
- };
53
-
54
- return (
55
- <>
56
- <PageTitle title={t("post", { ns: "modules" })} />
57
- <DataPanel
58
- url="/post"
59
- layout="table"
60
- id="post"
61
- selectable
62
- columns={[
63
- { key: "id", header: "ID", width: 64 },
64
- { key: "name", header: t("name", { ns: "post" }) },
65
- ]}
66
- selected={selectedItems as Post[]}
67
- multiple
68
- hasSearch
69
- sortable
70
- onItemDoubleClick={(item) => openUpdate(item)}
71
- menuActions={[
72
- {
73
- icon: <IconEdit className="mr-1 w-8 cursor-pointer" />,
74
- label: t("edit", { ns: "actions" }),
75
- tooltip: t("editTooltip", { ns: "post" }),
76
- handler: (items: Post[]) => {
77
- if (items.length === 1) openUpdate(items[0]);
78
- },
79
- show: "once",
80
- },
81
- {
82
- icon: <IconTrash className="mr-1 w-8 cursor-pointer" />,
83
- label: t("delete", { ns: "actions" }),
84
- tooltip: t("deleteTooltip", { ns: "post" }),
85
- variant: "destructive",
86
- handler: (items: Post[]) => {
87
- openDelete(items);
88
- },
89
- show: "some",
90
- },
91
- {
92
- icon: <IconPlus className="mr-1 w-8 cursor-pointer" />,
93
- label: t("create", { ns: "actions" }),
94
- tooltip: t("createTooltip", { ns: "post" }),
95
- variant: "default",
96
- handler: () => {
97
- openCreate();
98
- },
99
- show: "none",
100
- },
101
- ]}
102
- />
103
- </>
104
- );
105
- }