Explorar el Código

feat: remove mock e adiciona com base em campo do backend

ebagabee hace 3 semanas
padre
commit
f0f2cdc48f
Se han modificado 1 ficheros con 22 adiciones y 5 borrados
  1. 22 5
      src/pages/dashboard/DashboardPage.vue

+ 22 - 5
src/pages/dashboard/DashboardPage.vue

@@ -3,7 +3,7 @@
     <DefaultHeaderPage class="q-pa-sm">
       <template #after>
         <div class="flex items-center no-wrap" style="gap: 12px">
-          <template v-if="$q.screen.gt.sm">
+          <template v-if="$q.screen.gt.sm && lastLoginFormatted">
             <div
               class="column"
               style="line-height: 1.2; white-space: nowrap; flex-shrink: 0"
@@ -11,9 +11,9 @@
               <span class="text-caption text-grey-6 text-primary text-center"
                 >Ultimo acesso</span
               >
-              <span class="text-caption text-primary text-center"
-                >16/02/2026, 14:16</span
-              >
+              <span class="text-caption text-primary text-center">{{
+                lastLoginFormatted
+              }}</span>
             </div>
           </template>
 
@@ -201,7 +201,8 @@
 </template>
 
 <script setup>
-import { ref } from "vue";
+import { computed, ref } from "vue";
+import { userStore } from "src/stores/user";
 import { Doughnut } from "vue-chartjs";
 import { Chart as ChartJS, ArcElement, Tooltip, Legend } from "chart.js";
 import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
@@ -212,6 +213,22 @@ import AniversariantesCard from "src/components/charts/AniversariantesCard.vue";
 
 ChartJS.register(ArcElement, Tooltip, Legend);
 
+const store = userStore();
+
+const lastLoginFormatted = computed(() => {
+  const raw = store.user?.last_login_at;
+  if (!raw) return null;
+  const d = new Date(raw.replace(" ", "T") + "Z");
+  return new Intl.DateTimeFormat("pt-BR", {
+    day: "2-digit",
+    month: "2-digit",
+    year: "numeric",
+    hour: "2-digit",
+    minute: "2-digit",
+    timeZone: "America/Sao_Paulo",
+  }).format(d);
+});
+
 const faturamentoChart = {
   labels: [
     "17/02", "18/02", "19/02", "20/02", "21/02",