Files
twitter-lite/src/features/home/daily-brief.tsx
T

44 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { conversations } from "#/features/support/mock-conversations";
import { useWorkspaceState } from "#/features/workspace/workspace-state";
export function DailyBrief({ onOpenContact }: { onOpenContact: (id: string) => void }) {
const { tasks, statuses, entries } = useWorkspaceState();
const focus = tasks.find((task) => task.section === "focus" && task.status === "todo");
const optional = tasks.find((task) => task.section === "optional" && task.status === "todo");
const contacts = conversations.filter((person) => (statuses[person.id] ?? "now") === "now");
const firstContact = contacts[0];
const resume = entries.find(
(entry) =>
entry.kind === "再開地点" && !entries.some((other) => other.correctionOf === entry.id),
);
return (
<section className="home-brief" aria-label="Daily brief">
<p>
{focus ? `Start with “${focus.title}” today.` : "There are no priority tasks right now."}
{firstContact ? (
<>
{" "}
<button type="button" onClick={() => onOpenContact(firstContact.id)}>
Reply to {firstContact.name}
</button>
{contacts.length > 1
? ` — one of ${contacts.length} conversations to review.`
: " when you’re ready."}
</>
) : (
" There are no conversations awaiting your attention."
)}
</p>
{resume ? (
<p className="home-brief-secondary">
Your resume note: “
{resume.text.length > 100 ? `${resume.text.slice(0, 100)}…` : resume.text}”
</p>
) : optional ? (
<p className="home-brief-secondary">“{optional.title}” can wait until you have room.</p>
) : null}
</section>
);
}