<%
  const { utils, data } = it;
  const { getTextCase } = utils;
  const { apiLabel, apiClassName, apiClassInstanceName } = data;
  const apiNameCase = getTextCase(apiLabel);
%>

import { useQuery } from '@tanstack/react-query';

import { QueryHookParams } from '@apis/type';

import <%~ apiClassInstanceName %> from './<%~ apiClassName %>';
import { <%~ apiNameCase.pascal %>ParamGetType } from './<%~ apiClassName %>.type';

export const <%~ apiNameCase.snakeUpperCase %>_API_QUERY_KEY = {
  GET: (param?: <%~ apiNameCase.pascal %>ParamGetType) => ['<%~ apiLabel %>-list', param],
  GET_BY_ID: (id?: string) => ['<%~ apiLabel %>-by-id', id],
};

export function useGet<%~ apiNameCase.pascal %>ListQuery(params?: QueryHookParams<typeof <%~ apiClassInstanceName %>.get<%~ apiNameCase.pascal %>List>) {
  const queryKey = <%~ apiNameCase.snakeUpperCase %>_API_QUERY_KEY.GET(params?.variables);
  const query = useQuery(queryKey, () => <%~ apiClassInstanceName %>.get<%~ apiNameCase.pascal %>List(params?.variables), params?.options);
  return { ...query, queryKey };
}

export function useGet<%~ apiNameCase.pascal %>ByIdQuery(params: QueryHookParams<typeof <%~ apiClassInstanceName %>.get<%~ apiNameCase.pascal %>ById>) {
  const queryKey = <%~ apiNameCase.snakeUpperCase %>_API_QUERY_KEY.GET_BY_ID(params?.variables);
  const query = useQuery(queryKey, () => <%~ apiClassInstanceName %>.get<%~ apiNameCase.pascal %>ById(params?.variables), params?.options);

  return { ...query, queryKey };
}
