This commit is contained in:
David Ascanio 2026-02-13 01:49:41 -03:00
parent 9009b4f26e
commit e866f9ea0e
7 changed files with 465 additions and 55 deletions

View File

@ -4,6 +4,7 @@ import tailwindcss from "@tailwindcss/vite";
import { imageService } from "@unpic/astro/service";
import markdoc from "@astrojs/markdoc";
import icon from "astro-icon";
import node from "@astrojs/node";
// https://astro.build/config
export default defineConfig({
@ -24,4 +25,8 @@ export default defineConfig({
domains: ['placehold.co','ik.imagekit.io','picsum.photos'],
service: imageService(),
},
output: "server",
adapter: node({
mode: "standalone",
}),
});

191
package-lock.json generated
View File

@ -8,6 +8,7 @@
"version": "0.0.1",
"dependencies": {
"@astrojs/markdoc": "^0.15.10",
"@astrojs/node": "^9.5.3",
"@iconify-json/ph": "^1.2.2",
"@tailwindcss/vite": "^4.1.18",
"@unpic/astro": "^1.0.2",
@ -221,6 +222,20 @@
"vfile": "^6.0.3"
}
},
"node_modules/@astrojs/node": {
"version": "9.5.3",
"resolved": "https://registry.npmjs.org/@astrojs/node/-/node-9.5.3.tgz",
"integrity": "sha512-72jrSn0XtrD7COJVO6TxJmyU1yXdYK7MDdN/+fhqhf4YOhxuIPHclkXrJs8FbLCMx5ur56d/1ijX4XBeneqyXQ==",
"license": "MIT",
"dependencies": {
"@astrojs/internal-helpers": "0.7.5",
"send": "^1.2.1",
"server-destroy": "^1.0.1"
},
"peerDependencies": {
"astro": "^5.14.3"
}
},
"node_modules/@astrojs/prism": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@astrojs/prism/-/prism-3.3.0.tgz",
@ -3079,6 +3094,15 @@
"integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==",
"license": "MIT"
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
@ -3225,12 +3249,27 @@
"node": ">=4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/emoji-regex": {
"version": "10.6.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.6.0.tgz",
"integrity": "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/encoding-sniffer": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.1.tgz",
@ -3325,6 +3364,12 @@
"@esbuild/win32-x64": "0.25.12"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/escape-string-regexp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
@ -3346,6 +3391,15 @@
"@types/estree": "^1.0.0"
}
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/eventemitter3": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.4.tgz",
@ -3440,6 +3494,15 @@
"node": ">=20"
}
},
"node_modules/fresh": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
"integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@ -3752,6 +3815,26 @@
"integrity": "sha512-dTxcvPXqPvXBQpq5dUr6mEMJX4oIEFv6bwom3FDwKRDsuIjjJGANqhBuoAn9c1RQJIdAKav33ED65E2ys+87QQ==",
"license": "BSD-2-Clause"
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
@ -3774,6 +3857,12 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/iron-webcrypto": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/iron-webcrypto/-/iron-webcrypto-1.2.1.tgz",
@ -5015,6 +5104,31 @@
],
"license": "MIT"
},
"node_modules/mime-db": {
"version": "1.54.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
"integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz",
"integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==",
"license": "MIT",
"dependencies": {
"mime-db": "^1.54.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/minipass": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
@ -5176,6 +5290,18 @@
"integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==",
"license": "MIT"
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@ -5468,6 +5594,15 @@
"integrity": "sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==",
"license": "MIT"
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/readdirp": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",
@ -5779,6 +5914,44 @@
"node": ">=10"
}
},
"node_modules/send": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz",
"integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.3",
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"etag": "^1.8.1",
"fresh": "^2.0.0",
"http-errors": "^2.0.1",
"mime-types": "^3.0.2",
"ms": "^2.1.3",
"on-finished": "^2.4.1",
"range-parser": "^1.2.1",
"statuses": "^2.0.2"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/server-destroy": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/server-destroy/-/server-destroy-1.0.1.tgz",
"integrity": "sha512-rb+9B5YBIEzYcD6x2VKidaa+cqYBJQKnU4oe4E3ANwRRN56yk/ua1YCJT1n21NTS8w6CcOclAKNP3PhdCXKYtQ==",
"license": "ISC"
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/sharp": {
"version": "0.34.5",
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz",
@ -5877,6 +6050,15 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/string-width": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz",
@ -6042,6 +6224,15 @@
"tlds": "bin.js"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/trim-lines": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz",

