@extends('EcomAuthViews::layouts.authentication.layout' , ['title' => 'Add '.($type == "email" ? "Email Address" : "Phone Number") ])

@section('content')
    @php
        $country_code = country()->code();
    @endphp

    <form class="twa-form"  method="POST" id="otp-form">
        @csrf
        <input type="hidden" name="user_id" value="{{$user->id}}">

        @if($type == "phone")
            @component('EcomAuthViews::components.phone' , ['phone_value' => isset($phone_value) ? $phone_value : '' ]) @endcomponent
        @elseif($type == "email")
            @component('EcomGeneralViews::components.form.input', [ "parentClass" => "", "size" => "full", "type" => "text", "label" => ___('authentication.email') ])
                <input name="email" required value="{{old('email')}}"
                       placeholder="{{ ___('authentication.email') }}"></input>
                <span class="invalid-field"> @error('email') {{$message}}  @enderror </span>
            @endcomponent
        @endif

        @component('EcomGeneralViews::components.form.input', [ "parentClass" => "", "size" => "full", "type" => "submit", "label" => "" ])
            <input type="submit" value="@if($type == "email"){{ ___('authentication.add_email') }}@else {{ ___('authentication.add_phone') }} @endif"/>
        @endcomponent
    </form>



@endsection
@section('scripts')

    <script>

        function togglePassword(elem){
            let input = elem.parent().find('input');
            let type = input.attr('type');
            input.attr('type' , input.attr('type') == "password" ? 'text' : 'password');

            elem.find('i').toggleClass('fa-eye-slash');

        }


        $(document).ready(function () {
            AUTHENTICATION_InitCodeGroup('code-input-group');
            AUTHENTICATION_start_timer();
        });

    </script>

@endsection
