From cffc6acc2b1da70d8a48c1ece242156f09e3ca88 Mon Sep 17 00:00:00 2001 From: nquidox Date: Sun, 2 Nov 2025 23:40:44 +0300 Subject: [PATCH 1/6] zero prices block added --- src/api/zeroPrices.js | 27 ++++++++++ src/components/Navbar/NavBar.vue | 1 + src/router/index.js | 6 +++ src/services/apiClient.js | 6 ++- src/styles/styles.css | 5 ++ .../CollectionView/CollectionToolbar.vue | 11 ++-- src/views/ZeroPricesView.vue | 49 ++++++++++++++++++ src/views/ZeroPricesView/ZeroPriceCard.vue | 51 +++++++++++++++++++ .../ZeroPricesView/ZeroPricesToolbar.vue | 47 +++++++++++++++++ 9 files changed, 194 insertions(+), 9 deletions(-) create mode 100644 src/api/zeroPrices.js create mode 100644 src/views/ZeroPricesView.vue create mode 100644 src/views/ZeroPricesView/ZeroPriceCard.vue create mode 100644 src/views/ZeroPricesView/ZeroPricesToolbar.vue diff --git a/src/api/zeroPrices.js b/src/api/zeroPrices.js new file mode 100644 index 0000000..c69efd1 --- /dev/null +++ b/src/api/zeroPrices.js @@ -0,0 +1,27 @@ +import { apiClient } from '@/services/apiClient.js' + +export const useZeroPrices = () => { + const getZeroPrices = async () => { + try { + return await apiClient.get('/merch/zeroprices') + } catch (error) { + console.log('Get zero prices error: ', error) + throw error + } + } + + const deleteZeroPrices = async (list) => { + try { + await apiClient.delete('/merch/zeroprices', list) + } + catch (error) { + console.log('Delete zero prices error: ', error) + throw error + } + } + + return { + getZeroPrices, + deleteZeroPrices, + } +} diff --git a/src/components/Navbar/NavBar.vue b/src/components/Navbar/NavBar.vue index c2fcb65..a05c67c 100644 --- a/src/components/Navbar/NavBar.vue +++ b/src/components/Navbar/NavBar.vue @@ -17,6 +17,7 @@ const mainMenu = computed(() => { { label: 'Collection', key: 'collection' }, { label: 'Charts', key: 'charts' }, { label: 'Parsers', key: 'parsers' }, + { label: 'Zero prices', key: 'zeroprices' }, ] }) diff --git a/src/router/index.js b/src/router/index.js index 1a83844..0a0ff85 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -8,6 +8,7 @@ import PersonalView from '@/views/PersonalView.vue' import AddMerchView from '@/views/AddMerchView.vue' import DetailsView from '@/views/DetailsView.vue' import LabelsView from '@/views/LabelsView.vue' +import ZeroPricesView from '@/views/ZeroPricesView.vue' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -58,6 +59,11 @@ const router = createRouter({ name: 'labels', component: LabelsView, }, + { + path: '/zeroprices', + name: 'zeroprices', + component: ZeroPricesView, + }, ], }) diff --git a/src/services/apiClient.js b/src/services/apiClient.js index 7bc1f10..082f10a 100644 --- a/src/services/apiClient.js +++ b/src/services/apiClient.js @@ -138,12 +138,14 @@ export const apiClient = { return request(url, { method: 'POST', body: isFormData ? data : JSON.stringify(data), - // headers: isFormData ? {} : { 'Content-Type': 'application/json' } }) }, put: (url, data) => request(url, { method: 'PUT', body: JSON.stringify(data), }), - delete: (url) => request(url, { method: 'DELETE' }), + delete: (url, data) => request(url, { + method: 'DELETE', + body: data ? JSON.stringify(data) : undefined, + }), } diff --git a/src/styles/styles.css b/src/styles/styles.css index 67d9708..815f71a 100644 --- a/src/styles/styles.css +++ b/src/styles/styles.css @@ -197,3 +197,8 @@ body, justify-content: center; margin-bottom: 20px; } + +.padding-lr-30 { + padding-left: 30px; + padding-right: 30px; +} diff --git a/src/views/CollectionView/CollectionToolbar.vue b/src/views/CollectionView/CollectionToolbar.vue index 67e7e84..ebe8bc0 100644 --- a/src/views/CollectionView/CollectionToolbar.vue +++ b/src/views/CollectionView/CollectionToolbar.vue @@ -1,5 +1,5 @@ + + + + diff --git a/src/views/ZeroPricesView/ZeroPriceCard.vue b/src/views/ZeroPricesView/ZeroPriceCard.vue new file mode 100644 index 0000000..10c80d7 --- /dev/null +++ b/src/views/ZeroPricesView/ZeroPriceCard.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/src/views/ZeroPricesView/ZeroPricesToolbar.vue b/src/views/ZeroPricesView/ZeroPricesToolbar.vue new file mode 100644 index 0000000..8e3e9b2 --- /dev/null +++ b/src/views/ZeroPricesView/ZeroPricesToolbar.vue @@ -0,0 +1,47 @@ + + + + + From 7aa2ff1d3ace103b3a40893e631042f269e05158 Mon Sep 17 00:00:00 2001 From: nquidox Date: Sun, 2 Nov 2025 23:46:22 +0300 Subject: [PATCH 2/6] refresh on delete --- src/views/ZeroPricesView.vue | 7 ++++++- src/views/ZeroPricesView/ZeroPricesToolbar.vue | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/views/ZeroPricesView.vue b/src/views/ZeroPricesView.vue index d1ae267..adab776 100644 --- a/src/views/ZeroPricesView.vue +++ b/src/views/ZeroPricesView.vue @@ -26,6 +26,11 @@ const fetchZeroPrices = async () => { } } +const handleDeleted = () => { + toDelete.value = [] + fetchZeroPrices() +} + onMounted(() => { fetchZeroPrices() }) @@ -38,7 +43,7 @@ onMounted(() => {
- +
diff --git a/src/views/ZeroPricesView/ZeroPricesToolbar.vue b/src/views/ZeroPricesView/ZeroPricesToolbar.vue index 8e3e9b2..122e3d5 100644 --- a/src/views/ZeroPricesView/ZeroPricesToolbar.vue +++ b/src/views/ZeroPricesView/ZeroPricesToolbar.vue @@ -10,11 +10,13 @@ const props = defineProps({ const messages = useMessage() const { deleteZeroPrices } = useZeroPrices() +const emit = defineEmits(['deleted']) const handleDelete = async () => { try { await deleteZeroPrices(props.selected) messages.success("Selected zero prices deleted") + emit('deleted') } catch (error) { console.log(error) messages.error("Error deleting selected prices") @@ -23,7 +25,6 @@ const handleDelete = async () => { diff --git a/src/views/ZeroPricesView/ZeroPriceCard.vue b/src/views/ZeroPricesView/ZeroPriceCard.vue index 10c80d7..44236ee 100644 --- a/src/views/ZeroPricesView/ZeroPriceCard.vue +++ b/src/views/ZeroPricesView/ZeroPriceCard.vue @@ -1,21 +1,22 @@ @@ -24,7 +25,7 @@ const handleCheckboxChange = () => {
- + Delete diff --git a/src/views/ZeroPricesView/ZeroPricesToolbar.vue b/src/views/ZeroPricesView/ZeroPricesToolbar.vue index 122e3d5..abe01cb 100644 --- a/src/views/ZeroPricesView/ZeroPricesToolbar.vue +++ b/src/views/ZeroPricesView/ZeroPricesToolbar.vue @@ -10,7 +10,7 @@ const props = defineProps({ const messages = useMessage() const { deleteZeroPrices } = useZeroPrices() -const emit = defineEmits(['deleted']) +const emit = defineEmits(['deleted', 'selectAll']) const handleDelete = async () => { try { @@ -22,6 +22,11 @@ const handleDelete = async () => { messages.error("Error deleting selected prices") } } + +const handleSelectAll = async () => { + emit('selectAll') +} +