fix tickets add reort mail and design fixes

This commit is contained in:
Thomas Demirdjian
2025-10-29 15:36:12 +01:00
parent d1be3c19a2
commit ce285881ca
35 changed files with 1069 additions and 202 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

+1 -1
View File
@@ -1,5 +1,5 @@
exports.GEMINI_API_KEY = "AIzaSyBoPQC5ZaMKP73TlKGpZQp1mAw8ArHiH9Y";
// exports.SUNO_API_KEY = "543b5650b30d93e98d8046a830244c80"; client api key
exports.SUNO_API_KEY = "5a689606d3c59f58268b4963d5107361"; // api key
exports.RESEND_API_KEY = "re_";
+15
View File
@@ -1,3 +1,12 @@
const fs = require("fs");
const path = require("path");
const musicLandLogoBase64 = fs.readFileSync(
path.join(__dirname, "../assets/musicLandLogo.png"),
{ encoding: "base64" },
);
const musicLandLogoSrc = `data:image/png;base64,${musicLandLogoBase64}`;
function basicTemplate({ title = "", content = "", button = null }) {
const btn = button?.url
? `<p><a href="${button.url}" style="display:inline-block;padding:10px 16px;background:#6C5CE7;color:#fff;border-radius:8px;text-decoration:none">${
@@ -6,6 +15,9 @@ function basicTemplate({ title = "", content = "", button = null }) {
: "";
return `<!doctype html><html><body style="font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;line-height:1.5;color:#111">
<div style="max-width:640px;margin:40px auto;padding:24px;border:1px solid #eee;border-radius:12px">
<div style="text-align:center;margin-bottom:20px">
<img src="${musicLandLogoSrc}" alt="MusicLand" style="height:40px" />
</div>
<h2 style="margin:0 0 16px">${title}</h2>
<div>${content}</div>
${btn}
@@ -22,6 +34,9 @@ function welcomeTemplate({ firstName = "", lastName = "" }) {
<div style="max-width:640px;margin:0 auto;padding:40px 24px">
<div style="background:#151520;border-radius:16px;overflow:hidden;border:1px solid rgba(255,255,255,0.08)">
<div style="padding:32px 28px">
<div style="text-align:center;margin-bottom:24px">
<img src="${musicLandLogoSrc}" alt="MusicLand" style="height:48px" />
</div>
<p style="margin:0 0 12px;font-size:16px;letter-spacing:0.2px">${greeting}</p>
<h1 style="margin:0 0 16px;font-size:28px;line-height:1.2">Bienvenue sur MusicLand</h1>
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:rgba(255,255,255,0.85)">
+24 -19
View File
@@ -27,6 +27,7 @@ exports.sendNotificationWhenDocIsCreated = onDocumentCreated(
receiverCollection = "users",
message = "",
data: notifData = {},
mailOnly = false,
} = event.data.data();
if (!receiver || !message) {
@@ -40,27 +41,29 @@ exports.sendNotificationWhenDocIsCreated = onDocumentCreated(
emailNotifications = false,
} = (await db.collection(receiverCollection).doc(receiver).get()).data();
const tokensSet = new Set(
[]
.concat(Array.isArray(pushTokens) ? pushTokens : [])
.concat(pushToken ? [pushToken] : [])
.filter(Boolean),
);
const tokens = Array.from(tokensSet);
if (!mailOnly) {
const tokensSet = new Set(
[]
.concat(Array.isArray(pushTokens) ? pushTokens : [])
.concat(pushToken ? [pushToken] : [])
.filter(Boolean),
);
const tokens = Array.from(tokensSet);
if (!tokens?.length) {
console.warn("User push token not found");
return null;
if (!tokens?.length) {
console.warn("User push token not found");
return null;
}
await sendExpoNotification({
tokens,
receiverId: receiver,
receiverCollection,
title: title || "MusicLand",
message: message,
data: notifData || {},
});
}
await sendExpoNotification({
tokens,
receiverId: receiver,
receiverCollection,
title: title || "MusicLand",
message: message,
data: notifData || {},
});
if (emailNotifications && !!email) {
try {
if (!email) {
@@ -219,6 +222,7 @@ const sendNotification = async ({
receiverCollection = "users",
title = "",
message = null,
mailOnly = false,
data = {},
}) => {
try {
@@ -234,6 +238,7 @@ const sendNotification = async ({
time: admin.firestore.FieldValue.serverTimestamp(),
read: false,
readAt: null,
mailOnly,
data,
};
const { id } = await refList.notifications.add(payload);
+7 -1
View File
@@ -23,12 +23,18 @@ exports.onUserCreated = onDocumentCreated("users/{userID}", async (event) => {
return;
}
try {
await resendClient.emails.send({
console.log(`Sending welcome email to ${email}`);
const { data, error } = await resendClient.emails.send({
from: WELCOME_EMAIL_FROM,
to: [email],
subject: WELCOME_EMAIL_SUBJECT,
html: welcomeTemplate({ firstName, lastName }),
});
if (error) {
console.log("Failed to send welcome email:", error);
return;
}
console.log("Welcome email sent:", data);
} catch (error) {
console.log("Failed to send welcome email:", error);
}