Skip to content

Commit

Permalink
feat: starts trying to use queryOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
aviemet committed Oct 3, 2024
1 parent 4839d7f commit 0d2e225
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/frontend/queries/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { useQuery } from '@tanstack/react-query'
import { useQuery, queryOptions } from '@tanstack/react-query'
import { Routes } from '@/lib'
import axios from 'axios'
import { ComboboxData } from '@mantine/core'
import { type ReactQueryFunction } from '..'
import queryKeys from '../queryKeys'

export const useGetCommand: ReactQueryFunction<Schema.CommandsShow, {slug:string}> = ({ slug }, options) => {
return useQuery({
queryKey: [`command/${slug}`],
queryFn: async () => {
const res = await axios.get(Routes.apiCommand(slug))
return res.data
},
...queryOptions({
queryKey: queryKeys.commands.detail(slug),
queryFn: async () => {
const res = await axios.get(Routes.apiCommand(slug))
return res.data
},
}),
...options,
})
}
Expand Down

0 comments on commit 0d2e225

Please sign in to comment.