82 lines
2.7 KiB
JavaScript
82 lines
2.7 KiB
JavaScript
import axios from 'axios'
|
|
|
|
const OKI_API = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:1337'
|
|
const AWTIS_POU_CHAK_PAJ = process.env.NEXT_PUBLIC_AWTIS_POU_CHAK_PAJ || 6
|
|
|
|
export async function jwennTeksEpiSlug(slug) {
|
|
const response = await axios.get(`${OKI_API}/teks?slug=${slug}&_where[published_at_null]=false`)
|
|
return response.data[0]
|
|
}
|
|
|
|
export async function jwennAwtisEpiSlug(slug) {
|
|
const response = await axios.get(`${OKI_API}/awtis?slug=${slug}&_where[published_at_null]=false`)
|
|
return response.data[0]
|
|
}
|
|
|
|
export async function jwennAwtisKantite() {
|
|
const response = await axios.get(`${OKI_API}/awtis/count?_where[published_at_null]=false`)
|
|
return response.data
|
|
}
|
|
|
|
export async function jwennTeksKantite() {
|
|
const response = await axios.get(`${OKI_API}/teks/count?_where[published_at_null]=false`)
|
|
return response.data
|
|
}
|
|
|
|
export async function jwennAwtisPajinasyon(paj) {
|
|
const start = AWTIS_POU_CHAK_PAJ * (paj - 1)
|
|
const query = `_sort=published_at:DESC&_start=${start}&_limit=${AWTIS_POU_CHAK_PAJ}&_where[published_at_null]=false`
|
|
|
|
const response = await axios.get(`${OKI_API}/awtis?${query}`)
|
|
return response.data
|
|
}
|
|
|
|
export async function jwennTeks() {
|
|
const query = '_sort=tit:ASC&_where[published_at_null]=false'
|
|
|
|
const response = await axios.get(`${OKI_API}/teks?${query}`)
|
|
return response.data
|
|
}
|
|
|
|
export async function jwennDenyeTeks() {
|
|
const query = '_sort=published_at:DESC&_limit=6&_where[published_at_null]=false'
|
|
|
|
const response = await axios.get(`${OKI_API}/teks?${query}`)
|
|
return response.data
|
|
}
|
|
|
|
export async function jwennAnTeks(teksId) {
|
|
const response = await axios.get(`${OKI_API}/teks/${teksId}`)
|
|
return response.data
|
|
}
|
|
|
|
export async function jwennTeksEpiUserId(userId) {
|
|
const query = `_sort=tit:ASC&_where[user.id]=${userId}&_publicationState=preview&published_at_null=true`
|
|
|
|
const response = await axios.get(`${OKI_API}/teks?${query}`)
|
|
return response.data
|
|
}
|
|
|
|
export async function jwennSlugs() {
|
|
const response = await axios.get(`${OKI_API}/slugs`)
|
|
return response.data
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
export async function jwennUser(userId) {
|
|
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`
|
|
const response = await axios.get(`${OKI_API}/users?${query}`)
|
|
return response.data[0]
|
|
}
|