+ Array.isArray(digestData[key]) && (digestData[key]?.length ?? 0) > 0,
+ );
+
+ if (!hasItems) {
+ return null;
+ }
+
const CategorySection = ({
categoryKey,
items,
}: {
- categoryKey: keyof typeof availableCategories;
+ categoryKey: string;
items: DigestItem[];
}) => {
if (items.length === 0) return null;
-
const category = getCategoryInfo(categoryKey);
- const colors = colorClasses[category.color as keyof typeof colorClasses];
-
+ const colors =
+ colorClasses[category.color as keyof typeof colorClasses] ||
+ colorClasses.gray;
return (
@@ -456,20 +310,6 @@ export default function DigestEmail(props: DigestEmailProps) {
);
};
- // Return early if no digest items are found
- const hasItems =
- newsletter.length > 0 ||
- receipt.length > 0 ||
- marketing.length > 0 ||
- calendar.length > 0 ||
- coldEmail.length > 0 ||
- notification.length > 0 ||
- toReply.length > 0;
-
- if (!hasItems) {
- return null;
- }
-
return (
@@ -501,17 +341,20 @@ export default function DigestEmail(props: DigestEmailProps) {
- {getCategoriesWithItemsCount() > 1 && (
+ {getCategoriesWithItemsCount() > 0 && (
)}
-
-
-
-
-
-
-
+ {Object.keys(digestData).map((categoryKey) =>
+ Array.isArray(digestData[categoryKey]) &&
+ digestData[categoryKey]?.length > 0 ? (
+
+ ) : null,
+ )}
@@ -755,6 +598,40 @@ DigestEmail.PreviewProps = {
},
},
],
+ // --- Custom categories for testing ---
+ travel: [
+ {
+ from: "Expedia",
+ subject: "Your flight to Paris is booked!",
+ content: {
+ summary: "Flight departs July 10th at 7:00 PM. Confirmation #ABC123.",
+ },
+ },
+ {
+ from: "Airbnb",
+ subject: "Upcoming stay in Montmartre",
+ content: {
+ summary: "Check-in: July 11th, Check-out: July 18th. Host: Marie.",
+ },
+ },
+ ],
+ funnyStuff: [
+ {
+ from: "The Onion",
+ subject: "Area Man Unsure If He’s Living In Simulation Or Just Milwaukee",
+ content: {
+ summary:
+ "Local man questions reality after seeing three people in cheese hats.",
+ },
+ },
+ {
+ from: "Reddit",
+ subject: "Top meme of the day",
+ content: {
+ summary: "A cat wearing sunglasses and riding a Roomba.",
+ },
+ },
+ ],
};
function Footer({