@@ -142,33 +142,39 @@ export const workspaceToInitialValues = (
142
142
}
143
143
144
144
export const WorkspaceSchedulePage : React . FC = ( ) => {
145
+ const { username : usernameQueryParam , workspace : workspaceQueryParam } = useParams ( )
145
146
const navigate = useNavigate ( )
146
- const { workspace : workspaceQueryParam } = useParams ( )
147
- const workspaceId = firstOrItem ( workspaceQueryParam , null )
147
+ const username = firstOrItem ( usernameQueryParam , null )
148
+ const workspaceName = firstOrItem ( workspaceQueryParam , null )
148
149
const [ scheduleState , scheduleSend ] = useMachine ( workspaceSchedule )
149
150
const { formErrors, getWorkspaceError, workspace } = scheduleState . context
150
151
151
152
// Get workspace on mount and whenever workspaceId changes.
152
153
// scheduleSend should not change.
153
154
useEffect ( ( ) => {
154
- workspaceId && scheduleSend ( { type : "GET_WORKSPACE" , workspaceId } )
155
- } , [ workspaceId , scheduleSend ] )
155
+ username && workspaceName && scheduleSend ( { type : "GET_WORKSPACE" , username , workspaceName } )
156
+ } , [ username , workspaceName , scheduleSend ] )
156
157
157
- if ( ! workspaceId ) {
158
+ if ( ! username || ! workspaceName ) {
158
159
navigate ( "/workspaces" )
159
160
return null
160
161
} else if ( scheduleState . matches ( "idle" ) || scheduleState . matches ( "gettingWorkspace" ) || ! workspace ) {
161
162
return < FullScreenLoader />
162
163
} else if ( scheduleState . matches ( "error" ) ) {
163
- return < ErrorSummary error = { getWorkspaceError } retry = { ( ) => scheduleSend ( { type : "GET_WORKSPACE" , workspaceId } ) } />
164
+ return (
165
+ < ErrorSummary
166
+ error = { getWorkspaceError }
167
+ retry = { ( ) => scheduleSend ( { type : "GET_WORKSPACE" , username, workspaceName } ) }
168
+ />
169
+ )
164
170
} else if ( scheduleState . matches ( "presentForm" ) || scheduleState . matches ( "submittingSchedule" ) ) {
165
171
return (
166
172
< WorkspaceScheduleForm
167
173
fieldErrors = { formErrors }
168
174
initialValues = { workspaceToInitialValues ( workspace , dayjs . tz . guess ( ) ) }
169
175
isLoading = { scheduleState . tags . has ( "loading" ) }
170
176
onCancel = { ( ) => {
171
- navigate ( `/workspaces /${ workspaceId } ` )
177
+ navigate ( `/@ ${ username } /${ workspaceName } ` )
172
178
} }
173
179
onSubmit = { ( values ) => {
174
180
scheduleSend ( {
@@ -180,7 +186,7 @@ export const WorkspaceSchedulePage: React.FC = () => {
180
186
/>
181
187
)
182
188
} else if ( scheduleState . matches ( "submitSuccess" ) ) {
183
- navigate ( `/workspaces /${ workspaceId } ` )
189
+ navigate ( `/@ ${ username } /${ workspaceName } ` )
184
190
return < FullScreenLoader />
185
191
} else {
186
192
// Theoretically impossible - log and bail
0 commit comments