From 058dfb676f061184692a845a7bf16bbf0ba65ee8 Mon Sep 17 00:00:00 2001 From: Sam Hillier Date: Wed, 18 Dec 2024 18:37:33 +0000 Subject: [PATCH] refactor: migrate data fetch to tanstack query --- package-lock.json | 58 +++++++++++++++++++++++ package.json | 1 + src/components/CountriesBarChart.vue | 4 +- src/components/CountriesTable.vue | 4 +- src/components/GamesBarChart.vue | 4 +- src/components/GamesTable.vue | 4 +- src/main.ts | 6 ++- src/utils/fetchData.ts | 19 -------- src/utils/useFetchData.ts | 12 +++++ src/utils/{sortData.ts => useSortData.ts} | 2 +- src/views/Home.vue | 20 ++++---- 11 files changed, 93 insertions(+), 41 deletions(-) delete mode 100644 src/utils/fetchData.ts create mode 100644 src/utils/useFetchData.ts rename src/utils/{sortData.ts => useSortData.ts} (94%) diff --git a/package-lock.json b/package-lock.json index bfd225c..9259c67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@heroicons/vue": "^2.2.0", "@tailwindcss/vite": "^4.0.0-beta.6", + "@tanstack/vue-query": "^5.62.8", "chart.js": "^4.4.7", "pinia": "^2.2.6", "tailwindcss": "^4.0.0-beta.6", @@ -1512,6 +1513,57 @@ "vite": "^5.2.0 || ^6" } }, + "node_modules/@tanstack/match-sorter-utils": { + "version": "8.19.4", + "resolved": "https://registry.npmjs.org/@tanstack/match-sorter-utils/-/match-sorter-utils-8.19.4.tgz", + "integrity": "sha512-Wo1iKt2b9OT7d+YGhvEPD3DXvPv2etTusIMhMUoG7fbhmxcXCtIjJDEygy91Y2JFlwGyjqiBPRozme7UD8hoqg==", + "license": "MIT", + "dependencies": { + "remove-accents": "0.5.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/query-core": { + "version": "5.62.8", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.62.8.tgz", + "integrity": "sha512-4fV31vDsUyvNGrKIOUNPrZztoyL187bThnoQOvAXEVlZbSiuPONpfx53634MKKdvsDir5NyOGm80ShFaoHS/mw==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/vue-query": { + "version": "5.62.8", + "resolved": "https://registry.npmjs.org/@tanstack/vue-query/-/vue-query-5.62.8.tgz", + "integrity": "sha512-kOKTV6tu5iffq5/hOUpbohfwWH8nGhbCc9wf4UvihlhROILsWLrIPA5fOvdvc5VyozwKokdrubSdEukPZxpwXQ==", + "license": "MIT", + "dependencies": { + "@tanstack/match-sorter-utils": "^8.19.4", + "@tanstack/query-core": "5.62.8", + "@vue/devtools-api": "^6.6.3", + "vue-demi": "^0.14.10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "@vue/composition-api": "^1.1.2", + "vue": "^2.6.0 || ^3.3.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, "node_modules/@tsconfig/node22": { "version": "22.0.0", "resolved": "https://registry.npmjs.org/@tsconfig/node22/-/node22-22.0.0.tgz", @@ -3667,6 +3719,12 @@ "node": "^18.17.0 || >=20.5.0" } }, + "node_modules/remove-accents": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.5.0.tgz", + "integrity": "sha512-8g3/Otx1eJaVD12e31UbJj1YzdtVvzH85HV7t+9MJYk/u3XmkOUJ5Ys9wQrf9PCPK8+xn4ymzqYCiZl6QWKn+A==", + "license": "MIT" + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", diff --git a/package.json b/package.json index 23e42b0..446fd00 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "dependencies": { "@heroicons/vue": "^2.2.0", "@tailwindcss/vite": "^4.0.0-beta.6", + "@tanstack/vue-query": "^5.62.8", "chart.js": "^4.4.7", "pinia": "^2.2.6", "tailwindcss": "^4.0.0-beta.6", diff --git a/src/components/CountriesBarChart.vue b/src/components/CountriesBarChart.vue index 7c21072..b291a60 100644 --- a/src/components/CountriesBarChart.vue +++ b/src/components/CountriesBarChart.vue @@ -1,6 +1,6 @@