Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Nov 27, 2024
1 parent 83f6bc9 commit c4b2d1b
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 21 deletions.
3 changes: 3 additions & 0 deletions apps/dashboard/jobs/utils/transaction-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export async function handleTransactionNotifications(
description: t("notifications.transactions", {
numberOfTransactions: transactions.length,
}),
// For single transaction
amount: transactions[0]?.amount,
name: transactions[0]?.name,
},
user: {
subscriberId: user.id,
Expand Down
2 changes: 1 addition & 1 deletion packages/email/components/get-started.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function GetStarted() {
return (
<Section className="text-center mt-[50px] mb-[50px]">
<Button
className="bg-transparent rounded-md text-primary text-[14px] text-[#121212] font-medium no-underline text-center px-6 py-3 border border-solid border-[#121212]"
className="bg-transparent text-primary text-[14px] text-[#121212] font-medium no-underline text-center px-6 py-3 border border-solid border-[#121212]"
href="https://go.midday.ai/VmJhYxE"
>
Get started
Expand Down
102 changes: 84 additions & 18 deletions packages/email/emails/transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type Transaction = {
name: string;
currency: string;
category?: string;
status: "pending" | "posted";
teamName: string;
};

Expand All @@ -42,7 +41,6 @@ const defaultTransactions = [
amount: -1000,
currency: "USD",
name: "Spotify",
status: "pending",
},
{
id: "2",
Expand All @@ -51,23 +49,97 @@ const defaultTransactions = [
currency: "USD",
name: "H23504959",
category: "income",
status: "pending",
},
{
id: "3",
date: new Date().toISOString(),
amount: -1000,
currency: "USD",
name: "Webflow",
status: "posted",
},
{
id: "4",
date: new Date().toISOString(),
amount: -1000,
currency: "USD",
name: "Netflix",
status: "posted",
},
{
id: "5",
date: new Date().toISOString(),
amount: -2500,
currency: "USD",
name: "Adobe Creative Cloud",
},
{
id: "6",
date: new Date().toISOString(),
amount: -1499,
currency: "USD",
name: "Amazon Prime",
},
{
id: "7",
date: new Date().toISOString(),
amount: -999,
currency: "USD",
name: "Disney+",
},
{
id: "8",
date: new Date().toISOString(),
amount: -1299,
currency: "USD",
name: "Microsoft 365",
},
{
id: "9",
date: new Date().toISOString(),
amount: -899,
currency: "USD",
name: "Apple Music",
},
{
id: "10",
date: new Date().toISOString(),
amount: -1599,
currency: "USD",
name: "HBO Max",
},
{
id: "11",
date: new Date().toISOString(),
amount: -1999,
currency: "USD",
name: "Adobe Photoshop",
},
{
id: "12",
date: new Date().toISOString(),
amount: -799,
currency: "USD",
name: "YouTube Premium",
},
{
id: "13",
date: new Date().toISOString(),
amount: -1499,
currency: "USD",
name: "Dropbox Plus",
},
{
id: "14",
date: new Date().toISOString(),
amount: -999,
currency: "USD",
name: "Nintendo Online",
},
{
id: "15",
date: new Date().toISOString(),
amount: -1299,
currency: "USD",
name: "Slack",
},
];

Expand All @@ -87,6 +159,8 @@ export const TransactionsEmail = ({
numberOfTransactions: transactions.length,
});

const displayedTransactions = transactions.slice(0, 10);

return (
<Html>
<Tailwind>
Expand Down Expand Up @@ -169,7 +243,7 @@ export const TransactionsEmail = ({
</thead>

<tbody style={{ width: "100%", minWidth: "100% !important" }}>
{transactions?.map((transaction) => (
{displayedTransactions.map((transaction) => (
<tr
key={transaction.id}
className="border-0 border-b-[1px] border-solid border-[#E8E7E1] h-[45px]"
Expand All @@ -188,17 +262,9 @@ export const TransactionsEmail = ({
"!text-[#00C969]",
)}
>
<div className="flex space-x-2 items-center">
<Text className="text-[14px] m-0 p-0 mt-1 pb-1 line-clamp-1">
{transaction.name}
</Text>

{transaction.status === "pending" && (
<div className="flex space-x-1 items-center border text-xs py-1 px-2 h-[22px] text-[#878787]">
<span>Pending</span>
</div>
)}
</div>
<Text className="text-[14px] m-0 p-0 mt-1 pb-1 line-clamp-1">
{transaction.name}
</Text>
</Link>
</td>
<td align="left">
Expand All @@ -224,7 +290,7 @@ export const TransactionsEmail = ({

<Section className="text-center mt-[32px] mb-[32px]">
<Button
className="bg-transparent rounded-md text-primary text-[14px] text-[#121212] font-medium no-underline text-center px-6 py-3 border border-solid border-[#121212]"
className="bg-transparent text-primary text-[14px] text-[#121212] font-medium no-underline text-center px-6 py-3 border border-solid border-[#121212]"
href={`${baseAppUrl}/transactions?start=${transactions.at(0)?.date}&end=${transactions[transactions.length - 1]?.date}`}
>
{t("transactions.button")}
Expand Down
14 changes: 12 additions & 2 deletions packages/email/locales/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export function translations(locale: string, params?: TranslationParams) {
return {
"notifications.match": `We matched the transaction “${params?.transactionName}” against “${params?.fileName}”`,
"notifications.transaction": `You have a new transaction of ${params?.amount} from ${params?.from}`,
"notifications.transactions": `You have ${params?.numberOfTransactions} new transactions`,
"notifications.transactions":
params?.numberOfTransactions &&
typeof params?.numberOfTransactions === "number" &&
params?.numberOfTransactions > 1
? `You have ${params?.numberOfTransactions} new transactions`
: `You have a new transaction of ${params?.amount} from ${params?.name}`,
"notifications.invoicePaid": `Invoice ${params?.invoiceNumber} has been paid`,
"notifications.invoiceOverdue": `Invoice ${params?.invoiceNumber} is overdue`,
"transactions.subject": "New transactions",
Expand Down Expand Up @@ -58,7 +63,12 @@ export function translations(locale: string, params?: TranslationParams) {
return {
"notifications.match": `Vi matchade transaktionen “${params?.transactionName}” mot “${params?.fileName}”`,
"notifications.transaction": `Du har en ny transaktion på ${params?.amount} från ${params?.from}`,
"notifications.transactions": `Du har ${params?.numberOfTransactions} nya transaktioner`,
"notifications.transactions":
params?.numberOfTransactions &&
typeof params?.numberOfTransactions === "number" &&
params?.numberOfTransactions > 1
? `Du har ${params?.numberOfTransactions} nya transaktioner`
: `Du har en ny transaktion på ${params?.amount} från ${params?.name}`,
"notifications.invoicePaid": `Faktura ${params?.invoiceNumber} har betalats`,
"notifications.invoiceOverdue": `Faktura ${params?.invoiceNumber} är försenad`,
"transactions.subject": "Nya transaktioner",
Expand Down

0 comments on commit c4b2d1b

Please sign in to comment.