|
|
@@ -20,7 +20,27 @@
|
|
|
<div class="fonte-nome-profile font16 fontbold q-mt-md text-text">{{ user.name || '—' }}</div>
|
|
|
<div class="fonte-email-profile font9 fontmedium text-grey-6 q-my-sm">{{ user.email || '—' }}</div>
|
|
|
<div class="fonte-telefone-profile font9 fontmedium text-grey-7">{{ user.phone || '—' }}</div>
|
|
|
-
|
|
|
+
|
|
|
+ <div
|
|
|
+ v-if="shareCode"
|
|
|
+ class="row no-wrap q-gutter-x-xs q-mt-sm share-code cursor-pointer"
|
|
|
+ @click="copyShareCode"
|
|
|
+ >
|
|
|
+ <div class="font9 fontmedium text-grey-6 q-my-auto">
|
|
|
+ <span>
|
|
|
+ {{ $t('profile.share.code_label') }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="font12 fontbold gradient-diarista q-my-auto">
|
|
|
+ <span>
|
|
|
+ {{ shareCode }}
|
|
|
+ </span>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <q-icon class="q-my-auto" name="mdi-content-copy" size="14px" color="grey-6" />
|
|
|
+ </div>
|
|
|
+
|
|
|
<q-btn
|
|
|
v-if="!isPendingProvider"
|
|
|
outline
|
|
|
@@ -150,7 +170,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, onMounted } from 'vue';
|
|
|
+import { computed, ref, onMounted } from 'vue';
|
|
|
import { useQuasar } from 'quasar';
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
import { Browser } from '@capacitor/browser';
|
|
|
@@ -169,6 +189,7 @@ import { useRouter } from 'vue-router';
|
|
|
|
|
|
const PRIVACY_POLICY_URL = 'https://politicas.softpar.inf.br/politicas/politicaDiaristaPrestador.html';
|
|
|
const SUPPORT_PAGE_URL = 'https://politicas.softpar.inf.br/suportes/suporteDiaristaPrestador.html';
|
|
|
+const CLIENT_APP_STORE_URL = 'https://play.google.com/store/apps/details?id=br.com.diarista.client';
|
|
|
|
|
|
const appVersion = process.env.APP_VERSION;
|
|
|
|
|
|
@@ -184,25 +205,79 @@ const user = ref({
|
|
|
phone: ''
|
|
|
});
|
|
|
|
|
|
-// compartilha perfil
|
|
|
+const shareCode = computed(() => user.value.provider_share_code || '');
|
|
|
+
|
|
|
+const shareMessage = computed(() => t('profile.share.message', {
|
|
|
+ name: user.value.name,
|
|
|
+ code: shareCode.value,
|
|
|
+ link: CLIENT_APP_STORE_URL,
|
|
|
+}));
|
|
|
+
|
|
|
+const isShareCanceled = (error) => {
|
|
|
+ const message = String(error?.message ?? '').toLowerCase();
|
|
|
+
|
|
|
+ return error?.name === 'AbortError' || message.includes('canceled') || message.includes('cancelled');
|
|
|
+};
|
|
|
+
|
|
|
+const copyToClipboard = async (text) => {
|
|
|
+ try {
|
|
|
+ if (navigator?.clipboard?.writeText) {
|
|
|
+ await navigator.clipboard.writeText(text);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Erro ao copiar mensagem:', error);
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+};
|
|
|
+
|
|
|
+// compartilha perfil
|
|
|
const shareProfile = async () => {
|
|
|
- const message = t('profile.share.message', { name: user.value.name });
|
|
|
+ const message = shareMessage.value;
|
|
|
|
|
|
try {
|
|
|
+ const { value: canShare } = await Share.canShare();
|
|
|
+
|
|
|
+ if (!canShare) {
|
|
|
+ throw new Error('Share unavailable');
|
|
|
+ }
|
|
|
+
|
|
|
await Share.share({
|
|
|
- title: 'Diária App',
|
|
|
+ title: t('profile.share.title'),
|
|
|
text: message,
|
|
|
- dialogTitle: 'Compartilhar perfil',
|
|
|
+ dialogTitle: t('profile.share.dialog_title'),
|
|
|
});
|
|
|
} catch (error) {
|
|
|
- if (error?.name === 'AbortError') {
|
|
|
+ if (isShareCanceled(error)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
console.error('Erro ao compartilhar perfil:', error);
|
|
|
+
|
|
|
+ const copied = await copyToClipboard(message);
|
|
|
+
|
|
|
+ $q.notify({
|
|
|
+ message: copied ? t('profile.share.copied') : t('profile.share.error'),
|
|
|
+ color: copied ? 'positive' : 'negative',
|
|
|
+ });
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const copyShareCode = async () => {
|
|
|
+ if (!shareCode.value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const copied = await copyToClipboard(shareCode.value);
|
|
|
+
|
|
|
+ $q.notify({
|
|
|
+ message: copied ? t('profile.share.code_copied') : t('profile.share.error'),
|
|
|
+ color: copied ? 'positive' : 'negative',
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
const openEditProfile = () => {
|
|
|
$q.dialog({
|
|
|
component: ProfileEditDialog,
|
|
|
@@ -278,6 +353,10 @@ onMounted(async () => {
|
|
|
position: relative;
|
|
|
}
|
|
|
|
|
|
+.share-code {
|
|
|
+ letter-spacing: 0.5px;
|
|
|
+}
|
|
|
+
|
|
|
.btn-edit-profile {
|
|
|
border-radius: 6px;
|
|
|
}
|