Skip to content

Commit

Permalink
Fix home blink
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanalemunioz committed Oct 27, 2024
1 parent c0584fa commit 3497c4a
Show file tree
Hide file tree
Showing 11 changed files with 1,072 additions and 141 deletions.
27 changes: 22 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"framer-motion": "^11.0.14",
"lucide-react": "^0.358.0",
"next-themes": "^0.3.0",
"prism-react-renderer": "^2.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.51.0",
Expand Down
5 changes: 0 additions & 5 deletions src/components/code-sample.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
margin: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
display: none;
}

.code-tabs pre[class*="language-"].active {
display: block;
}

.code-tabs pre[class*="language-"].line-numbers {
Expand Down
227 changes: 102 additions & 125 deletions src/components/code-sample.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,104 @@
import { useEffect, useState } from "react";
import { useState } from "react";
import { PrismCode } from "./ui/prism-code";

import './prism';
const codeBlock =
`const Afip = require('@afipsdk/afip.js');
const afip = new Afip({ CUIT: 20409378472 });
const data = {
'PtoVta' : 1, // Punto de venta
'CbteTipo' : 6, // Tipo de comprobante
'ImpTotal' : 121, // Importe total
// ... etc.
};
const res = await afip.ElectronicBilling.createVoucher(data);
console.log({
'cae' : res['CAE'],
'vencimiento' : res['CAEFchVto']
});`

const codePHP =
`use Afip;
$afip = new Afip(array('CUIT' => 20409378472));
$data = array(
'PtoVta' => 1, // Punto de venta
'CbteTipo' => 6, // Tipo de comprobante
'ImpTotal' => 121, // Importe total
// ... etc.
);
$res = $afip->ElectronicBilling->CreateVoucher($data);
var_dump(array(
'cae' => $res['CAE'],
'vencimiento' => $res['CAEFchVto']
));`

const codeRuby =
`require "afip"
afip = Afip.new({ "CUIT": 20409378472 })
data = {
"PtoVta": 1, # Punto de venta
"CbteTipo": 6, # Tipo de comprobante
"ImpTotal": 121, # Importe total
# ... etc.
}
res = afip.ElectronicBilling.createVoucher(data)
puts {
"cae": res["CAE"],
"vencimiento": res["CAEFchVto"]
}`

const codePython =
`from afip import Afip
afip = Afip({ "CUIT": 20409378472 })
data = {
"PtoVta": 1, # Punto de venta
"CbteTipo": 6, # Tipo de comprobante
"ImpTotal": 121, # Importe total
# ... etc.
}
res = afip.ElectronicBilling.createVoucher(data)
print({
"cae": res["CAE"],
"vencimiento": res["CAEFchVto"]
})`

const codeAPI =
`curl --location 'https://app.afipsdk.com/api/v1/afip/requests' \\
--data '{
"environment": "dev",
"method": "FECAESolicitar",
"wsid": "wsfe",
"params": {
"FeCAEReq" : {
"FeDetReq" : {
"FECAEDetRequest" : {
"CbteFch" : 20240313,
"ImpTotal" : 121,
...
}
}
}
}
}'`

export default function CodeSample() {
const [activeLang, setActiveLang] = useState<'js'|'php'|'ruby'|'python'|'api'>('js');

useEffect(() => {
(window as any).Prism.highlightAll();
}, []);

return (
<div className="hero-figure anime-element">
<svg
Expand Down Expand Up @@ -69,125 +159,12 @@ export default function CodeSample() {
<img className="max-w-[20px]" src="/images/icons/api.svg" alt="api" /><span className="file">Factura</span>
</div>
</div>
<pre className={`line-numbers language-js ${activeLang === 'js' && 'active'}`} style={{whiteSpace: 'pre-wrap'}}>
<code>
{`
const Afip = require('@afipsdk/afip.js');
const afip = new Afip({ CUIT: 20409378472 });
const data = {
'PtoVta' : 1, // Punto de venta
'CbteTipo' : 6, // Tipo de comprobante
'ImpTotal' : 121, // Importe total
// ... etc.
};
const res = await afip.ElectronicBilling.createVoucher(data);
console.log({
'cae' : res['CAE'],
'vencimiento' : res['CAEFchVto']
});
`}

</code>
</pre>
<pre className={`line-numbers language-php ${activeLang === 'php' && 'active'}`} style={{whiteSpace: 'pre-wrap'}}>
<code>
{`
use Afip;
$afip = new Afip(array('CUIT' => 20409378472));
$data = array(
'PtoVta' => 1, // Punto de venta
'CbteTipo' => 6, // Tipo de comprobante
'ImpTotal' => 121, // Importe total
// ... etc.
);
$res = $afip->ElectronicBilling->CreateVoucher($data);
var_dump(array(
'cae' => $res['CAE'],
'vencimiento' => $res['CAEFchVto']
));
`}

</code>
</pre>
<pre className={`line-numbers language-ruby ${activeLang === 'ruby' && 'active'}`} style={{whiteSpace: 'pre-wrap'}}>
<code>
{`
require "afip"
afip = Afip.new({ "CUIT": 20409378472 })
data = {
"PtoVta": 1, # Punto de venta
"CbteTipo": 6, # Tipo de comprobante
"ImpTotal": 121, # Importe total
# ... etc.
}
res = afip.ElectronicBilling.createVoucher(data)
puts {
"cae": res["CAE"],
"vencimiento": res["CAEFchVto"]
}
`}

</code>
</pre>
<pre className={`line-numbers language-python ${activeLang === 'python' && 'active'}`} style={{whiteSpace: 'pre-wrap'}}>
<code>
{`
from afip import Afip
afip = Afip({ "CUIT": 20409378472 })
data = {
"PtoVta": 1, # Punto de venta
"CbteTipo": 6, # Tipo de comprobante
"ImpTotal": 121, # Importe total
# ... etc.
}
res = afip.ElectronicBilling.createVoucher(data)
print({
"cae": res["CAE"],
"vencimiento": res["CAEFchVto"]
})
`}

</code>
</pre>
<pre className={`line-numbers language-shell ${activeLang === 'api' && 'active'}`} style={{whiteSpace: 'pre-wrap'}}>
<code>
{`
curl --location 'https://app.afipsdk.com/api/v1/afip/requests' \\
--data '{
"environment": "dev",
"method": "FECAESolicitar",
"wsid": "wsfe",
"params": {
"FeCAEReq" : {
"FeDetReq" : {
"FECAEDetRequest" : {
"CbteFch" : 20240313,
"ImpTotal" : 121,
...
}
}
}
}
}'
`}
</code>
</pre>

{ activeLang === 'js' && <PrismCode codeBlock={codeBlock} lang="js" /> }
{ activeLang === 'php' && <PrismCode codeBlock={codePHP} lang="php" /> }
{ activeLang === 'ruby' && <PrismCode codeBlock={codeRuby} lang="ruby" /> }
{ activeLang === 'python' && <PrismCode codeBlock={codePython} lang="python" /> }
{ activeLang === 'api' && <PrismCode codeBlock={codeAPI} lang="shell" /> }
</div>
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions src/components/home-hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { siteConfig } from "@/config/site";
import { cn } from "@/lib/utils";
import { useEffect } from "react";

import './typewriter'

export default function HomeHero() {
useEffect(() => {

useEffect(() => {(async () => {
await import('./typewriter')

var app = document.getElementById('typewriter');

var typewriter: any = new (window as any).Typewriter(app, {
Expand Down Expand Up @@ -40,7 +41,7 @@ export default function HomeHero() {
.typeString('con Ruby')
.pauseFor(2500)
.start();
}, []);
})().catch(() => {})}, []);

return (
<>
Expand Down
Loading

0 comments on commit 3497c4a

Please sign in to comment.