mirror of
https://github.com/ArthurDanjou/arthome.git
synced 2026-01-14 12:14:33 +01:00
Working on arthome
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
export async function isAuthorized() {
|
||||
const { user } = useUserSession()
|
||||
const { data: authorized } = await useFetch('/api/authorized', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
email: user.value?.email ?? 'test@nuxt.com',
|
||||
},
|
||||
})
|
||||
return authorized.value
|
||||
}
|
||||
13
app/composables/categories.ts
Normal file
13
app/composables/categories.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export function useCategories() {
|
||||
async function getCategories() {
|
||||
return useAsyncData<CategoryType[]>(async () => {
|
||||
const res = await $fetch('/api/categories')
|
||||
console.log('res', res)
|
||||
return res
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
getCategories,
|
||||
}
|
||||
}
|
||||
21
app/composables/tabs.ts
Normal file
21
app/composables/tabs.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export function useTabs() {
|
||||
async function createTab(tab: TabType) {
|
||||
console.log('createTab', tab)
|
||||
return tab
|
||||
}
|
||||
|
||||
async function deleteTab(tab: TabType) {
|
||||
console.log('deleteTab', tab)
|
||||
return tab
|
||||
}
|
||||
|
||||
async function updateTab(tab: TabType) {
|
||||
console.log('updateTab', tab)
|
||||
return tab
|
||||
}
|
||||
|
||||
return {
|
||||
createTab,
|
||||
deleteTab,
|
||||
}
|
||||
}
|
||||
21
app/composables/toasts.ts
Normal file
21
app/composables/toasts.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
export function useSuccessToast(title: string, description?: string) {
|
||||
const toast = useToast()
|
||||
|
||||
toast.add({
|
||||
title,
|
||||
description,
|
||||
color: 'green',
|
||||
icon: 'i-ph:check-circle-duotone',
|
||||
})
|
||||
}
|
||||
|
||||
export function useErrorToast(title: string, description?: string) {
|
||||
const toast = useToast()
|
||||
|
||||
toast.add({
|
||||
title,
|
||||
description,
|
||||
color: 'red',
|
||||
icon: 'i-ph:x-circle-duotone',
|
||||
})
|
||||
}
|
||||
22
app/composables/user-limit.ts
Normal file
22
app/composables/user-limit.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export function useUserLimit() {
|
||||
function hasUserFreePlan() {
|
||||
return true
|
||||
}
|
||||
|
||||
function getRemainingCategories() {
|
||||
if (!hasUserFreePlan())
|
||||
return -1
|
||||
return 3
|
||||
}
|
||||
|
||||
function getRemainingTabs(category_id: number) {
|
||||
if (!hasUserFreePlan())
|
||||
return -1
|
||||
return category_id * 3
|
||||
}
|
||||
|
||||
return {
|
||||
getRemainingCategories,
|
||||
getRemainingTabs,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user