Skip to content

Commit bcd55b8

Browse files
fix(dashboard): Fix custom fields in GlobalSettings detail
1 parent 45d4b3c commit bcd55b8

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

packages/dashboard/src/app/routes/_authenticated/_global-settings/global-settings.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { Button } from '@/vdb/components/ui/button.js';
66
import { Input } from '@/vdb/components/ui/input.js';
77
import { Switch } from '@/vdb/components/ui/switch.js';
88
import { 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';
911
import {
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';
2122
import { Trans, useLingui } from '@/vdb/lib/trans.js';
2223
import { createFileRoute, useNavigate } from '@tanstack/react-router';
2324
import { toast } from 'sonner';
2425
import { globalSettingsDocument, updateGlobalSettingsDocument } from './global-settings.graphql.js';
2526

27+
const pageId = 'global-settings';
28+
2629
export 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

Comments
 (0)