import { MockupUnitProvider } from '../provider/MockupUnitProvider'
import type { PropertyUnit } from '../domain/property'
import { throwServiceError } from './errors'
import type { ItemResponse } from './types'

export const unitService = {
  async update(unitId: string, data: Partial<PropertyUnit>): Promise<ItemResponse<PropertyUnit>> {
    try {
      const unit = await MockupUnitProvider.update(unitId, data)
      return { data: unit }
    } catch (err) {
      throwServiceError('unitService.update', err)
    }
  },
}
