feat(frontend): Vue 3 + wa-sqlite + sync engine + auth + layouts

- package.json with Vue 3, Pinia, vue-router, wa-sqlite, Tailwind CSS 4, Vite
- wa-sqlite database layer with IDBBatchAtomicVFS (offline-first)
- Full schema mirroring backend tables (vehicles, orders, invoices, etc.)
- SyncEngine: fullSync, incrementalSync, pushQueue for offline queue
- Auth store with JWT parsing, login/register, plan tier detection
- Router with all routes and auth navigation guards
- AppLayout (sidebar desktop / bottom nav mobile) + AuthLayout
- Login/Register views connected to API contract
- SyncIndicator component (online/offline status)
- Reactive SQL query composable (useSqlQuery)
- Placeholder views for dashboard, orders, vehicles, appointments, catalog, settings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 17:22:50 +02:00
parent a16d01a669
commit c3482bba8d
27 changed files with 7614 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
const API_URL = import.meta.env.VITE_API_URL || '/api'
export const useAuthStore = defineStore('auth', () => {
const token = ref(localStorage.getItem('token'))
const payload = computed(() => {
if (!token.value) return null
try { return JSON.parse(atob(token.value.split('.')[1])) } catch { return null }
})
const isAuthenticated = computed(() => !!token.value && payload.value?.exp * 1000 > Date.now())
const tenantId = computed(() => payload.value?.tenant_id)
const plan = computed(() => payload.value?.plan || 'free')
async function login(email, password) {
const res = await fetch(`${API_URL}/auth/login`, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
})
if (!res.ok) throw new Error('Credentiale invalide')
const data = await res.json()
token.value = data.access_token
localStorage.setItem('token', data.access_token)
return data
}
async function register(email, password, tenant_name, telefon) {
const res = await fetch(`${API_URL}/auth/register`, {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password, tenant_name, telefon })
})
if (!res.ok) throw new Error('Inregistrare esuata')
const data = await res.json()
token.value = data.access_token
localStorage.setItem('token', data.access_token)
return data
}
function logout() { token.value = null; localStorage.removeItem('token') }
return { token, isAuthenticated, tenantId, plan, login, register, logout }
})