View File

@ -10,6 +10,7 @@
},
"dependencies": {
"@astrojs/markdoc": "^0.15.10",
"@astrojs/node": "^9.5.3",
"@iconify-json/ph": "^1.2.2",
"@tailwindcss/vite": "^4.1.18",
"@unpic/astro": "^1.0.2",

View File

@ -14,51 +14,66 @@ const { id, title } = Astro.props;
<h3 class="text-lg font-bold lg:text-2xl font-secondary text-center">Formulario de Registro</h3>
<div class="form py-4 mt-6 ">
<form id="voluteenFrom" class="flex flex-col gap-2 place-items-center" action="">
<form id="voluteenFrom"
action="/api/emailPostulacion/send"
method="post"
class="flex flex-col gap-2 place-items-center">
<label class="input rounded-none bg-white">
<span>Nombres <span class="text-error">*</span></span>
<input id="name" type="text" placeholder="Nombres" class="w-full max-w-xs rounded-none invalid:border-error focus:invalid:border-error" required/>
<input name="nombres" type="text" placeholder="Nombres"
class="w-full max-w-xs rounded-none invalid:border-error focus:invalid:border-error"
required />
</label>
<label class="input rounded-none bg-white">
<span>Apellidos <span class="text-error">*</span></span>
<input id="lastname" type="text" placeholder="Apellidos" class="w-full max-w-xs rounded-none invalid:border-error focus:invalid:border-error" required />
<input name="apellidos" type="text" placeholder="Apellidos"
class="w-full max-w-xs rounded-none invalid:border-error focus:invalid:border-error"
required />
</label>
<label class="input rounded-none bg-white">
<span>País</span>
<input id="country" type="text" placeholder="Pais" class="w-full max-w-xs rounded-none" />
<input name="pais" type="text" placeholder="Pais"
class="w-full max-w-xs rounded-none" />
</label>
<label class="input rounded-none bg-white">
<span>Lugar</span>
<input id="place" type="text" placeholder="Lugar" class="w-full max-w-xs rounded-none" />
<input name="lugar" type="text" placeholder="Lugar"
class="w-full max-w-xs rounded-none" />
</label>
<label class="input rounded-none bg-white">
<span>Dirección</span>
<input id="address" type="text" placeholder="Dirección" class="w-full max-w-xs rounded-none" />
<input name="direccion" type="text" placeholder="Dirección"
class="w-full max-w-xs rounded-none" />
</label>
<label class="input rounded-none bg-white">
<span>Teléfono <span class="text-error">*</span></span>
<input id="phone" type="text" placeholder="Teléfono" class="w-full max-w-xs rounded-none invalid:border-error focus:invalid:border-error" required />
<input name="telefono" type="text" placeholder="Teléfono"
class="w-full max-w-xs rounded-none invalid:border-error focus:invalid:border-error"
required />
</label>
<label class="input validator rounded-none bg-white">
<span>Email <span class="text-error">*</span></span>
<input id="email" type="email" placeholder="Ingresa Correo Electrónico" class="w-full max-w-xs rounded-none invalid:border-error focus:invalid:border-error" required />
<input name="email" type="email"
placeholder="Ingresa Correo Electrónico"
class="w-full max-w-xs rounded-none invalid:border-error focus:invalid:border-error"
required />
</label>
<div class="validator-hint hidden text-error text-sm">
Inserta un correo electrónico válido
</div>
<button type="submit" class="btn mt-4 bg-[#22523F] text-[#EBE6D2] border-0 hover:bg-[#EBE6D2]/90 hover:text-tertiary uppercase rounded-none">Enviar</button>
<button type="submit"
class="btn mt-4 bg-[#22523F] text-[#EBE6D2] border-0 hover:bg-[#EBE6D2]/90 hover:text-tertiary uppercase rounded-none">
Enviar
</button>
</form>
</div>
</div>
</dialog>

View File

@ -1,49 +1,109 @@
---
import { Icon } from "astro-icon/components";
import { Image } from "astro:assets"
import { Image } from "astro:assets";
import jbp from "../../assets/DRJBP-1.webp";
---
<div id="contact" class="bg-[#22523F]">
<div class="container mx-auto py-20 relative text-[#EBE5D0]">
<div class="absolute bottom-0 right-0 w-80 hidden lg:block">
<Image
src={jbp.src}
alt=""
/>
<Image src={jbp} alt="Centro del Reino de Paz y Justicia" />
</div>
<h4 class="text-lg text-center font-bold uppercase">Contacto</h4>
<h2 class="text-2xl lg:text-5xl text-center font-bold font-secondary my-8">Conectemos con visión y propósito</h2>
<h2 class="text-2xl lg:text-5xl text-center font-bold font-secondary my-8">
Conectemos con visión y propósito
</h2>
<div class="px-12 lg:px-4 lg:w-2/5 mx-auto">
<p class="text-lg font-light mb-10">El <strong>Centro del Reino de Paz y Justicia</strong> dispone de canales directos para consultas institucionales, participación en programas y actividades internacionales.</p>
<p class="text-lg font-light mb-10 wrap-break-word">Correo electrónico: <strong>info@centrodelreinodepazyjusticia.com</strong><br> Redes sociales: actualizaciones permanentes sobre actividades y convocatorias.</p>
<div class="flex flex-col gap-4">
<form action="">
<p class="text-lg font-light mb-10">
El <strong>Centro del Reino de Paz y Justicia</strong> dispone de canales
directos para consultas institucionales, participación en programas y
actividades internacionales.
</p>
<p class="text-lg font-light mb-10 break-words">
Correo electrónico:
<strong>info@centrodelreinodepazyjusticia.com</strong><br />
Redes sociales: actualizaciones permanentes sobre actividades y convocatorias.
</p>
<!-- FORMULARIO -->
<form method="POST" action="/api/emailInfo/send" class="flex flex-col gap-4">
<fieldset>
<input type="text" placeholder="Nombre y Apellido" class="bg-[#EBE5D0] w-full py-2 px-4 mb-2 placeholder:text-[#303335]"/>
<input type="text" placeholder="E-Mail" class="bg-[#EBE5D0] w-full py-2 px-4 mb-2 placeholder:text-[#303335]" />
<input
name="nombre"
type="text"
placeholder="Nombre y Apellido"
required
class="bg-[#EBE5D0] w-full py-2 px-4 mb-2 text-[#303335] placeholder:text-[#303335] focus:outline-none"
/>
<input
name="email"
type="email"
placeholder="E-Mail"
required
class="bg-[#EBE5D0] w-full py-2 px-4 mb-2 text-[#303335] placeholder:text-[#303335] focus:outline-none"
/>
<textarea
name="mensaje"
placeholder="Escriba su mensaje"
rows="5"
required
class="bg-[#EBE5D0] w-full py-2 px-4 mb-2 text-[#303335] placeholder:text-[#303335] focus:outline-none"
></textarea>
<textarea placeholder="Escriba su mensaje" rows="5" class="bg-[#EBE5D0] w-full py-2 px-4 mb-2 placeholder:text-[#303335]"></textarea>
</fieldset>
</form>
</div>
<div class="flex flex-row justify-between">
<div class="flex flex-row justify-between items-center mt-4">
<ul class="flex flex-row gap-2">
<li class="border-r-1 pr-2"><a href="https://x.com/CRPazYJusticia" target="_blank"><Icon name="ph:x-logo-thin" class="text-3xl" /></a></li>
<li class="border-r-1 pr-2"><a href="https://www.instagram.com/centrodelreinodepazyjusticia/" target="_blank"><Icon name="ph:instagram-logo-thin" class="text-3xl" /></a></li>
<li class="border-r-1 pr-2"><a href="https://www.facebook.com/Centrodelreinodepazyjusticia" target="_blank"><Icon name="ph:facebook-logo-thin" class="text-3xl" /></a></li>
<li><a href="https://www.youtube.com/@CentrodelReinodePazyJusticia" target="_blank"><Icon name="ph:youtube-logo-thin" class="text-3xl" /></a></li>
<li class="border-r pr-2">
<a href="#">
<Icon name="ph:linkedin-logo-thin" class="text-3xl" />
</a>
</li>
<li class="border-r pr-2">
<a href="#">
<Icon name="ph:instagram-logo-thin" class="text-3xl" />
</a>
</li>
<li class="border-r pr-2">
<a href="#">
<Icon name="ph:facebook-logo-thin" class="text-3xl" />
</a>
</li>
<li>
<a href="#">
<Icon name="ph:youtube-logo-thin" class="text-3xl" />
</a>
</li>
</ul>
<button class="bg-[#003421] px-4 py-2 text-sm hover:bg-[#EBE5D0] hover:text-[#003421] cursor-pointer transition">
<button
type="submit"
class="bg-[#003421] px-6 py-2 text-sm hover:bg-[#EBE5D0] hover:text-[#003421] cursor-pointer transition duration-300"
>
Enviar
</button>
</div>
</form>
</div>
<div class="mt-20">
<p class="px-4 text-sm text-white">©2026. Todos los Derechos Reservados. All Rights Reserved. Centro del Reino de Paz y Justicia</p>
</div>
<p class="px-4 text-sm text-white text-center">
©2026. Todos los Derechos Reservados. All Rights Reserved.
Centro del Reino de Paz y Justicia
</p>
</div>
</div>
</div>

View File

@ -0,0 +1,63 @@
import type { APIRoute } from "astro";
export const prerender = false;
export const POST: APIRoute = async ({ request }) => {
try {
// 🔹 Leer datos del formulario
const formData = await request.formData();
const nombre = formData.get("nombre")?.toString().trim();
const email = formData.get("email")?.toString().trim();
const mensaje = formData.get("mensaje")?.toString().trim();
// 🔹 Validación básica
if (!nombre || !email || !mensaje) {
return new Response(
JSON.stringify({ error: "Datos incompletos" }),
{ status: 302 }
);
}
const emailApiKey = import.meta.env.EMAIL_API_KEY;
// 🔹 Enviar a tu backend real
const response = await fetch("http://155.138.215.11:3050/email/send", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": emailApiKey!,
},
body: JSON.stringify({
type: "CENTRO_DEL_REINO_PAZ_Y_JUSTICIA_INFO",
data: {
nombre,
email,
mensaje,
},
}),
});
if (!response.ok) {
return new Response(
JSON.stringify({ error: "Error en servicio de correo" }),
{ status: 302 }
);
}
// 🔹 Redirección elegante después de enviar
return new Response(null, {
status: 302,
headers: {
Location: "/?success=true",
},
});
} catch (error) {
console.log(error)
return new Response(null, {
status: 302,
headers: {
Location: "/",
},
});
}
};

