Skip to content

Commit

Permalink
show mailhog email from the leaderboard (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshCasper authored Oct 28, 2024
1 parent 77a1f16 commit f19907f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion configurations/statemachine.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"Body": {
"Html": {
"Data.$": "States.Format('<html><body><h2>Hello {}</h2><p>Congratulations on completing the quiz!</p><p><strong>Your Score:</strong> {}/{}.</p><p>Best regards,<br/>Quiz Team</p></body></html>', $.Username, $.Score, $.TotalQuestions)",
"Data.$": "States.Format('<html><body><h2>Hello {}</h2><p>Congratulations on completing the quiz!</p><p><strong>Your Score:</strong> {}.</p><p>Best regards,<br/>LocalStack Team</p></body></html>', $.Username, $.Score)",
"Charset": "UTF-8"
}
}
Expand Down
26 changes: 23 additions & 3 deletions frontend/src/components/LeaderboardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
CircularProgress,
Alert,
Paper,
Stack,
} from '@mui/material';

function LeaderboardPage() {
Expand Down Expand Up @@ -44,6 +45,20 @@ function LeaderboardPage() {
navigate('/');
};

const handleViewEmailDemo = () => {
let targetURL = '';
const hostname = window.location.hostname;

if (hostname.includes('localhost')) {
targetURL = `http://localhost:4566/_extension/mailhog/`;
} else {
const baseOrigin = window.location.origin;
targetURL = `${baseOrigin}/_extension/mailhog/`;
}

window.open(targetURL, '_blank');
};

if (loading) {
return (
<Container maxWidth="sm" sx={{ textAlign: 'center', marginTop: 8 }}>
Expand Down Expand Up @@ -90,9 +105,14 @@ function LeaderboardPage() {
)}

<Box sx={{ marginTop: 4 }}>
<Button variant="contained" color="primary" onClick={handleGoHome}>
Go to Home
</Button>
<Stack spacing={2} direction="row" justifyContent="center">
<Button variant="contained" color="primary" onClick={handleGoHome}>
Go to Home
</Button>
<Button variant="contained" color="secondary" onClick={handleViewEmailDemo}>
View Email (Demo)
</Button>
</Stack>
</Box>
</Box>
</Container>
Expand Down

0 comments on commit f19907f

Please sign in to comment.