visuddhinanda 3 лет назад
Родитель
Сommit
9ce7e615e1

+ 3 - 3
dashboard/src/Router.tsx

@@ -184,9 +184,9 @@ const Widget = () => {
 
         <Route path="group" element={<StudioGroup />}>
           <Route path="list" element={<StudioGroupList />} />
-          <Route path=":groupid" element={<StudioGroupShow />} />
-          <Route path=":groupid/edit" element={<StudioGroupEdit />} />
-          <Route path=":groupid/show" element={<StudioGroupShow />} />
+          <Route path=":groupId" element={<StudioGroupShow />} />
+          <Route path=":groupId/edit" element={<StudioGroupEdit />} />
+          <Route path=":groupId/show" element={<StudioGroupShow />} />
         </Route>
 
         <Route path="course" element={<StudioCourse />}>

+ 62 - 105
dashboard/src/pages/studio/group/edit.tsx

@@ -1,10 +1,10 @@
 import { useIntl } from "react-intl";
 import { useParams } from "react-router-dom";
 import {
-	ProForm,
-	ProFormText,
-	ProFormSelect,
-	ProFormTextArea,
+  ProForm,
+  ProFormText,
+  ProFormSelect,
+  ProFormTextArea,
 } from "@ant-design/pro-components";
 import { message, Card } from "antd";
 
@@ -14,111 +14,68 @@ import { get } from "../../../request";
 import GoBack from "../../../components/studio/GoBack";
 
 interface IFormData {
-	name: string;
-	type: string;
-	lang: string;
-	summary: string;
-	studio: string;
+  id: string;
+  name: string;
+  description: string;
+  studioId: string;
 }
 const Widget = () => {
-	const intl = useIntl();
-	const { studioname, groupid } = useParams(); //url 参数
-	const [title, setTitle] = useState("Loading");
-	useEffect(() => {
-		get<IGroupResponse>(`/v2/group/${groupid}`).then((json) => {
-			setTitle(json.data.name);
-		});
-	}, [groupid]);
+  const intl = useIntl();
+  const { studioname, groupId } = useParams(); //url 参数
+  const [title, setTitle] = useState("Loading");
 
-	return (
-		<Card
-			title={
-				<GoBack to={`/studio/${studioname}/group/list`} title={title} />
-			}
-		>
-			<ProForm<IFormData>
-				onFinish={async (values: IFormData) => {
-					// TODO
-					values.studio = "aaaa";
-					console.log(values);
-					message.success(
-						intl.formatMessage({ id: "flashes.success" })
-					);
-				}}
-			>
-				<ProForm.Group>
-					<ProFormText
-						width="md"
-						name="name"
-						required
-						label={intl.formatMessage({ id: "channel.name" })}
-						rules={[
-							{
-								required: true,
-								message: intl.formatMessage({
-									id: "channel.create.message.noname",
-								}),
-							},
-						]}
-					/>
-				</ProForm.Group>
+  return (
+    <Card
+      title={<GoBack to={`/studio/${studioname}/group/list`} title={title} />}
+    >
+      <ProForm<IFormData>
+        onFinish={async (values: IFormData) => {
+          // TODO
+          console.log(values);
+          message.success(intl.formatMessage({ id: "flashes.success" }));
+        }}
+        formKey="group_edit"
+        request={async () => {
+          const res = await get<IGroupResponse>(`/v2/group/${groupId}`);
+          setTitle(res.data.name);
+          console.log(res.data);
+          return {
+            id: res.data.uid,
+            name: res.data.name,
+            description: res.data.description,
+            studioId: res.data.studio.id,
+          };
+        }}
+      >
+        <ProForm.Group>
+          <ProFormText
+            width="md"
+            name="name"
+            required
+            label={intl.formatMessage({ id: "forms.fields.name.label" })}
+            rules={[
+              {
+                required: true,
+                message: intl.formatMessage({
+                  id: "channel.create.message.noname",
+                }),
+              },
+            ]}
+          />
+        </ProForm.Group>
 
-				<ProForm.Group>
-					<ProFormSelect
-						options={[
-							{
-								value: "translation",
-								label: intl.formatMessage({
-									id: "channel.type.translation.label",
-								}),
-							},
-							{
-								value: "nissaya",
-								label: intl.formatMessage({
-									id: "channel.type.nissaya.label",
-								}),
-							},
-						]}
-						width="md"
-						name="type"
-						rules={[
-							{
-								required: true,
-								message: intl.formatMessage({
-									id: "channel.create.message.noname",
-								}),
-							},
-						]}
-						label={intl.formatMessage({ id: "channel.type" })}
-					/>
-				</ProForm.Group>
-				<ProForm.Group>
-					<ProFormSelect
-						options={[
-							{ value: "zh-Hans", label: "简体中文" },
-							{ value: "zh-Hant", label: "繁体中文" },
-							{ value: "en-US", label: "English" },
-						]}
-						width="md"
-						name="lang"
-						rules={[
-							{
-								required: true,
-								message: intl.formatMessage({
-									id: "channel.create.message.noname",
-								}),
-							},
-						]}
-						label={intl.formatMessage({ id: "channel.lang" })}
-					/>
-				</ProForm.Group>
-
-				<ProForm.Group>
-					<ProFormTextArea name="summary" label="简介" />
-				</ProForm.Group>
-			</ProForm>
-		</Card>
-	);
+        <ProForm.Group>
+          <ProFormTextArea
+            width="md"
+            name="description"
+            label={intl.formatMessage({
+              id: "forms.fields.description.label",
+            })}
+          />
+        </ProForm.Group>
+      </ProForm>
+    </Card>
+  );
 };
 
 export default Widget;

+ 5 - 5
dashboard/src/pages/studio/group/show.tsx

@@ -12,13 +12,13 @@ import GoBack from "../../../components/studio/GoBack";
 
 const Widget = () => {
   const intl = useIntl();
-  const { studioname, groupid } = useParams(); //url 参数
+  const { studioname, groupId } = useParams(); //url 参数
   const [title, setTitle] = useState("loading");
   useEffect(() => {
-    get<IGroupResponse>(`/v2/group/${groupid}`).then((json) => {
+    get<IGroupResponse>(`/v2/group/${groupId}`).then((json) => {
       setTitle(json.data.name);
     });
-  }, [groupid]);
+  }, [groupId]);
   return (
     <Card
       title={<GoBack to={`/studio/${studioname}/group/list`} title={title} />}
@@ -30,10 +30,10 @@ const Widget = () => {
     >
       <Row>
         <Col flex="auto">
-          <GroupFile groupId={groupid} />
+          <GroupFile groupId={groupId} />
         </Col>
         <Col flex="400px">
-          <GroupMember groupId={groupid} />
+          <GroupMember groupId={groupId} />
         </Col>
       </Row>
     </Card>