@@ -11,10 +11,9 @@ import { useNavigate } from 'react-router-dom'
1111import type { SetRequired } from 'type-fest'
1212
1313import {
14- apiQueryClient ,
1514 useApiMutation ,
15+ useApiQuery ,
1616 useApiQueryClient ,
17- usePrefetchedApiQuery ,
1817 type FloatingIpCreate ,
1918 type SiloIpPool ,
2019} from '@oxide/api'
@@ -32,13 +31,6 @@ import {
3231import { useForm , useProjectSelector , useToast } from 'app/hooks'
3332import { pb } from 'app/util/path-builder'
3433
35- CreateFloatingIpSideModalForm . loader = async ( ) => {
36- await apiQueryClient . prefetchQuery ( 'projectIpPoolList' , {
37- query : { limit : 1000 } ,
38- } )
39- return null
40- }
41-
4234const toListboxItem = ( p : SiloIpPool ) => {
4335 if ( ! p . isDefault ) {
4436 return { value : p . name , label : p . name }
@@ -66,8 +58,9 @@ const defaultValues: SetRequired<FloatingIpCreate, 'address'> = {
6658}
6759
6860export function CreateFloatingIpSideModalForm ( ) {
69- // Fetch 1000 to we can be sure to get them all.
70- const { data : allPools } = usePrefetchedApiQuery ( 'projectIpPoolList' , {
61+ // Fetch 1000 to we can be sure to get them all. Don't bother prefetching
62+ // because the list is hidden under the Advanced accordion.
63+ const { data : allPools } = useApiQuery ( 'projectIpPoolList' , {
7164 query : { limit : 1000 } ,
7265 } )
7366
@@ -126,7 +119,7 @@ export function CreateFloatingIpSideModalForm() {
126119
127120 < ListboxField
128121 name = "pool"
129- items = { allPools . items . map ( ( p ) => toListboxItem ( p ) ) }
122+ items = { ( allPools ? .items || [ ] ) . map ( ( p ) => toListboxItem ( p ) ) }
130123 label = "IP pool"
131124 control = { form . control }
132125 placeholder = "Select pool"
0 commit comments