Skip to content

Commit 5016b9a

Browse files
committed
Stub create workspace API
1 parent 797c82b commit 5016b9a

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

site/api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ export namespace Project {
2525

2626
return Promise.resolve([project1, project2])
2727
}
28+
29+
export const createProject = (name: string): Promise<string> => {
30+
return Promise.resolve("test-workspace")
31+
}
2832
}

site/pages/workspaces/create/[projectId].tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
import React from "react"
22
import { useRouter } from "next/router"
3+
import { useFormik } from "formik"
4+
5+
import * as API from "../../../api"
36

47
import { FormPage, FormButton } from "../../../components/PageTemplates"
58

69
const CreateProjectPage: React.FC = () => {
710
const router = useRouter()
811
const { projectId } = router.query
912

13+
14+
const form = useFormik({
15+
initialValues: {
16+
name: ""
17+
},
18+
onSubmit: async ({ name }) => {
19+
return API.Project.createProject(name)
20+
},
21+
})
22+
1023
const cancel = () => {
1124
router.back()
1225
}
1326

14-
const submit = () => {
15-
alert("Submitting workspace")
27+
const submit = async () => {
28+
const workspaceId = await form.submitForm()
29+
router.push(`/workspaces/${workspaceId}`)
1630
}
1731

1832
const buttons: FormButton[] = [

0 commit comments

Comments
 (0)