2020-12-11 01:35:49 +01:00
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
|
|
const OKI_API = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:1337'
|
2020-12-12 21:50:16 +01:00
|
|
|
const AWTIS_POU_CHAK_PAJ = process.env.NEXT_PUBLIC_AWTIS_POU_CHAK_PAJ || 6
|
2020-12-11 01:35:49 +01:00
|
|
|
|
2020-12-18 21:55:14 +01:00
|
|
|
export async function jwennTeksEpiSlug(slug) {
|
2020-12-23 20:38:15 +01:00
|
|
|
const response = await axios.get(`${OKI_API}/teks?slug=${slug}&_where[published_at_null]=false`)
|
2020-12-18 21:55:14 +01:00
|
|
|
return response.data[0]
|
2020-12-11 01:35:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function jwennAwtisKantite() {
|
2020-12-23 20:29:04 +01:00
|
|
|
const response = await axios.get(`${OKI_API}/awtis/count?_where[published_at_null]=false`)
|
2020-12-11 01:35:49 +01:00
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 20:29:59 +01:00
|
|
|
export async function jwennTeksKantite() {
|
|
|
|
|
const response = await axios.get(`${OKI_API}/teks/count?_where[published_at_null]=false`)
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-11 01:35:49 +01:00
|
|
|
export async function jwennAwtisPajinasyon(paj) {
|
2020-12-12 21:50:16 +01:00
|
|
|
const start = AWTIS_POU_CHAK_PAJ * (paj - 1)
|
2022-02-05 13:59:02 +04:00
|
|
|
const query = `_sort=updatedAt:DESC&_start=${start}&_limit=${AWTIS_POU_CHAK_PAJ}&_where[published_at_null]=false`
|
2020-12-11 01:35:49 +01:00
|
|
|
|
|
|
|
|
const response = await axios.get(`${OKI_API}/awtis?${query}`)
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function jwennTeks() {
|
2020-12-23 20:38:15 +01:00
|
|
|
const query = '_sort=tit:ASC&_where[published_at_null]=false'
|
2020-12-13 23:10:03 +01:00
|
|
|
|
2020-12-18 21:55:14 +01:00
|
|
|
const response = await axios.get(`${OKI_API}/teks?${query}`)
|
2020-12-11 01:35:49 +01:00
|
|
|
return response.data
|
|
|
|
|
}
|
2020-12-21 03:22:05 +01:00
|
|
|
|
2021-05-24 02:58:04 +02:00
|
|
|
export async function jwennTeksEpiUserId(userId) {
|
2022-03-25 00:04:30 +04:00
|
|
|
const query = `_sort=tit:ASC&_where[user.id]=${userId}&_publicationState=preview&published_at_null=true`
|
2021-05-24 02:58:04 +02:00
|
|
|
|
|
|
|
|
const response = await axios.get(`${OKI_API}/teks?${query}`)
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-21 03:22:05 +01:00
|
|
|
export async function jwennSlugs() {
|
|
|
|
|
const response = await axios.get(`${OKI_API}/slugs`)
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
2021-06-26 12:16:24 +02:00
|
|
|
|
|
|
|
|
export async function jwennKomanteEpiTeksId(teksId) {
|
|
|
|
|
const query = `_sort=published_at:DESC&_where[teks]=${teksId}&_where[published_at_null]=false`
|
|
|
|
|
const response = await axios.get(`${OKI_API}/komante?${query}`)
|
|
|
|
|
return response.data
|
|
|
|
|
}
|
2022-02-06 18:41:57 +04:00
|
|
|
|
|
|
|
|
export async function jwennUser(userId) {
|
2022-02-07 16:26:34 +04:00
|
|
|
const query = `_where[id]=${userId}&_where[confirmed]=true&_where[blocked]=false`
|
|
|
|
|
const response = await axios.get(`${OKI_API}/users?${query}`)
|
|
|
|
|
return response.data[0]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function jwennUserEpiEmail(email) {
|
|
|
|
|
const query = `_where[email]=${email}&_where[confirmed]=false&_where[blocked]=false`
|
2022-02-06 18:41:57 +04:00
|
|
|
const response = await axios.get(`${OKI_API}/users?${query}`)
|
|
|
|
|
return response.data[0]
|
|
|
|
|
}
|