Skip to content

Commit 7dde7da

Browse files
authored
Merge pull request #390 from CivicDataLab/dynamic-domain-fix
Domain was hardcoded in frontend,made it dynamic
2 parents 1f5dc1e + ad61ec9 commit 7dde7da

1 file changed

Lines changed: 26 additions & 14 deletions

File tree

  • app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/edit/[id]/details

app/[locale]/dashboard/[entityType]/[entitySlug]/aimodels/edit/[id]/details/page.tsx

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ const geographiesListQueryDoc: any = graphql(`
5353
}
5454
`);
5555

56+
const promptDomainEnumValuesQueryDoc: any = graphql(`
57+
query PromptDomainEnum {
58+
__type(name: "PromptDomain") {
59+
enumValues {
60+
name
61+
description
62+
}
63+
}
64+
}
65+
`);
66+
5667
const FetchAIModelDetails: any = graphql(`
5768
query AIModelDetails($filters: AIModelFilter) {
5869
aiModels(filters: $filters) {
@@ -191,6 +202,11 @@ export default function AIModelDetailsPage() {
191202
)
192203
);
193204

205+
const getPromptDomainEnumValues: { data: any; isLoading: boolean; error: any } =
206+
useQuery([`prompt_domain_enum_values_query`], () =>
207+
GraphQL(promptDomainEnumValuesQueryDoc, {}, [] as any)
208+
);
209+
194210
const AIModelData: {
195211
data: any;
196212
isLoading: boolean;
@@ -377,20 +393,16 @@ export default function AIModelDetailsPage() {
377393

378394
const domainOptions = [
379395
{ label: 'Click to select from dropdown', value: '' },
380-
{ label: 'Healthcare', value: 'HEALTHCARE' },
381-
{ label: 'Education', value: 'EDUCATION' },
382-
{ label: 'Legal', value: 'LEGAL' },
383-
{ label: 'Finance', value: 'FINANCE' },
384-
{ label: 'Agriculture', value: 'AGRICULTURE' },
385-
{ label: 'Environment', value: 'ENVIRONMENT' },
386-
{ label: 'Government', value: 'GOVERNMENT' },
387-
{ label: 'Technology', value: 'TECHNOLOGY' },
388-
{ label: 'Science', value: 'SCIENCE' },
389-
{ label: 'Social Services', value: 'SOCIAL_SERVICES' },
390-
{ label: 'Transportation', value: 'TRANSPORTATION' },
391-
{ label: 'Energy', value: 'ENERGY' },
392-
{ label: 'General', value: 'GENERAL' },
393-
{ label: 'Other', value: 'OTHER' },
396+
...(
397+
getPromptDomainEnumValues.data?.__type?.enumValues?.map((item: { name: string }) => ({
398+
label: item.name
399+
.toLowerCase()
400+
.split('_')
401+
.map((word: string) => word.charAt(0).toUpperCase() + word.slice(1))
402+
.join(' '),
403+
value: item.name,
404+
})) || []
405+
),
394406
];
395407

396408
const modelTypeOptions = [

0 commit comments

Comments
 (0)