From aa1204babe417b6645bd939de3d58dfe89a51581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 23:27:40 -0400 Subject: [PATCH] refactor(organization): extract shared GoalForm and ProjectForm shells Introduce goal-form/ and project-form/ directories each holding a single shared shell that handles both create and edit modes via a discriminated mode prop. The existing GoalCreator/GoalEditor and ProjectCreator/ProjectEditor become thin wrappers that forward props to the shared shell, eliminating duplicated state, JSX, and save/ delete handlers across the four files. --- .../components/organization/GoalCreator.tsx | 64 +----- .../components/organization/GoalEditor.tsx | 103 +--------- .../organization/ProjectCreator.tsx | 66 +------ .../components/organization/ProjectEditor.tsx | 103 +--------- .../organization/goal-form/GoalForm.tsx | 185 ++++++++++++++++++ .../organization/goal-form/index.ts | 2 + .../organization/project-form/ProjectForm.tsx | 162 +++++++++++++++ .../organization/project-form/index.ts | 2 + 8 files changed, 375 insertions(+), 312 deletions(-) create mode 100644 src/renderer/components/organization/goal-form/GoalForm.tsx create mode 100644 src/renderer/components/organization/goal-form/index.ts create mode 100644 src/renderer/components/organization/project-form/ProjectForm.tsx create mode 100644 src/renderer/components/organization/project-form/index.ts diff --git a/src/renderer/components/organization/GoalCreator.tsx b/src/renderer/components/organization/GoalCreator.tsx index 693e4194..fc78153e 100644 --- a/src/renderer/components/organization/GoalCreator.tsx +++ b/src/renderer/components/organization/GoalCreator.tsx @@ -1,8 +1,5 @@ -import { useState } from "react"; -import { Target } from "@phosphor-icons/react"; import type { AgentRecord, GoalRecord } from "@shared/types"; -import { ActionButton, Input, Select, TextArea } from "../ui"; -import { useT } from "../../i18n"; +import { GoalForm } from "./goal-form"; export function GoalCreator({ companyId, @@ -15,62 +12,5 @@ export function GoalCreator({ goals: GoalRecord[]; onSaved: () => Promise; }) { - const t = useT(); - const [title, setTitle] = useState(""); - const [description, setDescription] = useState(""); - const [ownerAgentId, setOwnerAgentId] = useState(agents[0]?.id ?? ""); - const [parentId, setParentId] = useState(""); - return ( -
- -