@@ -40,8 +40,6 @@ export const Workspace: React.FC<Props> = (props) => {
40
40
41
41
const handleCreateWorkspace = async ( formData : IWorkspace ) => {
42
42
if ( isSubmitting ) return ;
43
- const slug = formData . slug . split ( "/" ) ;
44
- formData . slug = slug [ slug . length - 1 ] ;
45
43
46
44
await workspaceService
47
45
. workspaceSlugCheck ( formData . slug )
@@ -118,11 +116,7 @@ export const Workspace: React.FC<Props> = (props) => {
118
116
onChange = { ( event ) => {
119
117
onChange ( event . target . value ) ;
120
118
setValue ( "name" , event . target . value ) ;
121
- if ( window && window . location . host ) {
122
- const host = window . location . host ;
123
- const slug = event . currentTarget . value . split ( "/" ) ;
124
- setValue ( "slug" , `${ host } /${ slug [ slug . length - 1 ] . toLocaleLowerCase ( ) . trim ( ) . replace ( / / g, "-" ) } ` ) ;
125
- }
119
+ setValue ( "slug" , event . target . value . toLocaleLowerCase ( ) . trim ( ) . replace ( / / g, "-" ) ) ;
126
120
} }
127
121
placeholder = "Enter workspace name..."
128
122
ref = { ref }
@@ -137,26 +131,25 @@ export const Workspace: React.FC<Props> = (props) => {
137
131
< Controller
138
132
control = { control }
139
133
name = "slug"
140
- render = { ( { field : { value, ref } } ) => (
141
- < div className = "flex items-center relative rounded-md bg-onboarding-background-200" >
134
+ render = { ( { field : { value, ref, onChange } } ) => (
135
+ < div
136
+ className = { `flex items-center px-3 relative rounded-md bg-onboarding-background-200 border ${
137
+ invalidSlug ? "border-red-500" : "border-onboarding-border-100"
138
+ } `}
139
+ >
140
+ < span className = "whitespace-nowrap text-sm" > { window && window . location . host } /</ span >
142
141
< Input
143
142
id = "slug"
144
143
name = "slug"
145
144
type = "text"
146
145
value = { value . toLocaleLowerCase ( ) . trim ( ) . replace ( / / g, "-" ) }
147
146
onChange = { ( e ) => {
148
- const host = window . location . host ;
149
- const slug = e . currentTarget . value . split ( "/" ) ;
150
- if ( slug . length > 1 ) {
151
- / ^ [ a - z A - Z 0 - 9 _ - ] + $ / . test ( slug [ slug . length - 1 ] ) ? setInvalidSlug ( false ) : setInvalidSlug ( true ) ;
152
- setValue ( "slug" , `${ host } /${ slug [ slug . length - 1 ] . toLocaleLowerCase ( ) . trim ( ) . replace ( / / g, "-" ) } ` ) ;
153
- } else {
154
- setValue ( "slug" , `${ host } /` ) ;
155
- }
147
+ / ^ [ a - z A - Z 0 - 9 _ - ] + $ / . test ( e . target . value ) ? setInvalidSlug ( false ) : setInvalidSlug ( true ) ;
148
+ onChange ( e . target . value . toLowerCase ( ) ) ;
156
149
} }
157
150
ref = { ref }
158
151
hasError = { Boolean ( errors . slug ) }
159
- className = "w-full h-[46px] border-onboarding- border-100 "
152
+ className = "w-full h-[46px] !px-0 border-none "
160
153
/>
161
154
</ div >
162
155
) }
0 commit comments