Task: Make only Name and Phone mandatory in the checkout form

Make only Name and Phone mandatory in the checkout form

Also, in case of an error, it is necessary to scroll to the problem field

Ворклоги

Теперь при ошибке заполнения форма скроллится к проблемному полю.

  useEffect(() => {
    const errorName = Object.entries(errors).at(0)?.[0]

    if (errorName) {
      const field = document.querySelector(`[name="${errorName}"]`)

      if (field) {
        field.scrollIntoView({ behavior: 'smooth', block: 'center' })
      }
    }
  }, [errors])