initial commit

This commit is contained in:
Inshal
2024-10-25 19:58:19 +05:00
commit 2046156f90
1558 changed files with 210706 additions and 0 deletions

14
resources/js/utils/api.js Normal file
View File

@@ -0,0 +1,14 @@
import { ofetch } from 'ofetch'
export const $api = ofetch.create({
baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
async onRequest({ options }) {
const accessToken = useCookie('accessToken').value
if (accessToken) {
options.headers = {
...options.headers,
Authorization: `Bearer ${accessToken}`,
}
}
},
})

View File

@@ -0,0 +1 @@
export const COOKIE_MAX_AGE_1_YEAR = 365 * 24 * 60 * 60

View File

@@ -0,0 +1,6 @@
export const paginationMeta = (options, total) => {
const start = (options.page - 1) * options.itemsPerPage + 1
const end = Math.min(options.page * options.itemsPerPage, total)
return `${total === 0 ? 0 : start} - ${end} of ${total}`
}