feat: 前后端+飞书全链路联调成功 - 创建项目自动发送飞书通知
This commit is contained in:
@@ -185,13 +185,29 @@ const WizardPage: React.FC = () => {
|
||||
const [project, setProject] = useState<ProjectData>(createEmptyProject());
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const next = () => setCurrent(Math.min(current + 1, STEPS.length - 1));
|
||||
const prev = () => setCurrent(Math.max(current - 1, 0));
|
||||
|
||||
const handleSubmit = () => {
|
||||
setSubmitted(true);
|
||||
Message.success(`项目「${project.name}」已创建!`);
|
||||
console.log('Project created:', project);
|
||||
const handleSubmit = async () => {
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const res = await fetch('/api/projects', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(project),
|
||||
});
|
||||
const data = await res.json();
|
||||
setSubmitted(true);
|
||||
Message.success(`项目「${project.name}」已创建!飞书通知已发送。`);
|
||||
console.log('Project created:', data);
|
||||
} catch (err) {
|
||||
Message.error('创建失败,请重试');
|
||||
console.error('Failed to create project:', err);
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
const renderStep = () => {
|
||||
@@ -328,6 +344,7 @@ const WizardPage: React.FC = () => {
|
||||
type="primary"
|
||||
onClick={handleSubmit}
|
||||
disabled={!project.name || !project.goal}
|
||||
loading={submitting}
|
||||
>
|
||||
创建项目
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user