import { formscreen } from "./formscreen.js";

export class rents_screen extends formscreen {
    #target;
    #email;
    #phone;

    get _email() {
        return this.#email();
    }   
        
    get _phone() {
        return this.#phone();
    }       

    constructor(target) {
        super();
        
        this.#target = target;
    }

    get _target() {
        return this.#target;
    }

    _build_form() {
        this.#email = this._create_input(
            "email",
            _("email-prompt"),
            _("email-sample"),
            (input) => { 
                input.type = "email"; 
            }
        );

        this.#phone = this._create_input(
            "phone",
            _("phone-number-prompt"),
            _("phone-number-sample"),
            (input) => {
                input.type = "tel";
               
                const add_prefix = () => {
                    if (input.value.length === 0) {
                        input.value = "+48 ";
                    }
                };

                input.addEventListener("click", add_prefix);
                input.addEventListener("focus", add_prefix);
            }
        );
    }
}
