diff --git a/apps/client/src/common/api/ontimeApi.ts b/apps/client/src/common/api/ontimeApi.ts index f7d8c06e6..c90cb3b15 100644 --- a/apps/client/src/common/api/ontimeApi.ts +++ b/apps/client/src/common/api/ontimeApi.ts @@ -247,13 +247,6 @@ export async function getLatestVersion(): Promise { }; } -/** - * @description HTTP POST request to create a new project file with given project data - */ -export async function postNew(initialData: Partial) { - return axios.post(`${ontimeURL}/new`, initialData); -} - /** * @description HTTP request to get the list of available project files */ @@ -382,11 +375,15 @@ export async function deleteProject(filename: string): Promise /** * @description HTTP request to create a project file */ -export async function createProject(filename: string): Promise { +export async function createProject( + project: Partial< + ProjectData & { + filename: string; + } + >, +): Promise { const url = `${ontimeURL}/project`; const decodedUrl = decodeURIComponent(url); - const res = await axios.post(decodedUrl, { - filename, - }); + const res = await axios.post(decodedUrl, project); return res.data; } diff --git a/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx b/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx new file mode 100644 index 000000000..6e3e6cd0a --- /dev/null +++ b/apps/client/src/features/app-settings/panel/project-panel/ProjectCreateForm.tsx @@ -0,0 +1,136 @@ +import { useEffect } from 'react'; +import { useForm } from 'react-hook-form'; +import { Button, Input, Textarea } from '@chakra-ui/react'; + +import style from './ProjectPanel.module.scss'; + +export type ProjectCreateFormValues = { + title?: string; + description?: string; + publicInfo?: string; + publicUrl?: string; + backstageInfo?: string; + backstageUrl?: string; +}; + +interface ProjectCreateFormProps { + onCancel: () => void; + onSubmit: (values: ProjectCreateFormValues) => Promise; + submitError: string | null; +} + +export default function ProjectCreateForm({ onSubmit, onCancel, submitError }: ProjectCreateFormProps) { + const { + handleSubmit, + register, + formState: { isSubmitting, isValid }, + setFocus, + } = useForm({ + defaultValues: { title: '' }, + values: { title: '' }, + resetOptions: { + keepDirtyValues: true, + }, + }); + + useEffect(() => { + setFocus('title'); + }, [setFocus]); + + return ( +
+
+ +
+
+ +
+
+