import { type ComponentType, forwardRef } from 'react'

export function withCxForm(Component): ComponentType {
  return forwardRef((props, ref) => {
    return (
      <Component
        ref={ref}
        {...props}
        data-cx-redirect-with-query
        data-cx-hijack-form
        data-cx-title="Título personalizado"
        data-cx-ingest-form
        data-cx-slug="slug123"
      />
    )
  })
}

export function withCxFieldName(Component): ComponentType {
  return forwardRef((props, ref) => {
    return <Component ref={ref} {...props} data-cx-field="name" />
  })
}

export function withCxFieldEmail(Component): ComponentType {
  return forwardRef((props, ref) => {
    return <Component ref={ref} {...props} data-cx-field="email" />
  })
}

export function withCxFormTelephone(Component): ComponentType {
  return forwardRef((props, ref) => {
    return <Component ref={ref} {...props} data-cx-field="telephone" />
  })
}

export function withCxFormLgpdApproved(Component): ComponentType {
  return forwardRef((props, ref) => {
    return <Component ref={ref} {...props} data-cx-field="lgpdApproved" />
  })
}

export function withCxFormWebsite(Component): ComponentType {
  return forwardRef((props, ref) => {
    return <Component ref={ref} {...props} data-cx-field="website" />
  })
}
