frontend/src/api/merch.js

28 lines
628 B
JavaScript
Raw Normal View History

2025-09-22 19:30:37 +03:00
import { apiClient } from '@/services/apiClient.js'
2025-09-22 19:41:47 +03:00
import router from '@/router/index.js'
2025-09-22 19:30:37 +03:00
export const useMerchApi = () => {
2025-09-22 19:41:47 +03:00
const addMerch = async (payload) => {
const response = await apiClient.post('/merch/', payload.value)
if (response.status === 200) {
router.push({ name: 'collection' })
} else {
console.log("Add merch error: ", response)
}
}
2025-09-22 19:30:37 +03:00
const deleteMerch = async (uuid) => {
try {
const response = await apiClient.delete(`/merch/${uuid}`)
return response.status
} catch (error) {
return error
}
}
return {
2025-09-22 19:41:47 +03:00
addMerch,
2025-09-22 19:30:37 +03:00
deleteMerch,
}
}