moved get merch list method

This commit is contained in:
nquidox 2025-09-22 19:59:51 +03:00
parent bd25bc90cf
commit 8b747f0a1e
2 changed files with 16 additions and 2 deletions

View file

@ -21,6 +21,17 @@ export const useMerchApi = () => {
}
}
const getMerchList = async () => {
try {
const response = await apiClient.get('/merch/')
if (response.status === 200) {
return response
}
} catch (error) {
return error
}
}
const deleteMerch = async (uuid) => {
try {
const response = await apiClient.delete(`/merch/${uuid}`)
@ -33,6 +44,7 @@ export const useMerchApi = () => {
return {
addMerch,
getMerchDetails,
getMerchList,
deleteMerch,
}
}

View file

@ -2,15 +2,17 @@
import CollectionToolbar from '@/views/CollectionView/CollectionToolbar.vue'
import CollectionMerchCard from '@/views/CollectionView/CollectionMerchCard.vue'
import { onMounted, ref } from 'vue'
import { apiClient } from '@/services/apiClient.js'
import { useMerchApi } from '@/api/merch.js'
const merchList = ref(null)
const loading = ref(true)
const error = ref(null)
const { getMerchList } = useMerchApi()
const fetchMerch = async () => {
try {
const response = await apiClient.get('/merch/')
const response = await getMerchList()
if (!response.ok) throw new Error('Network error')
merchList.value = await response.data
} catch (err) {