|
|
@@ -286,12 +286,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({
|
|
|
@@ -364,10 +361,10 @@ const validateCurrentStep = async () => {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (steps.value === 4) {
|
|
|
- const hasSelfie = !!stepFourForm.value.selfie_base64;
|
|
|
- const hasDocumentFront = !!stepFourForm.value.document_front_base64;
|
|
|
- const hasDocumentBack = !!stepFourForm.value.document_back_base64;
|
|
|
+ if(steps.value === 4) {
|
|
|
+ const hasSelfie = !!stepFourForm.value.selfie;
|
|
|
+ const hasDocumentFront = !!stepFourForm.value.document_front;
|
|
|
+ const hasDocumentBack = !!stepFourForm.value.document_back;
|
|
|
|
|
|
if (!hasSelfie || !hasDocumentFront || !hasDocumentBack) {
|
|
|
$q.notify({
|
|
|
@@ -432,66 +429,55 @@ const validateCodeInput = async () => {
|
|
|
|
|
|
const registerUserAndProvider = async () => {
|
|
|
const workingDays = mapWorkingDays();
|
|
|
- const providerEmail = stepThreeForm.value.email || email.value;
|
|
|
- const providerPhone = stepThreeForm.value.phone || phone.value;
|
|
|
- const providerName = stepThreeForm.value.name;
|
|
|
- const providerDocument = stepThreeForm.value.document;
|
|
|
-
|
|
|
- const payload = {
|
|
|
- ...stepThreeForm.value,
|
|
|
- email: providerEmail || undefined,
|
|
|
- phone: providerPhone || undefined,
|
|
|
- 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,
|
|
|
-
|
|
|
- recipient_name: providerName,
|
|
|
- recipient_email: providerEmail,
|
|
|
- recipient_description: `Prestador ${providerName}`,
|
|
|
- recipient_document: providerDocument,
|
|
|
- recipient_type: "individual",
|
|
|
- recipient_code: providerDocument,
|
|
|
- recipient_payment_mode: "bank_transfer",
|
|
|
- recipient_default_bank_account: {
|
|
|
- holder_name: providerName,
|
|
|
- holder_type: "individual",
|
|
|
- holder_document: providerDocument,
|
|
|
- bank: stepSixForm.value.bank,
|
|
|
- branch_number: stepSixForm.value.branch_number,
|
|
|
- branch_check_digit: stepSixForm.value.branch_check_digit || null,
|
|
|
- account_number: stepSixForm.value.account_number,
|
|
|
- account_check_digit: stepSixForm.value.account_check_digit,
|
|
|
- type: stepSixForm.value.account_type,
|
|
|
- metadata: [],
|
|
|
- pix_key: stepSixForm.value.pix_key || null,
|
|
|
- },
|
|
|
- recipient_metadata: [],
|
|
|
-
|
|
|
- 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: normalizeCurrency(stepFiveForm.value.daily_price_8h),
|
|
|
- daily_price_6h: normalizeCurrency(stepFiveForm.value.daily_price_6h),
|
|
|
- daily_price_4h: normalizeCurrency(stepFiveForm.value.daily_price_4h),
|
|
|
- daily_price_2h: normalizeCurrency(stepFiveForm.value.daily_price_2h),
|
|
|
- services_types_ids: stepFiveForm.value.services_types_ids,
|
|
|
- service_types_ids: stepFiveForm.value.services_types_ids,
|
|
|
-
|
|
|
- working_days: workingDays,
|
|
|
+ const form = new FormData();
|
|
|
+
|
|
|
+ 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);
|
|
|
};
|
|
|
|
|
|
- const response = await createUserAndProvider(payload);
|
|
|
- if ([200, 201].includes(response.status)) {
|
|
|
- steps.value = 8;
|
|
|
+ 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(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;
|