import { IBaseResponse } from '@/@core/types/api'
import { useCustomQuery } from '@/hooks/api'
import { ISetting } from '@/types/data/settings'
import { request } from '@/utils'

export const GET_SETTINGS_BY_GROUP_QUERY_KEY = 'get-settings-by-group'

export const useGetSettingsByGroup = (group_name: string) => {
  const queryKey: any = [GET_SETTINGS_BY_GROUP_QUERY_KEY, group_name]
  const getData = useCustomQuery<IBaseResponse<ISetting[]>>(queryKey, async () =>
    request({
      url: `dashboard/settings?group=${group_name}`
    })
  )
  return getData
}
