@hedhog/blog 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. package/dist/author/author.controller.d.ts +14 -0
  2. package/dist/author/author.controller.d.ts.map +1 -0
  3. package/dist/author/author.controller.js +89 -0
  4. package/dist/author/author.controller.js.map +1 -0
  5. package/dist/author/author.module.d.ts +3 -0
  6. package/dist/author/author.module.d.ts.map +1 -0
  7. package/dist/author/author.module.js +31 -0
  8. package/dist/author/author.module.js.map +1 -0
  9. package/dist/author/author.service.d.ts +19 -0
  10. package/dist/author/author.service.d.ts.map +1 -0
  11. package/dist/author/author.service.js +72 -0
  12. package/dist/author/author.service.js.map +1 -0
  13. package/dist/author/dto/create.dto.d.ts +5 -0
  14. package/dist/author/dto/create.dto.d.ts.map +1 -0
  15. package/dist/author/dto/create.dto.js +27 -0
  16. package/dist/author/dto/create.dto.js.map +1 -0
  17. package/dist/author/dto/delete.dto.d.ts +4 -0
  18. package/dist/author/dto/delete.dto.d.ts.map +1 -0
  19. package/dist/author/dto/delete.dto.js +23 -0
  20. package/dist/author/dto/delete.dto.js.map +1 -0
  21. package/dist/author/dto/update.dto.d.ts +6 -0
  22. package/dist/author/dto/update.dto.d.ts.map +1 -0
  23. package/dist/author/dto/update.dto.js +9 -0
  24. package/dist/author/dto/update.dto.js.map +1 -0
  25. package/dist/blog.module.d.ts +3 -0
  26. package/dist/blog.module.d.ts.map +1 -0
  27. package/dist/blog.module.js +35 -0
  28. package/dist/blog.module.js.map +1 -0
  29. package/dist/category/category.controller.d.ts +14 -0
  30. package/dist/category/category.controller.d.ts.map +1 -0
  31. package/dist/category/category.controller.js +91 -0
  32. package/dist/category/category.controller.js.map +1 -0
  33. package/dist/category/category.module.d.ts +3 -0
  34. package/dist/category/category.module.d.ts.map +1 -0
  35. package/dist/category/category.module.js +31 -0
  36. package/dist/category/category.module.js.map +1 -0
  37. package/dist/category/category.service.d.ts +19 -0
  38. package/dist/category/category.service.d.ts.map +1 -0
  39. package/dist/category/category.service.js +87 -0
  40. package/dist/category/category.service.js.map +1 -0
  41. package/dist/category/dto/create.dto.d.ts +5 -0
  42. package/dist/category/dto/create.dto.d.ts.map +1 -0
  43. package/dist/category/dto/create.dto.js +23 -0
  44. package/dist/category/dto/create.dto.js.map +1 -0
  45. package/dist/category/dto/delete.dto.d.ts +4 -0
  46. package/dist/category/dto/delete.dto.d.ts.map +1 -0
  47. package/dist/category/dto/delete.dto.js +23 -0
  48. package/dist/category/dto/delete.dto.js.map +1 -0
  49. package/dist/category/dto/update.dto.d.ts +6 -0
  50. package/dist/category/dto/update.dto.d.ts.map +1 -0
  51. package/dist/category/dto/update.dto.js +9 -0
  52. package/dist/category/dto/update.dto.js.map +1 -0
  53. package/dist/index.d.ts +2 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +18 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/post/dto/create.dto.d.ts +5 -0
  58. package/dist/post/dto/create.dto.d.ts.map +1 -0
  59. package/dist/post/dto/create.dto.js +26 -0
  60. package/dist/post/dto/create.dto.js.map +1 -0
  61. package/dist/post/dto/delete.dto.d.ts +4 -0
  62. package/dist/post/dto/delete.dto.d.ts.map +1 -0
  63. package/dist/post/dto/delete.dto.js +23 -0
  64. package/dist/post/dto/delete.dto.js.map +1 -0
  65. package/dist/post/dto/update.dto.d.ts +6 -0
  66. package/dist/post/dto/update.dto.d.ts.map +1 -0
  67. package/dist/post/dto/update.dto.js +9 -0
  68. package/dist/post/dto/update.dto.js.map +1 -0
  69. package/dist/post/post.controller.d.ts +14 -0
  70. package/dist/post/post.controller.d.ts.map +1 -0
  71. package/dist/post/post.controller.js +89 -0
  72. package/dist/post/post.controller.js.map +1 -0
  73. package/dist/post/post.module.d.ts +3 -0
  74. package/dist/post/post.module.d.ts.map +1 -0
  75. package/dist/post/post.module.js +31 -0
  76. package/dist/post/post.module.js.map +1 -0
  77. package/dist/post/post.service.d.ts +19 -0
  78. package/dist/post/post.service.d.ts.map +1 -0
  79. package/dist/post/post.service.js +72 -0
  80. package/dist/post/post.service.js.map +1 -0
  81. package/frontend/author/components/create-panel.d.ts +9 -0
  82. package/frontend/author/components/create-panel.d.ts.map +1 -0
  83. package/frontend/author/components/create-panel.js +42 -0
  84. package/frontend/author/components/create-panel.js.map +1 -0
  85. package/frontend/author/components/create-panel.tsx +60 -0
  86. package/frontend/author/components/update-panel.d.ts +7 -0
  87. package/frontend/author/components/update-panel.d.ts.map +1 -0
  88. package/frontend/author/components/update-panel.js +52 -0
  89. package/frontend/author/components/update-panel.js.map +1 -0
  90. package/frontend/author/components/update-panel.tsx +70 -0
  91. package/frontend/author/react-query/handlers.d.ts +5 -0
  92. package/frontend/author/react-query/handlers.d.ts.map +1 -0
  93. package/frontend/author/react-query/handlers.js +30 -0
  94. package/frontend/author/react-query/handlers.js.map +1 -0
  95. package/frontend/author/react-query/handlers.ts +28 -0
  96. package/frontend/author/react-query/requests.d.ts +10 -0
  97. package/frontend/author/react-query/requests.d.ts.map +1 -0
  98. package/frontend/author/react-query/requests.js +48 -0
  99. package/frontend/author/react-query/requests.js.map +1 -0
  100. package/frontend/author/react-query/requests.ts +53 -0
  101. package/frontend/category/components/create-panel.d.ts +9 -0
  102. package/frontend/category/components/create-panel.d.ts.map +1 -0
  103. package/frontend/category/components/create-panel.js +48 -0
  104. package/frontend/category/components/create-panel.js.map +1 -0
  105. package/frontend/category/components/create-panel.tsx +49 -0
  106. package/frontend/category/components/update-panel.d.ts +7 -0
  107. package/frontend/category/components/update-panel.d.ts.map +1 -0
  108. package/frontend/category/components/update-panel.js +61 -0
  109. package/frontend/category/components/update-panel.js.map +1 -0
  110. package/frontend/category/components/update-panel.tsx +59 -0
  111. package/frontend/category/react-query/handlers.d.ts +5 -0
  112. package/frontend/category/react-query/handlers.d.ts.map +1 -0
  113. package/frontend/category/react-query/handlers.js +30 -0
  114. package/frontend/category/react-query/handlers.js.map +1 -0
  115. package/frontend/category/react-query/handlers.ts +28 -0
  116. package/frontend/category/react-query/requests.d.ts +10 -0
  117. package/frontend/category/react-query/requests.d.ts.map +1 -0
  118. package/frontend/category/react-query/requests.js +49 -0
  119. package/frontend/category/react-query/requests.js.map +1 -0
  120. package/frontend/category/react-query/requests.ts +54 -0
  121. package/frontend/post/components/create-panel.d.ts +9 -0
  122. package/frontend/post/components/create-panel.d.ts.map +1 -0
  123. package/frontend/post/components/create-panel.js +54 -0
  124. package/frontend/post/components/create-panel.js.map +1 -0
  125. package/frontend/post/components/create-panel.tsx +74 -0
  126. package/frontend/post/components/update-panel.d.ts +7 -0
  127. package/frontend/post/components/update-panel.d.ts.map +1 -0
  128. package/frontend/post/components/update-panel.js +64 -0
  129. package/frontend/post/components/update-panel.js.map +1 -0
  130. package/frontend/post/components/update-panel.tsx +84 -0
  131. package/frontend/post/react-query/handlers.d.ts +5 -0
  132. package/frontend/post/react-query/handlers.d.ts.map +1 -0
  133. package/frontend/post/react-query/handlers.js +30 -0
  134. package/frontend/post/react-query/handlers.js.map +1 -0
  135. package/frontend/post/react-query/handlers.ts +28 -0
  136. package/frontend/post/react-query/requests.d.ts +10 -0
  137. package/frontend/post/react-query/requests.d.ts.map +1 -0
  138. package/frontend/post/react-query/requests.js +48 -0
  139. package/frontend/post/react-query/requests.js.map +1 -0
  140. package/frontend/post/react-query/requests.ts +53 -0
  141. package/hedhog.yaml +133 -0
  142. package/package.json +35 -0
