This commit is contained in:
jeremygan2021
2026-03-10 14:05:37 +08:00
parent 3d74ccc04f
commit 880192c358
9 changed files with 254 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Card, Button, Form, Input, Upload, message, Modal, Select } from 'antd';
import { Card, Button, Form, Input, Upload, App, Modal, Select } from 'antd';
import { UploadOutlined, CloudUploadOutlined, LinkOutlined } from '@ant-design/icons';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { createProject, updateProject, submitProject, uploadProjectFile } from '../../api';
@@ -8,6 +8,7 @@ const { TextArea } = Input;
const { Option } = Select;
const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }) => {
const { message } = App.useApp();
const [form] = Form.useForm();
const [fileList, setFileList] = useState([]);
const queryClient = useQueryClient();
@@ -82,15 +83,14 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
formData.append('file', file);
formData.append('project', initialValues?.id || ''); // Need project ID first usually
// Upload logic might need adjustment: create project first, then upload files?
// Or upload to temp storage then link?
// For simplicity, let's assume we create project first if not exists
if (!initialValues?.id) {
// Already handled above
return;
}
uploadMutation.mutate(formData);
uploadMutation.mutate(formData, {
onSuccess: (data) => {
onSuccess(data);
},
onError: (error) => {
onError(error);
}
});
};
return (