@@ -3,7 +3,7 @@ import { parse } from "@conform-to/zod";
3
3
import { RadioGroup } from "@radix-ui/react-radio-group" ;
4
4
import type { ActionFunction , LoaderFunctionArgs } from "@remix-run/node" ;
5
5
import { json , redirect } from "@remix-run/node" ;
6
- import { Form , useActionData } from "@remix-run/react" ;
6
+ import { Form , useActionData , useNavigation } from "@remix-run/react" ;
7
7
import { typedjson , useTypedLoaderData } from "remix-typedjson" ;
8
8
import { z } from "zod" ;
9
9
import { MainCenteredContainer } from "~/components/layout/AppLayout" ;
@@ -23,7 +23,7 @@ import { createOrganization } from "~/models/organization.server";
23
23
import { NewOrganizationPresenter } from "~/presenters/NewOrganizationPresenter.server" ;
24
24
import { commitCurrentProjectSession , setCurrentProjectId } from "~/services/currentProject.server" ;
25
25
import { requireUserId } from "~/services/session.server" ;
26
- import { plansPath , projectPath , rootPath , selectPlanPath } from "~/utils/pathBuilder" ;
26
+ import { projectPath , rootPath , selectPlanPath } from "~/utils/pathBuilder" ;
27
27
28
28
const schema = z . object ( {
29
29
orgName : z . string ( ) . min ( 3 ) . max ( 50 ) ,
@@ -86,6 +86,7 @@ export default function NewOrganizationPage() {
86
86
const { hasOrganizations } = useTypedLoaderData < typeof loader > ( ) ;
87
87
const lastSubmission = useActionData ( ) ;
88
88
const { isManagedCloud } = useFeatures ( ) ;
89
+ const navigation = useNavigation ( ) ;
89
90
90
91
const [ form , { orgName, projectName } ] = useForm ( {
91
92
id : "create-organization" ,
@@ -95,8 +96,11 @@ export default function NewOrganizationPage() {
95
96
return parse ( formData , { schema } ) ;
96
97
} ,
97
98
shouldRevalidate : "onSubmit" ,
99
+ shouldValidate : "onSubmit" ,
98
100
} ) ;
99
101
102
+ const isLoading = navigation . state === "submitting" || navigation . state === "loading" ;
103
+
100
104
return (
101
105
< MainCenteredContainer className = "max-w-[22rem]" >
102
106
< FormTitle LeadingIcon = "organization" title = "Create an Organization" />
@@ -161,7 +165,12 @@ export default function NewOrganizationPage() {
161
165
162
166
< FormButtons
163
167
confirmButton = {
164
- < Button type = "submit" variant = { "primary/small" } TrailingIcon = "arrow-right" >
168
+ < Button
169
+ type = "submit"
170
+ variant = { "primary/small" }
171
+ TrailingIcon = "arrow-right"
172
+ disabled = { isLoading }
173
+ >
165
174
Create
166
175
</ Button >
167
176
}
0 commit comments