diff --git a/app/components/home/HomeChart.client.vue b/app/components/home/HomeChart.client.vue deleted file mode 100644 index f365be5..0000000 --- a/app/components/home/HomeChart.client.vue +++ /dev/null @@ -1,150 +0,0 @@ - - - - - - - Revenue - - {{ formatNumber(total) }} - - - - - - - - - - - - - - - - - - diff --git a/app/components/home/HomeChart.server.vue b/app/components/home/HomeChart.server.vue deleted file mode 100644 index 893c837..0000000 --- a/app/components/home/HomeChart.server.vue +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - Revenue - - - --- - - - - - - - diff --git a/app/components/home/HomeDateRangePicker.vue b/app/components/home/HomeDateRangePicker.vue deleted file mode 100644 index 4eabd4d..0000000 --- a/app/components/home/HomeDateRangePicker.vue +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - {{ df.format(selected.start) }} - {{ df.format(selected.end) }} - - - {{ df.format(selected.start) }} - - - - Pick a date - - - - - - - - - - - - - - - - - - - diff --git a/app/components/home/HomePeriodSelect.vue b/app/components/home/HomePeriodSelect.vue deleted file mode 100644 index 614e056..0000000 --- a/app/components/home/HomePeriodSelect.vue +++ /dev/null @@ -1,49 +0,0 @@ - - - - - diff --git a/app/components/home/HomeSales.vue b/app/components/home/HomeSales.vue deleted file mode 100644 index 46159f1..0000000 --- a/app/components/home/HomeSales.vue +++ /dev/null @@ -1,112 +0,0 @@ - - - - - diff --git a/app/components/home/HomeStats.vue b/app/components/home/HomeStats.vue deleted file mode 100644 index 88a34c7..0000000 --- a/app/components/home/HomeStats.vue +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - {{ stat.value }} - - - - {{ stat.variation > 0 ? '+' : '' }}{{ stat.variation }}% - - - - - diff --git a/app/composables/useUsers.ts b/app/composables/useUsers.ts index 4369536..d09d2d6 100644 --- a/app/composables/useUsers.ts +++ b/app/composables/useUsers.ts @@ -1,8 +1,10 @@ +import type { Profile } from '~/types' + export function useUsers() { const supabase = useSupabaseClient() // Shared state using useState key - const users = useState('users-list', () => []) + const users = useState('users-list', () => []) const loading = useState('users-loading', () => false) const error = useState('users-error', () => null) @@ -23,10 +25,10 @@ export function useUsers() { return } - users.value = data || [] + users.value = (data as Profile[]) || [] } - async function addUser(user: any) { + async function addUser(user: Omit & { password?: string }) { loading.value = true error.value = null @@ -38,26 +40,30 @@ export function useUsers() { await loadUsers() } catch (err: any) { console.error(err) - error.value = err.data?.message || 'Erro ao adicionar usuário.' + error.value = err.data?.message || err.message || 'Erro ao adicionar usuário.' throw err } finally { loading.value = false } } - async function updateUser(user: any) { + async function updateUser(user: Partial & { user_id: string }) { loading.value = true error.value = null try { await $fetch('/api/users', { method: 'PUT', - body: user + body: { + id: user.user_id, + name: user.name, + role: user.role + } }) await loadUsers() } catch (err: any) { console.error(err) - error.value = err.data?.message || 'Erro ao atualizar usuário.' + error.value = err.data?.message || err.message || 'Erro ao atualizar usuário.' throw err } finally { loading.value = false @@ -75,7 +81,7 @@ export function useUsers() { await loadUsers() } catch (err: any) { console.error(err) - error.value = err.data?.message || 'Erro ao excluir usuário.' + error.value = err.data?.message || err.message || 'Erro ao excluir usuário.' throw err } finally { loading.value = false diff --git a/app/layouts/default.vue b/app/layouts/default.vue index 1baa370..40ce8a1 100644 --- a/app/layouts/default.vue +++ b/app/layouts/default.vue @@ -14,7 +14,7 @@ const links = [ } }, { - label: 'Anúncios', + label: 'Anúncios App', icon: 'i-lucide-megaphone', to: '/anuncios', onSelect: () => { diff --git a/app/pages/index.vue b/app/pages/index.vue index efeb427..8df19e6 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -1,7 +1,5 @@ @@ -41,36 +33,15 @@ const period = ref('daily') - - - - - - - - - - Dashboard Em construção... - - - - + + + + Bem-vindo ao Painel + Selecione uma opção no menu lateral para começar. + + + diff --git a/app/types/index.d.ts b/app/types/index.d.ts index d61378e..72d5dc8 100644 --- a/app/types/index.d.ts +++ b/app/types/index.d.ts @@ -1,44 +1,11 @@ -import type { AvatarProps } from '@nuxt/ui' +export type UserRole = 'user' | 'admin' -export type UserStatus = 'user' | 'admin' -export type SaleStatus = 'paid' | 'failed' | 'refunded' - -export interface User { - id: string - name: string - email: string - avatar?: AvatarProps - role: UserStatus -} - -export interface Mail { - id: number - unread?: boolean - from: User - subject: string - body: string - date: string -} - -export interface Stat { - title: string - icon: string - value: number | string - variation: number - formatter?: (value: number) => string -} - -export interface Sale { - id: string - date: string - status: SaleStatus +export interface Profile { + user_id: string email: string - amount: number + name: string + role: UserRole + created_at: string } -export type Period = 'daily' | 'weekly' | 'monthly' - -export interface Range { - start: Date - end: Date -} +export type User = Profile diff --git a/server/api/users.put.ts b/server/api/users.put.ts index d4d35ca..b4a92f4 100644 --- a/server/api/users.put.ts +++ b/server/api/users.put.ts @@ -24,7 +24,7 @@ export default defineEventHandler(async (event) => { const client = await serverSupabaseServiceRole(event) - const updates: any = {} + const updates: Record = {} if (name !== undefined) updates.name = name if (role !== undefined) updates.role = role
Revenue
- {{ formatNumber(total) }} -
- Revenue -
- --- -
Selecione uma opção no menu lateral para começar.