import type Client from '#models/client'
import { BaseTransformer } from '@adonisjs/core/transformers'

export default class ClientTransformer extends BaseTransformer<Client> {
  toObject() {
    const c = this.resource
    return {
      id: c.id,
      organizationId: c.organizationId,
      name: c.name,
      email: c.email,
      contactFirstName: c.contactFirstName,
      contactLastName: c.contactLastName,
      phone: c.phone,
      address: c.address,
      siret: c.siret,
      notes: c.notes,
      createdAt: c.createdAt.toISO()!,
      updatedAt: c.updatedAt?.toISO() ?? c.createdAt.toISO()!,
    }
  }
}
