(function ($) {
	"use strict";

	/* ===================================
		Add/Edit Job
	====================================== */

	//Hire a job Proposal
	$(document).on('click', '.gn-actions .gn-job-proposal-hire-btn', function (e) {
		e.preventDefault();
		let _this = $(this);
		let proposal_id = _this.data("gn-proposal-id");

		GigneoAlert.confirm({
			title: GigneoCommon.job_order_place_confirmation_title,
			text: GigneoCommon.job_order_place_confirmation_desc,
			confirmButtonText: GigneoCommon.job_order_place_confirmation_btn,
			icon: "info",
			showLoaderOnConfirm: false,
			allowOutsideClick: () => !Swal.isLoading(),
			preConfirm: () => {
				const confirmBtn = Swal.getConfirmButton();
				confirmBtn.classList.add('gn-loading');
				confirmBtn.disabled = true;

				return new Promise((resolve, reject) => {
					$.ajax({
						url: GigneoCommon.ajax_url,
						method: 'POST',
						data: {
							action: 'gigneo_job_order_place',
							id: proposal_id,
							security: GigneoCommon.security,
						},
						success: function (response) {
							if (response.success) {
								if (response.data.message) {
									GigneoAlert.toast({
										icon: 'success',
										title: GigneoCommon.success,
										text: response.data.message
									});
								}
								if (response.data.redirect) {
									window.location.href = response.data.redirect;
								}
							} else {
								GigneoAlert.toast({
									icon: 'error',
									title: GigneoCommon.error,
									text: response.data && response.data.message ? response.data.message : ''
								});
							}
						},
						error: function (response) {
							GigneoAlert.toast({
								icon: 'error',
								title: GigneoCommon.error,
								text: response.responseJSON && response.responseJSON.data && response.responseJSON.data.message ? response.responseJSON.data.message : ''
							});
						}
					});
				});
			}
		});

	});

	//Category change
	$(document).on('change', '.gn-job-edit-inner #gn-job-category', function () {
		let _this = $(this);
		let category = _this.val();
		let sub_selector = _this.parents('.gn-form-fields').find('#gn-job-subcategory');
		let job_type = $('#gn-job-specific-types');

		sub_selector.empty();

		if (category && GigneoDashboard.sub_categories[category] !== undefined) {
			sub_selector.removeAttr('disabled');
			job_type.attr('disabled', true);
			job_type.empty();

			let sub_categories = GigneoDashboard.sub_categories[category];

			sub_selector.append(
				$('<option>', {
					value: '',
					text: GigneoDashboard.default_sub_categories
				})
			);

			Object.entries(sub_categories).forEach(function ([value, label]) {
				sub_selector.append(
					$('<option>')
						.val(value)
						.html(label)
				);
			});

			sub_selector.trigger('change.select2');
		}

	});

	//Sub Category change
	$(document).on('change', '.gn-job-edit-inner #gn-job-subcategory', function () {
		let _this = $(this);
		let category = _this.val();
		let specific_types = _this.parents('.gn-form-fields').find('#gn-job-specific-types');

		specific_types.empty();

		if (category && GigneoDashboard.sub_categories[category] !== undefined) {
			specific_types.removeAttr('disabled');
			let sub_categories = GigneoDashboard.sub_categories[category];

			Object.entries(sub_categories).forEach(function ([value, label]) {
				specific_types.append(
					$('<option>')
						.val(value)
						.html(label)
				);
			});

			specific_types.trigger('change.select2');
		}

	});

	//Country State & Cities for location
	$(document).on('change', '#gn-job-form-details select[name="country_state"]', function () {
		let _this = $(this);
		let country_state = _this.val();
		let cities_selector = $('#gn-job-form-details select[name="city"]');

		// Reset dropdown
		cities_selector.empty();

		// Add default "None" option first
		cities_selector.append(
			$('<option>', {
				value: 'none',
				text: GigneoCommon.none ?? 'None'
			})
		);

		if (country_state && GigneoDashboard.cities[country_state] !== undefined) {
			let cities = GigneoDashboard.cities[country_state];

			Object.entries(cities).forEach(function ([value, label]) {
				cities_selector.append(
					$('<option>', {
						value: value,
						text: label
					})
				);
			});
		}

		// Refresh Select2
		cities_selector.trigger('change.select2');
	});

	function TinymceInit() {
		if (typeof tinymce === 'undefined') {
			return;
		}
		if (tinymce.get('gn-description')) {
			tinymce.get('gn-description').remove();
			tinymce.init({
				selector: '#gn-description',
				toolbar: 'bold italic bullist numlist link unlink',
				plugins: 'lists link',
				resize: false,
				menubar: false,
				branding: false,
				content_style: 'body { font-size: 14px; background-color: transparent; font-family: var(--gigneo-primary-font,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji) }',
				content_css: GigneoDashboard.tinymce_skin,
			});
		}
	}

	// Job Sidebar Toggle
	jQuery(document).on('ready', function () {
		function initToggle() {
			if (jQuery(window).width() <= 991) {

				jQuery('.gn-job-edit-step .gn-aside .gn-aside-body').hide();

				jQuery('.gn-job-edit-step .gn-aside .gn-aside-content > .gn-title')
					.off('click')
					.on('click', function () {

						var $this = jQuery(this);

						$this.toggleClass('gn-active');
						$this.next('.gn-aside-body').slideToggle(300);

					});

			} else {

				jQuery('.gn-job-edit-step .gn-aside .gn-aside-body').show();
				jQuery('.gn-job-edit-step .gn-aside .gn-aside-content > .gn-title')
					.removeClass('gn-active')
					.off('click');
			}
		}

		initToggle();

		jQuery(window).on('resize', function () {
			initToggle();
		});

	});

	$('.gn-job-media-documents > .gn-job-media').each(function (index) {

		$(`.gn-job-media-documents .gn-job-media-${index} .gn-job-media-upload-toggle`).GigneoUploader({
			previewSelector: `.gn-job-media-documents .gn-job-media-${index}`,
			inputSelector: `.gn-job-media-documents #gn-job-media-input-${index}`,
			removeSelector: `.gn-job-media-documents .gn-job-media-${index} .gn-job-media-remove`,
			crop: false,
			previewMode: 'custom',
			allowedExtensions: GigneoDashboard.job_document_extensions || ['jpg', 'png', 'pdf', 'doc', 'docx', 'mp4'],
			maxFileSize: (GigneoDashboard.job_document_max_size * 1024 * 1024) || 5242880,
			placeholderUrl: '',
			previewCallback: function (preview, attachment) {
				if (attachment.url) {
					$(preview).removeClass('gn-job-media-placeholder');
					$(preview).find('.gn-name').html(attachment.filename);
				} else {
					$(preview).addClass('gn-job-media-placeholder');
					$(document)
						.find('.gn-job-media-documents .gn-job-media-placeholder')
						.appendTo('.gn-job-media-documents');
					$(preview).find('.gn-name').empty();
				}
			}
		});

	});


	//Add screening question
	$(document).on('click', '.gn-add-screening-question', function (e) {
		e.preventDefault();

		let _this = $(this);
		let wrapper = $('#gn-screening-questions');
		let req_count = $(document).find('.gn-screening-questions .gn-screening-question').length;

		let req_template = wp.template('gn-screening-question');
		let req_html = req_template({ index: req_count });

		wrapper.find('.gn-screening-questions').append(req_html);

	});

	//Remove screening question
	$(document).on('click', '.gn-remove-screening-question', function (e) {
		e.preventDefault();

		let _this = $(this);
		let req_id = _this.data('gn-screening-question-id');
		if (req_id !== '') {
			$(document).find(`#gn-screening-question-${req_id}`).remove();
		}
	});

	//Change screening question Answer Type
	$(document).on('change', '.gn-screening-question-answer-type', function (e) {
		e.preventDefault();

		let _this = $(this);
		let val = _this.val();
		let selector = _this.parents('.gn-form-field ').find('.gn-screening-question-choices');

		if ('choice' === val) {
			selector.removeClass('d-none');
			selector.find('.gn-screening-question-choice input').removeClass('gn-not-required-field').addClass('gn-required-field');
		} else {
			selector.addClass('d-none');
			selector.find('.gn-screening-question-choice input').removeClass('gn-required-field').addClass('gn-not-required-field');
		}

	}
	);

	//Add screening question Choice
	$(document).on('click', '.gn-add-screening-question-choice', function (e) {
		e.preventDefault();

		let _this = $(this);
		let req_field_inex = $(_this).data('gn-field-id');
		let req_field = $(`#gn-screening-question-${req_field_inex}`);

		if (!req_field.length) {
			return
		}

		let index = req_field.find('.gn-screening-question-choice').length;

		let req_choice_template = wp.template('gn-screening-question-choice');
		let req_choice_html = req_choice_template({ field_id: req_field_inex, choice_id: index });

		req_field.find('.gn-screening-question-choice-actions').before(req_choice_html);

	});

	//Remove screening question Choice
	$(document).on('click', '.gn-remove-screening-question-choice', function (e) {
		e.preventDefault();

		let _this = $(this);
		let req_choice_id = _this.data('gn-screening-question-choice-id');
		if (req_choice_id !== '') {
			$(document).find(`#${req_choice_id}`).remove();
		}
	}
	);

	//Save job
	$(document).on('click', '.gn-job-save', function (e) {
		e.preventDefault();

		let btn = $(this);
		let type = btn.data('gn-type');
		let step_selector = $('.gn-job-edit-steps .gn-current-step');
		let step_keys = Object.keys(step_selector.data('gn-steps'));
		let step = btn.data('gn-step');
		let next_step = btn.data('gn-next-step');
		let prev_step = btn.data('gn-prev-step');
		let redirect_url = btn.data('gn-redirect-url');
		let form = btn.closest('#gn-job-form-' + step);


		// Force TinyMCE editors to save content to textarea
		if (typeof tinyMCE !== 'undefined') {
			tinyMCE.triggerSave();
		}

		let url = new URL(window.location.href);
		let params = new URLSearchParams(url.search);

		let id = params.get('p_id');
		let form_data = new FormData(form[0]);
		form_data.append('action', 'gigneo_save_job');
		form_data.append('step', step);
		form_data.append('id', id);
		form_data.append('type', type);
		form_data.append('security', GigneoCommon.security);
		let proceed = true;
		let submitBtn = btn;

		proceed = window.GigneoRequiredFormFields.init(form, proceed);

		if (proceed) {
			submitBtn.addClass('gn-loading').prop('disabled', true);

			$.ajax(
				{
					url: GigneoCommon.ajax_url,
					method: 'POST',
					data: form_data,
					contentType: false,
					processData: false,
					success: function (response) {
						if (response.success) {

							if (type === 'draft' || type === 'redirect') {
								window.location.href = redirect_url;
								return;
							}
							if (response?.data?.id !== undefined) {
								params.set('p_id', response.data.id);
							}

							if (type === 'publish') {
								let job_publish_modal = $('#gn-job-publish')
								job_publish_modal.addClass('gn-active');
							}

							if (next_step === 'screening' || next_step === undefined) {
								params.set('step', 'screening');
							}

							if (next_step) {
								params.set('step', next_step);

								$('.gn-job-edit-' + step).addClass('d-none');
								$('.gn-job-edit-' + next_step).removeClass('d-none');
								$('.gn-job-edit-steps [data-gn-step="' + step + '"]').removeClass('gn-active');
								$('.gn-job-edit-steps [data-gn-step="' + next_step + '"]').addClass('gn-active');
								step_selector.html(step_keys.indexOf(next_step) + 1);
							}
							TinymceInit();
							url.search = params.toString();
							window.history.replaceState({}, '', url.toString());

						} else {
							GigneoAlert.toast(
								{
									icon: 'error',
									title: GigneoCommon.error,
									text: response.data.message
								}
							);
						}
					},
					error: function (response) {
						GigneoAlert.toast(
							{
								icon: 'error',
								title: GigneoCommon.error,
								text: response.responseJSON.data.message
							}
						);
					},
					complete: function () {
						submitBtn.prop('disabled', false);
						submitBtn.removeClass('gn-loading');
					}
				}
			);
		}
	});

	//Back button functionality
	$(document).on('click', '.gn-job-back', function (e) {
		e.preventDefault();

		let btn = $(this);
		let step_selector = $('.gn-job-edit-steps .gn-current-step');
		let step_keys = Object.keys(step_selector.data('gn-steps'));
		let step = btn.data('gn-step');
		let prev_step = btn.data('gn-prev-step');

		if (!prev_step) {
			return false;
		}

		let url = new URL(window.location.href);
		let params = new URLSearchParams(url.search);

		params.set('step', prev_step);

		url.search = params.toString();
		window.history.replaceState({}, '', url.toString());

		$('.gn-job-edit-' + step).addClass('d-none');
		$('.gn-job-edit-' + prev_step).removeClass('d-none');
		$('.gn-job-edit-steps [data-gn-step="' + step + '"]').removeClass('gn-active');
		$('.gn-job-edit-steps [data-gn-step="' + prev_step + '"]').addClass('gn-active');
		step_selector.html(step_keys.indexOf(prev_step) + 1);

	});

	// Clone Job
	$(document).on('click', '.gn-clone-job', function (e) {
		e.preventDefault();
		const _this = $(this);
		const job_id = _this.data('gn-id');

		if (job_id === undefined || job_id === '') {
			return false;
		}

		_this.prop('disabled', true).addClass('gn-loading');

		$.ajax({
			url: GigneoCommon.ajax_url,
			method: 'POST',
			data: {
				action: 'gigneo_job_clone',
				id: job_id,
				security: GigneoCommon.security,
			},
			success: function (response) {
				if (response.success && response.data.redirect_url) {
					window.location.href = response.data.redirect_url;
				}
				_this.prop('disabled', false).removeClass('gn-loading');
			},
			error: function (response) {
				_this.prop('disabled', false).removeClass('gn-loading');
				GigneoAlert.toast({
					icon: 'error',
					title: GigneoCommon.error,
					text: response.responseJSON && response.responseJSON.data && response.responseJSON.data.message ? response.responseJSON.data.message : ''
				});
			},
		});
	});

	//Pause/Active job
	$('.gn-update-job-status').on('click', function (e) {
		e.preventDefault();
		let _this = $(this);
		let job_id = _this.data("gn-id");
		let job_status = _this.data("gn-status");
		let confirmationText = job_status === 'publish'
			? GigneoCommon.active_confirmation_desc
			: GigneoCommon.pause_confirmation_desc;

		GigneoAlert.confirm({
			title: GigneoCommon.confirmation_title,
			text: confirmationText,
			confirmButtonText: GigneoCommon.confirm,
			icon: "warning",
			showLoaderOnConfirm: false,
			allowOutsideClick: () => !Swal.isLoading(),
			preConfirm: () => {
				const confirmBtn = Swal.getConfirmButton();
				confirmBtn.classList.add('gn-loading');
				confirmBtn.disabled = true;

				return new Promise((resolve, reject) => {
					$.ajax({
						url: GigneoCommon.ajax_url,
						method: 'POST',
						data: {
							action: 'gigneo_pause_active_job',
							id: job_id,
							status: job_status,
							security: GigneoCommon.security,
						},
						success: function (response) {
							if (response.success) {
								// Redirect to edit page of the new service
								if (response.data.message) {
									GigneoAlert.toast({
										icon: 'success',
										title: GigneoCommon.success,
										text: response.data.message
									});
								}
								window.location.reload();
							} else {
								GigneoAlert.toast({
									icon: 'error',
									title: GigneoCommon.error,
									text: response.data && response.data.message ? response.data.message : ''
								});
							}
						},
						error: function (response) {
							GigneoAlert.toast({
								icon: 'error',
								title: GigneoCommon.error,
								text: response.responseJSON && response.responseJSON.data && response.responseJSON.data.message ? response.responseJSON.data.message : ''
							});
						}
					});
				});
			}
		});

	});

	//Featured job
	$('.gn-featured-job').on('click', function (e) {
		e.preventDefault();
		let _this = $(this);
		let job_id = _this.data("gn-id");
		let job_action = _this.data("gn-featured");
		let confirmationText = job_action ? GigneoCommon.featured_confirmation_desc : GigneoCommon.removed_featured_confirmation_desc;

		GigneoAlert.confirm({
			title: GigneoCommon.confirmation_title,
			text: confirmationText,
			confirmButtonText: GigneoCommon.confirm,
			icon: "warning",
			showLoaderOnConfirm: false,
			allowOutsideClick: () => !Swal.isLoading(),
			preConfirm: () => {
				const confirmBtn = Swal.getConfirmButton();
				confirmBtn.classList.add('gn-loading');
				confirmBtn.disabled = true;

				return new Promise((resolve, reject) => {
					$.ajax({
						url: GigneoCommon.ajax_url,
						method: 'POST',
						data: {
							action: 'gigneo_featured_job',
							id: job_id,
							featured: job_action,
							security: GigneoCommon.security,
						},
						success: function (response) {
							if (response.success) {
								// Redirect to edit page of the new service
								if (response.data.message) {
									GigneoAlert.toast({
										icon: 'success',
										title: GigneoCommon.success,
										text: response.data.message
									});
								}
								window.location.reload();
							} else {
								GigneoAlert.toast({
									icon: 'error',
									title: GigneoCommon.error,
									text: response.data && response.data.message ? response.data.message : ''
								});
							}
						},
						error: function (response) {
							GigneoAlert.toast({
								icon: 'error',
								title: GigneoCommon.error,
								text: response.responseJSON && response.responseJSON.data && response.responseJSON.data.message ? response.responseJSON.data.message : ''
							});
						}
					});
				});
			}
		});

	});

	//Service Draft
	$('.gn-draft-job').on('click', function (e) {
		e.preventDefault();
		let _this = $(this);
		let job_id = _this.data("gn-id");

		GigneoAlert.confirm({
			title: GigneoCommon.confirmation_title,
			text: GigneoCommon.draft_confirmation_desc,
			confirmButtonText: GigneoCommon.draft,
			icon: "warning",
			showLoaderOnConfirm: false,
			allowOutsideClick: () => !Swal.isLoading(),
			preConfirm: () => {
				const confirmBtn = Swal.getConfirmButton();
				confirmBtn.classList.add('gn-loading');
				confirmBtn.disabled = true;

				return new Promise((resolve, reject) => {
					$.ajax({
						url: GigneoCommon.ajax_url,
						method: 'POST',
						data: {
							action: 'gigneo_draft_job',
							id: job_id,
							security: GigneoCommon.security,
						},
						success: function (response) {
							if (response.success) {
								// Redirect to edit page of the new job
								if (response.data.message) {
									GigneoAlert.toast({
										icon: 'success',
										title: GigneoCommon.success,
										text: response.data.message
									});
								}
								window.location.reload();
							} else {
								GigneoAlert.toast({
									icon: 'error',
									title: GigneoCommon.error,
									text: response.data && response.data.message ? response.data.message : ''
								});
							}
						},
						error: function (response) {
							GigneoAlert.toast({
								icon: 'error',
								title: GigneoCommon.error,
								text: response.responseJSON && response.responseJSON.data && response.responseJSON.data.message ? response.responseJSON.data.message : ''
							});
						}
					});
				});
			}
		});

	});

	//Publish job form
	$(document).on('submit', '#gn-job-publish-form', function (e) {
		e.preventDefault();

		let _this = $(this);
		let proceed = true;
		let form_data = new FormData(this);
		let submit_btn = _this.find('button[type="submit"]');
		let redirect = submit_btn.data('gn-redirect-url')
		let url = new URL(window.location.href);
		let params = new URLSearchParams(url.search);
		let id = params.get('p_id');
		proceed = window.GigneoRequiredFormFields.init(_this, proceed);

		if (proceed) {

			form_data.append('action', 'gigneo_publish_job');
			form_data.append('security', GigneoCommon.security);
			form_data.append('id', id);

			submit_btn.addClass('gn-loading');

			$.ajax({
				url: GigneoCommon.ajax_url,
				method: 'POST',
				data: form_data,
				contentType: false,
				processData: false,
				success: function (response) {
					window.location.href = redirect;
					submit_btn.removeClass('gn-loading');
					if (response.success) {
						_this.parents('.gn-modal-wrapper').removeClass('gn-active');
						if (response.data.message) {
							GigneoAlert.toast({
								icon: 'success',
								title: GigneoCommon.success,
								text: response.data.message
							});
						}
					}
				},
				error: function (xhr, status, error) {
					submit_btn.removeClass('gn-loading');
					let error_message = xhr?.responseJSON?.data.message || GigneoCommon.went_wrong;
					GigneoAlert.toast({
						icon: 'error',
						title: GigneoCommon.error,
						text: error_message
					});
				}
			});
		}

	});

	//Job Remove
	$('.gn-remove-job').on('click', function (e) {
		e.preventDefault();
		let _this = $(this);
		let job_id = _this.data("gn-id");

		GigneoAlert.confirm({
			title: GigneoCommon.confirmation_title,
			text: GigneoCommon.delete_confirmation_desc,
			confirmButtonText: GigneoCommon.delete,
			icon: "error",
			showLoaderOnConfirm: false,
			allowOutsideClick: () => !Swal.isLoading(),
			preConfirm: () => {
				const confirmBtn = Swal.getConfirmButton();
				confirmBtn.classList.add('gn-loading');
				confirmBtn.disabled = true;

				return new Promise((resolve, reject) => {
					$.ajax({
						url: GigneoCommon.ajax_url,
						method: 'POST',
						data: {
							action: 'gigneo_remove_job',
							id: job_id,
							security: GigneoCommon.security,
						},
						success: function (response) {
							if (response.success) {
								// Redirect to edit page of the new service
								if (response.data.message) {
									GigneoAlert.toast({
										icon: 'success',
										title: GigneoCommon.success,
										text: response.data.message
									});
								}
								window.location.reload();
							} else {
								GigneoAlert.toast({
									icon: 'error',
									title: GigneoCommon.error,
									text: response.data && response.data.message ? response.data.message : ''
								});
							}
						},
						error: function (response) {
							GigneoAlert.toast({
								icon: 'error',
								title: GigneoCommon.error,
								text: response.responseJSON && response.responseJSON.data && response.responseJSON.data.message ? response.responseJSON.data.message : ''
							});
						}
					});
				});
			}
		});

	});

	// Shortlist Proposal
	$(document).on('click', '.gn-shortlist-btn', function (e) {
		e.preventDefault();
		const _this = $(this);
		const id = _this.data('gn-id');
		const icon = _this.find('i');
		const span = _this.find('span');

		if (!id) return;

		_this.addClass('gn-loading').prop('disabled', true);

		$.ajax({
			url: GigneoCommon.ajax_url,
			method: 'POST',
			data: {
				action: 'gigneo_shortlist_proposal',
				id: id,
				security: GigneoCommon.security,
			},
			success: function (response) {
				if (response.success) {
					const data = response.data;
					span.html(data.label);
					if (data.is_shortlisted === 'yes') {
						_this.addClass('gn-active');
					} else {
						_this.removeClass('gn-active');
					}
					location.reload();
				} else {
					GigneoAlert.toast({
						icon: 'error',
						title: GigneoCommon.error,
						text: response.data && response.data.message ? response.data.message : ''
					});
				}
				location.reload();
			},
			error: function (xhr) {
				GigneoAlert.toast({
					icon: 'error',
					title: GigneoCommon.error,
					text: xhr.responseJSON?.data?.message || GigneoCommon.went_wrong
				});
				location.reload();
			},
			complete: function () {
				_this.removeClass('gn-loading').prop('disabled', false);
				location.reload();
			}
		});
	});

	// Withdraw Proposal
	$(document).on('click', '.gn-action-withdraw-proposal', function (e) {
		e.preventDefault();
		let _this = $(this);
		let proposal_id = _this.data("gn-id");

		GigneoAlert.confirm({
			title: GigneoCommon.confirmation_title,
			text: GigneoCommon.delete_confirmation_desc,
			confirmButtonText: GigneoCommon.delete,
			icon: "error",
			showLoaderOnConfirm: false,
			allowOutsideClick: () => !Swal.isLoading(),
			preConfirm: () => {
				const confirmBtn = Swal.getConfirmButton();
				confirmBtn.classList.add('gn-loading');
				confirmBtn.disabled = true;

				return new Promise((resolve, reject) => {
					$.ajax({
						url: GigneoCommon.ajax_url,
						method: 'POST',
						data: {
							action: 'gigneo_withdraw_proposal',
							id: proposal_id,
							security: GigneoCommon.security,
						},
						success: function (response) {
							if (response.success) {
								if (response.data.message) {
									GigneoAlert.toast({
										icon: 'success',
										title: GigneoCommon.success,
										text: response.data.message
									});
								}
								window.location.reload();
							} else {
								GigneoAlert.toast({
									icon: 'error',
									title: GigneoCommon.error,
									text: response.data && response.data.message ? response.data.message : ''
								});
							}
						},
						error: function (response) {
							GigneoAlert.toast({
								icon: 'error',
								title: GigneoCommon.error,
								text: response.responseJSON && response.responseJSON.data && response.responseJSON.data.message ? response.responseJSON.data.message : ''
							});
						}
					});
				});
			}
		});

	});

})(jQuery);