Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsJorgeRdz03 committed Jun 3, 2024
2 parents 8d40023 + f4f9f23 commit 7243739
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 5 deletions.
12 changes: 12 additions & 0 deletions client/src/pages/Producto.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { Navigate, useNavigate } from "react-router-dom";
import { useLocation } from 'react-router-dom';
import PopupLogin from "../components/ui/Login/PopupLogin.jsx";
import { Helmet, HelmetProvider } from "react-helmet-async";
import { ArrowProps } from 'react-multi-carousel/lib/types'
import { faDiamond, faAngleLeft, faAngleRight } from '@fortawesome/free-solid-svg-icons';

const StyledRating = styled(Rating)({
'& .MuiRating-iconFilled': {
Expand Down Expand Up @@ -357,6 +359,16 @@ function Producto() {
sliderclassName=""
slidesToSlide={1}
swipeable
customLeftArrow={<FontAwesomeIcon
icon={faAngleLeft}
size="lg"
className="absolute cursor-pointer top-1/2 transform -translate-y-1/2 -left-0 text-3xl text-primary-900 aspect-square bg-[#e6e6e6] rounded-full text-[#036C65] p-3 hover:opacity-90 overflow-visible z-10"
/>}
customRightArrow={<FontAwesomeIcon
size="lg"
icon={faAngleRight}
className="absolute cursor-pointer top-1/2 transform -translate-y-1/2 -right-0 text-3xl text-primary-900 bg-[#e6e6e6] rounded-full aspect-square text-[#036C65] p-3 hover:opacity-90 overflow-visible z-10"
/>}
// className=''
>
{descuentos.map(oferta => (
Expand Down
10 changes: 7 additions & 3 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,13 @@ app.get("/api/step1.5", async (solicitud, respuesta) => {
});


cron.schedule("0 0 0 * * *",()=>{
perfil.LectorRenovacionSuscripcion()
});

cron.schedule("30 1 0 * * *",()=>{
perfil.LectorRenovacionSuscripcion();
perfil.Renovacion();
}); // se ejecutara 1 minutos con 30 segundos despues de las 0 horas



app.get("*", (solicitud, respuesta) => {
respuesta.sendFile(path.join(_dirname, "../client/dist/index.html"));
Expand Down
47 changes: 46 additions & 1 deletion server/controllers/perfil-data.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ async function getSuscripcion(solicitud,respuesta){

objeto_respuesta.fechaExpiracion = `${aE}-${mE}-${dE}`;
objeto_respuesta.fechaInicio = `${aI}-${mI}-${dI}`;

}


Expand Down Expand Up @@ -1154,6 +1155,49 @@ async function LectorRenovacionSuscripcion(){



async function Renovacion(){

let consulta = 'select * from clienteMembresia inner join cliente on clienteMembresia.fkCliente = cliente.fkUsuario where activo = 1 and fkMembresia = 1 and fechaInicio = curdate() and renovacion_auto = 1';

let [fields] = await conexion.query(mysql.format(consulta));

let f = fields;

let renovadores = [];

if(f != undefined){
for(let i in f){
renovadores.push(f[i].fkCliente); // anadir el id del cliente a la lista
}
}

for(let i in renovadores){
let consulta_correo = 'select * from usuario where pkIdUsuario = ?';

let [correo_usuario] = await conexion.query(mysql.format(consulta_correo,[renovadores[i]]));

let CE = correo_usuario[0].email;

let nU = correo_usuario[0].nombre;
let pU = correo_usuario[0].apellidoP;
let mU = correo_usuario[0].apellidoM;

let full_name = `${pU} ${mU} ${nU}`;

try{
//toca enviar al usuario un correo
await servicios.renovacionSuscripcion(CE,"token",full_name);
}catch(error){
console.log('no se pudo realizar el envio');
console.log(error);
}
}

}







Expand Down Expand Up @@ -1221,5 +1265,6 @@ export const methods = {
getOpcionesPago,
getSuscripcion,
deleteSuscripcion,
LectorRenovacionSuscripcion
LectorRenovacionSuscripcion,
Renovacion
}
57 changes: 56 additions & 1 deletion server/services/mail.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ async function vencimientoSuscripcion(direccion,token,full_name){
}


async function renovacionSuscripcion(direccion,token,full_name){
return await transporter.sendMail({
from:process.env.EMAIL_USER,
to:direccion,
subject:'Tu suscripcion ha sido renovada',
html:cuerpoRenovacion(token,full_name)
})
}



async function Cambio_de_correo(token,full_name,id,correo){
return await transporter.sendMail({
from:process.env.EMAIL_USER,
Expand Down Expand Up @@ -361,6 +372,49 @@ function cuerpoVencimiento(token,full_name){
}


function cuerpoRenovacion(token,full_name){
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
*{
padding: 0;
margin: 0;
}
.body-email{
background-color: #82E0AA;
padding: 8px;
display: flex;
flex-direction: column;
}
.body-email .header{
position: relative;
width: 100%;
background-color: aliceblue;
font-size: 25px;
padding: 2px;
}
</style>
</head>
<body>
<div class="body-email">
<div class="header">
<span>La suscripcion mensual ha sido cargada a tu cuenta.</span>
</div>
<div class="body">
<p>Estimad@ ${full_name}, le informamos que el cobro de la suscripcion mensual ya se realizo, el monto de la transaccion es de 199.00 pesos mexicanos, para ver mas detalle de la compra entre a la pagina de armony: link</p>
</div>
</div>
</body>
</html>`;
}





Expand All @@ -370,5 +424,6 @@ export const methods = {
Codigo_de_Verificacion,
Confirmacion_Contraseña,
CancelacionSuscripcion,
vencimientoSuscripcion
vencimientoSuscripcion,
renovacionSuscripcion
}

0 comments on commit 7243739

Please sign in to comment.