2023-05-03 21:31:01 +02:00
|
|
|
export const usePojmiStore = defineStore('pojmi', {
|
|
|
|
state: () => ({
|
|
|
|
pojmi: {}
|
|
|
|
}),
|
|
|
|
actions: {
|
2024-04-01 19:59:09 +02:00
|
|
|
async naloziPojme(jezik) {
|
2023-06-15 20:45:38 +02:00
|
|
|
const { jsonApiUrl, headers, deserialize } = useApi()
|
2023-05-03 21:31:01 +02:00
|
|
|
|
2024-04-01 19:59:09 +02:00
|
|
|
const data = await $fetch(`${jsonApiUrl(jezik)}/node/concept?sort=-changed`, { headers })
|
2023-05-03 21:31:01 +02:00
|
|
|
this.pojmi = await deserialize(data, s => ({
|
|
|
|
id: s.id,
|
|
|
|
naslov: s.title,
|
2024-01-19 14:23:07 +01:00
|
|
|
tekst: s.body ? s.body.processed : '',
|
2023-05-03 21:31:01 +02:00
|
|
|
media: s.field_media
|
|
|
|
}), 'naslov')
|
2023-06-15 20:45:38 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
async ustvariPojem(data) {
|
|
|
|
const { baseUrl, headers, deserialize } = useApi()
|
|
|
|
|
|
|
|
const req = await $fetch(`${baseUrl}/api/pojem/dodaj`, {
|
2023-12-16 01:53:05 +01:00
|
|
|
headers: {
|
|
|
|
'Accept': 'application/json',
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
2023-06-15 20:45:38 +02:00
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify(data)
|
|
|
|
})
|
|
|
|
|
|
|
|
const resp = await req.json()
|
|
|
|
console.log('nov pojem?', resp)
|
2023-05-03 21:31:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|