add link to catalog

This commit is contained in:
2025-12-19 12:55:42 -03:00
parent 3be296f1ac
commit 192be98c39
17 changed files with 514 additions and 46 deletions

View File

@@ -27,6 +27,7 @@ import { createSearch } from '@repo/util/meili'
import { request as req } from '@repo/util/request'
import placeholder from '@/assets/placeholder.webp'
import { Currency } from '@repo/ui/components/currency'
type Cert = {
exp_interval: number
@@ -220,12 +221,12 @@ function Course({
'font-bold': !custom_pricing
})}
>
{currency.format(metadata__unit_price)}
<Currency>{metadata__unit_price}</Currency>
</span>
{custom_pricing && (
<span className="font-bold">
{currency.format(custom_pricing)}
<Currency>{custom_pricing}</Currency>
</span>
)}
</li>

View File

@@ -0,0 +1,65 @@
import type { Route } from './+types/route'
import { data } from 'react-router'
export async function loader({ params, context, request }: Route.LoaderArgs) {
const url = new URL(request.url)
const cnpj = url.searchParams.get('cnpj')
const r = await fetch(`https://brasilapi.com.br/api/cnpj/v1/${cnpj}`, {
method: 'GET',
headers: {
'User-Agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36',
Accept: 'application/json'
}
})
if (!r.ok) {
throw new Response(await r.text(), { status: r.status })
}
return data({})
}
// export const prerender = false
// import type { APIRoute } from 'astro'
// import lodash from 'lodash'
// export const GET: APIRoute = async ({ params }) => {
// // await new Promise((r) => setTimeout(r, 2000))
// const cnpj = params.cnpj
// const res = await fetch(`https://brasilapi.com.br/api/cnpj/v1/${cnpj}`, {
// method: 'GET',
// headers: {
// 'User-Agent':
// 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36',
// Accept: 'application/json'
// }
// })
// if (!res.ok) {
// return new Response(null, {
// status: 404
// })
// }
// const json = await res.json()
// const addr = lodash.startCase(
// lodash.toLower(`${json.descricao_tipo_de_logradouro} ${json.logradouro}`)
// )
// return new Response(
// JSON.stringify({
// name: json.razao_social,
// address: {
// postcode: json.cep,
// address1: `${addr}, ${json.numero}`,
// neighborhood: lodash.capitalize(json.bairro),
// city: lodash.capitalize(json.municipio),
// state: json.uf
// }
// })
// )
// }