'use client'

import { request } from '@/utils'
import { IBaseResponse } from '@/@core/types/api'
import { IEntityProfile } from '@/types/data/profile/profile.interface'
import { useCustomMutation } from '@/hooks/api'

type DeliverySettingsPayload = Pick<
  IEntityProfile,
  'delivery_fee' | 'minimum_order' | 'preparation_time' | 'delivery_radius'
>

export const useUpdateLocationInfo = () => {
  return useCustomMutation<DeliverySettingsPayload, IBaseResponse<IEntityProfile>>(
    ['profile-update-location-info'],
    async payload => {
      const res = await request({
        url: '/entity/update-delivery-settings',
        method: 'POST',
        data: payload
      })
      return res.data
    }
  )
}
