I have an understanding issue of how to use next/navigation
router and passing data while using router.back()
.
I have a page where user can create a booking on route /booking/new
. In that form they need to select from a list of existing customers. If intended customer is not existing yet he can create a new customer by clicking on “new” which brings him to the route /customer/new
. Now after submitting the customer form I’m sending him back by router.back()
, because this page might be also opened from other places.
How is it possible now to pass the created customer ID to the last page (in this case /bookings/new
) to prefill the selection component with that customer?
Does it make sense to pass the lastRoute
to the /customer/new
and call router.push(lastRoute, data)
instead of router.back()
or is there a more elegant way to do it?
Writing the customer into booking object in database before submitting is not possible, because some required fields won’t be filled, yet.