|
|
@@ -117,12 +117,9 @@ const stepThreeForm = ref({
|
|
|
});
|
|
|
|
|
|
const stepFourForm = ref({
|
|
|
- selfie_file: null,
|
|
|
- selfie_base64: '',
|
|
|
- document_front_file: null,
|
|
|
- document_front_base64: '',
|
|
|
- document_back_file: null,
|
|
|
- document_back_base64: '',
|
|
|
+ selfie: null,
|
|
|
+ document_front: null,
|
|
|
+ document_back: null,
|
|
|
});
|
|
|
|
|
|
const stepFiveForm = ref({
|
|
|
@@ -179,9 +176,9 @@ const validateCurrentStep = async () => {
|
|
|
}
|
|
|
|
|
|
if(steps.value === 4) {
|
|
|
- const hasSelfie = !!stepFourForm.value.selfie_base64;
|
|
|
- const hasDocumentFront = !!stepFourForm.value.document_front_base64;
|
|
|
- const hasDocumentBack = !!stepFourForm.value.document_back_base64;
|
|
|
+ const hasSelfie = !!stepFourForm.value.selfie;
|
|
|
+ const hasDocumentFront = !!stepFourForm.value.document_front;
|
|
|
+ const hasDocumentBack = !!stepFourForm.value.document_back;
|
|
|
|
|
|
if (!hasSelfie || !hasDocumentFront || !hasDocumentBack) {
|
|
|
$q.notify({
|
|
|
@@ -229,38 +226,55 @@ const validateCodeInput = async () => {
|
|
|
|
|
|
const registerUserAndProvider = async () => {
|
|
|
const workingDays = mapWorkingDays();
|
|
|
+ const form = new FormData();
|
|
|
|
|
|
- const payload = {
|
|
|
- ...stepThreeForm.value,
|
|
|
- email: stepThreeForm.value.email || email.value,
|
|
|
- phone: stepThreeForm.value.phone || phone.value,
|
|
|
- code: code.value,
|
|
|
- birth_date: toISODate(stepThreeForm.value.birth_date),
|
|
|
- has_complement: !stepThreeForm.value.no_complement,
|
|
|
- complement: stepThreeForm.value.no_complement ? null : stepThreeForm.value.complement,
|
|
|
-
|
|
|
- selfie_base64: stepFourForm.value.selfie_base64,
|
|
|
- document_front_base64: stepFourForm.value.document_front_base64,
|
|
|
- document_back_base64: stepFourForm.value.document_back_base64,
|
|
|
-
|
|
|
- daily_price_8h: Number(stepFiveForm.value.daily_price_8h),
|
|
|
- daily_price_6h: Number(stepFiveForm.value.daily_price_6h),
|
|
|
- daily_price_4h: Number(stepFiveForm.value.daily_price_4h),
|
|
|
- daily_price_2h: Number(stepFiveForm.value.daily_price_2h),
|
|
|
- services_types_ids: stepFiveForm.value.services_types_ids,
|
|
|
+ const append = (key, val) => {
|
|
|
+ if (val === null || val === undefined) return;
|
|
|
+ if (typeof val === 'boolean') form.append(key, val ? '1' : '0');
|
|
|
+ else form.append(key, val);
|
|
|
+ };
|
|
|
|
|
|
- working_days: workingDays,
|
|
|
+ append('name', stepThreeForm.value.name);
|
|
|
+ append('email', stepThreeForm.value.email || email.value);
|
|
|
+ append('phone', stepThreeForm.value.phone || phone.value);
|
|
|
+ append('code', code.value);
|
|
|
+ append('rg', stepThreeForm.value.rg);
|
|
|
+ append('document', stepThreeForm.value.document);
|
|
|
+ append('birth_date', toISODate(stepThreeForm.value.birth_date));
|
|
|
+ append('zip_code', stepThreeForm.value.zip_code);
|
|
|
+ append('address', stepThreeForm.value.address);
|
|
|
+ append('has_complement', !stepThreeForm.value.no_complement);
|
|
|
+ append('complement', stepThreeForm.value.no_complement ? null : stepThreeForm.value.complement);
|
|
|
+ append('nickname', stepThreeForm.value.nickname);
|
|
|
+ append('instructions', stepThreeForm.value.instructions);
|
|
|
+ append('city', stepThreeForm.value.city);
|
|
|
+ append('state', stepThreeForm.value.state);
|
|
|
+ append('address_type', stepThreeForm.value.address_type);
|
|
|
+
|
|
|
+ append('daily_price_8h', Number(stepFiveForm.value.daily_price_8h));
|
|
|
+ append('daily_price_6h', Number(stepFiveForm.value.daily_price_6h));
|
|
|
+ append('daily_price_4h', Number(stepFiveForm.value.daily_price_4h));
|
|
|
+ append('daily_price_2h', Number(stepFiveForm.value.daily_price_2h));
|
|
|
+
|
|
|
+ (stepFiveForm.value.services_types_ids ?? []).forEach(id => form.append('services_types_ids[]', id));
|
|
|
+
|
|
|
+ workingDays.forEach((wd, i) => {
|
|
|
+ form.append(`working_days[${i}][day]`, wd.day);
|
|
|
+ form.append(`working_days[${i}][period]`, wd.period);
|
|
|
+ });
|
|
|
|
|
|
- };
|
|
|
+ form.append('selfie', stepFourForm.value.selfie);
|
|
|
+ form.append('document_front', stepFourForm.value.document_front);
|
|
|
+ form.append('document_back', stepFourForm.value.document_back);
|
|
|
|
|
|
- const response = await createUserAndProvider(payload);
|
|
|
+ const response = await createUserAndProvider(form);
|
|
|
if (response.status === 200) {
|
|
|
steps.value = 7;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const onSubmit = async () => {
|
|
|
- if (showSubStep.value) return; // Não submete o form principal se estiver em um sub-passo
|
|
|
+ if (showSubStep.value) return;
|
|
|
|
|
|
const isValid = await loginForm.value.validate();
|
|
|
if (!isValid) return;
|