first deploy with astro

This commit is contained in:
2025-03-11 20:57:48 -03:00
parent 772cc74550
commit ac4d429eca
21 changed files with 6094 additions and 13 deletions

View File

@@ -68,7 +68,7 @@ export default function Layout() {
</div>
</header>
<main className="p-4 lg:p-8">
<main className="p-4 lg:p-8 space-y-5">
{isNavigating ? <Loading /> : <Outlet />}
</main>
</section>

View File

@@ -1,17 +1,74 @@
import { useSuspenseQuery } from '@tanstack/react-query'
import { memo } from 'react'
import { Heading } from '~/components/heading'
import { CpfCnpj } from '~/components/cpf-cnpj'
import { Table, Tbody, Td, Th, Thead, Tr } from '~/components/table'
import { Abbr } from '~/components/abbr'
import { Datetime } from '~/components/datetime'
import axios from '~/axios'
export function meta({}) {
return [{ title: 'Usuários' }]
}
export default function Component() {
const info = useSuspenseQuery({
queryKey: ['users'],
queryFn: async () => {
await new Promise((r) => setTimeout(r, 3000))
return { data: 'todos' }
},
})
return <>users index</>
export async function clientLoader() {
await new Promise((r) => setTimeout(r, 2000))
const index = 'users'
const { data } = await axios.get('/search/', { params: { index } })
return data
}
export default function Component({ loaderData: { hits = [] } }) {
return (
<>
<Heading>Usuários</Heading>
<Table>
<Thead>
<Tr>
<Th>&nbsp;</Th>
<Th>Nome</Th>
<Th>CPF/CNPJ</Th>
<Th>Email</Th>
<Th>Último acesso</Th>
</Tr>
</Thead>
<Tbody>
{hits.map((props) => (
<Row key={props.id} {...props} />
))}
{hits.length === 0 && (
<Tr className="no-hover">
<Td colSpan={5}>Nada encontrado</Td>
</Tr>
)}
</Tbody>
</Table>
</>
)
}
const Row = memo(function Row({
id,
name,
cpf,
cnpj,
email,
lastLogin: last_login,
}) {
return (
<Tr className="cursor-pointer" data-hover={!cnpj}>
<Td>
<Abbr maxLen={6}>{id}</Abbr>
</Td>
<Td>
<Abbr>{name}</Abbr>
</Td>
<CpfCnpj as={Td}>{cpf ?? cnpj}</CpfCnpj>
<Td>
<Abbr>{email}</Abbr>
</Td>
<Datetime as={Td}>{last_login}</Datetime>
</Tr>
)
})