This commit is contained in:
xds
2026-02-04 14:43:22 +03:00
commit 4f460b2876
40 changed files with 11425 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import api from './api'
export const dataService = {
getAssets: async (limit, offset, type) => {
const params = { limit, offset }
if (type && type !== 'all') params.type = type
const response = await api.get('/assets', { params })
return response.data
},
getAsset: async (id) => {
const response = await api.get(`/assets/${id}`)
return response.data
},
getCharacters: async () => {
// Spec says /api/characters/ (with trailing slash) but usually client shouldn't matter too much if config is good,
// but let's follow spec if strictly needed. Axios usually handles this.
const response = await api.get('/characters/')
return response.data
},
getCharacterById: async (id) => {
const response = await api.get(`/characters/${id}`)
return response.data
},
getAssetsByCharacterId: async (charId, limit, offset) => {
const response = await api.get(`/characters/${charId}/assets`, { params: { limit, offset } })
return response.data
},
uploadAsset: async (file, linkedCharId) => {
const formData = new FormData()
formData.append('file', file)
if (linkedCharId) formData.append('linked_char_id', linkedCharId)
const response = await api.post('/assets/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
return response.data
}
}