diff --git a/package.json b/package.json index de2d2d0..7dce32a 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "format": "prettier --write src/" }, "dependencies": { + "@formkit/auto-animate": "^0.8.2", "axios": "^1.7.9", "vue": "^3.5.13", "vue3-toastify": "^0.2.8" diff --git a/src/App.vue b/src/App.vue index 6c17432..fe35ca7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,13 +10,14 @@ const showDrawer = ref(false); const items = ref([]); const isLoading = ref(false); + const isFetching = ref(false); const filters = reactive({ searchQuery: '', sortBy: '' }); const isCreatingOrder = ref(false); - const fetchItems = async (filters = {}) => { + const fetchItems = async (filters = {}, {isFirstLoading}) => { const params = {}; if (filters.searchQuery) { params.title = '*' + filters.searchQuery + '*' @@ -26,17 +27,21 @@ } try { - isLoading.value = true + if (isFirstLoading) { + isLoading.value = true + } + isFetching.value = true const { data } = await axios.get(`${import.meta.env.VITE_API_URL}/items`, { params }); items.value = data } catch (e) { console.error('Some error', e) } finally { isLoading.value = false + isFetching.value = false } } - onMounted(fetchItems) + onMounted(() => fetchItems({}, {isFirstLoading: true})) watch(filters, fetchItems) const toggleToFavorite = async (item) => { diff --git a/src/components/CardList.vue b/src/components/CardList.vue index 9aa0be4..ae0c5c1 100644 --- a/src/components/CardList.vue +++ b/src/components/CardList.vue @@ -12,7 +12,7 @@