@@ -74,7 +74,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
74
74
const [ searchParams ] = useSearchParams ( ) ;
75
75
const disabledParamsList = searchParams ?. get ( "disable_params" ) ?. split ( "," ) ;
76
76
77
- const { authErrors, errorCount } = getAuthErrors ( externalAuth ) ;
77
+ const authErrors = getAuthErrors ( externalAuth ) ;
78
78
const form : FormikContextType < TypesGen . CreateWorkspaceRequest > =
79
79
useFormik < TypesGen . CreateWorkspaceRequest > ( {
80
80
initialValues : {
@@ -91,6 +91,7 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
91
91
} ) ,
92
92
enableReinitialize : true ,
93
93
onSubmit : ( request ) => {
94
+ const errorCount = Object . keys ( authErrors ) . length ;
94
95
if ( errorCount > 0 ) {
95
96
form . setSubmitting ( false ) ;
96
97
return ;
@@ -242,22 +243,19 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({
242
243
) ;
243
244
} ;
244
245
245
- type ExternalAuthErrors = Record < string , string > ;
246
-
246
+ type VerifiableAuth = Readonly < { authenticated : boolean ; id : string } > ;
247
247
function getAuthErrors (
248
- externalAuth : readonly TypesGen . TemplateVersionExternalAuth [ ] ,
249
- ) {
250
- const authErrors : ExternalAuthErrors = { } ;
251
- let errorCount = 0 ;
248
+ authList : readonly VerifiableAuth [ ] ,
249
+ ) : Readonly < Record < string , string > > {
250
+ const authErrors : Record < string , string > = { } ;
252
251
253
- for ( const auth of externalAuth ) {
252
+ for ( const auth of authList ) {
254
253
if ( ! auth . authenticated ) {
255
254
authErrors [ auth . id ] = "You must authenticate to create a workspace!" ;
256
- errorCount ++ ;
257
255
}
258
256
}
259
257
260
- return { authErrors, errorCount } as const ;
258
+ return authErrors ;
261
259
}
262
260
263
261
const useStyles = makeStyles ( ( theme ) => ( {
0 commit comments