From 101ed5ea59dca988ac8eaad2ece50b51447bbbe9 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Wed, 20 Dec 2023 12:50:02 +0100 Subject: [PATCH] feat: simple list of last added prices (#26) * Basic list with last prices * Create PriceCard * compute price per kg --- src/components/PriceCard.vue | 50 ++++++++++++++++++++++++++++++++++++ src/routes.js | 2 ++ src/services/api.js | 12 +++++++++ src/views/PriceList.vue | 36 ++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 src/components/PriceCard.vue create mode 100644 src/views/PriceList.vue diff --git a/src/components/PriceCard.vue b/src/components/PriceCard.vue new file mode 100644 index 00000000000..53321ecd58c --- /dev/null +++ b/src/components/PriceCard.vue @@ -0,0 +1,50 @@ + + + diff --git a/src/routes.js b/src/routes.js index a50db029f6f..585ef030c42 100644 --- a/src/routes.js +++ b/src/routes.js @@ -2,6 +2,7 @@ import Home from './views/Home.vue' import SignIn from './views/SignIn.vue' import AddPriceHome from './views/AddPriceHome.vue' import AddPriceSingle from './views/AddPriceSingle.vue' +import PriceList from './views/PriceList.vue' import NotFound from './views/NotFound.vue' /** @type {import('vue-router').RouterOptions['routes']} */ @@ -10,5 +11,6 @@ export let routes = [ { path: '/sign-in', name: 'sign-in', component: SignIn, meta: { title: 'Sign in', icon: 'mdi-login', drawerMenu: true, requiresAuth: false } }, { path: '/add', name: 'add-price', component: AddPriceHome, meta: { title: 'Add a price', icon: 'mdi-plus', drawerMenu: true, requiresAuth: true }}, { path: '/add/single', name: 'add-price-single', component: AddPriceSingle, meta: { title: 'Add a single price', requiresAuth: true }}, + { path: '/prices', name: 'prices', component: PriceList, meta: { title: 'Last prices', icon: 'mdi-tag-multiple-outline', drawerMenu: true }}, { path: '/:path(.*)', component: NotFound }, ] diff --git a/src/services/api.js b/src/services/api.js index d2c2190965c..98af504d1e8 100644 --- a/src/services/api.js +++ b/src/services/api.js @@ -91,6 +91,18 @@ export default { .then((response) => response.json()) }, + getPrices(params = {}) { + const url = `${import.meta.env.VITE_OPEN_PRICES_API_URL}/prices?${new URLSearchParams(params)}` + return fetch(url, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${this.getToken()}` + }, + }) + .then((response) => response.json()) + }, + openstreetmapNominatimSearch(q) { return fetch(`https://nominatim.openstreetmap.org/search?q=${q}&format=json&limit=5`, { method: 'GET', diff --git a/src/views/PriceList.vue b/src/views/PriceList.vue new file mode 100644 index 00000000000..52ecded7c28 --- /dev/null +++ b/src/views/PriceList.vue @@ -0,0 +1,36 @@ + + +