|
@@ -15,7 +15,7 @@ import { toast } from 'sonner';
|
|
|
import { DataTablePagination } from '@d8d/shared-ui-components/components/admin/DataTablePagination';
|
|
import { DataTablePagination } from '@d8d/shared-ui-components/components/admin/DataTablePagination';
|
|
|
import { platformClientManager } from '../api/platformClient';
|
|
import { platformClientManager } from '../api/platformClient';
|
|
|
import { CreatePlatformSchema, UpdatePlatformSchema } from '@d8d/allin-platform-module/schemas';
|
|
import { CreatePlatformSchema, UpdatePlatformSchema } from '@d8d/allin-platform-module/schemas';
|
|
|
-import type { CreatePlatformDto, UpdatePlatformDto } from '@d8d/allin-platform-module/schemas';
|
|
|
|
|
|
|
+import type { CreatePlatformRequest, UpdatePlatformRequest } from '../api/types';
|
|
|
|
|
|
|
|
interface PlatformSearchParams {
|
|
interface PlatformSearchParams {
|
|
|
page: number;
|
|
page: number;
|
|
@@ -33,7 +33,7 @@ const PlatformManagement: React.FC = () => {
|
|
|
const [platformToDelete, setPlatformToDelete] = useState<number | null>(null);
|
|
const [platformToDelete, setPlatformToDelete] = useState<number | null>(null);
|
|
|
|
|
|
|
|
// 表单实例
|
|
// 表单实例
|
|
|
- const createForm = useForm<CreatePlatformDto>({
|
|
|
|
|
|
|
+ const createForm = useForm<CreatePlatformRequest>({
|
|
|
resolver: zodResolver(CreatePlatformSchema),
|
|
resolver: zodResolver(CreatePlatformSchema),
|
|
|
defaultValues: {
|
|
defaultValues: {
|
|
|
platformName: '',
|
|
platformName: '',
|
|
@@ -43,7 +43,7 @@ const PlatformManagement: React.FC = () => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const updateForm = useForm<UpdatePlatformDto>({
|
|
|
|
|
|
|
+ const updateForm = useForm<UpdatePlatformRequest>({
|
|
|
resolver: zodResolver(UpdatePlatformSchema),
|
|
resolver: zodResolver(UpdatePlatformSchema),
|
|
|
defaultValues: {}
|
|
defaultValues: {}
|
|
|
});
|
|
});
|
|
@@ -69,7 +69,7 @@ const PlatformManagement: React.FC = () => {
|
|
|
|
|
|
|
|
// 创建平台
|
|
// 创建平台
|
|
|
const createMutation = useMutation({
|
|
const createMutation = useMutation({
|
|
|
- mutationFn: async (data: CreatePlatformDto) => {
|
|
|
|
|
|
|
+ mutationFn: async (data: CreatePlatformRequest) => {
|
|
|
const res = await platformClientManager.get().createPlatform.$post({ json: data });
|
|
const res = await platformClientManager.get().createPlatform.$post({ json: data });
|
|
|
if (res.status !== 200) throw new Error('创建平台失败');
|
|
if (res.status !== 200) throw new Error('创建平台失败');
|
|
|
return await res.json();
|
|
return await res.json();
|
|
@@ -87,7 +87,7 @@ const PlatformManagement: React.FC = () => {
|
|
|
|
|
|
|
|
// 更新平台
|
|
// 更新平台
|
|
|
const updateMutation = useMutation({
|
|
const updateMutation = useMutation({
|
|
|
- mutationFn: async (data: UpdatePlatformDto) => {
|
|
|
|
|
|
|
+ mutationFn: async (data: UpdatePlatformRequest) => {
|
|
|
const res = await platformClientManager.get().updatePlatform.$post({
|
|
const res = await platformClientManager.get().updatePlatform.$post({
|
|
|
json: data
|
|
json: data
|
|
|
});
|
|
});
|
|
@@ -187,7 +187,7 @@ const PlatformManagement: React.FC = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 处理创建表单提交
|
|
// 处理创建表单提交
|
|
|
- const handleCreateSubmit = async (data: CreatePlatformDto) => {
|
|
|
|
|
|
|
+ const handleCreateSubmit = async (data: CreatePlatformRequest) => {
|
|
|
try {
|
|
try {
|
|
|
await createMutation.mutateAsync(data);
|
|
await createMutation.mutateAsync(data);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -196,7 +196,7 @@ const PlatformManagement: React.FC = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 处理编辑表单提交
|
|
// 处理编辑表单提交
|
|
|
- const handleUpdateSubmit = async (data: UpdatePlatformDto) => {
|
|
|
|
|
|
|
+ const handleUpdateSubmit = async (data: UpdatePlatformRequest) => {
|
|
|
try {
|
|
try {
|
|
|
await updateMutation.mutateAsync(data);
|
|
await updateMutation.mutateAsync(data);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
@@ -398,7 +398,15 @@ const PlatformManagement: React.FC = () => {
|
|
|
<FormItem>
|
|
<FormItem>
|
|
|
<FormLabel>联系邮箱</FormLabel>
|
|
<FormLabel>联系邮箱</FormLabel>
|
|
|
<FormControl>
|
|
<FormControl>
|
|
|
- <Input placeholder="请输入联系邮箱" {...field} data-testid="contact-email-input" />
|
|
|
|
|
|
|
+ <Input
|
|
|
|
|
+ placeholder="请输入联系邮箱"
|
|
|
|
|
+ value={field.value || ''}
|
|
|
|
|
+ onChange={field.onChange}
|
|
|
|
|
+ onBlur={field.onBlur}
|
|
|
|
|
+ name={field.name}
|
|
|
|
|
+ ref={field.ref}
|
|
|
|
|
+ data-testid="contact-email-input"
|
|
|
|
|
+ />
|
|
|
</FormControl>
|
|
</FormControl>
|
|
|
<FormMessage />
|
|
<FormMessage />
|
|
|
</FormItem>
|
|
</FormItem>
|
|
@@ -469,7 +477,15 @@ const PlatformManagement: React.FC = () => {
|
|
|
<FormItem>
|
|
<FormItem>
|
|
|
<FormLabel>联系邮箱</FormLabel>
|
|
<FormLabel>联系邮箱</FormLabel>
|
|
|
<FormControl>
|
|
<FormControl>
|
|
|
- <Input placeholder="请输入联系邮箱" {...field} data-testid="contact-email-input" />
|
|
|
|
|
|
|
+ <Input
|
|
|
|
|
+ placeholder="请输入联系邮箱"
|
|
|
|
|
+ value={field.value || ''}
|
|
|
|
|
+ onChange={field.onChange}
|
|
|
|
|
+ onBlur={field.onBlur}
|
|
|
|
|
+ name={field.name}
|
|
|
|
|
+ ref={field.ref}
|
|
|
|
|
+ data-testid="contact-email-input"
|
|
|
|
|
+ />
|
|
|
</FormControl>
|
|
</FormControl>
|
|
|
<FormMessage />
|
|
<FormMessage />
|
|
|
</FormItem>
|
|
</FormItem>
|