import UrlUtils from '~/services/utils/urlUtils'

export const useAdminUrl = () => {
  const runtimeConfig = useRuntimeConfig()

  const makeAdminUrl = (
    tail: string,
    query: Record<string, string> = {},
  ): string => {
    const baseUrl =
      runtimeConfig.baseUrlAdminLegacy ??
      runtimeConfig.public.baseUrlAdminLegacy
    let url = UrlUtils.join(baseUrl, '#', tail)
    url = UrlUtils.addQuery(url, query)
    return url
  }

  return { makeAdminUrl }
}
