diff --git a/src/App.jsx b/src/App.jsx index c902699..2da3584 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,8 +1,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 +12,7 @@ function App() { const [emails, setEmails] = useState(initialEmails) const [hideRead, setHideRead] = useState(false) const [currentTab, setCurrentTab] = useState('inbox') + const [currentEmail, setCurrentEmail] = useState(null) const unreadEmails = emails.filter(email => !email.read) const starredEmails = emails.filter(email => email.starred) @@ -41,6 +42,14 @@ function App() { if (currentTab === 'starred') filteredEmails = getStarredEmails(filteredEmails) + const showEmail = (email) => { + setCurrentEmail(email) + } + + const goBack = () => { + setCurrentEmail(null) + } + return (
@@ -62,15 +71,17 @@ function App() {
-
    - {filteredEmails.map((email, index) => ( -
  • -
    - toggleRead(email)} - /> -
    -
    - toggleStar(email)} - /> -
    -
    {email.sender}
    -
    {email.title}
    -
  • - ))} -
+ {currentEmail ? ( + + ) : ( + )}
) diff --git a/src/components/Email.jsx b/src/components/Email.jsx new file mode 100644 index 0000000..d618336 --- /dev/null +++ b/src/components/Email.jsx @@ -0,0 +1,36 @@ +function Email({email, index, toggleRead, toggleStar}) { + // console.log(email) + //const stopPropagation = (e) => e.stopPropagation(); + return( + <> +
  • setCurrentMail(email)} + > +
    + toggleRead(email)} + //onClick={stopPropagation} + /> +
    +
    + toggleStar(email)} + //onClick={stopPropagation} + /> +
    +
    {email.sender}
    +
    {email.title}
    +
  • + + ) +} + +export default Email; \ No newline at end of file diff --git a/src/components/EmailView.jsx b/src/components/EmailView.jsx new file mode 100644 index 0000000..07bf734 --- /dev/null +++ b/src/components/EmailView.jsx @@ -0,0 +1,17 @@ +function EmailView({email, goBack}) { + return( + <> +
    + +
    +

    {email.title}

    +

    from: {email.sender}

    +
    +
    + + ) +} + +export default EmailView; \ No newline at end of file diff --git a/src/components/Emails.jsx b/src/components/Emails.jsx new file mode 100644 index 0000000..2648911 --- /dev/null +++ b/src/components/Emails.jsx @@ -0,0 +1,17 @@ +import Email from './Email' + +function Emails({filteredEmails, toggleRead, toggleStar, showEmail}) { + return ( + <> + + + ) +} + +export default Emails; \ No newline at end of file