@@ -0,0 +1,59 @@
1
+ import FormPanel, {
2
+ FormPanelRef,
3
+ getFieldsLocale,
4
+ } from "@/components/custom/form-panel";
5
+ import { Overlay } from "@/components/custom/overlay";
6
+ import { TabPanel } from "@/components/custom/tab-panel";
7
+ import { EnumFieldType } from "@/enums/EnumFieldType";
8
+ import { useCategoryGet, useCategoryUpdate } from "@/features/category";
9
+ import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
10
+ import { Category } from "@/types/models";
11
+ import { t } from "i18next";
12
+ import { forwardRef, useImperativeHandle, useRef } from "react";
13
+
14
+ export type CategoryUpdatePanelProps = {
15
+ data: Category;
16
+ onUpdated?: (data: Category) => void;
17
+ };
18
+
19
+ export const CategoryUpdatePanel = forwardRef(
20
+ ({ data, onUpdated }: CategoryUpdatePanelProps, ref) => {
21
+ const { data: item, isLoading } = useCategoryGet(data.id as number);
22
+ const { mutate: categoryUpdate } = useCategoryUpdate();
23
+ const formRef = useRef<FormPanelRef>(null);
24
+
25
+ useEffectAfterFirstUpdate(() => {
26
+ if (item && formRef.current) {
27
+ formRef.current.setValuesFromItem(item);
28
+ }
29
+ }, [item]);
30
+
31
+ useImperativeHandle(ref, () => ({}));
32
+
33
+ return (
34
+ <TabPanel
35
+ activeTabIndex={0}
36
+ tabs={[
37
+ {
38
+ title: t("details", { ns: "actions" }),
39
+ children: (
40
+ <Overlay loading={isLoading}>
41
+ <FormPanel
42
+ ref={formRef}
43
+ fields={[...getFieldsLocale([{ name: "name" }])]}
44
+ button={{ text: t("save", { ns: "actions" }) }}
45
+ onSubmit={(data) => {
46
+ categoryUpdate({ id: data.id, data });
47
+ if (typeof onUpdated === "function") {
48
+ onUpdated(data);
49
+ }
50
+ }}
51
+ />
52
+ </Overlay>
53
+ ),
54
+ },
55
+ ]}
56
+ />
57
+ );
58
+ },
59
+ );
@@ -0,0 +1,5 @@
1
+ export declare function useCategoryCreate(): any;
2
+ export declare function useCategoryDelete(): any;
3
+ export declare function useCategoryUpdate(): any;
4
+ export declare function useCategoryGet(id: number): any;
5
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["handlers.ts"],"names":[],"mappings":"AAMA,wBAAgB,iBAAiB,QAGhC;AAED,wBAAgB,iBAAiB,QAGhC;AAED,wBAAgB,iBAAiB,QAGhC;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,OAMxC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCategoryCreate = useCategoryCreate;
4
+ exports.useCategoryDelete = useCategoryDelete;
5
+ exports.useCategoryUpdate = useCategoryUpdate;
6
+ exports.useCategoryGet = useCategoryGet;
7
+ const use_default_mutation_1 = require("@/hooks/use-default-mutation");
8
+ const react_query_1 = require("@tanstack/react-query");
9
+ const requests_1 = require("./requests");
10
+ const scope = "category";
11
+ function useCategoryCreate() {
12
+ const { categoryCreate } = (0, requests_1.requests)();
13
+ return (0, use_default_mutation_1.useDefaultMutation)(scope, "create", categoryCreate);
14
+ }
15
+ function useCategoryDelete() {
16
+ const { categoryDelete } = (0, requests_1.requests)();
17
+ return (0, use_default_mutation_1.useDefaultMutation)(scope, "delete", categoryDelete);
18
+ }
19
+ function useCategoryUpdate() {
20
+ const { categoryUpdate } = (0, requests_1.requests)();
21
+ return (0, use_default_mutation_1.useDefaultMutation)(scope, "update", categoryUpdate);
22
+ }
23
+ function useCategoryGet(id) {
24
+ const { categoryGet } = (0, requests_1.requests)();
25
+ return (0, react_query_1.useQuery)({
26
+ queryKey: [scope, "get"],
27
+ queryFn: () => categoryGet(id),
28
+ });
29
+ }
30
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["handlers.ts"],"names":[],"mappings":";;AAMA,8CAGC;AAED,8CAGC;AAED,8CAGC;AAED,wCAMC;AA3BD,uEAAkE;AAClE,uDAAiD;AACjD,yCAAsC;AAEtC,MAAM,KAAK,GAAG,UAAU,CAAC;AAEzB,SAAgB,iBAAiB;IAC/B,MAAM,EAAE,cAAc,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IACtC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC7D,CAAC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,EAAE,cAAc,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IACtC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC7D,CAAC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,EAAE,cAAc,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IACtC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC7D,CAAC;AAED,SAAgB,cAAc,CAAC,EAAU;IACvC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IACnC,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;QACxB,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC;KAC/B,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +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 = "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
+ }
@@ -0,0 +1,10 @@
1
+ import { PaginationParams } from "@/types";
2
+ import { Category } from "@/types/models";
3
+ export declare function requests(): {
4
+ categoryCreate: (data: Category) => Promise<any>;
5
+ categoryUpdate: (id: number, data: Category) => Promise<any>;
6
+ categoryDelete: (ids: number[]) => Promise<any>;
7
+ categoryList: (params: PaginationParams) => Promise<any>;
8
+ categoryGet: (id: number) => Promise<any>;
9
+ };
10
+ //# sourceMappingURL=requests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["requests.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,gBAAgB,EAAoB,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,wBAAgB,QAAQ;2BAgBc,QAAQ;yBAgBV,MAAM,QAAQ,QAAQ;0BARrB,MAAM,EAAE;2BArBP,gBAAgB;sBAOrB,MAAM;EAqCtC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requests = requests;
4
+ const use_app_1 = require("@/hooks/use-app");
5
+ const http_method_1 = require("@/types/http-method");
6
+ const utils_1 = require("@hedhog/utils");
7
+ function requests() {
8
+ const { request } = (0, use_app_1.useApp)();
9
+ const categoryList = async (params) => {
10
+ return request({
11
+ url: "/category",
12
+ params,
13
+ });
14
+ };
15
+ const categoryGet = async (id) => {
16
+ return request({
17
+ url: `/category/${id}`,
18
+ });
19
+ };
20
+ const categoryCreate = async (data) => {
21
+ return request({
22
+ url: "/category",
23
+ method: http_method_1.HttpMethod.POST,
24
+ data: (0, utils_1.formatDataWithLocale)(data),
25
+ });
26
+ };
27
+ const categoryDelete = async (ids) => {
28
+ return request({
29
+ url: "/category",
30
+ data: { ids },
31
+ method: http_method_1.HttpMethod.DELETE,
32
+ });
33
+ };
34
+ const categoryUpdate = async (id, data) => {
35
+ return request({
36
+ url: `/category/${id}`,
37
+ method: http_method_1.HttpMethod.PATCH,
38
+ data: (0, utils_1.formatDataWithLocale)(data),
39
+ });
40
+ };
41
+ return {
42
+ categoryCreate,
43
+ categoryUpdate,
44
+ categoryDelete,
45
+ categoryList,
46
+ categoryGet,
47
+ };
48
+ }
49
+ //# sourceMappingURL=requests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requests.js","sourceRoot":"","sources":["requests.ts"],"names":[],"mappings":";;AAMA,4BA+CC;AArDD,6CAAyC;AAGzC,qDAAiD;AACjD,yCAAqD;AAErD,SAAgB,QAAQ;IACtB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,gBAAM,GAAE,CAAC;IAE7B,MAAM,YAAY,GAAG,KAAK,EAAE,MAAwB,EAAE,EAAE;QACtD,OAAO,OAAO,CAA6B;YACzC,GAAG,EAAE,WAAW;YAChB,MAAM;SACP,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,KAAK,EAAE,EAAU,EAAE,EAAE;QACvC,OAAO,OAAO,CAAW;YACvB,GAAG,EAAE,aAAa,EAAE,EAAE;SACvB,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,EAAE,IAAc,EAAE,EAAE;QAC9C,OAAO,OAAO,CAAW;YACvB,GAAG,EAAE,WAAW;YAChB,MAAM,EAAE,wBAAU,CAAC,IAAI;YACvB,IAAI,EAAE,IAAA,4BAAoB,EAAC,IAAI,CAAC;SACjC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,EAAE,GAAa,EAAE,EAAE;QAC7C,OAAO,OAAO,CAAS;YACrB,GAAG,EAAE,WAAW;YAChB,IAAI,EAAE,EAAE,GAAG,EAAE;YACb,MAAM,EAAE,wBAAU,CAAC,MAAM;SAC1B,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,EAAE,EAAU,EAAE,IAAc,EAAE,EAAE;QAC1D,OAAO,OAAO,CAAW;YACvB,GAAG,EAAE,aAAa,EAAE,EAAE;YACtB,MAAM,EAAE,wBAAU,CAAC,KAAK;YACxB,IAAI,EAAE,IAAA,4BAAoB,EAAC,IAAI,CAAC;SACjC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,cAAc;QACd,cAAc;QACd,cAAc;QACd,YAAY;QACZ,WAAW;KACZ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,54 @@
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
+ });
15
+ };
16
+
17
+ const categoryGet = async (id: number) => {
18
+ return request<Category>({
19
+ url: `/category/${id}`,
20
+ });
21
+ };
22
+
23
+ const categoryCreate = async (data: Category) => {
24
+ return request<Category>({
25
+ url: "/category",
26
+ method: HttpMethod.POST,
27
+ data: formatDataWithLocale(data),
28
+ });
29
+ };
30
+
31
+ const categoryDelete = async (ids: number[]) => {
32
+ return request<Delete>({
33
+ url: "/category",
34
+ data: { ids },
35
+ method: HttpMethod.DELETE,
36
+ });
37
+ };
38
+
39
+ const categoryUpdate = async (id: number, data: Category) => {
40
+ return request<Category>({
41
+ url: `/category/${id}`,
42
+ method: HttpMethod.PATCH,
43
+ data: formatDataWithLocale(data),
44
+ });
45
+ };
46
+
47
+ return {
48
+ categoryCreate,
49
+ categoryUpdate,
50
+ categoryDelete,
51
+ categoryList,
52
+ categoryGet,
53
+ };
54
+ }
@@ -0,0 +1,9 @@
1
+ import { Post } from "@/types/models";
2
+ export type PostCreatePanelRef = {
3
+ submit: () => void;
4
+ };
5
+ export type PostCreatePanelProps = {
6
+ onCreated?: (data: Post) => void;
7
+ };
8
+ export declare const PostCreatePanel: any;
9
+ //# sourceMappingURL=create-panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-panel.d.ts","sourceRoot":"","sources":["create-panel.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,eAAe,KA0D3B,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PostCreatePanel = void 0;
7
+ const form_panel_1 = __importDefault(require("@/components/custom/form-panel"));
8
+ const EnumFieldType_1 = require("@/enums/EnumFieldType");
9
+ const person_type_1 = require("@/features/person-type");
10
+ const react_1 = require("react");
11
+ const react_i18next_1 = require("react-i18next");
12
+ exports.PostCreatePanel = (0, react_1.forwardRef)(({ onCreated }, ref) => {
13
+ const formRef = (0, react_1.useRef)(null);
14
+ const { t } = (0, react_i18next_1.useTranslation)(["post", "actions"]);
15
+ const { mutateAsync: createPost } = (0, person_type_1.usePostCreate)();
16
+ (0, react_1.useImperativeHandle)(ref, () => ({
17
+ submit: () => {
18
+ var _a;
19
+ (_a = formRef.current) === null || _a === void 0 ? void 0 : _a.submit();
20
+ },
21
+ }), [formRef]);
22
+ return (<form_panel_1.default ref={formRef} fields={[
23
+ {
24
+ name: "title",
25
+ label: { text: t("title", { ns: "translation" }) },
26
+ type: EnumFieldType_1.EnumFieldType.TEXT,
27
+ required: true,
28
+ },
29
+ {
30
+ name: "content",
31
+ label: { text: t("content", { ns: "translation" }) },
32
+ type: EnumFieldType_1.EnumFieldType.TEXT,
33
+ required: true,
34
+ },
35
+ {
36
+ name: "author_id",
37
+ label: { text: t("author_id", { ns: "translation" }) },
38
+ type: EnumFieldType_1.EnumFieldType.TEXT,
39
+ required: true,
40
+ },
41
+ {
42
+ name: "category_id",
43
+ label: { text: t("category_id", { ns: "translation" }) },
44
+ type: EnumFieldType_1.EnumFieldType.TEXT,
45
+ required: true,
46
+ },
47
+ ]} button={{ text: t("create", { ns: "actions" }) }} onSubmit={async (data) => {
48
+ const createdData = await createPost(data);
49
+ if (typeof onCreated === "function") {
50
+ onCreated(createdData);
51
+ }
52
+ }}/>);
53
+ });
54
+ //# sourceMappingURL=create-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-panel.js","sourceRoot":"","sources":["create-panel.tsx"],"names":[],"mappings":";;;;;;AAAA,gFAAyE;AACzE,yDAAsD;AACtD,wDAAuD;AAEvD,iCAAgE;AAChE,iDAA+C;AAUlC,QAAA,eAAe,GAAG,IAAA,kBAAU,EACvC,CAAC,EAAE,SAAS,EAAwB,EAAE,GAAG,EAAE,EAAE;IAC3C,MAAM,OAAO,GAAG,IAAA,cAAM,EAAe,IAAI,CAAC,CAAC;IAC3C,MAAM,EAAE,CAAC,EAAE,GAAG,IAAA,8BAAc,EAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAClD,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAA,2BAAa,GAAE,CAAC;IAEpD,IAAA,2BAAmB,EACjB,GAAG,EACH,GAAG,EAAE,CAAC,CAAC;QACL,MAAM,EAAE,GAAG,EAAE;;YACX,MAAA,OAAO,CAAC,OAAO,0CAAE,MAAM,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC,EACF,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,OAAO,CACL,CAAC,oBAAS,CACR,GAAG,CAAC,CAAC,OAAO,CAAC,CACb,MAAM,CAAC,CAAC;YACN;gBACE,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;gBAClD,IAAI,EAAE,6BAAa,CAAC,IAAI;gBACxB,QAAQ,EAAE,IAAI;aACf;YAED;gBACE,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;gBACpD,IAAI,EAAE,6BAAa,CAAC,IAAI;gBACxB,QAAQ,EAAE,IAAI;aACf;YAED;gBACE,IAAI,EAAE,WAAW;gBACjB,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;gBACtD,IAAI,EAAE,6BAAa,CAAC,IAAI;gBACxB,QAAQ,EAAE,IAAI;aACf;YAED;gBACE,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,aAAa,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;gBACxD,IAAI,EAAE,6BAAa,CAAC,IAAI;gBACxB,QAAQ,EAAE,IAAI;aACf;SACF,CAAC,CACF,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,CACjD,QAAQ,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACvB,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;gBACpC,SAAS,CAAC,WAAW,CAAC,CAAC;YACzB,CAAC;QACH,CAAC,CAAC,EACF,CACH,CAAC;AACJ,CAAC,CACF,CAAC"}
@@ -0,0 +1,74 @@
1
+ import FormPanel, { FormPanelRef } from "@/components/custom/form-panel";
2
+ import { EnumFieldType } from "@/enums/EnumFieldType";
3
+ import { usePostCreate } from "@/features/person-type";
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
+ export const PostCreatePanel = forwardRef(
17
+ ({ onCreated }: PostCreatePanelProps, ref) => {
18
+ const formRef = useRef<FormPanelRef>(null);
19
+ const { t } = useTranslation(["post", "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
+ );
@@ -0,0 +1,7 @@
1
+ import { Post } from "@/types/models";
2
+ export type PostUpdatePanelProps = {
3
+ data: Post;
4
+ onUpdated?: (data: Post) => void;
5
+ };
6
+ export declare const PostUpdatePanel: any;
7
+ //# sourceMappingURL=update-panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-panel.d.ts","sourceRoot":"","sources":["update-panel.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,eAAe,KAoE3B,CAAC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PostUpdatePanel = void 0;
7
+ const form_panel_1 = __importDefault(require("@/components/custom/form-panel"));
8
+ const overlay_1 = require("@/components/custom/overlay");
9
+ const tab_panel_1 = require("@/components/custom/tab-panel");
10
+ const EnumFieldType_1 = require("@/enums/EnumFieldType");
11
+ const post_1 = require("@/features/post");
12
+ const use_effect_after_first_update_1 = __importDefault(require("@/hooks/use-effect-after-first-update"));
13
+ const i18next_1 = require("i18next");
14
+ const react_1 = require("react");
15
+ exports.PostUpdatePanel = (0, react_1.forwardRef)(({ data, onUpdated }, ref) => {
16
+ const { data: item, isLoading } = (0, post_1.usePostGet)(data.id);
17
+ const { mutate: postUpdate } = (0, post_1.usePostUpdate)();
18
+ const formRef = (0, react_1.useRef)(null);
19
+ (0, use_effect_after_first_update_1.default)(() => {
20
+ if (item && formRef.current) {
21
+ formRef.current.setValuesFromItem(item);
22
+ }
23
+ }, [item]);
24
+ (0, react_1.useImperativeHandle)(ref, () => ({}));
25
+ return (<tab_panel_1.TabPanel activeTabIndex={0} tabs={[
26
+ {
27
+ title: (0, i18next_1.t)("details", { ns: "actions" }),
28
+ children: (<overlay_1.Overlay loading={isLoading}>
29
+ <form_panel_1.default ref={formRef} fields={[
30
+ {
31
+ name: "title",
32
+ label: { text: (0, i18next_1.t)("title", { ns: "translation" }) },
33
+ type: EnumFieldType_1.EnumFieldType.TEXT,
34
+ required: true,
35
+ },
36
+ {
37
+ name: "content",
38
+ label: { text: (0, i18next_1.t)("content", { ns: "translation" }) },
39
+ type: EnumFieldType_1.EnumFieldType.TEXT,
40
+ required: true,
41
+ },
42
+ {
43
+ name: "author_id",
44
+ label: { text: (0, i18next_1.t)("author_id", { ns: "translation" }) },
45
+ type: EnumFieldType_1.EnumFieldType.TEXT,
46
+ required: true,
47
+ },
48
+ {
49
+ name: "category_id",
50
+ label: { text: (0, i18next_1.t)("category_id", { ns: "translation" }) },
51
+ type: EnumFieldType_1.EnumFieldType.TEXT,
52
+ required: true,
53
+ },
54
+ ]} button={{ text: (0, i18next_1.t)("save", { ns: "actions" }) }} onSubmit={(data) => {
55
+ postUpdate({ id: data.id, data });
56
+ if (typeof onUpdated === "function") {
57
+ onUpdated(data);
58
+ }
59
+ }}/>
60
+ </overlay_1.Overlay>),
61
+ },
62
+ ]}/>);
63
+ });
64
+ //# sourceMappingURL=update-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-panel.js","sourceRoot":"","sources":["update-panel.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,84 @@
1
+ import FormPanel, { FormPanelRef } from "@/components/custom/form-panel";
2
+ import { Overlay } from "@/components/custom/overlay";
3
+ import { TabPanel } from "@/components/custom/tab-panel";
4
+ import { EnumFieldType } from "@/enums/EnumFieldType";
5
+ import { usePostGet, usePostUpdate } from "@/features/post";
6
+ import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
7
+ import { Post } from "@/types/models";
8
+ import { t } from "i18next";
9
+ import { forwardRef, useImperativeHandle, useRef } from "react";
10
+
11
+ export type PostUpdatePanelProps = {
12
+ data: Post;
13
+ onUpdated?: (data: Post) => void;
14
+ };
15
+
16
+ export const PostUpdatePanel = forwardRef(
17
+ ({ data, onUpdated }: PostUpdatePanelProps, ref) => {
18
+ const { data: item, isLoading } = usePostGet(data.id as number);
19
+ const { mutate: postUpdate } = usePostUpdate();
20
+ const formRef = useRef<FormPanelRef>(null);
21
+
22
+ useEffectAfterFirstUpdate(() => {
23
+ if (item && formRef.current) {
24
+ formRef.current.setValuesFromItem(item);
25
+ }
26
+ }, [item]);
27
+
28
+ useImperativeHandle(ref, () => ({}));
29
+
30
+ return (
31
+ <TabPanel
32
+ activeTabIndex={0}
33
+ tabs={[
34
+ {
35
+ title: t("details", { ns: "actions" }),
36
+ children: (
37
+ <Overlay loading={isLoading}>
38
+ <FormPanel
39
+ ref={formRef}
40
+ fields={[
41
+ {
42
+ name: "title",
43
+ label: { text: t("title", { ns: "translation" }) },
44
+ type: EnumFieldType.TEXT,
45
+ required: true,
46
+ },
47
+
48
+ {
49
+ name: "content",
50
+ label: { text: t("content", { ns: "translation" }) },
51
+ type: EnumFieldType.TEXT,
52
+ required: true,
53
+ },
54
+
55
+ {
56
+ name: "author_id",
57
+ label: { text: t("author_id", { ns: "translation" }) },
58
+ type: EnumFieldType.TEXT,
59
+ required: true,
60
+ },
61
+
62
+ {
63
+ name: "category_id",
64
+ label: { text: t("category_id", { ns: "translation" }) },
65
+ type: EnumFieldType.TEXT,
66
+ required: true,
67
+ },
68
+ ]}
69
+ button={{ text: t("save", { ns: "actions" }) }}
70
+ onSubmit={(data) => {
71
+ postUpdate({ id: data.id, data });
72
+ if (typeof onUpdated === "function") {
73
+ onUpdated(data);
74
+ }
75
+ }}
76
+ />
77
+ </Overlay>
78
+ ),
79
+ },
80
+ ]}
81
+ />
82
+ );
83
+ },
84
+ );
@@ -0,0 +1,5 @@
1
+ export declare function usePostCreate(): any;
2
+ export declare function usePostDelete(): any;
3
+ export declare function usePostUpdate(): any;
4
+ export declare function usePostGet(id: number): any;
5
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["handlers.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,QAG5B;AAED,wBAAgB,aAAa,QAG5B;AAED,wBAAgB,aAAa,QAG5B;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,OAMpC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePostCreate = usePostCreate;
4
+ exports.usePostDelete = usePostDelete;
5
+ exports.usePostUpdate = usePostUpdate;
6
+ exports.usePostGet = usePostGet;
7
+ const use_default_mutation_1 = require("@/hooks/use-default-mutation");
8
+ const react_query_1 = require("@tanstack/react-query");
9
+ const requests_1 = require("./requests");
10
+ const scope = "post";
11
+ function usePostCreate() {
12
+ const { postCreate } = (0, requests_1.requests)();
13
+ return (0, use_default_mutation_1.useDefaultMutation)(scope, "create", postCreate);
14
+ }
15
+ function usePostDelete() {
16
+ const { postDelete } = (0, requests_1.requests)();
17
+ return (0, use_default_mutation_1.useDefaultMutation)(scope, "delete", postDelete);
18
+ }
19
+ function usePostUpdate() {
20
+ const { postUpdate } = (0, requests_1.requests)();
21
+ return (0, use_default_mutation_1.useDefaultMutation)(scope, "update", postUpdate);
22
+ }
23
+ function usePostGet(id) {
24
+ const { postGet } = (0, requests_1.requests)();
25
+ return (0, react_query_1.useQuery)({
26
+ queryKey: [scope, "get"],
27
+ queryFn: () => postGet(id),
28
+ });
29
+ }
30
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["handlers.ts"],"names":[],"mappings":";;AAMA,sCAGC;AAED,sCAGC;AAED,sCAGC;AAED,gCAMC;AA3BD,uEAAkE;AAClE,uDAAiD;AACjD,yCAAsC;AAEtC,MAAM,KAAK,GAAG,MAAM,CAAC;AAErB,SAAgB,aAAa;IAC3B,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IAClC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC;AAED,SAAgB,aAAa;IAC3B,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IAClC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC;AAED,SAAgB,aAAa;IAC3B,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IAClC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC;AAED,SAAgB,UAAU,CAAC,EAAU;IACnC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IAC/B,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;QACxB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KAC3B,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +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 = "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
+ }