diff --git a/src/App.jsx b/src/App.jsx index c902699..62af8c0 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,6 +3,8 @@ import { useState } from 'react' import initialEmails from './data/emails' import './styles/App.css' +import Emails from './components/Emails' +import EmailView from './components/EmailView' const getReadEmails = emails => emails.filter(email => !email.read) @@ -12,6 +14,7 @@ function App() { const [emails, setEmails] = useState(initialEmails) const [hideRead, setHideRead] = useState(false) const [currentTab, setCurrentTab] = useState('inbox') + const [selectedEmail, setSelectedEmail] = useState(null) const unreadEmails = emails.filter(email => !email.read) const starredEmails = emails.filter(email => email.starred) @@ -88,34 +91,21 @@ function App() {
- + {selectedEmail ? ( + setSelectedEmail(null)} + /> + ) : ( + + )}
+ ) } diff --git a/src/components/Email.jsx b/src/components/Email.jsx new file mode 100644 index 0000000..fed37b2 --- /dev/null +++ b/src/components/Email.jsx @@ -0,0 +1,36 @@ +function Email({ email, toggleRead, toggleStar, openEmail }) { + return ( +
  • +
    + { + e.stopPropagation(); + toggleRead(email); + }} + /> +
    + +
    + { + e.stopPropagation(); + toggleStar(email); + }} + /> +
    + +
    +
    {email.sender}
    +
    {email.title}
    +
    +
  • + ) +} + +export default Email diff --git a/src/components/EmailView.jsx b/src/components/EmailView.jsx new file mode 100644 index 0000000..ff7ffad --- /dev/null +++ b/src/components/EmailView.jsx @@ -0,0 +1,12 @@ +function EmailView({ email, goBack }) { + return ( +
    + +

    {email.title}

    +

    From: {email.sender}

    +

    {email.body || "No content available"}

    +
    + ) +} + +export default EmailView diff --git a/src/components/Emails.jsx b/src/components/Emails.jsx new file mode 100644 index 0000000..54afa71 --- /dev/null +++ b/src/components/Emails.jsx @@ -0,0 +1,19 @@ +import Email from "./Email.jsx" + +function Emails({ emails, toggleRead, toggleStar, openEmail }) { + return ( + + ) +} + +export default Emails