Skip to content
Merged
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: 3 additions & 1 deletion components/Nav/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ function classNames(...classes: string[]) {
const Nav = () => {
const { data: session } = useSession();

const { data: count } = trpc.notification.getCount.useQuery();
const { data: count } = trpc.notification.getCount.useQuery(undefined, {
enabled: session ? true : false,
});

const userNavigation = [
{
Expand Down
14 changes: 9 additions & 5 deletions pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ export const authOptions: NextAuthOptions = {
return;
}
const htmlMessage = createWelcomeEmailTemplate(user?.name || undefined);
sendEmail({
recipient: user.email,
htmlMessage,
subject: "Welcome to Codú 🎉 | Here is your community invite 💌",
});
try {
sendEmail({
recipient: user.email,
htmlMessage,
subject: "Welcome to Codú 🎉 | Here is your community invite 💌",
});
} catch (error) {
console.log("Error in createUser event:", error);
}
},
},
};
Expand Down
27 changes: 13 additions & 14 deletions utils/sendEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,22 @@ const sendEmail = async (config: MailConfig) => {
const emailSchema = z.string().email();
const to = emailSchema.parse(recipient);
// send some mail
try {
await transporter.sendMail(
{
from: "[email protected]",
to,
subject,
html: htmlMessage,
},
(err, info) => {
transporter.sendMail(
{
from: "[email protected]",
to,
subject,
html: htmlMessage,
},
(err, info) => {
if (err) {
console.log("Error sending mail:", err);
} else {
console.log(info.envelope);
console.log(info.messageId);
}
);
} catch (error) {
console.log("Error sending mail.");
console.log(error);
}
}
);
};

export default sendEmail;