<template> <div class="min-h-screen bg-background p-6"> <div class="max-w-7xl mx-auto">…
- Usercode
- Assistant
</div>
</section>
<!-- Education Information Section -->
<section class="mb-8">
<div class="bg-white shadow-lg rounded-lg">
<div class="px-6 py-4 border-b flex justify-between items-center">
<h2 class="text-2xl font-semibold text-black flex">
Step 2: Education Information
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.66699 25.3337H8.34899L21.9977 11.685L20.3157 10.003L6.66699 23.6517V25.3337ZM5.87233 27.3337C5.53077 27.3337 5.24455 27.2181 5.01366 26.987C4.78255 26.7561 4.66699 26.4699 4.66699 26.1283V23.8183C4.66699 23.4932 4.72944 23.1833 4.85433 22.8887C4.97899 22.594 5.15077 22.3372 5.36966 22.1183L22.2543 5.24132C22.4559 5.05821 22.6784 4.91677 22.922 4.81699C23.1658 4.71699 23.4213 4.66699 23.6887 4.66699C23.956 4.66699 24.2149 4.71444 24.4653 4.80933C24.716 4.90422 24.9379 5.0551 25.131 5.26199L26.7593 6.91066C26.9662 7.10377 27.1137 7.32599 27.2017 7.57733C27.2897 7.82866 27.3337 8.07999 27.3337 8.33133C27.3337 8.59955 27.2879 8.85544 27.1963 9.09899C27.1048 9.34277 26.9591 9.56544 26.7593 9.76699L9.88232 26.631C9.66344 26.8499 9.40666 27.0217 9.11199 27.1463C8.81733 27.2712 8.50744 27.3337 8.18233 27.3337H5.87233ZM21.142 10.8587L20.3157 10.003L21.9977 11.685L21.142 10.8587Z" fill="#81C045"/>
</svg>
</h2>
<svg
@click="toggleSection('education')"
:class="{'transform rotate-180': isOpen.education}"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-black cursor-pointer transition-transform duration-300"
fill="none" viewBox="0 0 24 24" stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</div>
<transition name="fade">
<div v-show="isOpen.education" class="px-6 py-4">
<div v-if="request.doc.education_information && request.doc.education_information.length">
<div v-for="(education, index) in request.doc.education_information" :key="education.id" class="mb-6">
<div class="flex justify-between items-center mb-2">
<h3 class="text-xl font-medium text-black flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-green-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c1.1046 0 2 .8954 2 2v2c0 1.1046-.8954 2-2 2s-2-.8954-2-2V10c0-1.1046.8954-2 2-2z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 10h-6l-2 2H5v6h14v-6z" />
</svg>
{{ education.name_of_school_or_college_university || `تعليم ${index + 1}` }}
</h3>
<span class="text-sm text-mutedText">#{{ index + 1 }}</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="space-y-2">
<InfoRow label="اسم المدرسة/الكلية/الجامعة" :value="education.name_of_school_or_college_university" />
<InfoRow label="مجال الدراسة/التخصص" :value="education.field_of_study_or_major" />
</div>
<div class="space-y-2">
<InfoRow label="البلد" :value="education.country" />
<InfoRow label="المدينة" :value="education.city" />
<InfoRow label="المحافظة" :value="education.governorate" />
<InfoRow label="تفاصيل الموقع" :value="education.location_text || 'N/A'" />
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
<div class="space-y-2">
<InfoRow label="تاريخ البدء" :value="formatDate(education.from_date)" />
<InfoRow label="تاريخ الانتهاء" :value="formatDate(education.to_date)" />
</div>
<div class="space-y-2">
<InfoRow label="الهاتف" :value="education.phone" />
<InfoRow label="الامتداد" :value="education.ext || 'N/A'" />
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
<div class="space-y-2">
<InfoRow label="الدبلوم" :value="education.diploma" />
<InfoRow label="اسم آخر" :value="education.another_name || 'لا'" />
</div>
</div>
</div>
</div>
<div v-else>
<p class="text-mutedText">لا توجد سجلات لمعلومات التعليم.</p>
</div>
</div>
</transition>
</div>
</section>
<!-- Employment History Section -->
<section class="mb-8">
<div class="bg-white shadow-lg rounded-lg">
<div class="px-6 py-4 border-b flex justify-between items-center">
<h2 class="text-2xl font-semibold text-black flex pr-2">
Step 3: Employment History
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.66699 25.3337H8.34899L21.9977 11.685L20.3157 10.003L6.66699 23.6517V25.3337ZM5.87233 27.3337C5.53077 27.3337 5.24455 27.2181 5.01366 26.987C4.78255 26.7561 4.66699 26.4699 4.66699 26.1283V23.8183C4.66699 23.4932 4.72944 23.1833 4.85433 22.8887C4.97899 22.594 5.15077 22.3372 5.36966 22.1183L22.2543 5.24132C22.4559 5.05821 22.6784 4.91677 22.922 4.81699C23.1658 4.71699 23.4213 4.66699 23.6887 4.66699C23.956 4.66699 24.2149 4.71444 24.4653 4.80933C24.716 4.90422 24.9379 5.0551 25.131 5.26199L26.7593 6.91066C26.9662 7.10377 27.1137 7.32599 27.2017 7.57733C27.2897 7.82866 27.3337 8.07999 27.3337 8.33133C27.3337 8.59955 27.2879 8.85544 27.1963 9.09899C27.1048 9.34277 26.9591 9.56544 26.7593 9.76699L9.88232 26.631C9.66344 26.8499 9.40666 27.0217 9.11199 27.1463C8.81733 27.2712 8.50744 27.3337 8.18233 27.3337H5.87233ZM21.142 10.8587L20.3157 10.003L21.9977 11.685L21.142 10.8587Z" fill="#81C045"/>
</svg>
</h2>
<svg
@click="toggleSection('employment')"
:class="{'transform rotate-180': isOpen.employment}"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-black cursor-pointer transition-transform duration-300"
fill="none" viewBox="0 0 24 24" stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</div>
<transition name="fade">
<div v-show="isOpen.employment" class="px-6 py-4">
<div v-if="request.doc.employment_history && request.doc.employment_history.length">
<div v-for="(employment, index) in request.doc.employment_history" :key="employment.id" class="mb-6">
<div class="flex justify-between items-center mb-2">
<h3 class="text-xl font-medium text-text flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-primary" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c1.1046 0 2 .8954 2 2v2c0 1.1046-.8954 2-2 2s-2-.8954-2-2V10c0-1.1046.8954-2 2-2z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 10h-6l-2 2H5v6h14v-6z" />
</svg>
{{ employment.company || `وظيفة ${index + 1}` }}
</h3>
<span class="text-sm text-mutedText">#{{ index + 1 }}</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="space-y-2">
<InfoRow label="الشركة" :value="employment.company" />
<InfoRow label="اسم صاحب العمل" :value="employment.name_of_your_employer" />
<InfoRow label="إذن للاتصال بالمُشغّل" :value="employment.contact_the_employer ? 'نعم' : 'لا'" />
<InfoRow label="إصدار الراتب من قبل الشركة" :value="employment.issuing_salary ? 'نعم' : 'لا'" />
</div>
<div class="space-y-2">
<InfoRow label="البلد" :value="employment.country" />
<InfoRow label="المدينة" :value="employment.city" />
<InfoRow label="المحافظة" :value="employment.governorate" />
<InfoRow label="تفاصيل الموقع" :value="employment.location_text || 'N/A'" />
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
<div class="space-y-2">
<InfoRow label="استمرارية الوظيفة" :value="employment.continuous ? 'نعم' : 'لا'" />
<InfoRow label="نشاط الوظيفة متوقف" :value="employment.activity_has_stopped ? 'نعم' : 'لا'" />
</div>
<div class="space-y-2">
<InfoRow label="تاريخ البدء" :value="formatDate(employment.from_date)" />
<InfoRow label="تاريخ الانتهاء" :value="formatDate(employment.end_date)" />
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
<div class="space-y-2">
<InfoRow label="الهاتف" :value="employment.phone" />
<InfoRow label="الامتداد" :value="employment.ext || 'N/A'" />
</div>
<div class="space-y-2">
<InfoRow label="المسمى الوظيفي الحالي" :value="employment.official_job_title_held_currently" />
<InfoRow label="نوع الوظيفة" :value="employment.type_of_employment" />
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
<div class="space-y-2">
<InfoRow label="الشركة لها أسماء مختلفة" :value="employment.the_company_has_different_names ? 'نعم' : 'لا'" />
<InfoRow label="لديك لقب" :value="employment.you_have_a_nicknamecx ? 'نعم' : 'لا'" />
</div>
<div class="space-y-2">
<InfoRow label="أسماء الشركة المختلفة" :value="employment.different_company_names || 'N/A'" />
<InfoRow label="اللقب" :value="employment.nickname || 'N/A'" />
</div>
</div>
</div>
</div>
<div v-else>
<p class="text-mutedText">لا توجد سجلات لتاريخ التوظيف.</p>
</div>
</div>
</transition>
</div>
</section>
<!-- Professional Qualifications Section -->
<section class="mb-8">
<div class="bg-white shadow-lg rounded-lg">
<div class="px-6 py-4 border-b flex justify-between items-center">
<h2 class="text-2xl font-semibold text-black flex">
Step 4:Professional qualification verification
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.66699 25.3337H8.34899L21.9977 11.685L20.3157 10.003L6.66699 23.6517V25.3337ZM5.87233 27.3337C5.53077 27.3337 5.24455 27.2181 5.01366 26.987C4.78255 26.7561 4.66699 26.4699 4.66699 26.1283V23.8183C4.66699 23.4932 4.72944 23.1833 4.85433 22.8887C4.97899 22.594 5.15077 22.3372 5.36966 22.1183L22.2543 5.24132C22.4559 5.05821 22.6784 4.91677 22.922 4.81699C23.1658 4.71699 23.4213 4.66699 23.6887 4.66699C23.956 4.66699 24.2149 4.71444 24.4653 4.80933C24.716 4.90422 24.9379 5.0551 25.131 5.26199L26.7593 6.91066C26.9662 7.10377 27.1137 7.32599 27.2017 7.57733C27.2897 7.82866 27.3337 8.07999 27.3337 8.33133C27.3337 8.59955 27.2879 8.85544 27.1963 9.09899C27.1048 9.34277 26.9591 9.56544 26.7593 9.76699L9.88232 26.631C9.66344 26.8499 9.40666 27.0217 9.11199 27.1463C8.81733 27.2712 8.50744 27.3337 8.18233 27.3337H5.87233ZM21.142 10.8587L20.3157 10.003L21.9977 11.685L21.142 10.8587Z" fill="#81C045"/>
</svg>
</h2>
<svg
@click="toggleSection('professional')"
:class="{'transform rotate-180': isOpen.professional}"
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-black cursor-pointer transition-transform duration-300"
fill="none" viewBox="0 0 24 24" stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</div>
<transition name="fade">
<div v-show="isOpen.professional" class="px-6 py-4">
<div v-if="request.doc.professional_qualification && request.doc.professional_qualification.length">
<div v-for="(qualification, index) in request.doc.professional_qualification" :key="qualification.id" class="mb-6">
<div class="flex justify-between items-center mb-2">
<h3 class="text-xl font-medium text-gray-800 flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-black" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c1.1046 0 2 .8954 2 2v2c0 1.1046-.8954 2-2 2s-2-.8954-2-2V10c0-1.1046.8954-2 2-2z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 10h-6l-2 2H5v6h14v-6z" />
</svg>
{{ qualification.awarding_body || `مؤهل مهني ${index + 1}` }}
</h3>
<span class="text-sm text-mutedText">#{{ index + 1 }}</span>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="space-y-2">
<InfoRow label="الجهة المانحة" :value="qualification.awarding_body" />
<InfoRow label="رقم الرخصة أو الشهادة" :value="qualification.license_or_certificate_number" />
<InfoRow label="البلد المصدّر" :value="qualification.issuing_country" />
</div>
<div class="space-y-2">
<InfoRow label="تاريخ الحصول" :value="formatDate(qualification.date_awarded)" />
<InfoRow label="تاريخ الانتهاء" :value="qualification.is_an_expiration_date ? formatDate(qualification.expiration_date) : 'N/A'" />
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
<div class="space-y-2">
<InfoRow label="اسم الجوائز/الوصف" :value="qualification.award_name_description" />
</div>
<div class="space-y-2">
<InfoRow label="تاريخ انتهاء المؤهل" :value="qualification.is_an_expiration_date ? 'نعم' : 'لا'" />
<InfoRow label="اسمك يتغير في هذا المؤهل" :value="qualification.your_name_varies ? 'نعم' : 'لا'" />
</div>
</div>
</div>
</div>
<div v-else>
<p class="text-mutedText">لا توجد سجلات للمؤهلات المهنية.</p>
</div>
</div>
</transition>
</div>
</section>
<!-- Footer -->
<!-- <footer class="text-center text-mutedText mt-12">
© 2024 Asofi . جميع الحقوق محفوظة.
</footer> -->
</div>
Your Vue component is well-structured and comprehensive, effectively organizing the review of various user information sections. However, there are a few areas where improvements can be made to enhance maintainability, usability, and alignment with best practices. Below are some recommendations and observations:
In your <style scoped> section, you're redefining Tailwind's utility classes such as .text-black, .text-primary, etc. For example:
.text-black {
color: #10B981; /* This is a green color, not black */
}
Overriding Tailwind's default utility classes can lead to confusion and unexpected styling across your application, especially if other components rely on Tailwind's standard styling.
Instead of overriding Tailwind's classes, define custom classes with unique names for your specific color needs. For example:
/* Custom color classes */
.text-custom-green {
color: #10B981;
}
.text-custom-primary {
color: #1E40AF;
}
Then, update your template to use these custom classes:
<h1 class="text-4xl font-bold text-custom-green"> Review your information </h1>
Your main component handles multiple sections (Personal Information, Education Information, Employment History, Professional Qualifications) within a single file. While you use the InfoRow component, further decomposition can improve readability and maintainability.
Create separate sub-components for each section. This approach promotes reusability and makes each component easier to manage and test.
Example Structure:
components/
├── Review/
│ ├── PersonalInfo.vue
│ ├── EducationInfo.vue
│ ├── EmploymentHistory.vue
│ └── ProfessionalQualifications.vue
├── InfoRow.vue
Example: PersonalInfo.vue
<template>
<section class="mb-8">
<div class="bg-white shadow-lg rounded-lg">
<div class="px-6 py-4 border-b flex justify-between items-center">
<h2 class="text-2xl font-semibold text-custom-green flex">
Step 1: Personal Information
<!-- SVG Icon -->
</h2>
<svg
@click="toggleSection"
:class="{'transform rotate-180': isOpen}"
class="h-6 w-6 text-black cursor-pointer transition-transform duration-300"
fill="none" viewBox="0 0 24 24" stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</div>
<transition name="fade">
<div v-show="isOpen" class="px-6 py-4">
<!-- Personal Information Content -->
</div>
</transition>
</div>
</section>
</template>
<script setup>
import { ref } from 'vue'
const isOpen = ref(true)
const toggleSection = () => {
isOpen.value = !isOpen.value
}
</script>
Then, in your main component, you can import and use these sub-components:
<template>
<div class="min-h-screen bg-background p-6">
<div class="max-w-7xl mx-auto">
<!-- Header -->
<header class="mb-8 text-center">
<!-- Header Content -->
</header>
<!-- Sections -->
<PersonalInfo />
<EducationInfo />
<EmploymentHistory />
<ProfessionalQualifications />
<!-- Footer -->
</div>
</div>
</template>
<script setup>
import PersonalInfo from '../../components/Review/PersonalInfo.vue'
import EducationInfo from '../../components/Review/EducationInfo.vue'
import EmploymentHistory from '../../components/Review/EmploymentHistory.vue'
import ProfessionalQualifications from '../../components/Review/ProfessionalQualifications.vue'
</script>
The collapsible sections are currently toggled using SVG icons without any accessibility considerations. Screen readers and keyboard navigation might not interpret these toggles correctly.
Enhance accessibility by using semantic HTML elements and ARIA attributes. For example, use <button> elements for toggles and manage aria-expanded states.
Example:
<button
@click="toggleSection"
:aria-expanded="isOpen"
class="flex items-center focus:outline-none"
>
<svg
:class="{'transform rotate-180': isOpen}"
class="h-6 w-6 text-black transition-transform duration-300"
fill="none" viewBox="0 0 24 24" stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
Additionally, ensure that all interactive elements are keyboard accessible and provide meaningful focus states.
The formatDate function uses the browser's locale by default. Depending on your user base, this might lead to inconsistent date formats.
Consider specifying a locale or allowing the user to select their preferred date format. This ensures consistency across different users.
Example:
const formatDate = (dateStr) => {
if (!dateStr) return 'N/A'
const options = { year: 'numeric', month: 'long', day: 'numeric' }
return new Date(dateStr).toLocaleDateString('ar-EG', options) // Specify Arabic (Egypt) locale
}
Alternatively, use a library like date-fns or Moment.js for more advanced date formatting and localization.
watch LogicThe watch function initializes certain fields if they are missing. However, directly mutating newDoc inside the watch might not be reactive, especially if createDocumentResource doesn't anticipate such mutations.
Ensure that the data structure is correctly initialized when fetching the document. If createDocumentResource allows for setting default values, utilize that feature. Otherwise, consider using computed properties or default values in your template to handle missing data gracefully.
Example: Using Computed Properties
import { computed } from 'vue'
const employmentHistory = computed(() => request.doc.employment_history || [])
const educationInformation = computed(() => request.doc.education_information || [])
const professionalQualification = computed(() => request.doc.professional_qualification || [])
Then, update your template to use these computed properties:
<div v-if="employmentHistory.length">
<div v-for="(employment, index) in employmentHistory" :key="employment.id">
<!-- Employment Content -->
</div>
</div>
<div v-else>
<p class="text-mutedText">لا توجد سجلات لتاريخ التوظيف.</p>
</div>
While you handle missing data by showing 'N/A', consider other edge cases such as invalid dates or unexpected data types.
Enhance your data handling to validate and sanitize inputs. This can prevent runtime errors and improve the user experience.
Example: Enhanced formatDate Function
const formatDate = (dateStr) => {
if (!dateStr || isNaN(Date.parse(dateStr))) return 'N/A'
const options = { year: 'numeric', month: 'long', day: 'numeric' }
return new Date(dateStr).toLocaleDateString('ar-EG', options)
}
Additionally, ensure that all dynamic data is properly escaped or sanitized to prevent security vulnerabilities like XSS attacks.
The current styles redefine some utility classes and use specific color codes directly within the CSS, which might reduce flexibility.
Leverage Tailwind's configuration to define custom colors and extend the utility classes. This maintains utility-first benefits while allowing customization.
Example: Extending Tailwind in tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
'custom-green': '#10B981',
'custom-primary': '#1E40AF',
// Add more custom colors as needed
},
},
},
}
Then, use these custom color classes directly in your template without needing to define them in scoped CSS:
<h1 class="text-4xl font-bold text-custom-green"> Review your information </h1>
This approach maintains consistency and leverages Tailwind's powerful utility classes without conflicts.
Large amounts of data rendered conditionally can impact performance, especially if the data grows.
Implement lazy loading or pagination for sections with extensive data. Additionally, use Vue's v-memo or v-once where appropriate to prevent unnecessary re-renders.
Example: Using v-if Efficiently
Ensure that heavy computations or large loops are only processed when necessary.
<transition name="fade">
<div v-show="isOpen.education" class="px-6 py-4">
<!-- Education Content -->
</div>
</transition>
Consider using v-if instead of v-show if the content is significantly large and you want to prevent it from being in the DOM when not visible.
The print functionality is straightforward, but consider adding feedback once the print dialog is triggered.
Use the vue-toastification library to notify users that the print dialog has been opened.
Example:
const printReport = () => {
window.print()
toast.success('تم فتح نافذة الطباعة.')
}
This provides immediate feedback to the user, enhancing the user experience.
While some parts of the code are commented, adding more descriptive comments can help future developers understand the logic better.
Include comments explaining complex logic, especially within the watch function and computed properties. This aids in maintainability and onboarding new developers.
Example:
// Watch the request document and ensure essential fields are initialized
watch(() => request.doc, (newDoc) => {
if (newDoc) {
if (!newDoc.employment_history) {
newDoc.employment_history = []
}
// Initialize other fields similarly
}
}, { immediate: true })
Ensure that each section and its toggle functionality work as expected across different scenarios.
Implement unit tests using Vue Test Utils and a testing framework like Jest to automate testing of component behavior.
Example: Testing Toggle Functionality
import { mount } from '@vue/test-utils'
import PersonalInfo from '@/components/Review/PersonalInfo.vue'
describe('PersonalInfo.vue', () => {
it('toggles section visibility when toggle button is clicked', async () => {
const wrapper = mount(PersonalInfo)
expect(wrapper.find('.px-6.py-4').isVisible()).toBe(true)
const toggleButton = wrapper.find('button')
await toggleButton.trigger('click')
expect(wrapper.find('.px-6.py-4').isVisible()).toBe(false)
await toggleButton.trigger('click')
expect(wrapper.find('.px-6.py-4').isVisible()).toBe(true)
})
})
Your component effectively organizes and displays user information with a clear structure. By addressing the points above, you can enhance its maintainability, usability, and alignment with best practices. This will lead to a more robust and user-friendly application.
If you have any specific questions or need further assistance with particular aspects of your component, feel free to ask!
Not yet included in a published release.