text: import {
    Form,
    FormError,
    FieldError,
    Label,
    TextField,
    Submit,
  } from '@redwoodjs/forms'
  
  const AdForm = (props) => {
    const onSubmit = (data) => {
      props.onSave(data, props?.ad?.id)
    }
  
    return (
      <div className="rw-form-wrapper">
        <Form onSubmit={onSubmit} error={props.error}>
          <FormError
            error={props.error}
            wrapperClassName="rw-form-error-wrapper"
            titleClassName="rw-form-error-title"
            listClassName="rw-form-error-list"
          />
  
          <Label
            name="text"
            className="rw-label"
            errorClassName="rw-label rw-label-error"
          >
            Text
          </Label>
          <TextField
            name="text"
            defaultValue={props.ad?.text}
            className="rw-input"
            errorClassName="rw-input rw-input-error"
            validation={{ required: true }}
          />
          <FieldError name="text" className="rw-field-error" />
  
          {!props.isEdit && (
            <>
              <Label
                name="owner"
                className="rw-label"
                errorClassName="rw-label rw-label-error"
              >
                Owner
              </Label>
              <TextField
                name="owner"
                defaultValue={props.ad?.owner}
                className="rw-input"
                errorClassName="rw-input rw-input-error"
                validation={{ required: true }}
              />
              <FieldError name="owner" className="rw-field-error" />
            </>
          )}
  
          {props.isEdit && (
            <>
              <Label
                name="amount"
                className="rw-label"
                errorClassName="rw-label rw-label-error"
              >
                Amount
              </Label>
              <TextField
                name="amount"
                defaultValue={props.ad?.amount}
                className="rw-input"
                errorClassName="rw-input rw-input-error"
                validation={{ required: true }}
              />
              <FieldError name="amount" className="rw-field-error" />
            </>
          )}
          <div className="rw-button-group">
            <Submit disabled={props.loading} className="rw-button rw-button-blue">
              Save
            </Submit>
          </div>
        </Form>
      </div>
    )
  }
  
  export default AdForm
  