diff --git a/.ottotime b/.ottotime index 0b2dcb5..5515a63 100644 --- a/.ottotime +++ b/.ottotime @@ -44,4 +44,33 @@ 1766567819-999:59 1766627818- 5:26 1766745865- 1:03 -1766745972- 0:00 +1766745972- 0:18 +1766750094- 3:08 +1766750709- 0:01 +1767040128- 9:51 +1767041161- 0:22 +1767041921- 14:15 +1767043405- 10:42 +1767044635- 3:33 +1767045452- 0:00 +1767126192- 0:08 +1767126849- 30:00 +1767131581- 5:29 +1767132321-185:10 +1767171670-188:07 +1767210073- 9:39 +1767211444- 0:04 +1767211861- 0:00 +1767220551- 3:19 +1767221303- 0:00 +1767260442- 2:58 +1767284298- 0:00 +1767292714- 3:54 +1767307670- 4:05 +1767308254- 1:10 +1767308644- 4:02 +1767309280- 4:02 +1767339059- 0:21 +1767339386- 2:51 +1767340009- 87:57 +1767345728- 7:30 diff --git a/app.vue b/app.vue index 56cb578..7d74ac0 100644 --- a/app.vue +++ b/app.vue @@ -8,49 +8,17 @@ import 'primeicons/primeicons.css' -const siteData = ref() const nuxtApp = useNuxtApp() -const categoriesStore = useCategoriesStore() -const placeStore = useMyPlacesStore() -const authStore = useAuthStore() -const configStore = useMyConfigStore() -const { loadToken, getToken } = useAuthToken() async function loadData() { // Először betöltjük a tokent (natív appnál Preferences-ből) await loadToken() const token = getToken() - const { data } = await useFetch('https://olcsoberauto.hu/rest/init', - { - headers: { - 'auth-key': token || '' - } - } - ) - if (data.value?.user) { - authStore.user = data.value.user - console.log(data.value.user) - } - - if (data.value?.config) { - configStore.config = data.value.config - } - - if (data.value?.states) { - configStore.states = data.value.states - } - - if (data.value?.categories) { - categoriesStore.categories = data.value.categories - placeStore.places = data.value.places - } } nuxtApp.hooks.hook('app:mounted', async () => { - console.log('mounted...') - await loadData() }) @@ -75,7 +43,8 @@ html { } /* Jobb görgetési élmény */ -html, body { +html, +body { overscroll-behavior: none; } @@ -130,4 +99,5 @@ body:has(.card-loading) { pre { font-size: 13px; } + \ No newline at end of file diff --git a/composables/useApi.ts b/composables/useApi.ts new file mode 100644 index 0000000..c9dc79c --- /dev/null +++ b/composables/useApi.ts @@ -0,0 +1,43 @@ +/** + * Központi API composable + * Az összes API hívás ezen keresztül történik + */ + +export const useApi = () => { + const config = useRuntimeConfig() + const baseUrl = config.public.apiBase as string + + /** + * API végpont URL összeállítása + */ + const getUrl = (endpoint: string): string => { + // Ha már teljes URL, visszaadjuk + if (endpoint.startsWith('http')) { + return endpoint + } + // Biztosítjuk, hogy az endpoint /-vel kezdődjön + const path = endpoint.startsWith('/') ? endpoint : `/${endpoint}` + return `${baseUrl}${path}` + } + + /** + * useFetch wrapper az API hívásokhoz + */ + const apiFetch = (endpoint: string, options?: Parameters[1]) => { + return useFetch(getUrl(endpoint), options) + } + + /** + * $fetch wrapper az API hívásokhoz (nem reaktív, közvetlen hívás) + */ + const apiRequest = (endpoint: string, options?: Parameters[1]) => { + return $fetch(getUrl(endpoint), options) + } + + return { + baseUrl, + getUrl, + apiFetch, + apiRequest + } +} diff --git a/middleware/01-profile.global.ts b/middleware/01-profile.global.ts index ab490fe..7f4f70d 100644 --- a/middleware/01-profile.global.ts +++ b/middleware/01-profile.global.ts @@ -42,4 +42,12 @@ export default defineNuxtRouteMiddleware(async (to, from) => { if (missingFields.length > 0) { return navigateTo('/profile') } + + // Ha foglalás oldalon vagyunk + if (to.fullPath.match(/^\/rent/gi)) { + // console.log(authStore.rent) + // if(!authStore.rent?.auto_felvetel_datum){ + // return navigateTo('/rent/date-from') + // } + } }) diff --git a/nuxt.config.ts b/nuxt.config.ts index 24fb35a..caa8975 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -2,12 +2,20 @@ import * as path from "path"; export default defineNuxtConfig({ compatibilityDate: '2024-12-29', + runtimeConfig: { + public: { + apiBase: process.env.NUXT_PUBLIC_API_BASE || 'https://olcsoberauto.hu/rest' + } + }, devServer: { host: '0.0.0.0', port: 3280 }, ssr: false, - modules: ["@primevue/nuxt-module", "@pinia/nuxt", "@nuxt/icon", "@vite-pwa/nuxt"], + modules: ["@primevue/nuxt-module", "@pinia/nuxt", "@pinia-plugin-persistedstate/nuxt", "@nuxt/icon", "@vite-pwa/nuxt"], + piniaPluginPersistedstate: { + storage: 'localStorage' + }, css: ['@/assets/styles/tailwind.css', '@/assets/styles/base.css', '@/assets/styles/fonts.css'], primevue: { options: { diff --git a/package.json b/package.json index 93ebb4c..be550cf 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "nuxt-app", "type": "module", - "version": "1.0.2", - "versionCode": 3, + "version": "1.0.4", + "versionCode": 4, "scripts": { "build": "nuxt build", "dev": "nuxt dev", @@ -39,6 +39,7 @@ "@capacitor/preferences": "^8.0.0", "@capacitor/splash-screen": "^8.0.0", "@capacitor/status-bar": "^8.0.0", + "@pinia-plugin-persistedstate/nuxt": "^1.2.1", "primeicons": "^7.0.0", "primevue": "^4.3.9", "tailwindcss": "^3.4.17", diff --git a/pages/index.vue b/pages/index.vue index 45bffb5..df3397d 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -44,7 +44,7 @@ function logOut(){
- +
diff --git a/pages/login.vue b/pages/login.vue index 4fa8aa8..453f02d 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -4,7 +4,7 @@
- +
diff --git a/pages/login/code.vue b/pages/login/code.vue index 22aa27d..31f3e3a 100644 --- a/pages/login/code.vue +++ b/pages/login/code.vue @@ -2,6 +2,7 @@ \ No newline at end of file diff --git a/pages/rent/thanks.vue b/pages/rent/thanks.vue index 394661c..e694947 100644 --- a/pages/rent/thanks.vue +++ b/pages/rent/thanks.vue @@ -3,21 +3,25 @@
-
+
- +
- \ No newline at end of file + \ No newline at end of file diff --git a/plugins/capacitor.client.ts b/plugins/capacitor.client.ts index fa250d8..89c62c9 100644 --- a/plugins/capacitor.client.ts +++ b/plugins/capacitor.client.ts @@ -4,14 +4,49 @@ import { SplashScreen } from '@capacitor/splash-screen' import { Haptics, ImpactStyle } from '@capacitor/haptics' import { Capacitor } from '@capacitor/core' -export default defineNuxtPlugin((nuxtApp) => { +export default defineNuxtPlugin(async (nuxtApp) => { + + const siteData = ref() + const categoriesStore = useCategoriesStore() + const placeStore = useMyPlacesStore() + const authStore = useAuthStore() + const configStore = useMyConfigStore() + const { loadToken, getToken } = useAuthToken() + + const { apiFetch } = useApi() + const token = await loadToken() + console.log(token) + const { data } = await apiFetch('/init', + { + headers: { + 'auth-key': token || '' + } + } + ) + + if (data.value?.user) { + authStore.user = data.value.user + } + + if (data.value?.config) { + configStore.config = data.value.config + } + + if (data.value?.states) { + configStore.states = data.value.states + } + + if (data.value?.categories) { + categoriesStore.categories = data.value.categories + placeStore.places = data.value.places + } + // Csak natív platformon fut if (!Capacitor.isNativePlatform()) { return } const router = useRouter() - // Android hardware back button kezelése App.addListener('backButton', async ({ canGoBack }) => { // Ha van history, navigáljunk vissza diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 59b8220..402b3a2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,6 +35,9 @@ importers: '@capacitor/status-bar': specifier: ^8.0.0 version: 8.0.0(@capacitor/core@8.0.0) + '@pinia-plugin-persistedstate/nuxt': + specifier: ^1.2.1 + version: 1.2.1(@pinia/nuxt@0.9.0(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))))(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))) primeicons: specifier: ^7.0.0 version: 7.0.0 @@ -1435,6 +1438,12 @@ packages: resolution: {integrity: sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==} engines: {node: '>= 10.0.0'} + '@pinia-plugin-persistedstate/nuxt@1.2.1': + resolution: {integrity: sha512-q8s+4aQW/AjBMyeqLL48/qzBR5lcgnvvf1525ovNuKf6Wl9CsoLjPKh/5X8vNoKGwSow4gP7lVmdYPQRypgjgg==} + deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. + peerDependencies: + '@pinia/nuxt': ^0.5.0 + '@pinia/nuxt@0.9.0': resolution: {integrity: sha512-2yeRo7LeyCF68AbNeL3xu2h6uw0617RkcsYxmA8DJM0R0PMdz5wQHnc44KeENQxR/Mrq8T910XVT6buosqsjBQ==} peerDependencies: @@ -4178,6 +4187,20 @@ packages: resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==} engines: {node: '>=4'} + pinia-plugin-persistedstate@4.7.1: + resolution: {integrity: sha512-WHOqh2esDlR3eAaknPbqXrkkj0D24h8shrDPqysgCFR6ghqP/fpFfJmMPJp0gETHsvrh9YNNg6dQfo2OEtDnIQ==} + peerDependencies: + '@nuxt/kit': '>=3.0.0' + '@pinia/nuxt': '>=0.10.0' + pinia: '>=3.0.0' + peerDependenciesMeta: + '@nuxt/kit': + optional: true + '@pinia/nuxt': + optional: true + pinia: + optional: true + pinia@2.3.1: resolution: {integrity: sha512-khUlZSwt9xXCaTbbxFYBKDc/bWAGWJjOgvxETwkTN7KRm66EeT1ZdZj6i2ceh9sP2Pzqsbc704r2yngBrxBVug==} peerDependencies: @@ -7539,6 +7562,16 @@ snapshots: '@parcel/watcher-win32-ia32': 2.5.1 '@parcel/watcher-win32-x64': 2.5.1 + '@pinia-plugin-persistedstate/nuxt@1.2.1(@pinia/nuxt@0.9.0(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))))(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3)))': + dependencies: + '@nuxt/kit': 3.20.2(magicast@0.5.1) + '@pinia/nuxt': 0.9.0(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))) + defu: 6.1.4 + pinia-plugin-persistedstate: 4.7.1(@nuxt/kit@3.20.2(magicast@0.5.1))(@pinia/nuxt@0.9.0(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))))(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))) + transitivePeerDependencies: + - magicast + - pinia + '@pinia/nuxt@0.9.0(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3)))': dependencies: '@nuxt/kit': 3.20.2(magicast@0.5.1) @@ -10743,6 +10776,14 @@ snapshots: pify@3.0.0: {} + pinia-plugin-persistedstate@4.7.1(@nuxt/kit@3.20.2(magicast@0.5.1))(@pinia/nuxt@0.9.0(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))))(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))): + dependencies: + defu: 6.1.4 + optionalDependencies: + '@nuxt/kit': 3.20.2(magicast@0.5.1) + '@pinia/nuxt': 0.9.0(magicast@0.5.1)(pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3))) + pinia: 2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3)) + pinia@2.3.1(typescript@5.9.3)(vue@3.5.26(typescript@5.9.3)): dependencies: '@vue/devtools-api': 6.6.4 diff --git a/public/euro_cars_rent_a_car_logo.svg b/public/euro_cars_rent_a_car_logo.svg new file mode 100644 index 0000000..1173a6e --- /dev/null +++ b/public/euro_cars_rent_a_car_logo.svg @@ -0,0 +1,16 @@ +euro_cars_rent_a_car_logo \ No newline at end of file diff --git a/public/icon.png b/public/icon.png index d4e9007..b8ddc65 100644 Binary files a/public/icon.png and b/public/icon.png differ diff --git a/public/splash-dark.png b/public/splash-dark.png new file mode 100644 index 0000000..34e08f2 Binary files /dev/null and b/public/splash-dark.png differ diff --git a/public/splash.png b/public/splash.png new file mode 100644 index 0000000..34e08f2 Binary files /dev/null and b/public/splash.png differ diff --git a/stores/auth.ts b/stores/auth.ts index 91d3067..6caa5a1 100644 --- a/stores/auth.ts +++ b/stores/auth.ts @@ -2,13 +2,23 @@ import { defineStore } from 'pinia' export const useAuthStore = defineStore({ id: 'AuthStore', - state: () => ({ user: null, rentals: null, rent: {} }), + state: () => ({ user: null, rentals: null, rent: {}, token: null }), + persist: { + storage: localStorage, + }, + getters:{ + token(){ + return this.token + } + }, actions: { async getData() { const { getToken } = useAuthToken() + const { apiFetch } = useApi() const token = getToken() if (token) { - const { data } = await useFetch('https://olcsoberauto.hu/rest/me', + this.token = token + const { data } = await apiFetch('/me', { headers: { 'auth-key': token @@ -27,6 +37,7 @@ export const useAuthStore = defineStore({ await clearToken() this.user = null this.rentals = null + this.token = null this.rent = {} navigateTo('/login') }