View File

@ -0,0 +1,75 @@
import type { APIRoute } from "astro";
export const prerender = false;
export const POST: APIRoute = async ({ request }) => {
try {
// 🔹 Leer datos del formulario
const formData = await request.formData();
const nombres = formData.get("nombres")?.toString().trim();
const apellidos = formData.get("apellidos")?.toString().trim();
const pais = formData.get("pais")?.toString().trim();
const lugar = formData.get("lugar")?.toString().trim();
const direccion = formData.get("direccion")?.toString().trim();
const telefono = formData.get("telefono")?.toString().trim();
const email = formData.get("email")?.toString().trim();
// 🔹 Validación básica
if (!nombres || !apellidos || !telefono || !email) {
return Response.redirect("/?error=datos", 303);
}
const dataSend = {
nombres,
apellidos,
pais,
lugar,
direccion,
telefono,
email
};
console.log(dataSend)
const emailApiKey = import.meta.env.EMAIL_API_KEY;
// 🔹 Enviar a tu backend real
const response = await fetch("http://155.138.215.11:3050/email/send", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": emailApiKey!,
},
body: JSON.stringify({
type: "CENTRO_DEL_REINO_PAZ_Y_JUSTICIA_POSTULACION",
data: dataSend,
}),
});
console.log(response)
if (!response.ok) {
return new Response(null, {
status: 302,
headers: {
Location: "/",
},
});
}
// 🔹 Redirección elegante después de enviar
return new Response(null, {
status: 302,
headers: {
Location: "/?success=true",
},
});
} catch (error) {
console.log(error)
return new Response(null, {
status: 302,
headers: {
Location: "/",
},
});
}
};