export const useConnections = () => {
  const getSuggestions = (params = {}) =>
    $fetch('/api/connections/suggestions', { params })

  const getMyConnections = () =>
    $fetch('/api/connections')

  const requestConnection = (recipientId) =>
    $fetch('/api/connections', { method: 'POST', body: { recipientId } })

  const confirmConnection = (id) =>
    $fetch(`/api/connections/${id}/confirm`, { method: 'POST' })

  const hideConnection = (id) =>
    $fetch(`/api/connections/${id}/hide`, { method: 'POST' })

  const withdrawConnection = (id) =>
    $fetch(`/api/connections/${id}/withdraw`, { method: 'POST' })

  const getPendingCount = () =>
    $fetch('/api/connections/pending-count')

  return {
    getSuggestions,
    getMyConnections,
    requestConnection,
    confirmConnection,
    hideConnection,
    withdrawConnection,
    getPendingCount,
  }
}
