|
@@ -1,23 +1,41 @@
|
|
|
import { useIntl } from "react-intl";
|
|
import { useIntl } from "react-intl";
|
|
|
import { ProForm, ProFormText } from "@ant-design/pro-components";
|
|
import { ProForm, ProFormText } from "@ant-design/pro-components";
|
|
|
import { message } from "antd";
|
|
import { message } from "antd";
|
|
|
|
|
+import { post } from "../../request";
|
|
|
|
|
+import { IGroupRequest, IGroupResponse } from "../api/Group";
|
|
|
|
|
|
|
|
interface IFormData {
|
|
interface IFormData {
|
|
|
name: string;
|
|
name: string;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-type IWidgetGroupCreate = {
|
|
|
|
|
- studio: string | undefined;
|
|
|
|
|
-};
|
|
|
|
|
-const Widget = (param: IWidgetGroupCreate) => {
|
|
|
|
|
|
|
+interface IWidgetGroupCreate {
|
|
|
|
|
+ studio?: string;
|
|
|
|
|
+ onCreate?: Function;
|
|
|
|
|
+}
|
|
|
|
|
+const Widget = ({ studio, onCreate }: IWidgetGroupCreate) => {
|
|
|
const intl = useIntl();
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<ProForm<IFormData>
|
|
<ProForm<IFormData>
|
|
|
onFinish={async (values: IFormData) => {
|
|
onFinish={async (values: IFormData) => {
|
|
|
// TODO
|
|
// TODO
|
|
|
|
|
+ if (typeof studio === "undefined") {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
console.log(values);
|
|
console.log(values);
|
|
|
- message.success(intl.formatMessage({ id: "flashes.success" }));
|
|
|
|
|
|
|
+ const res = await post<IGroupRequest, IGroupResponse>(`/v2/group`, {
|
|
|
|
|
+ name: values.name,
|
|
|
|
|
+ studio_name: studio,
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log(res);
|
|
|
|
|
+ if (res.ok) {
|
|
|
|
|
+ message.success(intl.formatMessage({ id: "flashes.success" }));
|
|
|
|
|
+ if (typeof onCreate !== "undefined") {
|
|
|
|
|
+ onCreate();
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.error(res.message);
|
|
|
|
|
+ }
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
<ProForm.Group>
|
|
<ProForm.Group>
|