-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populate encounter edit options based on questionnaire tags (#9927)
Co-authored-by: Gigin George <[email protected]>
- Loading branch information
1 parent
0e6f7ba
commit dcd59bd
Showing
3 changed files
with
39 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
import query from "@/Utils/request/query"; | ||
import questionnaireApi from "@/types/questionnaire/questionnaireApi"; | ||
|
||
interface EditQuestionnaireOption { | ||
slug: string; | ||
title: string; | ||
} | ||
|
||
const DEFAULT_OPTIONS: EditQuestionnaireOption[] = [ | ||
{ | ||
slug: "encounter", | ||
title: "Update Encounter", | ||
}, | ||
]; | ||
|
||
export default function useQuestionnaireOptions(slug: string) { | ||
const { data } = useQuery({ | ||
queryKey: ["questionnaire", slug] as const, | ||
queryFn: query(questionnaireApi.list, { | ||
queryParams: { | ||
tag_slug: slug, | ||
}, | ||
}), | ||
}); | ||
|
||
const questionnaireOptions = | ||
data?.results?.map((q) => ({ | ||
slug: q.slug, | ||
title: q.title, | ||
})) ?? []; | ||
|
||
return [...DEFAULT_OPTIONS, ...questionnaireOptions]; | ||
} |