Commit bc107254 authored by Deep Dey's avatar Deep Dey

feat: add admission portal page for admin

parent 6fae70c0
This diff is collapsed.
* {
margin: 0;
padding: 0;
}
body {
font-family: "Poppins", sans-serif;
font-style: normal;
background-color: #f1f1f1;
width: 100%;
height: 100%;
}
.la-body-container {
padding: 0px 100px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.la-header {
display: flex;
width: 100%;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: center;
}
.la-header-title {
font-size: 1.8rem;
font-weight: bold;
padding-top: 15px;
}
.la-header-sub-title {
font-size: 1rem;
}
.la-header-sub-title span {
font-weight: bold;
}
.la-form-container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 100%;
margin-top: 30px;
}
/* Form */
#application-form {
width: 60%;
padding-bottom: 30px;
}
.la-form-group {
width: 100%;
margin-bottom: 15px;
}
.la-form-group label {
display: block;
margin-bottom: 4px;
font-size: 13px;
color: #706c6c;
}
.la-form-group label.is-invalid {
color: crimson;
}
.la-form-group label span {
color: crimson;
font-weight: 600;
}
.la-form-group .la-form-control {
width: 100%;
padding: 8px;
box-sizing: border-box;
border: 1px solid #b9b7b7;
outline: none;
}
.la-form-group .la-form-control.is-invalid {
border: 1px solid crimson;
color: crimson;
}
.la-form-group .la-invalid-feedback,
.la-form-group small {
display: block;
margin-top: 3px;
color: #3c3939;
font-size: 11px;
}
.la-form-group .la-invalid-feedback {
color: crimson;
}
.form-btn {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.btn {
display: flex;
justify-content: center;
align-items: center;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid transparent;
padding: .355rem .75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: .25rem;
transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
cursor: pointer;
}
.btn-sumbit {
width: 250px;
margin-top: 15px;
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
.btn-sumbit:hover {
color: #fff;
background-color: #0069d9;
border-color: #0062cc;
}
.form-image-group {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
margin-top: 30px;
}
.form-image-group .la-form-group {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
/* width: 30%; */
padding: 0px 10px;
}
.image-preview {
width: 100px;
height: 100px;
/* border: 1px solid #ddd; */
margin: 10px;
object-fit: cover;
}
.loader {
display: none;
border: 3px solid #f3f3f3;
border-top: 3px solid #3498db;
border-radius: 50%;
width: 25px;
height: 25px;
animation: spin 2s linear infinite;
}
input[type="file"] {
font-size: 12px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@media only screen and (max-width: 768px) {
#application-form {
width: 100%;
}
.form-image-group{
display: flex;
flex-wrap: wrap;
/* flex-direction: column; */
}
.la-form-group{
width: 100%;
}
/* input[type="file"] {
width: 80%;
} */
.la-body-container {
padding: 0px 60px;
}
}
\ No newline at end of file
$(document).ready(function () {
$('#staffDepartmentContainer').hide();
$('#staffCategoryContainer').hide();
$('#exStudentInfoContainer').hide();
$('#denominationContainer').hide();
$('#churchContainer').hide();
$('#fatherDenominationContainer').hide();
$('#fatherChurchContainer').hide();
$('#motherDenominationContainer').hide();
$('#motherChurchContainer').hide();
$('#addressCheck').click(function () {
if ($(this).is(':checked')) {
$('#correspondenceAddress').prop('disabled', true)
$('#correspondenceAddress').val($('#homeAddress').val());
} else {
$('#correspondenceAddress').prop('disabled', false);
}
});
$('#homeAddress').on('input', function () {
if ($('#addressCheck').is(':checked')) {
$('#correspondenceAddress').val($('#homeAddress').val());
}
})
//TODO: depending on class it will set the min and max date
$('#dateOfBirth').click(function () {
var currentDate = new Date();
var currentYear = currentDate.getFullYear();
var upperLimitDate = new Date(currentYear - 1, 0, 1);
var lowerLimitDate = new Date(currentYear - 2, 0, 2);
// Format the dates as YYYY-MM-DD strings
var upperLimitDateString = upperLimitDate.toISOString().split('T')[0];
var lowerLimitDateString = lowerLimitDate.toISOString().split('T')[0];
$('#dateOfBirth').attr('max', upperLimitDateString);
$('#dateOfBirth').attr('min', lowerLimitDateString);
});
$('#category').on('change', function () {
if ($(this).val() === 'Staff Child') {
$('#staffDepartmentContainer').show();
$('#staffCategoryContainer').show();
$('#exStudentInfoContainer').hide();
} else if ($(this).val() === 'Ex-Student') {
$('#exStudentInfoContainer').show();
$('#staffDepartmentContainer').hide();
$('#staffCategoryContainer').hide();
} else {
$('#staffDepartmentContainer').hide();
$('#staffCategoryContainer').hide();
$('#exStudentInfoContainer').hide();
}
});
$('#religion').on('change', function () {
if ($(this).val() === 'Christian') {
$('#denominationContainer').show();
$('#churchContainer').show();
} else {
$('#denominationContainer').hide();
$('#churchContainer').hide();
}
});
$('#fatherReligion').on('change', function () {
if ($(this).val() === 'Christian') {
$('#fatherDenominationContainer').show();
$('#fatherChurchContainer').show();
} else {
$('#fatherDenominationContainer').hide();
$('#fatherChurchContainer').hide();
}
});
$('#motherReligion').on('change', function () {
if ($(this).val() === 'Christian') {
$('#motherDenominationContainer').show();
$('#motherChurchContainer').show();
} else {
$('#motherDenominationContainer').hide();
$('#motherChurchContainer').hide();
}
});
function readURL(input, previewId) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$(previewId).attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
// Bind change events to file inputs for image preview
$('input[name="candidateImage"]').change(function () {
readURL(this, '#candidateImage');
});
$('input[name="fatherImage"]').change(function () {
readURL(this, '#fatherImage');
});
$('input[name="motherImage"]').change(function () {
readURL(this, '#motherImage');
});
$.validator.addMethod(
'regex',
function (value, element, regexpr) {
if (value == '') {
return true;
}
return regexpr.test(value);
},
'Please check your input'
);
$.validator.addMethod(
'extension',
function (value, element, param) {
let fileExtension = value.split('.').pop().toLowerCase();
return this.optional(element) || param.includes(fileExtension);
},
'Please upload a file with a valid extension'
);
$.validator.addMethod(
'fileSize',
function (value, element, param) {
if (element.files.length === 0) {
return true; // No file selected
}
var fileSize = element.files[0].size;
return this.optional(element) || fileSize <= param;
},
'Please upload a file smaller than the specified size'
);
$('#application-form').validate({
rules: {
formSubmitCheck: 'required',
},
messages: {
formSubmitCheck: 'Please check this box to submit the form',
},
errorPlacement: function (error, element) {
element.prev('label').addClass('is-invalid');
element.next('.la-invalid-feedback').html(error.html());
},
highlight: function (element) {
$(element).addClass('is-invalid');
},
unhighlight: function (element) {
$(element).removeClass('is-invalid');
$(element).prev('label').removeClass('is-invalid');
$(element).next('.la-invalid-feedback').html('');
},
submitHandler: function (form) {
var formData = new FormData(form);
let jsonData = {};
$('#duplicateFatherEmail').each(function () {
formData.set('duplicateFatherEmail', this.checked);
});
//TODO: validate the form for custom validations
let reconfiguredFormData = reconfigureFormData(formData);
if (!reconfiguredFormData) {
return false;
}
$('.loader').css('display', 'inline-block');
$('.btn-text').css('display', 'none');
$('#btn-sumbit').prop('disabled', true);
$.ajax({
// TODO: move the url to a constant file
url: BASE_URL_LAMARTIN + '/admission-form/admin-submit',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function (response) {
formData.forEach((value, key) => {
jsonData[key] = value;
});
sessionStorage.setItem('userData', JSON.stringify(jsonData));
window.location.href = 'success.html';
},
error: function (xhr, status, error) {
$('.loader').css('display', 'none');
$('.btn-text').css('display', 'inline-block');
$('#btn-sumbit').prop('disabled', false);
if (xhr.responseText) {
console.log(xhr.responseText);
console.log(JSON.parse(xhr.responseText).message);
var errorMessage = JSON.parse(xhr.responseText).message;
$('#messageModal .modal-title').text('Error');
$('#messageModal .modal-body').text(JSON.parse(xhr.responseText).message);
$('#messageModal').modal('show');
} else {
$('#messageModal .modal-title').html('Error');
$('#messageModal .modal-body').html('No response from server');
$('#messageModal').modal('show');
}
},
});
return false;
},
});
function reconfigureFormData(formData) {
let reconfiguredFormData = new FormData();
reconfiguredFormData = formData;
var errorElements = [];
// conditional validation on category
if (!formData.get('correspondenceAddress')) {
let correspondenceAddress = formData.get('homeAddress');
reconfiguredFormData.set('correspondenceAddress', correspondenceAddress);
}
if (formData.get('category') === 'Staff Child') {
//TODO: add validation for staff
reconfiguredFormData.set('exStudentInfo', '');
}
else if (formData.get('category') === 'Ex-Student') {
//TODO: add validation for ex-student
reconfiguredFormData.set('staffDepartment', '');
reconfiguredFormData.set('staffCategory', '');
} else {
reconfiguredFormData.set('staffDepartment', '');
reconfiguredFormData.set('staffCategory', '');
reconfiguredFormData.set('exStudentInfo', '');
}
// conditional validation on candidate religion
if (formData.get('religion') === 'Christian') {
//TODO: add validation for denomination and church
} else {
reconfiguredFormData.set('denomination', '');
reconfiguredFormData.set('church', '');
}
// conditional validation on candidate father's religion
if (formData.get('fatherReligion') === 'Christian') {
//TODO: add validation for father's denomination and church
} else {
reconfiguredFormData.set('fatherDenomination', '');
reconfiguredFormData.set('fatherChurch', '');
}
// conditional validation on candidate mother's religion
if (formData.get('motherReligion') === 'Christian') {
//TODO: add validation for mother's denomination and church
} else {
reconfiguredFormData.set('motherDenomination', '');
reconfiguredFormData.set('motherChurch', '');
}
if (errorElements.length > 0) {
$('html, body').animate({
scrollTop: $(errorElements[0]).offset().top - 100
}, 200);
return null;
}
return reconfigureFormData;
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment