<!-- المكون الفرعي: --> <!-- stepsSections/step1.vue --> <template> <div class="pt-3…
- Usercode
- Assistant
<div class="lg:grid grid-rows-2 lg:gap-2">
<h1 class="text-lg font-medium mb-1 mt-4 text-black">Name</h1>
<Info
text="Please provide your name exactly as it appears on your current government-issued identification document such as your Passport,
Driver’s License or National Identification Document"
/>
</div>
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<StyledInput
labelText="Employer Name"
:isMandatory="true"
infoText="Employer Name"
inputType="text"
v-model="employerName"
:isValid="store.step1.employer_name.isValid"
:validationMessage="store.step1.employer_name.validationMessage"
name="employer_name"
id="EmployerName"
/>
<SupportingText>Supporting text</SupportingText>
</FieldContainer>
<FieldContainer>
<StyledInput
labelText="First Name"
:isMandatory="true"
infoText="First Name"
inputType="text"
v-model="firstName"
:isValid="store.step1.first_name.isValid"
:validationMessage="store.step1.first_name.validationMessage"
name="first_name"
id="firstName"
/>
</FieldContainer>
</div>
<FieldContainer>
<CheckBox
name="certify"
id="certify"
>
I certify that I do not have a Middle Name on my official identification document
</CheckBox>
</FieldContainer>
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<StyledInput
labelText="Middle Name"
inputType="text"
v-model="middleName"
:isValid="store.step1.middle_name.isValid"
:validationMessage="store.step1.middle_name.validationMessage"
name="middle_name"
id="MiddleName"
/>
</FieldContainer>
</div>
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<StyledInput
labelText="Last Name"
:isMandatory="true"
infoText="Last Name"
inputType="text"
v-model="lastName"
:isValid="store.step1.last_name.isValid"
:validationMessage="store.step1.last_name.validationMessage"
name="last_name"
id="lastName"
/>
</FieldContainer>
<FieldContainer>
<Autocomp
id="suffix"
name="suffix"
labelText="Suffix"
infoText="Select your suffix"
inputType="text"
:options="optionSuffix"
v-model="suffix"
:isValid="store.step1.suffix.isValid"
:validationMessage="store.step1.suffix.validationMessage"
/>
</FieldContainer>
</div>
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<Autocomp
name="country_now"
id="country"
labelText="Country"
infoText="Select your country"
inputType="text"
:options="optionCountry"
v-model="country"
:isValid="store.step1.country_now.isValid"
:validationMessage="store.step1.country_now.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<Textarea
id="street_address"
name="street_address"
labelText="Street Address"
labelColor="blue"
infoText="Street Address"
size="xl"
v-model="streetAddress"
:isValid="store.step1.suffix.isValid"
:validationMessage="store.step1.suffix.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<Autocomp
name="city"
id="city"
labelText="City"
infoText="City"
inputType="text"
:options="optionCity"
v-model="city"
:isValid="store.step1.city.isValid"
:validationMessage="store.step1.city.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<Autocomp
name="governorate"
id="governorate"
labelText="Governorate"
infoText="Governorate"
inputType="text"
:options="optionGovernorate"
v-model="governorate"
:isValid="store.step1.governorate.isValid"
:validationMessage="store.step1.governorate.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<StyledInput
labelText="Location Text"
:isMandatory="true"
infoText="Location Text"
inputType="text"
v-model="locationText"
:isValid="store.step1.location_text.isValid"
:validationMessage="store.step1.location_text.validationMessage"
name="location_text"
id="locationText"
/>
</FieldContainer>
<FieldContainer>
<StyledInput
labelText="Zip Code"
:isMandatory="true"
infoText="Zip Code"
inputType="text"
v-model="zipCode"
:isValid="store.step1.zip_code.isValid"
:validationMessage="store.step1.zip_code.validationMessage"
name="zip_code"
id="zipCode"
/>
</FieldContainer>
</div>
<FieldContainer>
<CheckBox
name="certify"
id="certify"
>
I certify this is my current legal name, exactly as it is displayed on my government-issued identification document *
</CheckBox>
</FieldContainer>
<div class="lg:grid grid-ows-2 lg:gap-2">
<h1 class="text-lg font-medium text-black">Alias Name</h1>
<Info
text="Skip this section if you do not have any alias names.
Please provide:
Any other names appearing on government-issued identity documents where that name differs from your primary identity document; or
A prior legal name which can include your birth surname or any official change to a legal name and government identity documents were issued; or
A name that you use in an “official” capacity which can include any name under which you hold a professional qualification or that you use(d) to apply for any credit or may be recorded in any employee file at a current or past employer."
/>
<!-- <Toggle>
<FieldContainer>
<StyledInput
labelText="First Name"
:isMandatory="true"
infoText="First Name"
inputType="text"
v-model="step1.first_name.value"
@input="handleInput('first_name', step1.first_name.value)"
name="first_name"
id="firstName"
/>
</FieldContainer>
<FieldContainer>
<StyledInput
labelText="Middle Name"
inputType="text"
name="middle_name"
id="MiddleName"
/>
</FieldContainer>
<FieldContainer>
<StyledInput
labelText="Last Name"
:isMandatory="true"
infoText="Last Name"
inputType="text"
v-model="step1.last_name.value"
@input="handleInput('last_name', step1.last_name.value)"
name="last_name"
id="lastName"
/>
</FieldContainer>
</Toggle> -->
</div>
<!-- <InfoRow label="Username" value="Instructions for Verifying Basic Information Instructions for Verifying Basic Information."/> -->
<!-- <Info
text="Instructions for Verifying Basic Information Instructions for Verifying Basic Information."
/> -->
<div class="lg:grid grid-ows-2 lg:gap-2">
<FieldContainer>
<StyledInput
labelText="Email"
:isMandatory="true"
infoText="Please enter your email address"
inputType="email"
name="email"
id="email"
v-model="email"
:isValid="store.step1.email.isValid"
:validationMessage="store.step1.email.validationMessage"
/>
</FieldContainer>
<Info
text=" Taakd may occasionally need to contact you for clarification of items on your Background Verification. We will never share or sell your email address"
/>
</div>
<div class="lg:grid grid-ows-2 lg:gap-2">
<h1 class="text-lg font-medium text-black">Identification</h1>
<Info
text=" Most public records are stored using your name and birth date, so providing this information allows us to accurately search these sources"
/>
</div>
<!-- To Date -->
<FieldContainer>
<StyledInput
id="to_date"
name="to_date"
labelText="To Date"
infoText="End date of your education."
inputType="date"
validationMessage="To Date is required."
/>
</FieldContainer>
</div>
<div class="pt-5 flex w-full justify-center">
<Button level="other" @click="save" :disabled="loading" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
<span v-if="loading">جاري الحفظ...</span>
<span v-else>save -></span>
</Button>
</div>
It looks like you've developed a comprehensive Vue component for collecting personal information, leveraging Vue 3 with the Composition API and Pinia for state management. However, there are a few issues and areas for improvement that I noticed in your code. Below, I'll outline these issues and provide suggestions to enhance your component's functionality and reliability.
computed Property MappingsIn your computed properties, governorate is incorrectly linked to store.step1.city.value, and city is linked to store.step1.governorate.value. This mismatch can cause data binding issues where selecting a city inadvertently updates the governorate and vice versa.
Ensure that each computed property correctly corresponds to its respective state in the store.
const governorate = computed({
get: () => store.step1.governorate.value,
set: (val: string) => store.updateStep1('governorate', { value: val })
});
const city = computed({
get: () => store.step1.city.value,
set: (val: string) => store.updateStep1('city', { value: val })
});
street_address Textareasuffix Instead of street_addressIn your Textarea component for street_address, both :isValid and :validationMessage are incorrectly bound to store.step1.suffix.
<Textarea
id="street_address"
name="street_address"
labelText="Street Address"
labelColor="blue"
infoText="Street Address"
size="xl"
v-model="streetAddress"
:isValid="store.step1.suffix.isValid"
:validationMessage="store.step1.suffix.validationMessage"
/>
street_addressModify the bindings to correctly reference street_address validation state.
<Textarea
id="street_address"
name="street_address"
labelText="Street Address"
labelColor="blue"
infoText="Street Address"
size="xl"
v-model="streetAddress"
:isValid="store.step1.street_address.isValid"
:validationMessage="store.step1.street_address.validationMessage"
/>
CheckBox Components with the Same id and nameCheckBox Components Share the Same id and name AttributesHaving multiple form elements with the same id or name can cause accessibility issues and unexpected behaviors.
<FieldContainer>
<CheckBox
name="certify"
id="certify"
>
I certify that I do not have a Middle Name on my official identification document
</CheckBox>
</FieldContainer>
<!-- ... later in the code ... -->
<FieldContainer>
<CheckBox
name="certify"
id="certify"
>
I certify this is my current legal name, exactly as it is displayed on my government-issued identification document *
</CheckBox>
</FieldContainer>
id and name AttributesEnsure each CheckBox has unique identifiers and consider binding their states to the store if they're intended to capture user inputs.
<FieldContainer>
<CheckBox
name="no_middle_name"
id="no_middle_name"
v-model="noMiddleName"
>
I certify that I do not have a Middle Name on my official identification document
</CheckBox>
</FieldContainer>
<FieldContainer>
<CheckBox
name="confirm_legal_name"
id="confirm_legal_name"
v-model="confirmLegalName"
>
I certify this is my current legal name, exactly as it is displayed on my government-issued identification document *
</CheckBox>
</FieldContainer>
Add Corresponding computed Properties:
const noMiddleName = computed({
get: () => store.step1.no_middle_name.value,
set: (val: boolean) => store.updateStep1('no_middle_name', { value: val })
});
const confirmLegalName = computed({
get: () => store.step1.confirm_legal_name.value,
set: (val: boolean) => store.updateStep1('confirm_legal_name', { value: val })
});
Your validation messages currently say "يرجى تحديد ." and "يرجى اختيار ." which translates to "Please specify ." and "Please choose .", respectively. These messages are vague and could be more descriptive to guide the user effectively.
Enhance the validation messages to clearly indicate what is required.
// For employer_name
if (!step1.employer_name.value) {
store.updateStep1('employer_name', {
isValid: false,
validationMessage: 'يرجى إدخال اسم صاحب العمل.',
});
isValid = false;
} else {
store.updateStep1('employer_name', {
isValid: true,
validationMessage: '',
});
}
// For first_name
if (!step1.first_name.value) {
store.updateStep1('first_name', {
isValid: false,
validationMessage: 'يرجى إدخال الاسم الأول.',
});
isValid = false;
} else {
store.updateStep1('first_name', {
isValid: true,
validationMessage: '',
});
}
// For last_name
if (!step1.last_name.value) {
store.updateStep1('last_name', {
isValid: false,
validationMessage: 'يرجى إدخال الاسم الأخير.',
});
isValid = false;
} else {
store.updateStep1('last_name', {
isValid: true,
validationMessage: '',
});
}
Ensure that all form fields, especially checkboxes and additional inputs like date_of_birth and to_date, are properly bound to the store and include necessary validation.
Example for date_of_birth and to_date:
<FieldContainer>
<StyledInput
id="date_of_birth"
name="date_of_birth"
labelText="Date of Birth"
infoText="تاريخ ميلادك."
inputType="date"
v-model="dateOfBirth"
:isValid="store.step1.date_of_birth.isValid"
:validationMessage="store.step1.date_of_birth.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<StyledInput
id="to_date"
name="to_date"
labelText="To Date"
infoText="تاريخ نهاية التعليم الخاص بك."
inputType="date"
v-model="toDate"
:isValid="store.step1.to_date.isValid"
:validationMessage="store.step1.to_date.validationMessage"
/>
</FieldContainer>
Add Corresponding computed Properties:
const dateOfBirth = computed({
get: () => store.step1.date_of_birth.value,
set: (val: string) => store.updateStep1('date_of_birth', { value: val })
});
const toDate = computed({
get: () => store.step1.to_date.value,
set: (val: string) => store.updateStep1('to_date', { value: val })
});
Implement Validation in the save Function:
// Validate date_of_birth
if (!step1.date_of_birth.value) {
store.updateStep1('date_of_birth', {
isValid: false,
validationMessage: 'يرجى إدخال تاريخ الميلاد.',
});
isValid = false;
} else {
store.updateStep1('date_of_birth', {
isValid: true,
validationMessage: '',
});
}
// Validate to_date
if (!step1.to_date.value) {
store.updateStep1('to_date', {
isValid: false,
validationMessage: 'يرجى إدخال تاريخ النهاية.',
});
isValid = false;
} else {
store.updateStep1('to_date', {
isValid: true,
validationMessage: '',
});
}
The save button currently displays 'save ->' when not loading, which might be confusing in a localized (Arabic) context.
Update the button text to Arabic and ensure all form elements are accessible.
<div class="pt-5 flex w-full justify-center">
<Button
level="other"
@click="save"
:disabled="loading"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
>
<span v-if="loading">جاري الحفظ...</span>
<span v-else>حفظ</span>
</Button>
</div>
Improve Accessibility:
label elements are correctly associated with their corresponding inputs using the for attribute.aria attributes where necessary to enhance screen reader compatibility.Cleaning up commented-out code and unused imports can make your component more maintainable and readable.
Review and remove any commented sections or unused imports unless they're placeholders for future development.
<!-- Remove or uncomment and properly implement if needed -->
<!-- <Toggle>
...
</Toggle> -->
<!-- Remove unused imports -->
// import InfoRow from '../../components/InfoRow.vue';
// import Toggle from "../../components/toggle.vue";
// import FieldsGroup from "../../components/fieldsGroup.vue";
Here's the revised version of your component incorporating the discussed changes:
Form Accessibility: Ensure all form controls are accessible by adding appropriate aria attributes and ensuring color contrasts meet accessibility standards.
Error Handling: Implement more granular error handling in the save function to provide users with specific feedback on what went wrong.
Internationalization (i18n): If your application needs to support multiple languages, consider integrating a localization library like vue-i18n to manage translations effectively.
Reusable Components: Make sure components like CheckBox, StyledInput, and Autocomp are fully reusable and handle all necessary props and events to facilitate ease of maintenance and scalability.
By addressing these issues and implementing the suggested improvements, your Vue component will be more robust, user-friendly, and maintainable. If you have specific questions or need further assistance with any part of the component, feel free to ask!
Not yet included in a published release.
<!-- stepsSections/step1.vue -->
<template>
<div class="pt-3 container">
<h1 class="text-3xl font-bold mb-3 text-black">Personal Information</h1>
<ul>
<li>All fields marked with an asterisk ( * ) are required.</li>
<li>
Providing your information as completely and accurately as possible will help speed up the completion of your Background Verification
</li>
</ul>
<!-- Name Section -->
<div class="lg:grid grid-rows-2 lg:gap-2">
<h1 class="text-lg font-medium mb-1 mt-4 text-black">Name</h1>
<Info
text="Please provide your name exactly as it appears on your current government-issued identification document such as your Passport, Driver’s License or National Identification Document"
/>
</div>
<!-- Employer and First Name -->
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<StyledInput
labelText="Employer Name"
:isMandatory="true"
infoText="Employer Name"
inputType="text"
v-model="employerName"
:isValid="store.step1.employer_name.isValid"
:validationMessage="store.step1.employer_name.validationMessage"
name="employer_name"
id="EmployerName"
/>
<SupportingText>Supporting text</SupportingText>
</FieldContainer>
<FieldContainer>
<StyledInput
labelText="First Name"
:isMandatory="true"
infoText="First Name"
inputType="text"
v-model="firstName"
:isValid="store.step1.first_name.isValid"
:validationMessage="store.step1.first_name.validationMessage"
name="first_name"
id="firstName"
/>
</FieldContainer>
</div>
<!-- No Middle Name Certification -->
<FieldContainer>
<CheckBox
name="no_middle_name"
id="no_middle_name"
v-model="noMiddleName"
>
I certify that I do not have a Middle Name on my official identification document
</CheckBox>
</FieldContainer>
<!-- Middle Name -->
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<StyledInput
labelText="Middle Name"
inputType="text"
v-model="middleName"
:isValid="store.step1.middle_name.isValid"
:validationMessage="store.step1.middle_name.validationMessage"
name="middle_name"
id="MiddleName"
/>
</FieldContainer>
</div>
<!-- Last Name and Suffix -->
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<StyledInput
labelText="Last Name"
:isMandatory="true"
infoText="Last Name"
inputType="text"
v-model="lastName"
:isValid="store.step1.last_name.isValid"
:validationMessage="store.step1.last_name.validationMessage"
name="last_name"
id="lastName"
/>
</FieldContainer>
<FieldContainer>
<Autocomp
id="suffix"
name="suffix"
labelText="Suffix"
infoText="Select your suffix"
inputType="text"
:options="optionSuffix"
v-model="suffix"
:isValid="store.step1.suffix.isValid"
:validationMessage="store.step1.suffix.validationMessage"
/>
</FieldContainer>
</div>
<!-- Country, Street Address, City, Governorate, Location Text, Zip Code -->
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<Autocomp
name="country_now"
id="country"
labelText="Country"
infoText="Select your country"
inputType="text"
:options="optionCountry"
v-model="country"
:isValid="store.step1.country_now.isValid"
:validationMessage="store.step1.country_now.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<Textarea
id="street_address"
name="street_address"
labelText="Street Address"
labelColor="blue"
infoText="Street Address"
size="xl"
v-model="streetAddress"
:isValid="store.step1.street_address.isValid"
:validationMessage="store.step1.street_address.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<Autocomp
name="city"
id="city"
labelText="City"
infoText="City"
inputType="text"
:options="optionCity"
v-model="city"
:isValid="store.step1.city.isValid"
:validationMessage="store.step1.city.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<Autocomp
name="governorate"
id="governorate"
labelText="Governorate"
infoText="Governorate"
inputType="text"
:options="optionGovernorate"
v-model="governorate"
:isValid="store.step1.governorate.isValid"
:validationMessage="store.step1.governorate.validationMessage"
/>
</FieldContainer>
<FieldContainer>
<StyledInput
labelText="Location Text"
:isMandatory="true"
infoText="Location Text"
inputType="text"
v-model="locationText"
:isValid="store.step1.location_text.isValid"
:validationMessage="store.step1.location_text.validationMessage"
name="location_text"
id="locationText"
/>
</FieldContainer>
<FieldContainer>
<StyledInput
labelText="Zip Code"
:isMandatory="true"
infoText="Zip Code"
inputType="text"
v-model="zipCode"
:isValid="store.step1.zip_code.isValid"
:validationMessage="store.step1.zip_code.validationMessage"
name="zip_code"
id="zipCode"
/>
</FieldContainer>
</div>
<!-- Confirmation of Legal Name -->
<FieldContainer>
<CheckBox
name="confirm_legal_name"
id="confirm_legal_name"
v-model="confirmLegalName"
>
I certify this is my current legal name, exactly as it is displayed on my government-issued identification document *
</CheckBox>
</FieldContainer>
<!-- Alias Name Section -->
<div class="lg:grid grid-cols-2 lg:gap-2">
<h1 class="text-lg font-medium text-black">Alias Name</h1>
<Info
text="Skip this section if you do not have any alias names. Please provide:
- Any other names appearing on government-issued identity documents where that name differs from your primary identity document; or
- A prior legal name which can include your birth surname or any official change to a legal name and government identity documents were issued; or
- A name that you use in an “official” capacity which can include any name under which you hold a professional qualification or that you use(d) to apply for any credit or may be recorded in any employee file at a current or past employer."
/>
</div>
<!-- Email and Additional Info -->
<div class="lg:grid grid-cols-2 lg:gap-2">
<FieldContainer>
<StyledInput
labelText="Email"
:isMandatory="true"
infoText="Please enter your email address"
inputType="email"
name="email"
id="email"
v-model="email"
:isValid="store.step1.email.isValid"
:validationMessage="store.step1.email.validationMessage"
/>
</FieldContainer>
<Info
text="Taakd may occasionally need to contact you for clarification of items on your Background Verification. We will never share or sell your email address."
/>
</div>
<!-- Identification Section -->
<div class="lg:grid grid-cols-2 lg:gap-2">
<h1 class="text-lg font-medium text-black">Identification</h1>
<Info
text="Most public records are stored using your name and birth date, so providing this information allows us to accurately search these sources."
/>
</div>
<!-- Date Fields -->
<div class="lg:grid grid-cols-2 lg:gap-2">
<!-- Date of Birth -->
<FieldContainer>
<StyledInput
id="date_of_birth"
name="date_of_birth"
labelText="Date of Birth"
infoText="تاريخ ميلادك."
inputType="date"
v-model="dateOfBirth"
:isValid="store.step1.date_of_birth.isValid"
:validationMessage="store.step1.date_of_birth.validationMessage"
/>
</FieldContainer>
<!-- To Date -->
<FieldContainer>
<StyledInput
id="to_date"
name="to_date"
labelText="To Date"
infoText="تاريخ نهاية التعليم الخاص بك."
inputType="date"
v-model="toDate"
:isValid="store.step1.to_date.isValid"
:validationMessage="store.step1.to_date.validationMessage"
/>
</FieldContainer>
</div>
<!-- Save Button -->
<div class="pt-5 flex w-full justify-center">
<Button
level="other"
@click="save"
:disabled="loading"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
>
<span v-if="loading">جاري الحفظ...</span>
<span v-else>حفظ</span>
</Button>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue';
import { useVerificationRequestStore } from '../../stores/verificationRequest';
import CheckBox from '../../components/checkBox.vue';
import FieldContainer from '../../components/fieldContainer.vue';
import StyledInput from '../../components/styledInput.vue';
import SupportingText from '../../components/supportingText.vue';
import Info from './components/info.vue';
import { useToast } from 'vue-toastification';
import Button from '../../components/button.vue';
import Autocomp from '../../components/autocomp.vue';
import Textarea from '../../components/textarea.vue';
const store = useVerificationRequestStore();
const toast = useToast();
// Loading State
const loading = ref(false);
// Dropdown Options
const optionSuffix = reactive([
{ value: "", label: "" },
{ value: "Junior (Jr.)", label: "Junior (Jr.)" },
{ value: "Senior (Sr.)", label: "Senior (Sr.)" },
]);
const optionCountry = ['اليمن', 'المملكة العربية السعودية', 'الإمارات', 'قطر', 'البحرين'];
const optionCity = ['الرياض', 'جدة', 'مكة', 'الدمام', 'الخبر'];
const optionGovernorate = ['البطحاء', 'الرحمانية', 'مهد الرمثية', 'السليمانية', 'أبها'];
// Load Data on Mount
onMounted(async () => {
loading.value = true;
await store.loadDocument();
loading.value = false;
});
// Computed Properties for Form Fields
const employerName = computed({
get: () => store.step1.employer_name.value,
set: (val: string) => store.updateStep1('employer_name', { value: val })
});
const firstName = computed({
get: () => store.step1.first_name.value,
set: (val: string) => store.updateStep1('first_name', { value: val })
});
const lastName = computed({
get: () => store.step1.last_name.value,
set: (val: string) => store.updateStep1('last_name', { value: val })
});
const middleName = computed({
get: () => store.step1.middle_name.value,
set: (val: string) => store.updateStep1('middle_name', { value: val })
});
const suffix = computed({
get: () => store.step1.suffix.value,
set: (val: string) => store.updateStep1('suffix', { value: val })
});
const country = computed({
get: () => store.step1.country_now.value,
set: (val: string) => store.updateStep1('country_now', { value: val })
});
const governorate = computed({
get: () => store.step1.governorate.value,
set: (val: string) => store.updateStep1('governorate', { value: val })
});
const city = computed({
get: () => store.step1.city.value,
set: (val: string) => store.updateStep1('city', { value: val })
});
const locationText = computed({
get: () => store.step1.location_text.value,
set: (val: string) => store.updateStep1('location_text', { value: val })
});
const streetAddress = computed({
get: () => store.step1.street_address.value,
set: (val: string) => store.updateStep1('street_address', { value: val })
});
const zipCode = computed({
get: () => store.step1.zip_code.value,
set: (val: string) => store.updateStep1('zip_code', { value: val })
});
const email = computed({
get: () => store.step1.email.value,
set: (val: string) => store.updateStep1('email', { value: val })
});
const noMiddleName = computed({
get: () => store.step1.no_middle_name.value,
set: (val: boolean) => store.updateStep1('no_middle_name', { value: val })
});
const confirmLegalName = computed({
get: () => store.step1.confirm_legal_name.value,
set: (val: boolean) => store.updateStep1('confirm_legal_name', { value: val })
});
const dateOfBirth = computed({
get: () => store.step1.date_of_birth.value,
set: (val: string) => store.updateStep1('date_of_birth', { value: val })
});
const toDate = computed({
get: () => store.step1.to_date.value,
set: (val: string) => store.updateStep1('to_date', { value: val })
});
// Save Function with Validation
const save = async () => {
const { step1 } = store;
let isValid = true;
// Employer Name Validation
if (!step1.employer_name.value) {
store.updateStep1('employer_name', {
isValid: false,
validationMessage: 'يرجى إدخال اسم صاحب العمل.',
});
isValid = false;
} else {
store.updateStep1('employer_name', {
isValid: true,
validationMessage: '',
});
}
// First Name Validation
if (!step1.first_name.value) {
store.updateStep1('first_name', {
isValid: false,
validationMessage: 'يرجى إدخال الاسم الأول.',
});
isValid = false;
} else {
store.updateStep1('first_name', {
isValid: true,
validationMessage: '',
});
}
// Last Name Validation
if (!step1.last_name.value) {
store.updateStep1('last_name', {
isValid: false,
validationMessage: 'يرجى إدخال الاسم الأخير.',
});
isValid = false;
} else {
store.updateStep1('last_name', {
isValid: true,
validationMessage: '',
});
}
// Date of Birth Validation
if (!step1.date_of_birth.value) {
store.updateStep1('date_of_birth', {
isValid: false,
validationMessage: 'يرجى إدخال تاريخ الميلاد.',
});
isValid = false;
} else {
store.updateStep1('date_of_birth', {
isValid: true,
validationMessage: '',
});
}
// To Date Validation
if (!step1.to_date.value) {
store.updateStep1('to_date', {
isValid: false,
validationMessage: 'يرجى إدخال تاريخ النهاية.',
});
isValid = false;
} else {
store.updateStep1('to_date', {
isValid: true,
validationMessage: '',
});
}
// Confirm Legal Name Validation
if (!step1.confirm_legal_name.value) {
toast.error('يرجى تأكيد أن الاسم القانوني صحيح.');
isValid = false;
}
if (!isValid) {
toast.error('يرجى تصحيح الأخطاء قبل الحفظ.');
return;
}
// Proceed to Save Data
try {
loading.value = true;
const updatedFields = {
employer_name: store.step1.employer_name.value,
first_name: store.step1.first_name.value,
last_name: store.step1.last_name.value,
middle_name: store.step1.middle_name.value,
suffix: store.step1.suffix.value,
country_now: store.step1.country_now.value,
city: store.step1.city.value,
governorate: store.step1.governorate.value,
location_text: store.step1.location_text.value,
street_address: store.step1.street_address.value,
zip_code: store.step1.zip_code.value,
email: store.step1.email.value,
no_middle_name: store.step1.no_middle_name.value,
confirm_legal_name: store.step1.confirm_legal_name.value,
date_of_birth: store.step1.date_of_birth.value,
to_date: store.step1.to_date.value,
// Add other fields as necessary
};
console.log("Updated Fields:", updatedFields);
await store.updateDocumentFields(updatedFields);
toast.success('تم حفظ البيانات بنجاح.');
} catch (error) {
console.error('Error saving data:', error);
toast.error('حدث خطأ أثناء حفظ البيانات.');
} finally {
loading.value = false;
}
};
</script>
<style scoped>
/* Add additional styles if necessary */
</style>