Hi there, quick question if there is a better (faster) practice to the effect that I'm trying to achieve.
Basically the user navigates to a page where he can book appoinmentments. In the loader, I validate the query-strings "date" and "duration" against some data in my DB and an external api - this query can take up to 200ms when the api is cold.
If the query is validated, I go on and show my own data defferred - great UX here. But when the query is invalid (for example, you cant book on holidays / weekends ) - i throw a redirect to the next possible date - for example monday. Then that validation loader runs again, leading to a possible 500ms delay.
export const loader = async({request}) => {
const {isValid, data} = await validateQuery(request)
if(!isValid){
throw redirect(data.url)}
}
return defer(...myData)
}
Since I have to await those queries in the loader (deferred data can't throw redirects if I'm correct) - it sometimes leads to some bad UX. Is there any better practice? Validating in JSON and then using the client to update the query params?
Thanks!