diff --git a/packages/web/components/templates/settings/SettingsTable.tsx b/packages/web/components/templates/settings/SettingsTable.tsx index d57c74955..91b367e14 100644 --- a/packages/web/components/templates/settings/SettingsTable.tsx +++ b/packages/web/components/templates/settings/SettingsTable.tsx @@ -29,6 +29,8 @@ type SettingsTableRowProps = { title: string isLast: boolean + onClick?: () => void + sublineElement: JSX.Element titleElement?: JSX.Element extraElement?: JSX.Element @@ -130,6 +132,7 @@ export const SettingsTableRow = (props: SettingsTableRowProps): JSX.Element => { padding: '10px 12px', border: '0.5px solid $grayBgActive', width: '100%', + cursor: !!props.onClick ? 'pointer' : 'unset', '&:hover': { background: 'rgba(255, 234, 159, 0.12)', }, @@ -139,6 +142,7 @@ export const SettingsTableRow = (props: SettingsTableRowProps): JSX.Element => { paddingLeft: '0', }, }} + onClick={props.onClick} > { } type ViewRecentEmailModalProps = { + display: 'html' | 'text' recentEmail: RecentEmail onOpenChange: (open: boolean) => void } @@ -114,16 +115,28 @@ const ViewRecentEmailModal = ( > - - {props.recentEmail.text} - + {props.display == 'text' ? ( + + {props.recentEmail.text} + + ) : ( + + )} @@ -132,13 +145,29 @@ const ViewRecentEmailModal = ( export default function RecentEmails(): JSX.Element { const { recentEmails, revalidate, isValidating } = useGetRecentEmailsQuery() - const [viewingEmail, setViewingEmail] = useState( - undefined - ) + const [viewingEmailText, setViewingEmailText] = useState< + RecentEmail | undefined + >(undefined) + + const [viewingEmailHtml, setViewingEmailHtml] = useState< + RecentEmail | undefined + >(undefined) applyStoredTheme(false) const sortedRecentEmails = useMemo(() => { + return [ + { + id: 'id', + from: 'jackson-from', + to: 'jacksonh', + subject: 'this is a test email', + type: 'article', + text: 'this is the text', + html: 'this is boldthis is a linkmore text', + createdAt: '2023-02-01', + }, + ] return recentEmails.sort((a, b) => b.createdAt.localeCompare(a.createdAt)) }, [recentEmails]) @@ -154,6 +183,9 @@ export default function RecentEmails(): JSX.Element { { + setViewingEmailHtml(recentEmail) + }} isLast={i === sortedRecentEmails.length - 1} sublineElement={ @@ -184,7 +216,7 @@ export default function RecentEmails(): JSX.Element { text="View Text" action={() => { console.log('viewing text: ', recentEmail) - setViewingEmail(recentEmail) + setViewingEmailText(recentEmail) }} /> {recentEmail.type != 'article' && ( @@ -216,10 +248,18 @@ export default function RecentEmails(): JSX.Element { /> )} - {viewingEmail && ( + {viewingEmailText && ( setViewingEmail(undefined)} + display="text" + recentEmail={viewingEmailText} + onOpenChange={() => setViewingEmailText(undefined)} + /> + )} + {viewingEmailHtml && ( + setViewingEmailHtml(undefined)} /> )}