@@ -8,15 +8,60 @@ import {
88 Checkbox ,
99 FormControlLabel ,
1010 Typography ,
11+ Modal ,
12+ Box ,
1113} from '@material-ui/core' ;
14+ import { makeStyles } from '@material-ui/styles' ;
1215import ExpandMoreIcon from '@material-ui/icons/ExpandMore' ;
1316
17+ const useStyles = makeStyles ( ( ) => ( {
18+ root : {
19+ display : 'flex' ,
20+ flexDirection : 'column' ,
21+ gap : '20px' ,
22+ maxWidth : '800px' ,
23+ padding : '20px' ,
24+ } ,
25+ modalBox : {
26+ position : 'absolute' ,
27+ top : '50%' ,
28+ left : '50%' ,
29+ transform : 'translate(-50%, -50%)' ,
30+ width : 400 ,
31+ backgroundColor : 'white' ,
32+ boxShadow : '0px 4px 20px rgba(0, 0, 0, 0.1)' ,
33+ padding : '32px' ,
34+ borderRadius : '8px' ,
35+ } ,
36+ sectionTitle : {
37+ marginTop : '20px' ,
38+ marginBottom : '10px' ,
39+ } ,
40+ accordionDetails : {
41+ flexDirection : 'column' ,
42+ gap : '15px' ,
43+ } ,
44+ neighborhoodSubtitle : {
45+ marginTop : '15px' ,
46+ } ,
47+ sendTitle : {
48+ marginTop : '30px' ,
49+ marginBottom : '10px' ,
50+ } ,
51+ buttonContainer : {
52+ display : 'flex' ,
53+ gap : '10px' ,
54+ marginTop : '10px' ,
55+ } ,
56+ } ) ) ;
57+
1458/**
1559 * AdminNewsletter - Displays a form to fill out and send a newsletter.
1660 *
1761 * @returns {ReactElement } - A Material-UI form for newsletter generation
1862 */
1963const AdminNewsletter = ( ) => {
64+ const classes = useStyles ( ) ;
2065 const [ sections , setSections ] = useState ( {
2166 recentlyReleased : false ,
2267 topLoved : false ,
@@ -27,21 +72,38 @@ const AdminNewsletter = () => {
2772 sublease : false ,
2873 reels : false ,
2974 } ) ;
75+ const [ showModal , setShowModal ] = useState ( false ) ;
76+
77+ const openModal = ( ) => setShowModal ( true ) ;
78+ const closeModal = ( ) => setShowModal ( false ) ;
3079
3180 const handleSectionToggle = ( section : keyof typeof sections ) => {
3281 setSections ( ( prev ) => ( { ...prev , [ section ] : ! prev [ section ] } ) ) ;
3382 } ;
3483
3584 return (
36- < div
37- style = { {
38- display : 'flex' ,
39- flexDirection : 'column' ,
40- gap : '20px' ,
41- maxWidth : '800px' ,
42- padding : '20px' ,
43- } }
44- >
85+ < div className = { classes . root } >
86+ < Modal
87+ open = { showModal }
88+ onClose = { closeModal }
89+ aria-labelledby = "modal-modal-title"
90+ aria-describedby = "modal-modal-description"
91+ >
92+ < Box className = { classes . modalBox } >
93+ < Typography variant = "h6" component = "h2" gutterBottom >
94+ IMPORTANT: Confirm Send
95+ </ Typography >
96+ < Typography id = "modal-modal-title" >
97+ This newsletter will be sent to all subscribers. Please make sure that you have tested
98+ the content and formatting by sending a single test email to yourself. Are you sure you
99+ want to continue?
100+ </ Typography >
101+ < Button variant = "contained" color = "primary" onClick = { closeModal } >
102+ Send to all users
103+ </ Button >
104+ </ Box >
105+ </ Modal >
106+
45107 < Typography variant = "h4" component = "h2" >
46108 Newsletter Generation
47109 </ Typography >
@@ -73,7 +135,7 @@ const AdminNewsletter = () => {
73135 placeholder = "https://example.com/header.jpg"
74136 />
75137
76- < Typography variant = "h6" style = { { marginTop : '20px' , marginBottom : '10px' } } >
138+ < Typography variant = "h6" className = { classes . sectionTitle } >
77139 Optional Sections
78140 </ Typography >
79141
@@ -93,7 +155,7 @@ const AdminNewsletter = () => {
93155 < AccordionSummary expandIcon = { < ExpandMoreIcon /> } >
94156 < Typography > Recently Released Properties</ Typography >
95157 </ AccordionSummary >
96- < AccordionDetails style = { { flexDirection : 'column' , gap : '15px' } } >
158+ < AccordionDetails className = { classes . accordionDetails } >
97159 < TextField
98160 label = "Close to Campus Property IDs"
99161 variant = "outlined"
@@ -128,7 +190,7 @@ const AdminNewsletter = () => {
128190 < AccordionSummary expandIcon = { < ExpandMoreIcon /> } >
129191 < Typography > Top Loved Properties</ Typography >
130192 </ AccordionSummary >
131- < AccordionDetails style = { { flexDirection : 'column' , gap : '15px' } } >
193+ < AccordionDetails className = { classes . accordionDetails } >
132194 < TextField
133195 label = "Highest Rated Property IDs"
134196 variant = "outlined"
@@ -171,7 +233,7 @@ const AdminNewsletter = () => {
171233 < AccordionSummary expandIcon = { < ExpandMoreIcon /> } >
172234 < Typography > Advice from Upperclassmen</ Typography >
173235 </ AccordionSummary >
174- < AccordionDetails style = { { flexDirection : 'column' , gap : '15px' } } >
236+ < AccordionDetails className = { classes . accordionDetails } >
175237 < TextField
176238 label = "Advice Content"
177239 variant = "outlined"
@@ -206,7 +268,7 @@ const AdminNewsletter = () => {
206268 < AccordionSummary expandIcon = { < ExpandMoreIcon /> } >
207269 < Typography > New Feature Spotlight</ Typography >
208270 </ AccordionSummary >
209- < AccordionDetails style = { { flexDirection : 'column' , gap : '15px' } } >
271+ < AccordionDetails className = { classes . accordionDetails } >
210272 < TextField
211273 label = "Feature Image URL"
212274 variant = "outlined"
@@ -248,7 +310,7 @@ const AdminNewsletter = () => {
248310 < AccordionSummary expandIcon = { < ExpandMoreIcon /> } >
249311 < Typography > Neighborhood Comparison</ Typography >
250312 </ AccordionSummary >
251- < AccordionDetails style = { { flexDirection : 'column' , gap : '15px' } } >
313+ < AccordionDetails className = { classes . accordionDetails } >
252314 < Typography variant = "subtitle2" color = "textSecondary" >
253315 Neighborhood 1
254316 </ Typography >
@@ -274,7 +336,11 @@ const AdminNewsletter = () => {
274336 placeholder = "Describe this neighborhood"
275337 />
276338
277- < Typography variant = "subtitle2" color = "textSecondary" style = { { marginTop : '15px' } } >
339+ < Typography
340+ variant = "subtitle2"
341+ color = "textSecondary"
342+ className = { classes . neighborhoodSubtitle }
343+ >
278344 Neighborhood 2
279345 </ Typography >
280346 < TextField
@@ -318,7 +384,7 @@ const AdminNewsletter = () => {
318384 < AccordionSummary expandIcon = { < ExpandMoreIcon /> } >
319385 < Typography > Area Spotlight</ Typography >
320386 </ AccordionSummary >
321- < AccordionDetails style = { { flexDirection : 'column' , gap : '15px' } } >
387+ < AccordionDetails className = { classes . accordionDetails } >
322388 < TextField
323389 label = "Area Name"
324390 variant = "outlined"
@@ -375,7 +441,7 @@ const AdminNewsletter = () => {
375441 < AccordionSummary expandIcon = { < ExpandMoreIcon /> } >
376442 < Typography > Sublease Spotlight</ Typography >
377443 </ AccordionSummary >
378- < AccordionDetails style = { { flexDirection : 'column' , gap : '15px' } } >
444+ < AccordionDetails className = { classes . accordionDetails } >
379445 < TextField
380446 label = "Sublease Image URL"
381447 variant = "outlined"
@@ -418,7 +484,7 @@ const AdminNewsletter = () => {
418484 < AccordionSummary expandIcon = { < ExpandMoreIcon /> } >
419485 < Typography > Reels</ Typography >
420486 </ AccordionSummary >
421- < AccordionDetails style = { { flexDirection : 'column' , gap : '15px' } } >
487+ < AccordionDetails className = { classes . accordionDetails } >
422488 < TextField
423489 label = "Reel GIF URL"
424490 variant = "outlined"
@@ -439,7 +505,7 @@ const AdminNewsletter = () => {
439505 </ div >
440506
441507 { /* Send Options */ }
442- < Typography variant = "h6" style = { { marginTop : '30px' , marginBottom : '10px' } } >
508+ < Typography variant = "h6" className = { classes . sendTitle } >
443509 Send Newsletter
444510 </ Typography >
445511
@@ -452,11 +518,11 @@ const AdminNewsletter = () => {
452518 helperText = "Send a test to this email address"
453519 />
454520
455- < div style = { { display : 'flex' , gap : '10px' , marginTop : '10px' } } >
521+ < div className = { classes . buttonContainer } >
456522 < Button variant = "contained" color = "primary" >
457523 Send Test Email
458524 </ Button >
459- < Button variant = "contained" color = "secondary" >
525+ < Button variant = "contained" color = "secondary" onClick = { openModal } >
460526 Send to All Subscribers
461527 </ Button >
462528 </ div >
0 commit comments