Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/env.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const EMAIL = "mail@mail.com";
export const PASSWORD = "passcode";
export const EMAIL = "your_mail";
export const PASSWORD = "password";
5 changes: 3 additions & 2 deletions backend/logics/CreateEvent/createEvent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ const client = new GraphQLClient(hasuraEndpoint, {

export class CreateEvent{
async create_event(req, res){
const { eventName, duration, locationType, locationDetail } = req.body;
console.log(eventName, duration, locationType, locationDetail);
const { eventName, duration, locationType, locationDetail, user_uuid } = req.body;
console.log(eventName, duration, locationType, locationDetail, user_uuid);

try {
const data = await client.request( new_event.CreateEvent(),{
user_uuid,
eventName,
duration: parseInt(duration),
locationType,
Expand Down
16 changes: 8 additions & 8 deletions backend/logics/CreateEvent/query.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export class CreateEventQuery{
CreateEvent(){
return `
mutation MyMutation($eventName: String!, $duration: Int!, $locationType: String!, $locationDetail: String!) {
insert_kalenview_create_events_one(object: {event_name: $eventName, duration: $duration, location_type: $locationType, location_detail: $locationDetail}) {
event_name
duration
location_type
location_detail
created_at
mutation MyMutation($eventName: String!, $duration: Int!, $locationType: String!, $locationDetail: String!, $user_uuid: uuid!) {
insert_kalenview_create_events_one(object: {event_name: $eventName, duration: $duration, location_type: $locationType, location_detail: $locationDetail, uuid: $user_uuid}) {
event_name
duration
location_type
location_detail
created_at
}
}
}
`;
}
}
4 changes: 2 additions & 2 deletions backend/logics/Login/login.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const generateJwtToken = () => {
"admin",
"user"
],
"x-hasura-default-role": "admin"
// "x-hasura-default-role": "user"
"x-hasura-default-role": "admin"
// "x-hasura-default-role": "user"
}
}

Expand Down
106 changes: 48 additions & 58 deletions backend/logics/Mailer/mailer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,70 @@ import Mailgen from 'mailgen';
import { EMAIL, PASSWORD } from '../../env.mjs';

export class Mailer {

async send_real_mail(req, res) {

const { eventType, eventDetail, userEmail, userName, day, eventName, date, startTime, endTime } = req.body;
console.log(userEmail, userName, day, eventName, date, startTime, endTime); // testmail@test.com New Name MON abcdef 2024-05-27 15:00 15:30
console.log(userEmail, userName, day, eventName, date, startTime, endTime);

const config = {
service: 'gmail',
auth: {
user: EMAIL,
pass: PASSWORD
}
}
};

const transporter = nodemailer.createTransport(config);

const MailGenerator = new Mailgen({
theme: "default",
product: {
name: "Event Scheduler of Kalenview ",
link: "https://mailgen.js"
}
});
try {
// Log to ensure EMAIL and PASSWORD are correctly loaded
console.log('Email:', EMAIL);
console.log('Password:', PASSWORD ? 'Password is set' : 'Password is not set');

const response = {
body: {
name: userName,
intro: `You have an upcoming event/meeting: ${eventName}`,
table: {
data: [
{
'Event Info' : 'Date',
description: date
},
{
item: 'Day',
description: day
},
{
item: 'Start Time',
description: startTime
},
{
item: 'End Time',
description: endTime
},
{
item: 'Event Location',
description: eventType
},
{
item: 'Event Description',
description: eventDetail
}
]
},
outro: "Kindly be present there are per the scheduled time"
}
}
const MailGenerator = new Mailgen({
theme: 'default',
product: {
name: 'Event Scheduler of Kalenview',
link: 'https://mailgen.js'
}
});

const mail = MailGenerator.generate(response);
const response = {
body: {
name: userName,
intro: `You have an upcoming event/meeting: ${eventName}`,
table: {
data: [
{ 'Event Info': 'Date', description: date },
{ item: 'Day', description: day },
{ item: 'Start Time', description: startTime },
{ item: 'End Time', description: endTime },
{ item: 'Event Location', description: eventType },
{ item: 'Event Description', description: eventDetail }
]
},
outro: "Kindly be present there as per the scheduled time"
}
};

let message = {
from: EMAIL,
to: [userEmail, "pramanickdebesh1412@gmail.com"],
subject: `Event Reminder: ${eventName}`,
html: mail
}
const mail = MailGenerator.generate(response);

transporter.sendMail(message).then(() => {
return res.status(201).json({ "msg": "Email is sent" })
}).catch(error => {
return res.status(500).json({ error })
});
let message = {
from: EMAIL,
to: [userEmail, "pramanickdebesh1412@gmail.com"],
subject: `Event Reminder: ${eventName}`,
html: mail
};

transporter.sendMail(message).then(() => {
return res.status(201).json({ "msg": "Email is sent" });
}).catch(error => {
console.error('Error sending email:', error);
return res.status(500).json({ error: 'Failed to send email' });
});

} catch (error) {
console.error('Mailgen initialization error:', error);
return res.status(500).json({ error: 'Mailgen initialization failed' });
}
}
}
Loading