@hedhog/blog 0.0.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 +14 -0
- package/dist/author/author.controller.d.ts.map +1 -0
- package/dist/author/author.controller.js +89 -0
- package/dist/author/author.controller.js.map +1 -0
- package/dist/author/author.module.d.ts +3 -0
- package/dist/author/author.module.d.ts.map +1 -0
- package/dist/author/author.module.js +31 -0
- package/dist/author/author.module.js.map +1 -0
- package/dist/author/author.service.d.ts +19 -0
- package/dist/author/author.service.d.ts.map +1 -0
- package/dist/author/author.service.js +72 -0
- package/dist/author/author.service.js.map +1 -0
- package/dist/author/dto/create.dto.d.ts +5 -0
- package/dist/author/dto/create.dto.d.ts.map +1 -0
- package/dist/author/dto/create.dto.js +27 -0
- package/dist/author/dto/create.dto.js.map +1 -0
- package/dist/author/dto/delete.dto.d.ts +4 -0
- package/dist/author/dto/delete.dto.d.ts.map +1 -0
- package/dist/author/dto/delete.dto.js +23 -0
- package/dist/author/dto/delete.dto.js.map +1 -0
- package/dist/author/dto/update.dto.d.ts +6 -0
- package/dist/author/dto/update.dto.d.ts.map +1 -0
- package/dist/author/dto/update.dto.js +9 -0
- package/dist/author/dto/update.dto.js.map +1 -0
- package/dist/blog.module.d.ts +3 -0
- package/dist/blog.module.d.ts.map +1 -0
- package/dist/blog.module.js +35 -0
- package/dist/blog.module.js.map +1 -0
- package/dist/category/category.controller.d.ts +14 -0
- package/dist/category/category.controller.d.ts.map +1 -0
- package/dist/category/category.controller.js +91 -0
- package/dist/category/category.controller.js.map +1 -0
- package/dist/category/category.module.d.ts +3 -0
- package/dist/category/category.module.d.ts.map +1 -0
- package/dist/category/category.module.js +31 -0
- package/dist/category/category.module.js.map +1 -0
- package/dist/category/category.service.d.ts +19 -0
- package/dist/category/category.service.d.ts.map +1 -0
- package/dist/category/category.service.js +87 -0
- package/dist/category/category.service.js.map +1 -0
- package/dist/category/dto/create.dto.d.ts +5 -0
- package/dist/category/dto/create.dto.d.ts.map +1 -0
- package/dist/category/dto/create.dto.js +23 -0
- package/dist/category/dto/create.dto.js.map +1 -0
- package/dist/category/dto/delete.dto.d.ts +4 -0
- package/dist/category/dto/delete.dto.d.ts.map +1 -0
- package/dist/category/dto/delete.dto.js +23 -0
- package/dist/category/dto/delete.dto.js.map +1 -0
- package/dist/category/dto/update.dto.d.ts +6 -0
- package/dist/category/dto/update.dto.d.ts.map +1 -0
- package/dist/category/dto/update.dto.js +9 -0
- package/dist/category/dto/update.dto.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/post/dto/create.dto.d.ts +5 -0
- package/dist/post/dto/create.dto.d.ts.map +1 -0
- package/dist/post/dto/create.dto.js +26 -0
- package/dist/post/dto/create.dto.js.map +1 -0
- package/dist/post/dto/delete.dto.d.ts +4 -0
- package/dist/post/dto/delete.dto.d.ts.map +1 -0
- package/dist/post/dto/delete.dto.js +23 -0
- package/dist/post/dto/delete.dto.js.map +1 -0
- package/dist/post/dto/update.dto.d.ts +6 -0
- package/dist/post/dto/update.dto.d.ts.map +1 -0
- package/dist/post/dto/update.dto.js +9 -0
- package/dist/post/dto/update.dto.js.map +1 -0
- package/dist/post/post.controller.d.ts +14 -0
- package/dist/post/post.controller.d.ts.map +1 -0
- package/dist/post/post.controller.js +89 -0
- package/dist/post/post.controller.js.map +1 -0
- package/dist/post/post.module.d.ts +3 -0
- package/dist/post/post.module.d.ts.map +1 -0
- package/dist/post/post.module.js +31 -0
- package/dist/post/post.module.js.map +1 -0
- package/dist/post/post.service.d.ts +19 -0
- package/dist/post/post.service.d.ts.map +1 -0
- package/dist/post/post.service.js +72 -0
- package/dist/post/post.service.js.map +1 -0
- package/frontend/author/components/create-panel.d.ts +9 -0
- package/frontend/author/components/create-panel.d.ts.map +1 -0
- package/frontend/author/components/create-panel.js +42 -0
- package/frontend/author/components/create-panel.js.map +1 -0
- package/frontend/author/components/create-panel.tsx +60 -0
- package/frontend/author/components/update-panel.d.ts +7 -0
- package/frontend/author/components/update-panel.d.ts.map +1 -0
- package/frontend/author/components/update-panel.js +52 -0
- package/frontend/author/components/update-panel.js.map +1 -0
- package/frontend/author/components/update-panel.tsx +70 -0
- package/frontend/author/react-query/handlers.d.ts +5 -0
- package/frontend/author/react-query/handlers.d.ts.map +1 -0
- package/frontend/author/react-query/handlers.js +30 -0
- package/frontend/author/react-query/handlers.js.map +1 -0
- package/frontend/author/react-query/handlers.ts +28 -0
- package/frontend/author/react-query/requests.d.ts +10 -0
- package/frontend/author/react-query/requests.d.ts.map +1 -0
- package/frontend/author/react-query/requests.js +48 -0
- package/frontend/author/react-query/requests.js.map +1 -0
- package/frontend/author/react-query/requests.ts +53 -0
- package/frontend/category/components/create-panel.d.ts +9 -0
- package/frontend/category/components/create-panel.d.ts.map +1 -0
- package/frontend/category/components/create-panel.js +48 -0
- package/frontend/category/components/create-panel.js.map +1 -0
- package/frontend/category/components/create-panel.tsx +49 -0
- package/frontend/category/components/update-panel.d.ts +7 -0
- package/frontend/category/components/update-panel.d.ts.map +1 -0
- package/frontend/category/components/update-panel.js +61 -0
- package/frontend/category/components/update-panel.js.map +1 -0
- package/frontend/category/components/update-panel.tsx +59 -0
- package/frontend/category/react-query/handlers.d.ts +5 -0
- package/frontend/category/react-query/handlers.d.ts.map +1 -0
- package/frontend/category/react-query/handlers.js +30 -0
- package/frontend/category/react-query/handlers.js.map +1 -0
- package/frontend/category/react-query/handlers.ts +28 -0
- package/frontend/category/react-query/requests.d.ts +10 -0
- package/frontend/category/react-query/requests.d.ts.map +1 -0
- package/frontend/category/react-query/requests.js +49 -0
- package/frontend/category/react-query/requests.js.map +1 -0
- package/frontend/category/react-query/requests.ts +54 -0
- package/frontend/post/components/create-panel.d.ts +9 -0
- package/frontend/post/components/create-panel.d.ts.map +1 -0
- package/frontend/post/components/create-panel.js +54 -0
- package/frontend/post/components/create-panel.js.map +1 -0
- package/frontend/post/components/create-panel.tsx +74 -0
- package/frontend/post/components/update-panel.d.ts +7 -0
- package/frontend/post/components/update-panel.d.ts.map +1 -0
- package/frontend/post/components/update-panel.js +64 -0
- package/frontend/post/components/update-panel.js.map +1 -0
- package/frontend/post/components/update-panel.tsx +84 -0
- package/frontend/post/react-query/handlers.d.ts +5 -0
- package/frontend/post/react-query/handlers.d.ts.map +1 -0
- package/frontend/post/react-query/handlers.js +30 -0
- package/frontend/post/react-query/handlers.js.map +1 -0
- package/frontend/post/react-query/handlers.ts +28 -0
- package/frontend/post/react-query/requests.d.ts +10 -0
- package/frontend/post/react-query/requests.d.ts.map +1 -0
- package/frontend/post/react-query/requests.js +48 -0
- package/frontend/post/react-query/requests.js.map +1 -0
- package/frontend/post/react-query/requests.ts +53 -0
- package/hedhog.yaml +133 -0
- package/package.json +35 -0
@@ -0,0 +1,42 @@
|
|
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.AuthorCreatePanel = 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.AuthorCreatePanel = (0, react_1.forwardRef)(({ onCreated }, ref) => {
|
13
|
+
const formRef = (0, react_1.useRef)(null);
|
14
|
+
const { t } = (0, react_i18next_1.useTranslation)(["author", "actions"]);
|
15
|
+
const { mutateAsync: createAuthor } = (0, person_type_1.useAuthorCreate)();
|
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: "name",
|
25
|
+
label: { text: t("name", { ns: "translation" }) },
|
26
|
+
type: EnumFieldType_1.EnumFieldType.TEXT,
|
27
|
+
required: true,
|
28
|
+
},
|
29
|
+
{
|
30
|
+
name: "email",
|
31
|
+
label: { text: t("email", { ns: "translation" }) },
|
32
|
+
type: EnumFieldType_1.EnumFieldType.TEXT,
|
33
|
+
required: true,
|
34
|
+
},
|
35
|
+
]} button={{ text: t("create", { ns: "actions" }) }} onSubmit={async (data) => {
|
36
|
+
const createdData = await createAuthor(data);
|
37
|
+
if (typeof onCreated === "function") {
|
38
|
+
onCreated(createdData);
|
39
|
+
}
|
40
|
+
}}/>);
|
41
|
+
});
|
42
|
+
//# 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,wDAAyD;AAEzD,iCAAgE;AAChE,iDAA+C;AAUlC,QAAA,iBAAiB,GAAG,IAAA,kBAAU,EACzC,CAAC,EAAE,SAAS,EAA0B,EAAE,GAAG,EAAE,EAAE;IAC7C,MAAM,OAAO,GAAG,IAAA,cAAM,EAAe,IAAI,CAAC,CAAC;IAC3C,MAAM,EAAE,CAAC,EAAE,GAAG,IAAA,8BAAc,EAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IACpD,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,IAAA,6BAAe,GAAE,CAAC;IAExD,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,MAAM;gBACZ,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;gBACjD,IAAI,EAAE,6BAAa,CAAC,IAAI;gBACxB,QAAQ,EAAE,IAAI;aACf;YAED;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;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,YAAY,CAAC,IAAI,CAAC,CAAC;YAC7C,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,60 @@
|
|
1
|
+
import FormPanel, { FormPanelRef } from "@/components/custom/form-panel";
|
2
|
+
import { EnumFieldType } from "@/enums/EnumFieldType";
|
3
|
+
import { useAuthorCreate } from "@/features/person-type";
|
4
|
+
import { Author } from "@/types/models";
|
5
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
6
|
+
import { useTranslation } from "react-i18next";
|
7
|
+
|
8
|
+
export type AuthorCreatePanelRef = {
|
9
|
+
submit: () => void;
|
10
|
+
};
|
11
|
+
|
12
|
+
export type AuthorCreatePanelProps = {
|
13
|
+
onCreated?: (data: Author) => void;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const AuthorCreatePanel = forwardRef(
|
17
|
+
({ onCreated }: AuthorCreatePanelProps, ref) => {
|
18
|
+
const formRef = useRef<FormPanelRef>(null);
|
19
|
+
const { t } = useTranslation(["author", "actions"]);
|
20
|
+
const { mutateAsync: createAuthor } = useAuthorCreate();
|
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: "name",
|
38
|
+
label: { text: t("name", { ns: "translation" }) },
|
39
|
+
type: EnumFieldType.TEXT,
|
40
|
+
required: true,
|
41
|
+
},
|
42
|
+
|
43
|
+
{
|
44
|
+
name: "email",
|
45
|
+
label: { text: t("email", { ns: "translation" }) },
|
46
|
+
type: EnumFieldType.TEXT,
|
47
|
+
required: true,
|
48
|
+
},
|
49
|
+
]}
|
50
|
+
button={{ text: t("create", { ns: "actions" }) }}
|
51
|
+
onSubmit={async (data) => {
|
52
|
+
const createdData = await createAuthor(data);
|
53
|
+
if (typeof onCreated === "function") {
|
54
|
+
onCreated(createdData);
|
55
|
+
}
|
56
|
+
}}
|
57
|
+
/>
|
58
|
+
);
|
59
|
+
},
|
60
|
+
);
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-panel.d.ts","sourceRoot":"","sources":["update-panel.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIxC,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,iBAAiB,KAsD7B,CAAC"}
|
@@ -0,0 +1,52 @@
|
|
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.AuthorUpdatePanel = 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 author_1 = require("@/features/author");
|
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.AuthorUpdatePanel = (0, react_1.forwardRef)(({ data, onUpdated }, ref) => {
|
16
|
+
const { data: item, isLoading } = (0, author_1.useAuthorGet)(data.id);
|
17
|
+
const { mutate: authorUpdate } = (0, author_1.useAuthorUpdate)();
|
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: "name",
|
32
|
+
label: { text: (0, i18next_1.t)("name", { ns: "translation" }) },
|
33
|
+
type: EnumFieldType_1.EnumFieldType.TEXT,
|
34
|
+
required: true,
|
35
|
+
},
|
36
|
+
{
|
37
|
+
name: "email",
|
38
|
+
label: { text: (0, i18next_1.t)("email", { ns: "translation" }) },
|
39
|
+
type: EnumFieldType_1.EnumFieldType.TEXT,
|
40
|
+
required: true,
|
41
|
+
},
|
42
|
+
]} button={{ text: (0, i18next_1.t)("save", { ns: "actions" }) }} onSubmit={(data) => {
|
43
|
+
authorUpdate({ id: data.id, data });
|
44
|
+
if (typeof onUpdated === "function") {
|
45
|
+
onUpdated(data);
|
46
|
+
}
|
47
|
+
}}/>
|
48
|
+
</overlay_1.Overlay>),
|
49
|
+
},
|
50
|
+
]}/>);
|
51
|
+
});
|
52
|
+
//# sourceMappingURL=update-panel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-panel.js","sourceRoot":"","sources":["update-panel.tsx"],"names":[],"mappings":";;;;;;AAAA,gFAAyE;AACzE,yDAAsD;AACtD,6DAAyD;AACzD,yDAAsD;AACtD,8CAAkE;AAClE,0GAA8E;AAE9E,qCAA4B;AAC5B,iCAAgE;AAOnD,QAAA,iBAAiB,GAAG,IAAA,kBAAU,EACzC,CAAC,EAAE,IAAI,EAAE,SAAS,EAA0B,EAAE,GAAG,EAAE,EAAE;IACnD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,EAAY,CAAC,CAAC;IAClE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,IAAA,wBAAe,GAAE,CAAC;IACnD,MAAM,OAAO,GAAG,IAAA,cAAM,EAAe,IAAI,CAAC,CAAC;IAE3C,IAAA,uCAAyB,EAAC,GAAG,EAAE;QAC7B,IAAI,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YAC5B,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,IAAA,2BAAmB,EAAC,GAAG,EAAE,GAAG,EA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AAC,EACF,CACH,CAAC;AACJ,CAAC,CACF,CAAC"}
|
@@ -0,0 +1,70 @@
|
|
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 { useAuthorGet, useAuthorUpdate } from "@/features/author";
|
6
|
+
import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
|
7
|
+
import { Author } from "@/types/models";
|
8
|
+
import { t } from "i18next";
|
9
|
+
import { forwardRef, useImperativeHandle, useRef } from "react";
|
10
|
+
|
11
|
+
export type AuthorUpdatePanelProps = {
|
12
|
+
data: Author;
|
13
|
+
onUpdated?: (data: Author) => void;
|
14
|
+
};
|
15
|
+
|
16
|
+
export const AuthorUpdatePanel = forwardRef(
|
17
|
+
({ data, onUpdated }: AuthorUpdatePanelProps, ref) => {
|
18
|
+
const { data: item, isLoading } = useAuthorGet(data.id as number);
|
19
|
+
const { mutate: authorUpdate } = useAuthorUpdate();
|
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: "name",
|
43
|
+
label: { text: t("name", { ns: "translation" }) },
|
44
|
+
type: EnumFieldType.TEXT,
|
45
|
+
required: true,
|
46
|
+
},
|
47
|
+
|
48
|
+
{
|
49
|
+
name: "email",
|
50
|
+
label: { text: t("email", { ns: "translation" }) },
|
51
|
+
type: EnumFieldType.TEXT,
|
52
|
+
required: true,
|
53
|
+
},
|
54
|
+
]}
|
55
|
+
button={{ text: t("save", { ns: "actions" }) }}
|
56
|
+
onSubmit={(data) => {
|
57
|
+
authorUpdate({ id: data.id, data });
|
58
|
+
if (typeof onUpdated === "function") {
|
59
|
+
onUpdated(data);
|
60
|
+
}
|
61
|
+
}}
|
62
|
+
/>
|
63
|
+
</Overlay>
|
64
|
+
),
|
65
|
+
},
|
66
|
+
]}
|
67
|
+
/>
|
68
|
+
);
|
69
|
+
},
|
70
|
+
);
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["handlers.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,QAG9B;AAED,wBAAgB,eAAe,QAG9B;AAED,wBAAgB,eAAe,QAG9B;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,OAMtC"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.useAuthorCreate = useAuthorCreate;
|
4
|
+
exports.useAuthorDelete = useAuthorDelete;
|
5
|
+
exports.useAuthorUpdate = useAuthorUpdate;
|
6
|
+
exports.useAuthorGet = useAuthorGet;
|
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 = "author";
|
11
|
+
function useAuthorCreate() {
|
12
|
+
const { authorCreate } = (0, requests_1.requests)();
|
13
|
+
return (0, use_default_mutation_1.useDefaultMutation)(scope, "create", authorCreate);
|
14
|
+
}
|
15
|
+
function useAuthorDelete() {
|
16
|
+
const { authorDelete } = (0, requests_1.requests)();
|
17
|
+
return (0, use_default_mutation_1.useDefaultMutation)(scope, "delete", authorDelete);
|
18
|
+
}
|
19
|
+
function useAuthorUpdate() {
|
20
|
+
const { authorUpdate } = (0, requests_1.requests)();
|
21
|
+
return (0, use_default_mutation_1.useDefaultMutation)(scope, "update", authorUpdate);
|
22
|
+
}
|
23
|
+
function useAuthorGet(id) {
|
24
|
+
const { authorGet } = (0, requests_1.requests)();
|
25
|
+
return (0, react_query_1.useQuery)({
|
26
|
+
queryKey: [scope, "get"],
|
27
|
+
queryFn: () => authorGet(id),
|
28
|
+
});
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=handlers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["handlers.ts"],"names":[],"mappings":";;AAMA,0CAGC;AAED,0CAGC;AAED,0CAGC;AAED,oCAMC;AA3BD,uEAAkE;AAClE,uDAAiD;AACjD,yCAAsC;AAEtC,MAAM,KAAK,GAAG,QAAQ,CAAC;AAEvB,SAAgB,eAAe;IAC7B,MAAM,EAAE,YAAY,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IACpC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,eAAe;IAC7B,MAAM,EAAE,YAAY,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IACpC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,eAAe;IAC7B,MAAM,EAAE,YAAY,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IACpC,OAAO,IAAA,yCAAkB,EAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,YAAY,CAAC,EAAU;IACrC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,mBAAQ,GAAE,CAAC;IACjC,OAAO,IAAA,sBAAQ,EAAC;QACd,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;QACxB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;KAC7B,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 = "author";
|
6
|
+
|
7
|
+
export function useAuthorCreate() {
|
8
|
+
const { authorCreate } = requests();
|
9
|
+
return useDefaultMutation(scope, "create", authorCreate);
|
10
|
+
}
|
11
|
+
|
12
|
+
export function useAuthorDelete() {
|
13
|
+
const { authorDelete } = requests();
|
14
|
+
return useDefaultMutation(scope, "delete", authorDelete);
|
15
|
+
}
|
16
|
+
|
17
|
+
export function useAuthorUpdate() {
|
18
|
+
const { authorUpdate } = requests();
|
19
|
+
return useDefaultMutation(scope, "update", authorUpdate);
|
20
|
+
}
|
21
|
+
|
22
|
+
export function useAuthorGet(id: number) {
|
23
|
+
const { authorGet } = requests();
|
24
|
+
return useQuery({
|
25
|
+
queryKey: [scope, "get"],
|
26
|
+
queryFn: () => authorGet(id),
|
27
|
+
});
|
28
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { PaginationParams } from "@/types";
|
2
|
+
import { Author } from "@/types/models";
|
3
|
+
export declare function requests(): {
|
4
|
+
authorCreate: (data: Author) => Promise<any>;
|
5
|
+
authorUpdate: (id: number, data: Author) => Promise<any>;
|
6
|
+
authorDelete: (ids: number[]) => Promise<any>;
|
7
|
+
authorList: (params: PaginationParams) => Promise<any>;
|
8
|
+
authorGet: (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,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,wBAAgB,QAAQ;yBAgBY,MAAM;uBAgBR,MAAM,QAAQ,MAAM;wBARnB,MAAM,EAAE;yBArBP,gBAAgB;oBAOrB,MAAM;EAqCpC"}
|
@@ -0,0 +1,48 @@
|
|
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
|
+
function requests() {
|
7
|
+
const { request } = (0, use_app_1.useApp)();
|
8
|
+
const authorList = async (params) => {
|
9
|
+
return request({
|
10
|
+
url: "/author",
|
11
|
+
params,
|
12
|
+
});
|
13
|
+
};
|
14
|
+
const authorGet = async (id) => {
|
15
|
+
return request({
|
16
|
+
url: `/author/${id}`,
|
17
|
+
});
|
18
|
+
};
|
19
|
+
const authorCreate = async (data) => {
|
20
|
+
return request({
|
21
|
+
url: "/author",
|
22
|
+
method: http_method_1.HttpMethod.POST,
|
23
|
+
data: data,
|
24
|
+
});
|
25
|
+
};
|
26
|
+
const authorDelete = async (ids) => {
|
27
|
+
return request({
|
28
|
+
url: "/author",
|
29
|
+
data: { ids },
|
30
|
+
method: http_method_1.HttpMethod.DELETE,
|
31
|
+
});
|
32
|
+
};
|
33
|
+
const authorUpdate = async (id, data) => {
|
34
|
+
return request({
|
35
|
+
url: `/author/${id}`,
|
36
|
+
method: http_method_1.HttpMethod.PATCH,
|
37
|
+
data: data,
|
38
|
+
});
|
39
|
+
};
|
40
|
+
return {
|
41
|
+
authorCreate,
|
42
|
+
authorUpdate,
|
43
|
+
authorDelete,
|
44
|
+
authorList,
|
45
|
+
authorGet,
|
46
|
+
};
|
47
|
+
}
|
48
|
+
//# sourceMappingURL=requests.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"requests.js","sourceRoot":"","sources":["requests.ts"],"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{ Delete, PaginationParams, PaginationResult } from "@/types";
|
3
|
+
import { Author } from "@/types/models";
|
4
|
+
import { HttpMethod } from "@/types/http-method";
|
5
|
+
|
6
|
+
export function requests() {
|
7
|
+
const { request } = useApp();
|
8
|
+
|
9
|
+
const authorList = async (params: PaginationParams) => {
|
10
|
+
return request<PaginationResult<Author>>({
|
11
|
+
url: "/author",
|
12
|
+
params,
|
13
|
+
});
|
14
|
+
};
|
15
|
+
|
16
|
+
const authorGet = async (id: number) => {
|
17
|
+
return request<Author>({
|
18
|
+
url: `/author/${id}`,
|
19
|
+
});
|
20
|
+
};
|
21
|
+
|
22
|
+
const authorCreate = async (data: Author) => {
|
23
|
+
return request<Author>({
|
24
|
+
url: "/author",
|
25
|
+
method: HttpMethod.POST,
|
26
|
+
data: data,
|
27
|
+
});
|
28
|
+
};
|
29
|
+
|
30
|
+
const authorDelete = async (ids: number[]) => {
|
31
|
+
return request<Delete>({
|
32
|
+
url: "/author",
|
33
|
+
data: { ids },
|
34
|
+
method: HttpMethod.DELETE,
|
35
|
+
});
|
36
|
+
};
|
37
|
+
|
38
|
+
const authorUpdate = async (id: number, data: Author) => {
|
39
|
+
return request<Author>({
|
40
|
+
url: `/author/${id}`,
|
41
|
+
method: HttpMethod.PATCH,
|
42
|
+
data: data,
|
43
|
+
});
|
44
|
+
};
|
45
|
+
|
46
|
+
return {
|
47
|
+
authorCreate,
|
48
|
+
authorUpdate,
|
49
|
+
authorDelete,
|
50
|
+
authorList,
|
51
|
+
authorGet,
|
52
|
+
};
|
53
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Category } from "@/types/models";
|
2
|
+
export type CategoryCreatePanelRef = {
|
3
|
+
submit: () => void;
|
4
|
+
};
|
5
|
+
export type CategoryCreatePanelProps = {
|
6
|
+
onCreated?: (data: Category) => void;
|
7
|
+
};
|
8
|
+
export declare const CategoryCreatePanel: 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":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,KA8B/B,CAAC"}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
exports.CategoryCreatePanel = void 0;
|
27
|
+
const form_panel_1 = __importStar(require("@/components/custom/form-panel"));
|
28
|
+
const person_type_1 = require("@/features/person-type");
|
29
|
+
const react_1 = require("react");
|
30
|
+
const react_i18next_1 = require("react-i18next");
|
31
|
+
exports.CategoryCreatePanel = (0, react_1.forwardRef)(({ onCreated }, ref) => {
|
32
|
+
const formRef = (0, react_1.useRef)(null);
|
33
|
+
const { t } = (0, react_i18next_1.useTranslation)(["category", "actions"]);
|
34
|
+
const { mutateAsync: createCategory } = (0, person_type_1.useCategoryCreate)();
|
35
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
36
|
+
submit: () => {
|
37
|
+
var _a;
|
38
|
+
(_a = formRef.current) === null || _a === void 0 ? void 0 : _a.submit();
|
39
|
+
},
|
40
|
+
}), [formRef]);
|
41
|
+
return (<form_panel_1.default ref={formRef} fields={[...(0, form_panel_1.getFieldsLocale)([{ name: "name" }])]} button={{ text: t("create", { ns: "actions" }) }} onSubmit={async (data) => {
|
42
|
+
const createdData = await createCategory(data);
|
43
|
+
if (typeof onCreated === "function") {
|
44
|
+
onCreated(createdData);
|
45
|
+
}
|
46
|
+
}}/>);
|
47
|
+
});
|
48
|
+
//# sourceMappingURL=create-panel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-panel.js","sourceRoot":"","sources":["create-panel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAGwC;AAExC,wDAA2D;AAE3D,iCAAgE;AAChE,iDAA+C;AAUlC,QAAA,mBAAmB,GAAG,IAAA,kBAAU,EAC3C,CAAC,EAAE,SAAS,EAA4B,EAAE,GAAG,EAAE,EAAE;IAC/C,MAAM,OAAO,GAAG,IAAA,cAAM,EAAe,IAAI,CAAC,CAAC;IAC3C,MAAM,EAAE,CAAC,EAAE,GAAG,IAAA,8BAAc,EAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;IACtD,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,IAAA,+BAAiB,GAAE,CAAC;IAE5D,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,CAAC,GAAG,IAAA,4BAAe,EAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CACjD,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,cAAc,CAAC,IAAI,CAAC,CAAC;YAC/C,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,49 @@
|
|
1
|
+
import FormPanel, {
|
2
|
+
FormPanelRef,
|
3
|
+
getFieldsLocale,
|
4
|
+
} from "@/components/custom/form-panel";
|
5
|
+
import { EnumFieldType } from "@/enums/EnumFieldType";
|
6
|
+
import { useCategoryCreate } from "@/features/person-type";
|
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
|
+
export const CategoryCreatePanel = forwardRef(
|
20
|
+
({ onCreated }: CategoryCreatePanelProps, ref) => {
|
21
|
+
const formRef = useRef<FormPanelRef>(null);
|
22
|
+
const { t } = useTranslation(["category", "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
|
+
);
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-panel.d.ts","sourceRoot":"","sources":["update-panel.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,KAwC/B,CAAC"}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.CategoryUpdatePanel = void 0;
|
30
|
+
const form_panel_1 = __importStar(require("@/components/custom/form-panel"));
|
31
|
+
const overlay_1 = require("@/components/custom/overlay");
|
32
|
+
const tab_panel_1 = require("@/components/custom/tab-panel");
|
33
|
+
const category_1 = require("@/features/category");
|
34
|
+
const use_effect_after_first_update_1 = __importDefault(require("@/hooks/use-effect-after-first-update"));
|
35
|
+
const i18next_1 = require("i18next");
|
36
|
+
const react_1 = require("react");
|
37
|
+
exports.CategoryUpdatePanel = (0, react_1.forwardRef)(({ data, onUpdated }, ref) => {
|
38
|
+
const { data: item, isLoading } = (0, category_1.useCategoryGet)(data.id);
|
39
|
+
const { mutate: categoryUpdate } = (0, category_1.useCategoryUpdate)();
|
40
|
+
const formRef = (0, react_1.useRef)(null);
|
41
|
+
(0, use_effect_after_first_update_1.default)(() => {
|
42
|
+
if (item && formRef.current) {
|
43
|
+
formRef.current.setValuesFromItem(item);
|
44
|
+
}
|
45
|
+
}, [item]);
|
46
|
+
(0, react_1.useImperativeHandle)(ref, () => ({}));
|
47
|
+
return (<tab_panel_1.TabPanel activeTabIndex={0} tabs={[
|
48
|
+
{
|
49
|
+
title: (0, i18next_1.t)("details", { ns: "actions" }),
|
50
|
+
children: (<overlay_1.Overlay loading={isLoading}>
|
51
|
+
<form_panel_1.default ref={formRef} fields={[...(0, form_panel_1.getFieldsLocale)([{ name: "name" }])]} button={{ text: (0, i18next_1.t)("save", { ns: "actions" }) }} onSubmit={(data) => {
|
52
|
+
categoryUpdate({ id: data.id, data });
|
53
|
+
if (typeof onUpdated === "function") {
|
54
|
+
onUpdated(data);
|
55
|
+
}
|
56
|
+
}}/>
|
57
|
+
</overlay_1.Overlay>),
|
58
|
+
},
|
59
|
+
]}/>);
|
60
|
+
});
|
61
|
+
//# sourceMappingURL=update-panel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"update-panel.js","sourceRoot":"","sources":["update-panel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAGwC;AACxC,yDAAsD;AACtD,6DAAyD;AAEzD,kDAAwE;AACxE,0GAA8E;AAE9E,qCAA4B;AAC5B,iCAAgE;AAOnD,QAAA,mBAAmB,GAAG,IAAA,kBAAU,EAC3C,CAAC,EAAE,IAAI,EAAE,SAAS,EAA4B,EAAE,GAAG,EAAE,EAAE;IACrD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAA,yBAAc,EAAC,IAAI,CAAC,EAAY,CAAC,CAAC;IACpE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,IAAA,4BAAiB,GAAE,CAAC;IACvD,MAAM,OAAO,GAAG,IAAA,cAAM,EAAe,IAAI,CAAC,CAAC;IAE3C,IAAA,uCAAyB,EAAC,GAAG,EAAE;QAC7B,IAAI,IAAI,I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