Skip to content

Commit 7aa9f0d

Browse files
Bounty email updates (dubinc#3735)
Co-authored-by: Pedro Ladeira <57876830+pepeladeira@users.noreply.github.com>
1 parent 9040360 commit 7aa9f0d

2 files changed

Lines changed: 60 additions & 5 deletions

File tree

apps/web/app/(ee)/api/cron/bounties/notify-partners/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export async function POST(req: Request) {
154154
name: bounty.name,
155155
type: bounty.type,
156156
endsAt: bounty.endsAt,
157+
rewardAmount: bounty.rewardAmount,
157158
description: bounty.description,
158159
},
159160
program: {

packages/email/src/templates/new-bounty-available.tsx

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { DUB_WORDMARK, formatDate } from "@dub/utils";
1+
import { currencyFormatter, DUB_WORDMARK, formatDate } from "@dub/utils";
22
import {
33
Body,
4+
Column,
45
Container,
56
Head,
67
Heading,
@@ -9,19 +10,28 @@ import {
910
Link,
1011
Markdown,
1112
Preview,
13+
Row,
1214
Section,
1315
Tailwind,
1416
Text,
1517
} from "@react-email/components";
1618
import { BountyThumbnailImage } from "../components/bounty-thumbnail";
1719
import { Footer } from "../components/footer";
1820

21+
const ICONS = {
22+
calendar: "https://assets.dub.co/cms/icon-calendar-bounty.png",
23+
gift: "https://assets.dub.co/cms/icon-gift-bounty.png",
24+
} as const;
25+
26+
type Icon = keyof typeof ICONS;
27+
1928
export default function NewBountyAvailable({
2029
bounty = {
2130
id: "bty_xxx",
2231
name: "Promote Acme at your campus and earn $500",
2332
type: "performance",
2433
endsAt: new Date(),
34+
rewardAmount: 10000,
2535
description:
2636
"How **does** it work?\n\nGet a group _together_ of at least 15 other people interested in trying out [Acme](https://dub.co). Then, during the event, take a photo of the group using Acme. When submitting, provide any links to the event or photos. Once confirmed, we'll create a one-time commission for you.",
2737
},
@@ -36,6 +46,7 @@ export default function NewBountyAvailable({
3646
name: string;
3747
type: "performance" | "submission";
3848
endsAt: Date | null;
49+
rewardAmount: number | null;
3950
description: string | null;
4051
};
4152
program: {
@@ -44,6 +55,18 @@ export default function NewBountyAvailable({
4455
};
4556
email: string;
4657
}) {
58+
const formattedRewardAmount =
59+
bounty.rewardAmount != null
60+
? currencyFormatter(bounty.rewardAmount, {
61+
trailingZeroDisplay: "stripIfInteger",
62+
})
63+
: null;
64+
65+
const iconSizeClassByIcon: Record<Icon, string> = {
66+
calendar: "h-4.5 w-4.5",
67+
gift: "h-4.5 w-4.5",
68+
};
69+
4770
return (
4871
<Html>
4972
<Head />
@@ -68,10 +91,41 @@ export default function NewBountyAvailable({
6891
<Text className="m-0 p-0 text-base font-semibold text-neutral-900">
6992
{bounty.name}
7093
</Text>
71-
{bounty.endsAt && (
72-
<Text className="m-0 p-0 text-sm font-medium text-neutral-500">
73-
Ends {formatDate(bounty.endsAt)}
74-
</Text>
94+
{(bounty.endsAt || formattedRewardAmount) && (
95+
<Section className="pt-2">
96+
{bounty.endsAt && (
97+
<Row>
98+
<Column className="w-5 align-middle">
99+
<Img
100+
src={ICONS.calendar}
101+
className={iconSizeClassByIcon.calendar}
102+
alt=""
103+
/>
104+
</Column>
105+
<Column className="pl-2">
106+
<Text className="m-0 text-base font-normal text-neutral-500">
107+
Ends {formatDate(bounty.endsAt)}
108+
</Text>
109+
</Column>
110+
</Row>
111+
)}
112+
{formattedRewardAmount && (
113+
<Row className={bounty.endsAt ? "mt-1" : ""}>
114+
<Column className="w-5 align-middle">
115+
<Img
116+
src={ICONS.gift}
117+
className={iconSizeClassByIcon.gift}
118+
alt=""
119+
/>
120+
</Column>
121+
<Column className="pl-2">
122+
<Text className="m-0 text-base font-normal text-neutral-500">
123+
Earn {formattedRewardAmount}
124+
</Text>
125+
</Column>
126+
</Row>
127+
)}
128+
</Section>
75129
)}
76130
</Section>
77131

0 commit comments

Comments
 (0)