Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
55 changes: 55 additions & 0 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,61 @@ app.post('/api/remove-saved-landlord', authenticate, saveLandlordHandler(false))
// These endpoints allow for adding and removing landlords to/from a user's saved list.
// Both endpoints use the saveLandlordHandler function with appropriate boolean parameters.

app.post(
'/api/send-email-to-landlord/:landlordEmail/:message/:subject',
authenticate,
async (req, res) => {
if (!req.user) throw new Error('Not authenticated');

const userId = req.user.uid;
const userRecord = await auth().getUser(userId);
const userEmail = userRecord?.email;
const { landlordEmail, message, subject } = req.params;

try {
if (!cuaptsEmail || !cuaptsEmailPassword) {
throw new Error('Host email or password not found');
}
if (!userEmail) {
throw new Error('User email not found');
}

const transporter = nodemailer.createTransport({
service: 'gmail',
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
type: 'login',
user: cuaptsEmail,
pass: cuaptsEmailPassword,
},
});

const mailOptions = {
from: { name: 'The CUApts Team', address: cuaptsEmail },
to: landlordEmail,
subject,
text: message,
replyTo: userEmail,
};

transporter.sendMail(mailOptions, (error, info) => {
if (error) {
console.log('Error sending email:', error);
return res.status(500).send('Error sending email');
}
console.log('Email sent:', info.response);
return res.status(200).send('Email sent successfully');

});
} catch (err) {
console.log(err);
res.status(500).send('Error');
}
}
);

/**
* update-review-status
*
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/assets/bathtub-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/assets/bedroom-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/assets/close-button-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions frontend/src/assets/date-dropdown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions frontend/src/assets/send-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/src/components/Apartment/AptInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CardData } from '../../App';
type Props = {
readonly landlordId: string | null;
readonly landlord: string;
readonly contact: string | null;
readonly contact: () => void;
readonly address: string | null;
readonly buildings: CardData[];
readonly latitude?: number;
Expand Down
Loading
Loading