feat: search component and loading splashscreen

This commit is contained in:
2025-08-08 14:36:05 +03:00
parent a8bb5eb493
commit 2fb841ef08
12 changed files with 217 additions and 35 deletions

View File

@@ -37,6 +37,7 @@ export const useProductsStore = defineStore('products', {
this.page = 1;
this.hasMore = true;
this.loadFinished = false;
this.search = '';
this.products = {
data: [],
meta: {},

View File

@@ -0,0 +1,51 @@
import {defineStore} from "pinia";
import ftch from "@/utils/ftch.js";
export const useSearchStore = defineStore('search', {
state: () => ({
search: '',
page: 1,
products: {
data: [],
meta: {},
},
isLoading: false,
isSearchPerformed: false,
}),
actions: {
reset() {
this.search = '';
this.isSearchPerformed = false;
this.isLoading = false;
this.page = 1;
this.products = {
data: [],
meta: {},
};
},
async performSearch() {
if (!this.search) {
return this.reset();
}
try {
this.isLoading = true;
this.products = await ftch('products', {
page: this.page,
perPage: 10,
search: this.search,
});
} catch (error) {
console.error(error);
} finally {
this.isLoading = false;
this.isSearchPerformed = true;
}
},
},
});

View File

@@ -22,6 +22,7 @@ export const useSettingsStore = defineStore('settings', {
actions: {
async load() {
console.log('Load settings');
const settings = await fetchSettings();
this.manifest_url = settings.manifest_url;
this.app_name = settings.app_name;