Initial commit
This commit is contained in:
47
resources/views/login/merchant/index.blade copy.php
Normal file
47
resources/views/login/merchant/index.blade copy.php
Normal file
@@ -0,0 +1,47 @@
|
||||
@extends('layouts.login')
|
||||
|
||||
@section('page_title')
|
||||
Airtime Sales | Merchant Login
|
||||
@endsection
|
||||
|
||||
@section('page_content')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="text-center m-b-md">
|
||||
<h3>Merchant Login</h3>
|
||||
<!-- <small>This is the best app ever!</small> -->
|
||||
<div class="text-center w-75 m-auto">
|
||||
<!-- <p class="text-muted mb-4">Admin Panel Login</p> -->
|
||||
@if (Session::has('login-error'))
|
||||
<p class=" text-danger mb-4"> {{ Session::get('login-error') }} </p>
|
||||
@endif
|
||||
@include('commons.notifications')
|
||||
</div>
|
||||
</div>
|
||||
<div class="hpanel">
|
||||
<div class="panel-body">
|
||||
<form action="{{ url('merchant/login') }}" id="loginForm" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="username">Phone Number</label>
|
||||
<input type="text" placeholder="" title="Please enter you username" required="" value="" name="phone_number" id="username" class="form-control">
|
||||
<span class="help-block small">Your registered phone number</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="password">Merchant PIN</label>
|
||||
<input type="password" title="Please enter your PIN" placeholder="******" required="" value="" name="pin" id="password" class="form-control">
|
||||
<span class="help-block small">Your merchant pin</span>
|
||||
</div>
|
||||
<div class="checkbox"></div>
|
||||
<button class="btn btn-warning btn-block">Login</button>
|
||||
<p class="text-center" style="padding: 10px;">-- OR --</p>
|
||||
<!-- <a class="btn btn-warning btn-block" href=""><i class="fa fa-user-plus"></i> Register</a> -->
|
||||
|
||||
<a class="btn btn-danger btn-block" href="{{ url('merchant/register') }}">Register</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
188
resources/views/login/merchant/index.blade.php
Normal file
188
resources/views/login/merchant/index.blade.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Airtime Sales | Merchant Login</title>
|
||||
<!-- Vendor styles -->
|
||||
<link rel="stylesheet" href="{{ url('public/theme_assets/vendor/fontawesome/css/font-awesome.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url('public/theme_assets/vendor/metisMenu/dist/metisMenu.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url('public/theme_assets/vendor/animate.css/animate.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url('public/theme_assets/vendor/bootstrap/dist/css/bootstrap.css') }}" />
|
||||
|
||||
<!-- App styles -->
|
||||
<link rel="stylesheet" href="{{ url('public/theme_assets/fonts/pe-icon-7-stroke/css/pe-icon-7-stroke.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url('public/theme_assets/fonts/pe-icon-7-stroke/css/helper.css') }}" />
|
||||
<link rel="stylesheet" href="{{ url('public/theme_assets/styles/style.css') }}">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css" />
|
||||
<style>
|
||||
/* Ensures the phone dropdown takes up the full width of the Bootstrap form-control */
|
||||
.iti { width: 100%; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="blank">
|
||||
|
||||
<!-- Simple splash screen-->
|
||||
<div class="splash"> <div class="color-line"></div><div class="splash-title"><h1>Homer - Responsive Admin Theme</h1><p>Special Admin Theme for small and medium webapp with very clean and aesthetic style and feel. </p><div class="spinner"> <div class="rect1"></div> <div class="rect2"></div> <div class="rect3"></div> <div class="rect4"></div> <div class="rect5"></div> </div> </div> </div>
|
||||
<!--[if lt IE 7]>
|
||||
<p class="alert alert-danger">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
||||
<![endif]-->
|
||||
|
||||
<div class="color-line"></div>
|
||||
|
||||
<div class="login-container">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="text-center m-b-md">
|
||||
<h3>Merchant Login</h3>
|
||||
<!-- <small>This is the best app ever!</small> -->
|
||||
<div class="text-center w-75 m-auto">
|
||||
<!-- <p class="text-muted mb-4">Admin Panel Login</p> -->
|
||||
@if (Session::has('login-error'))
|
||||
<p class=" text-danger mb-4"> {{ Session::get('login-error') }} </p>
|
||||
@endif
|
||||
@include('commons.notifications')
|
||||
</div>
|
||||
</div>
|
||||
<div class="hpanel">
|
||||
<div class="panel-body">
|
||||
<form action="{{ url('merchant/login') }}" id="loginForm" method="POST">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="phone">Phone Number</label>
|
||||
<input type="tel" id="phone" class="form-control" placeholder="" title="Please enter your phone number" required="">
|
||||
<input type="hidden" name="phone_number" id="full_phone_number">
|
||||
|
||||
<span id="phone-error" class="help-block small text-danger" style="display: none;">Invalid phone number format.</span>
|
||||
|
||||
<span class="help-block small text-muted">Your registered phone number</span>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="password">Merchant PIN</label>
|
||||
<input type="password" title="Please enter your PIN" placeholder="******" required="" name="pin" id="password" class="form-control">
|
||||
<span class="help-block small">Your merchant pin</span>
|
||||
</div>
|
||||
|
||||
<div class="checkbox"></div>
|
||||
|
||||
<button type="submit" class="btn btn-warning btn-block">Login</button>
|
||||
<p class="text-center" style="padding: 10px;">-- OR --</p>
|
||||
<a class="btn btn-danger btn-block" href="{{ url('merchant/register') }}">Register</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-center">
|
||||
<strong></strong> {{ date('Y') }} Click Mobile Ltd. <br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Vendor scripts -->
|
||||
<script src="{{ url('public/theme_assets/vendor/jquery/dist/jquery.min.js') }}"></script>
|
||||
<script src="{{ url('public/theme_assets/vendor/jquery-ui/jquery-ui.min.js') }}"></script>
|
||||
<script src="{{ url('public/theme_assets/vendor/slimScroll/jquery.slimscroll.min.js') }}"></script>
|
||||
<script src="{{ url('public/theme_assets/vendor/bootstrap/dist/js/bootstrap.min.js') }}"></script>
|
||||
<script src="{{ url('public/theme_assets/vendor/metisMenu/dist/metisMenu.min.js') }}"></script>
|
||||
<script src="{{ url('public/theme_assets/vendor/iCheck/icheck.min.js') }}"></script>
|
||||
|
||||
<!-- App scripts -->
|
||||
<script src="{{ url('public/theme_assets/scripts/homer.js') }}"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var phoneInputField = document.querySelector("#phone");
|
||||
var errorMsg = $("#phone-error");
|
||||
var formGroup = $("#phone").closest('.form-group');
|
||||
var submitBtn = $('#loginForm button[type="submit"]');
|
||||
|
||||
// 1. Setup CSRF token for Laravel AJAX POST requests
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('input[name="_token"]').val()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var phoneInput = window.intlTelInput(phoneInputField, {
|
||||
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
|
||||
preferredCountries: ["mw", "zm", "bw"],
|
||||
separateDialCode: true,
|
||||
});
|
||||
|
||||
// 3. Function to perform the AJAX check
|
||||
function checkCountrySupport() {
|
||||
var countryData = phoneInput.getSelectedCountryData();
|
||||
var isoCode = countryData.iso2.toUpperCase();
|
||||
|
||||
// Optional: Change button state to show it's loading
|
||||
submitBtn.prop('disabled', true).text('Checking...');
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url('/merchant/check-country') }}",
|
||||
method: 'POST',
|
||||
data: { iso_code: isoCode },
|
||||
success: function(response) {
|
||||
if (response.supported) {
|
||||
|
||||
formGroup.removeClass('has-error');
|
||||
errorMsg.hide();
|
||||
submitBtn.prop('disabled', false).text('Login');
|
||||
} else {
|
||||
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text(response.message).show();
|
||||
submitBtn.text('Login'); // Reset text, but keep disabled
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text('Could not verify country. Please try again.').show();
|
||||
submitBtn.prop('disabled', false).text('Login');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#phone').on('keyup', function() {
|
||||
if (phoneInput.isValidNumber()) {
|
||||
checkCountrySupport();
|
||||
} else {
|
||||
formGroup.removeClass('has-error');
|
||||
errorMsg.hide();
|
||||
submitBtn.prop('disabled', false).text('Login');
|
||||
}
|
||||
});
|
||||
|
||||
phoneInputField.addEventListener("countrychange", function() {
|
||||
if ($('#phone').val().trim() !== "" && phoneInput.isValidNumber()) {
|
||||
checkCountrySupport();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#loginForm').submit(function(e) {
|
||||
if (!phoneInput.isValidNumber()) {
|
||||
e.preventDefault();
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text('Invalid phone number format.').show();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var countryData = phoneInput.getSelectedCountryData();
|
||||
$('<input>').attr({ type: 'hidden', name: 'country_iso', value: countryData.iso2.toUpperCase() }).appendTo('#loginForm');
|
||||
$('#full_phone_number').val(phoneInput.getNumber());
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
38
resources/views/login/merchant/register-success.blade.php
Normal file
38
resources/views/login/merchant/register-success.blade.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Merchant Sign Up Success</title>
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.success-message {
|
||||
max-width: 400px;
|
||||
margin: 100px auto;
|
||||
padding: 20px;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, .1);
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="success-message">
|
||||
<h2 class="text-success">Sign Up Successful!</h2>
|
||||
<p>Thank you for signing up. Your account has been created successfully.</p>
|
||||
<p>You will receive a confirmation SMS after verification.</p>
|
||||
<a class="btn btn-primary" href="{{ url('/') }}">Home Page</a>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS and dependencies -->
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
145
resources/views/login/merchant/register.blade copy.php
Normal file
145
resources/views/login/merchant/register.blade copy.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Merchant Sign Up</title>
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.signup-form {
|
||||
max-width: 400px;
|
||||
margin: 50px auto;
|
||||
padding: 20px;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, .1);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="signup-form">
|
||||
<h2 class="text-center">Merchant Sign Up</h2>
|
||||
@include('commons.notifications')
|
||||
<form action="{{ url('merchant/register') }}" id="registerForm" method="POST">
|
||||
{{ csrf_field() }}
|
||||
|
||||
<div class="form-group">
|
||||
<label for="fullname">Fullname</label>
|
||||
<input type="text" class="form-control" name="fullname" id="fullname" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="phone">Phone</label>
|
||||
<input type="text" class="form-control" name="phone" id="phone" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="language">Language</label>
|
||||
<select class="form-control" id="language" name="language" required>
|
||||
<option disabled selected>-- Select--</option>
|
||||
<option value="chichewa">Chichewa</option>
|
||||
<option value="english">English</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-block">Sign Up</button>
|
||||
</form>
|
||||
<p class="text-center mt-3">Already have an account? <a href="{{ url('merchant/login') }}">Login here</a></p>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS and dependencies -->
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var phoneInputField = document.querySelector("#phone");
|
||||
var errorMsg = $("#phone-error");
|
||||
var formGroup = $("#phone").closest('.form-group');
|
||||
var submitBtn = $('#loginForm button[type="submit"]');
|
||||
|
||||
// 1. Setup CSRF token for Laravel AJAX POST requests
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('input[name="_token"]').val()
|
||||
}
|
||||
});
|
||||
|
||||
// 2. Initialize intl-tel-input
|
||||
var phoneInput = window.intlTelInput(phoneInputField, {
|
||||
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
|
||||
preferredCountries: ["mw", "zm", "bw"],
|
||||
separateDialCode: true,
|
||||
});
|
||||
|
||||
// 3. Function to perform the AJAX check
|
||||
function checkCountrySupport() {
|
||||
var countryData = phoneInput.getSelectedCountryData();
|
||||
var isoCode = countryData.iso2.toUpperCase();
|
||||
|
||||
// Optional: Change button state to show it's loading
|
||||
submitBtn.prop('disabled', true).text('Checking...');
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url('/merchant/check-country') }}",
|
||||
method: 'POST',
|
||||
data: { iso_code: isoCode },
|
||||
success: function(response) {
|
||||
if (response.supported) {
|
||||
// Country is good! Clear errors and enable login button
|
||||
formGroup.removeClass('has-error');
|
||||
errorMsg.hide();
|
||||
submitBtn.prop('disabled', false).text('Login');
|
||||
} else {
|
||||
// Country unsupported. Show the custom message from Laravel
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text(response.message).show();
|
||||
submitBtn.text('Login'); // Reset text, but keep disabled
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
// Fallback if the server request fails
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text('Could not verify country. Please try again.').show();
|
||||
submitBtn.prop('disabled', false).text('Login');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#phone').on('keyup', function() {
|
||||
if (phoneInput.isValidNumber()) {
|
||||
checkCountrySupport();
|
||||
} else {
|
||||
formGroup.removeClass('has-error');
|
||||
errorMsg.hide();
|
||||
submitBtn.prop('disabled', false).text('Login');
|
||||
}
|
||||
});
|
||||
|
||||
phoneInputField.addEventListener("countrychange", function() {
|
||||
if ($('#phone').val().trim() !== "" && phoneInput.isValidNumber()) {
|
||||
checkCountrySupport();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('#loginForm').submit(function(e) {
|
||||
if (!phoneInput.isValidNumber()) {
|
||||
e.preventDefault();
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text('Invalid phone number format.').show();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var countryData = phoneInput.getSelectedCountryData();
|
||||
$('<input>').attr({ type: 'hidden', name: 'country_iso', value: countryData.iso2.toUpperCase() }).appendTo('#loginForm');
|
||||
$('#full_phone_number').val(phoneInput.getNumber());
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
153
resources/views/login/merchant/register.blade.php
Normal file
153
resources/views/login/merchant/register.blade.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Merchant Sign Up</title>
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.css" />
|
||||
|
||||
<style>
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
.signup-form {
|
||||
max-width: 400px;
|
||||
margin: 50px auto;
|
||||
padding: 20px;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, .1);
|
||||
}
|
||||
.iti {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="signup-form">
|
||||
<h2 class="text-center">Merchant Sign Up</h2>
|
||||
@include('commons.notifications')
|
||||
<form action="{{ url('merchant/register') }}" id="registerForm" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<div class="form-group">
|
||||
<label for="phone">Phone</label>
|
||||
<input type="tel" class="form-control" id="phone" required>
|
||||
<input type="hidden" name="phone" id="full_phone_number">
|
||||
<span id="phone-error" class="help-block small text-danger" style="display: none;">Invalid phone number format.</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="fullname">Fullname</label>
|
||||
<input type="text" class="form-control" name="fullname" id="fullname" required>
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label for="language">Language</label>
|
||||
<select class="form-control" id="language" name="language" required>
|
||||
<option disabled selected>-- Select--</option>
|
||||
<option value="chichewa">Chichewa</option>
|
||||
<option value="english">English</option>
|
||||
</select>
|
||||
</div> -->
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-block">Sign Up</button>
|
||||
</form>
|
||||
<p class="text-center mt-3">Already have an account? <a href="{{ url('merchant/login') }}">Login here</a></p>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS and dependencies -->
|
||||
<script src="{{ url('public/theme_assets/vendor/jquery/dist/jquery.min.js') }}"></script>
|
||||
<script src="{{ url('public/theme_assets/vendor/jquery-ui/jquery-ui.min.js') }}"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"></script>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var phoneInputField = document.querySelector("#phone");
|
||||
var errorMsg = $("#phone-error");
|
||||
var formGroup = $("#phone").closest('.form-group');
|
||||
var submitBtn = $('#registerForm button[type="submit"]');
|
||||
|
||||
// 1. Setup CSRF token for Laravel AJAX
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('input[name="_token"]').val()
|
||||
}
|
||||
});
|
||||
|
||||
// 2. Initialize intl-tel-input
|
||||
var phoneInput = window.intlTelInput(phoneInputField, {
|
||||
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
|
||||
preferredCountries: ["mw", "zm", "bw"],
|
||||
separateDialCode: true,
|
||||
});
|
||||
|
||||
// 3. Reusable AJAX check
|
||||
function checkCountrySupport() {
|
||||
var countryData = phoneInput.getSelectedCountryData();
|
||||
var isoCode = countryData.iso2.toUpperCase();
|
||||
|
||||
submitBtn.prop('disabled', true).text('Checking...');
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url('/merchant/check-country') }}", // Reusing the endpoint!
|
||||
method: 'POST',
|
||||
data: { iso_code: isoCode },
|
||||
success: function(response) {
|
||||
if (response.supported) {
|
||||
formGroup.removeClass('has-error');
|
||||
errorMsg.hide();
|
||||
submitBtn.prop('disabled', false).text('Sign Up');
|
||||
} else {
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text(response.message).show();
|
||||
submitBtn.text('Sign Up'); // Keep disabled to prevent submission
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text('Could not verify country. Please try again.').show();
|
||||
submitBtn.prop('disabled', false).text('Sign Up');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 4. Listeners for typing and flag changes
|
||||
$('#phone').on('keyup', function() {
|
||||
if (phoneInput.isValidNumber()) {
|
||||
checkCountrySupport();
|
||||
} else {
|
||||
formGroup.removeClass('has-error');
|
||||
errorMsg.hide();
|
||||
submitBtn.prop('disabled', false).text('Sign Up');
|
||||
}
|
||||
});
|
||||
|
||||
phoneInputField.addEventListener("countrychange", function() {
|
||||
if ($('#phone').val().trim() !== "" && phoneInput.isValidNumber()) {
|
||||
checkCountrySupport();
|
||||
}
|
||||
});
|
||||
|
||||
// 5. Final Form Submission Intercept
|
||||
$('#registerForm').submit(function(e) {
|
||||
if (!phoneInput.isValidNumber()) {
|
||||
e.preventDefault();
|
||||
formGroup.addClass('has-error');
|
||||
errorMsg.text('Invalid phone number format.').show();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Append country code and formatted number for Laravel
|
||||
var countryData = phoneInput.getSelectedCountryData();
|
||||
$('<input>').attr({ type: 'hidden', name: 'country_iso', value: countryData.iso2.toUpperCase() }).appendTo('#registerForm');
|
||||
$('#full_phone_number').val(phoneInput.getNumber());
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user