MCPcopy
hub / github.com/makeplane/plane / ModuleForm

Function ModuleForm

apps/web/core/components/modules/form.tsx:43–251  ·  view source on GitHub ↗
(props: Props)

Source from the content-addressed store, hash-verified

41};
42
43export function ModuleForm(props: Props) {
44 const { handleFormSubmit, handleClose, status, projectId, setActiveProject, data, isMobile = false } = props;
45 // store hooks
46 const { projectsWithCreatePermissions } = useUser();
47 // form info
48 const {
49 formState: { errors, isSubmitting, dirtyFields },
50 handleSubmit,
51 control,
52 reset,
53 } = useForm<IModule>({
54 defaultValues: {
55 project_id: projectId,
56 name: data?.name || "",
57 description: data?.description || "",
58 status: data?.status || "backlog",
59 lead_id: data?.lead_id || null,
60 member_ids: data?.member_ids || [],
61 },
62 });
63
64 const { getIndex } = getTabIndex(ETabIndices.PROJECT_MODULE, isMobile);
65
66 const { t } = useTranslation();
67
68 const handleCreateUpdateModule = async (formData: Partial<IModule>) => {
69 await handleFormSubmit(formData, dirtyFields);
70
71 reset({
72 ...defaultValues,
73 });
74 };
75
76 useEffect(() => {
77 reset({
78 ...defaultValues,
79 ...data,
80 });
81 }, [data, reset]);
82
83 return (
84 <form onSubmit={handleSubmit(handleCreateUpdateModule)}>
85 <div className="space-y-5 p-5">
86 <div className="flex items-center gap-x-3">
87 {!status && (
88 <Controller
89 control={control}
90 name="project_id"
91 render={({ field: { value, onChange } }) => (
92 <div className="h-7">
93 <ProjectDropdown
94 value={value}
95 onChange={(val) => {
96 if (!Array.isArray(val)) {
97 onChange(val);
98 setActiveProject(val);
99 }
100 }}

Callers

nothing calls this directly

Calls 8

useUserFunction · 0.90
getTabIndexFunction · 0.90
useTranslationFunction · 0.90
getDateFunction · 0.90
getIndexFunction · 0.85
handleSubmitFunction · 0.50
onChangeFunction · 0.50

Tested by

no test coverage detected