@@ -6,6 +6,8 @@ import { Button } from '@/vdb/components/ui/button.js';
66import { Input } from '@/vdb/components/ui/input.js' ;
77import { Switch } from '@/vdb/components/ui/switch.js' ;
88import { NEW_ENTITY_PATH } from '@/vdb/constants.js' ;
9+ import { extendDetailFormQuery } from '@/vdb/framework/document-extension/extend-detail-form-query.js' ;
10+ import { addCustomFields } from '@/vdb/framework/document-introspection/add-custom-fields.js' ;
911import {
1012 CustomFieldsPageBlock ,
1113 DetailFormGrid ,
@@ -16,20 +18,25 @@ import {
1618 PageLayout ,
1719 PageTitle ,
1820} from '@/vdb/framework/layout-engine/page-layout.js' ;
19- import { useDetailPage } from '@/vdb/framework/page/use-detail-page.js' ;
20- import { api } from '@/vdb/graphql/api.js' ;
21+ import { getDetailQueryOptions , useDetailPage } from '@/vdb/framework/page/use-detail-page.js' ;
2122import { Trans , useLingui } from '@/vdb/lib/trans.js' ;
2223import { createFileRoute , useNavigate } from '@tanstack/react-router' ;
2324import { toast } from 'sonner' ;
2425import { globalSettingsDocument , updateGlobalSettingsDocument } from './global-settings.graphql.js' ;
2526
27+ const pageId = 'global-settings' ;
28+
2629export const Route = createFileRoute ( '/_authenticated/_global-settings/global-settings' ) ( {
2730 component : GlobalSettingsPage ,
2831 loader : async ( { context } ) => {
29- await context . queryClient . ensureQueryData ( {
30- queryFn : ( ) => api . query ( globalSettingsDocument ) ,
31- queryKey : [ 'DetailPage' , 'globalSettings' ] ,
32- } ) ;
32+ const { extendedQuery : extendedQueryDocument } = extendDetailFormQuery (
33+ addCustomFields ( globalSettingsDocument ) ,
34+ pageId ,
35+ ) ;
36+ await context . queryClient . ensureQueryData (
37+ getDetailQueryOptions ( extendedQueryDocument , { id : '' } ) ,
38+ { } ,
39+ ) ;
3340 return {
3441 breadcrumb : [ { path : '/global-settings' , label : < Trans > Global settings</ Trans > } ] ,
3542 } ;
@@ -45,8 +52,9 @@ function GlobalSettingsPage() {
4552
4653 const { form, submitHandler, entity, isPending } = useDetailPage ( {
4754 queryDocument : globalSettingsDocument ,
48- entityField : 'globalSettings ' ,
55+ entityName : 'GlobalSettings ' ,
4956 updateDocument : updateGlobalSettingsDocument ,
57+ pageId,
5058 setValuesForUpdate : entity => {
5159 return {
5260 id : entity . id ,
@@ -78,7 +86,7 @@ function GlobalSettingsPage() {
7886 } ) ;
7987
8088 return (
81- < Page pageId = "global-settings" form = { form } submitHandler = { submitHandler } entity = { entity } >
89+ < Page pageId = { pageId } form = { form } submitHandler = { submitHandler } entity = { entity } >
8290 < PageTitle >
8391 < Trans > Global settings</ Trans >
8492 </ PageTitle >
0 commit comments