1
1
import { createClient } from "@hey-api/client-fetch" ;
2
2
import { toast as notify } from "react-toastify" ;
3
- import { ActionFunctionArgs , LoaderFunctionArgs , json } from "@remix-run/node" ;
3
+ import { ActionFunctionArgs , LoaderFunctionArgs } from "@remix-run/node" ;
4
4
import {
5
5
Link ,
6
6
useActionData ,
@@ -104,7 +104,7 @@ export async function action({ request }: ActionFunctionArgs) {
104
104
client : evolverClient ,
105
105
} ,
106
106
) ;
107
- return json ( procedureState . data ) ;
107
+ return procedureState . data ;
108
108
} catch ( error ) {
109
109
return submission . reply ( { formErrors : [ "unable to dispatch action" ] } ) ;
110
110
}
@@ -121,7 +121,7 @@ export async function action({ request }: ActionFunctionArgs) {
121
121
client : evolverClient ,
122
122
} ,
123
123
) ;
124
- return json ( procedureState . data ) ;
124
+ return procedureState . data ;
125
125
} catch ( error ) {
126
126
return submission . reply ( {
127
127
formErrors : [ "unable to start calibration" ] ,
@@ -138,7 +138,7 @@ export async function action({ request }: ActionFunctionArgs) {
138
138
client : evolverClient ,
139
139
} ,
140
140
) ;
141
- return json ( procedureState . data ) ;
141
+ return procedureState . data ;
142
142
} catch ( error ) {
143
143
return submission . reply ( { formErrors : [ "unable to dispatch action" ] } ) ;
144
144
}
@@ -150,10 +150,7 @@ export async function action({ request }: ActionFunctionArgs) {
150
150
export async function loader ( { params } : LoaderFunctionArgs ) {
151
151
const { id, hardware_name } = params ;
152
152
const targetDevice = await db . device . findUnique ( { where : { device_id : id } } ) ;
153
- if ( ! targetDevice ) {
154
- return json ( { actions : [ ] } ) ;
155
- }
156
- const { url } = targetDevice ;
153
+ const { url } = targetDevice ?? { url : "" } ;
157
154
const evolverClient = createClient ( {
158
155
baseUrl : url ,
159
156
} ) ;
@@ -177,10 +174,10 @@ export async function loader({ params }: LoaderFunctionArgs) {
177
174
} ,
178
175
) ;
179
176
180
- return json ( {
177
+ return {
181
178
actions : procedureActions ?. actions ,
182
179
state : procedureState ,
183
- } ) ;
180
+ } ;
184
181
}
185
182
186
183
const CalibrationProcedure = ( { actions, state } ) => {
@@ -363,8 +360,6 @@ export function ErrorBoundary() {
363
360
364
361
export default function CalibrateHardware ( ) {
365
362
const { actions, state } = useLoaderData < typeof loader > ( ) ;
366
- const { id, hardware_name } : { id : string ; hardware_name : string } =
367
- useParams ( ) ;
368
363
369
364
const actionData = useActionData < typeof action > ( ) ;
370
365
0 commit comments