UI enhancement
This commit is contained in:
parent
53922952c6
commit
1a15409b2d
6 changed files with 295 additions and 214 deletions
|
|
@ -33,16 +33,38 @@ export function emailLabels(email) {
|
|||
if (/project|proposal|website|development|sow|contract/.test(text)) {
|
||||
labels.push({ name: "Projects", tone: "violet" });
|
||||
}
|
||||
if (/client|customer|internship|candidate/.test(text)) {
|
||||
if (/client|customer|internship|candidate|revdau|desi clans/.test(text)) {
|
||||
labels.push({ name: "Clients", tone: "blue" });
|
||||
}
|
||||
if (/hr|hiring|recruit|offer letter|onboarding/.test(text)) {
|
||||
labels.push({ name: "HR", tone: "violet" });
|
||||
}
|
||||
if (/invoice|bill|payment|finance|receipt/.test(text)) {
|
||||
labels.push({ name: "Finance", tone: "amber" });
|
||||
}
|
||||
if (/integration|api|webhook|connect/.test(text)) {
|
||||
labels.push({ name: "Integrations", tone: "green" });
|
||||
}
|
||||
if (/ai|agent|llm|gpt|model/.test(text)) {
|
||||
labels.push({ name: "AI", tone: "pink" });
|
||||
}
|
||||
if (/domain|dns|mx|spf|dkim/.test(text)) {
|
||||
labels.push({ name: "Domains", tone: "amber" });
|
||||
}
|
||||
if (/linkedin|twitter|facebook|instagram|social/.test(text)) {
|
||||
labels.push({ name: "Social", tone: "green" });
|
||||
}
|
||||
if (/notification|update|alert|noreply|security/.test(text)) {
|
||||
labels.push({ name: "Updates", tone: "blue" });
|
||||
}
|
||||
if (/personal|family/.test(text)) {
|
||||
labels.push({ name: "Personal", tone: "green" });
|
||||
}
|
||||
return labels.slice(0, 2);
|
||||
const unique = [];
|
||||
labels.forEach((label) => {
|
||||
if (!unique.some((item) => item.name === label.name)) unique.push(label);
|
||||
});
|
||||
return unique.slice(0, 2);
|
||||
}
|
||||
|
||||
export function matchesLens(email, lens) {
|
||||
|
|
@ -109,7 +131,30 @@ function extractMeetingTime(text) {
|
|||
const match = text.match(/\b(\d{1,2}:\d{2})\s*(am|pm)?/i)
|
||||
|| text.match(/\b(\d{1,2})\s*(am|pm)\b/i);
|
||||
if (!match) return null;
|
||||
return match[0].replace(/\s+/g, "").toUpperCase();
|
||||
const raw = match[0].replace(/\s+/g, " ").trim();
|
||||
if (/am|pm/i.test(raw)) return raw.toUpperCase();
|
||||
const [hours, minutes] = raw.split(":").map(Number);
|
||||
if (Number.isNaN(hours)) return raw;
|
||||
const period = hours >= 12 ? "PM" : "AM";
|
||||
const hour12 = hours % 12 || 12;
|
||||
return `${hour12}:${String(minutes || 0).padStart(2, "0")} ${period}`;
|
||||
}
|
||||
|
||||
function extractVenue(text) {
|
||||
if (/google meet|meet\.google/i.test(text)) return "Google Meet";
|
||||
if (/zoom/i.test(text)) return "Zoom";
|
||||
if (/teams|microsoft teams/i.test(text)) return "Teams";
|
||||
if (/video call|video meeting/i.test(text)) return "Video call";
|
||||
return "";
|
||||
}
|
||||
|
||||
function extractReplyStatus(text) {
|
||||
if (/confirm|confirmation|awaiting/.test(text)) return "Awaiting confirmation";
|
||||
if (/proposal|quote/.test(text)) return "Proposal reply";
|
||||
if (/invoice|payment|bill/.test(text)) return "Payment follow-up";
|
||||
if (/review|feedback/.test(text)) return "Needs review";
|
||||
if (/reply|respond/.test(text)) return "Needs reply";
|
||||
return "Needs attention";
|
||||
}
|
||||
|
||||
function extractDeadline(text) {
|
||||
|
|
@ -141,6 +186,7 @@ export function inboxContext(emails) {
|
|||
id: email.id,
|
||||
name: senderDisplayName(email),
|
||||
age: formatRelativeAge(emailTimestamp(email)),
|
||||
status: extractReplyStatus(emailSearchText(email)),
|
||||
}));
|
||||
|
||||
const today = [];
|
||||
|
|
@ -150,8 +196,10 @@ export function inboxContext(emails) {
|
|||
const time = extractMeetingTime(text);
|
||||
if (!time) return;
|
||||
const label = (email.subject || "Meeting").trim().slice(0, 42);
|
||||
const venue = extractVenue(text);
|
||||
const tone = /invoice|payment|bill/.test(text) ? "amber" : /client|demo/.test(text) ? "blue" : "green";
|
||||
if (!today.some((item) => item.time === time && item.label === label)) {
|
||||
today.push({ time, label });
|
||||
today.push({ time, label, venue, tone });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue