-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmailSummaryCard.js
More file actions
113 lines (98 loc) · 2.89 KB
/
EmailSummaryCard.js
File metadata and controls
113 lines (98 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React from 'react';
import styled, { keyframes } from 'styled-components';
const fadeIn = keyframes`
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
`;
const SummaryCard = styled.article`
background: ${(props) => props.theme.colors.cardBackground};
padding: 1.5rem;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
transition: transform 0.2s ease, box-shadow 0.2s ease;
animation: ${fadeIn} 0.6s ease-out forwards;
animation-delay: ${(props) => props.delay * 0.1}s;
cursor: pointer;
border-left: 4px solid ${(props) => props.theme.colors.accentPrimary};
&:hover {
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}
`;
const Sender = styled.div`
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 0.5rem;
h4 {
margin: 0;
font-size: 1rem;
font-weight: 600;
color: ${(props) => props.theme.colors.textPrimary};
}
`;
const Subject = styled.h5`
margin: 0 0 0.5rem 0;
font-size: 0.95rem;
font-weight: 500;
color: ${(props) => props.theme.colors.textPrimary};
`;
const Summary = styled.p`
margin: 0;
font-size: 0.875rem;
line-height: 1.5;
color: ${(props) => props.theme.colors.textSecondary};
`;
const Label = styled.span`
display: inline-block;
padding: 0.25rem 0.75rem;
border-radius: 4px;
font-size: 0.75rem;
font-weight: 500;
text-transform: uppercase;
background: ${(props) => props.color};
color: ${(props) => props.theme.colors.textInverted};
`;
const TagContainer = styled.div`
margin-top: 0.75rem;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
`;
const Tag = styled.span`
background: ${(props) => props.theme.colors.tagBackground};
color: ${(props) => props.theme.colors.tagText};
padding: 0.25rem 0.75rem;
font-size: 0.75rem;
border-radius: 4px;
text-transform: uppercase;
font-weight: 500;
`;
const candidate_labels = ["Education", "Health", "Finance", "Technology", "Announcements", "Online Learning"];
const classifyEmail = (email) => {
const lowerText = `${email.subject} ${email.summary}`.toLowerCase();
return candidate_labels.filter(label =>
lowerText.includes(label.toLowerCase()) // Simple keyword matching
);
};
const EmailSummaryCard = ({ email, delay }) => {
const tags = classifyEmail(email);
return (
<SummaryCard delay={delay}>
<Sender>
<h4>{email.sender}</h4>
<Label color={email.labelColor}>{email.label}</Label>
</Sender>
<Subject>{email.subject}</Subject>
<Summary>{email.summary}</Summary>
{tags.length > 0 && (
<TagContainer>
{tags.map((tag, index) => (
<Tag key={index}>{tag}</Tag>
))}
</TagContainer>
)}
</SummaryCard>
);
};
export default EmailSummaryCard;