|
|
@@ -1,24 +1,44 @@
|
|
|
-import { ProForm, ProFormText, ProFormSelect } from "@ant-design/pro-components";
|
|
|
+import {
|
|
|
+ ProForm,
|
|
|
+ ProFormText,
|
|
|
+ ProFormSelect,
|
|
|
+} from "@ant-design/pro-components";
|
|
|
import { useIntl } from "react-intl";
|
|
|
import { message } from "antd";
|
|
|
+import LangSelect from "../LangSelect";
|
|
|
+import { IAnthologyCreateRequest, IAnthologyResponse } from "../../api/Article";
|
|
|
+import { post } from "../../../request";
|
|
|
|
|
|
interface IFormData {
|
|
|
title: string;
|
|
|
lang: string;
|
|
|
+ studio: string;
|
|
|
}
|
|
|
|
|
|
type IWidgetAnthologyCreate = {
|
|
|
- studio: string | undefined;
|
|
|
+ studio?: string;
|
|
|
};
|
|
|
-const Widget = (param: IWidgetAnthologyCreate) => {
|
|
|
+const Widget = (prop: IWidgetAnthologyCreate) => {
|
|
|
const intl = useIntl();
|
|
|
|
|
|
return (
|
|
|
<ProForm<IFormData>
|
|
|
onFinish={async (values: IFormData) => {
|
|
|
// TODO
|
|
|
+ values.studio = prop.studio ? prop.studio : "";
|
|
|
console.log(values);
|
|
|
- message.success(intl.formatMessage({ id: "flashes.success" }));
|
|
|
+ const res = await post<
|
|
|
+ IAnthologyCreateRequest,
|
|
|
+ IAnthologyResponse
|
|
|
+ >(`/v2/anthology`, values);
|
|
|
+ console.log(res);
|
|
|
+ if (res.ok) {
|
|
|
+ message.success(
|
|
|
+ intl.formatMessage({ id: "flashes.success" })
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ message.error(res.message);
|
|
|
+ }
|
|
|
}}
|
|
|
>
|
|
|
<ProForm.Group>
|
|
|
@@ -26,31 +46,22 @@ const Widget = (param: IWidgetAnthologyCreate) => {
|
|
|
width="md"
|
|
|
name="title"
|
|
|
required
|
|
|
- label={intl.formatMessage({ id: "channel.name" })}
|
|
|
+ label={intl.formatMessage({
|
|
|
+ id: "forms.fields.title.label",
|
|
|
+ })}
|
|
|
rules={[
|
|
|
{
|
|
|
required: true,
|
|
|
- message: intl.formatMessage({ id: "channel.create.message.noname" }),
|
|
|
+ message: intl.formatMessage({
|
|
|
+ id: "forms.message.title.required",
|
|
|
+ }),
|
|
|
+ max: 255,
|
|
|
},
|
|
|
]}
|
|
|
/>
|
|
|
</ProForm.Group>
|
|
|
<ProForm.Group>
|
|
|
- <ProFormSelect
|
|
|
- options={[
|
|
|
- {
|
|
|
- value: "zh-Hans",
|
|
|
- label: intl.formatMessage({ id: "languages.zh-Hans" }),
|
|
|
- },
|
|
|
- {
|
|
|
- value: "en-US",
|
|
|
- label: intl.formatMessage({ id: "English" }),
|
|
|
- },
|
|
|
- ]}
|
|
|
- width="md"
|
|
|
- name="lang"
|
|
|
- label={intl.formatMessage({ id: "forms.fields.lang.label" })}
|
|
|
- />
|
|
|
+ <LangSelect />
|
|
|
</ProForm.Group>
|
|
|
</ProForm>
|
|
|
);
|