import {
  FollowShopParams,
  UnfollowShopParams,
} from '@shopify/shop-minis-platform/actions'

import {useHandleAction} from '../../internal/useHandleAction'
import {useShopActions} from '../../internal/useShopActions'

interface UseFollowedShopsActionsReturns {
  /**
   * Follows a shop.
   */
  followShop: (params: FollowShopParams) => Promise<boolean>
  /**
   * Unfollows a shop.
   */
  unfollowShop: (params: UnfollowShopParams) => Promise<boolean>
}

export const useFollowedShopsActions = (): UseFollowedShopsActionsReturns => {
  const {followShop, unfollowShop} = useShopActions()

  return {
    followShop: useHandleAction(followShop),
    unfollowShop: useHandleAction(unfollowShop),
  }
}
