Skip to content

Commit 542e462

Browse files
committed
debug metadata prefill
1 parent 6b13a5f commit 542e462

File tree

1 file changed

+31
-22
lines changed
  • app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components

1 file changed

+31
-22
lines changed

app/[locale]/dashboard/organization/[organizationId]/dataset/[id]/edit/components/EditMetadata.tsx

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ export function EditMetadata({ id }: { id: string }) {
114114

115115
const queryClient = useQueryClient();
116116

117+
const getDatasetMetadata: {
118+
data: any;
119+
isLoading: boolean;
120+
refetch: any;
121+
error: any;
122+
} = useQuery([`metadata_values_query_${id}`], () =>
123+
GraphQL(datasetMetadataQueryDoc, { filters: { id: id } }),
124+
{
125+
refetchOnMount: true,
126+
refetchOnReconnect: true,
127+
}
128+
);
129+
117130
const getCategoriesList: { data: any; isLoading: boolean; error: any } =
118131
useQuery([`categories_list_query`], () =>
119132
GraphQL(categoriesListQueryDoc, [])
@@ -137,15 +150,6 @@ export function EditMetadata({ id }: { id: string }) {
137150
})
138151
);
139152

140-
const getDatasetMetadata: {
141-
data: any;
142-
isLoading: boolean;
143-
refetch: any;
144-
error: any;
145-
} = useQuery([`metadata_values_query_${id}`], () =>
146-
GraphQL(datasetMetadataQueryDoc, { filters: { id: id } })
147-
);
148-
149153
const updateMetadataMutation = useMutation(
150154
(data: { UpdateMetadataInput: UpdateMetadataInput }) =>
151155
GraphQL(updateMetadataMutationDoc, data),
@@ -180,19 +184,22 @@ export function EditMetadata({ id }: { id: string }) {
180184
[key: string]: any;
181185
} = {};
182186

183-
dataset.metadata?.map((field) => {
184-
if (field.metadataItem.dataType === 'MULTISELECT') {
185-
// Convert comma-separated string to array of {label, value} objects
186-
defaultVal[field.metadataItem.id] = field.value
187-
.split(', ')
188-
.map((value: string) => ({
189-
label: value,
190-
value: value,
191-
}));
192-
} else {
193-
defaultVal[field.metadataItem.id] = field.value;
194-
}
195-
});
187+
console.log(dataset,'prefill log');
188+
189+
dataset?.metadata.length > 0 &&
190+
dataset?.metadata?.map((field) => {
191+
if (field.metadataItem.dataType === 'MULTISELECT') {
192+
// Convert comma-separated string to array of {label, value} objects
193+
defaultVal[field.metadataItem.id] = field.value
194+
.split(', ')
195+
.map((value: string) => ({
196+
label: value,
197+
value: value,
198+
}));
199+
} else {
200+
defaultVal[field.metadataItem.id] = field.value;
201+
}
202+
});
196203

197204
defaultVal['description'] = dataset.description || '';
198205

@@ -318,6 +325,8 @@ export function EditMetadata({ id }: { id: string }) {
318325
return null;
319326
}
320327

328+
console.log(getDatasetMetadata);
329+
321330
return (
322331
<>
323332
{!getTagsList?.isLoading &&

0 commit comments

Comments
 (0)