@extends('layouts.app') @section('title', __('الوظائف')) {{-- @section('meta_title', $SEO['meta_title']) @section('description', $SEO['meta_description']) @section('keywords', $SEO['meta_keywords']) @section('og:title', $SEO['og_title']) @section('og:description', $SEO['og_description']) @section('og_image', $SEO['image']) --}} @vite('resources/css/about.css') @push('styles') @endpush @section('content')

{{ __('job.start_career') }}

{{ __('job.apply_desc') }}

@include('partials.footerPages')
{{-- --}}
@push('scripts') {{-- --}} document.getElementById('cv').addEventListener('change', function () { const nameEl = document.getElementById('cv-chosen-name'); if (this.files && this.files.length > 0) { nameEl.textContent = this.files[0].name; nameEl.style.color = '#e57e3a'; } else { nameEl.textContent = (document.documentElement.lang.startsWith('ar')) ? 'لم يتم اختيار ملف' : 'No file chosen'; nameEl.style.color = ''; } }); function submitJobForm(e) { e.preventDefault(); // مسح جميع الأخطاء السابقة document.querySelectorAll('.error-text').forEach(el => el.textContent = ''); document.querySelectorAll('.input-error').forEach(el => el.classList.remove('input-error')); const form = document.getElementById('job-form'); let hasError = false; // --- التحقق من الاسم الأول --- const firstName = form.querySelector('[name="first_name"]'); if (!firstName.value.trim()) { hasError = true; document.getElementById('error-first_name').textContent = 'هذا الحقل مطلوب'; firstName.classList.add('input-error'); } // --- التحقق من اسم العائلة --- const lastName = form.querySelector('[name="last_name"]'); if (!lastName.value.trim()) { hasError = true; document.getElementById('error-last_name').textContent = 'هذا الحقل مطلوب'; lastName.classList.add('input-error'); } // --- التحقق من البريد الإلكتروني --- const email = form.querySelector('[name="email"]'); const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!email.value.trim()) { hasError = true; document.getElementById('error-email').textContent = 'هذا الحقل مطلوب'; email.classList.add('input-error'); } else if (!emailRegex.test(email.value.trim())) { hasError = true; document.getElementById('error-email').textContent = 'يرجى إدخال بريد إلكتروني صالح'; email.classList.add('input-error'); } // --- التحقق من السيرة الذاتية --- const cv = form.querySelector('[name="cv"]'); if (!cv.files || cv.files.length === 0) { hasError = true; document.getElementById('error-cv').textContent = 'يرجى رفع السيرة الذاتية'; cv.classList.add('input-error'); } else { const allowedTypes = [ 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ]; if (!allowedTypes.includes(cv.files[0].type)) { hasError = true; document.getElementById('error-cv').textContent = 'يرجى رفع ملف بصيغة PDF أو DOC أو DOCX'; cv.classList.add('input-error'); } } // --- التحقق من خطاب التقديم --- const coverLetter = form.querySelector('[name="cover_letter"]'); if (!coverLetter.value.trim()) { hasError = true; document.getElementById('error-cover_letter').textContent = 'هذا الحقل مطلوب'; coverLetter.classList.add('input-error'); } // --- رقم التواصل --- const phone = form.querySelector('[name="phone"]'); if (!phone.value.trim()) { hasError = true; document.getElementById('error-phone').textContent = "{{ __('job.field_required') }}"; phone.classList.add('input-error'); } else if (!iti.isValidNumber()) { hasError = true; document.getElementById('error-phone').textContent = "{{ __('job.phone_invalid') }}"; phone.classList.add('input-error'); } // إيقاف الإرسال إذا يوجد خطأ if (hasError) { // التمرير لأول حقل فيه خطأ const firstError = form.querySelector('.input-error'); if (firstError) { firstError.scrollIntoView({ behavior: 'smooth', block: 'center' }); } return; } // --- الإرسال --- const btn = document.getElementById('job-submit-btn'); const btnText = document.getElementById('btn-text'); const btnLoader = document.getElementById('btn-loader'); btn.disabled = true; btnLoader.style.display = 'inline-block'; const formData = new FormData(form); // إضافة الرقم الكامل مع رمز الدولة formData.set('phone', iti.getNumber()); // (اختياري) لتسهيل تمييز نوع النموذج في الـ API formData.append('form_type', 'job_request'); fetch("https://darbcp.sys.newtouch.sa/api/external/submit-form", { method: "POST", body: formData, headers: { 'Accept': 'application/json' } }) .then(res => res.json()) .then(data => { if (data.success) { const msgBox = document.getElementById('form-message'); msgBox.style.display = 'block'; msgBox.className = 'alert-box alert-success'; msgBox.textContent = "{{ __('job.success_message') }}"; msgBox.scrollIntoView({ behavior: 'smooth' }); form.reset(); document.querySelectorAll('.error-text').forEach(el => el.textContent = ''); document.querySelectorAll('.input-error').forEach(el => el.classList.remove('input-error')); const cvLabel = document.getElementById('cv-label'); if (cvLabel) { cvLabel.textContent = 'لم يتم اختيار ملف'; cvLabel.style.color = 'rgba(255,255,255,0.6)'; } } else { Swal.fire({ icon: 'error', title: 'لم يتم الإرسال', text: 'حدثت مشكلة أثناء إرسال الطلب، حاول مرة أخرى.' }); } }) .catch(() => { const msgBox = document.getElementById('form-message'); msgBox.style.display = 'block'; msgBox.className = 'alert-box alert-error'; msgBox.textContent = 'حدث خطأ أثناء الإرسال، حاول مرة أخرى.'; msgBox.scrollIntoView({ behavior: 'smooth' }); }) .finally(() => { btn.disabled = false; btnLoader.style.display = 'none'; }); } @endpush @endsection