diff --git a/compforge/.firebase/hosting.YnVpbGQ.cache b/compforge/.firebase/hosting.YnVpbGQ.cache index 9fe633e8af3c8415ab4bd00d67f82b29fdcf4466..30d1130358bc380e7e02e86346255ff09064562b 100644 --- a/compforge/.firebase/hosting.YnVpbGQ.cache +++ b/compforge/.firebase/hosting.YnVpbGQ.cache @@ -1,17 +1,17 @@ -404.html,1586351207960,b7bab6b83fa074653ff28c8d2a64135d3434575f70a12ab3d3ba8080461b9537 -asset-manifest.json,1586351226513,9bdae63ab9813e4828dd4dd4b39c2c71ba8ebadbc23780ac8eb61a63a8ed5ee3 -favicon.ico,1586351207967,a7f9959c242eab6cdf79ddb2d1d2a4112a7c7ba3ecc911ddf7bf7b1fff54a07d -index.html,1586351226513,33e3b871cf77ab7078c0779dc9135fb0e19a7c1b05fb5ef53b4c82375d7fde50 -manifest.json,1586351207972,15492b46b805f4ba9408ae30685145c16c1fdd2163fe3934f1c8f6c6d0eb0800 -precache-manifest.def63341b2b22b203538bbf1684d6536.js,1586351226540,d04d6a0f2339061ceb249d63e22bbb89663d5909eb421577c99beec3de614e27 -robots.txt,1586351207977,2544ca049f223a42bff01f72ad930a5edba75bbb7199d0f8430a02ff5aca16ec -service-worker.js,1586351226513,95a9901b401055db71838ab85b04416f96ba7aed1c65eed7e193b89dd46a024b -static/css/main.5f361e03.chunk.css,1586351226551,1225945381892d813e90efe1c2bf85dad429fb1fce6829657a852a833b2081a3 -static/css/main.5f361e03.chunk.css.map,1586351226562,598f7972010d8f32c864cacf97d3770434b6aaf52e74a00c2e8b1b13faf78d9f -static/js/2.d615869a.chunk.js,1586351226562,6c42fbde1e3559adc87dded8956e7580a99f9f119a63df2e65265157d6f1a46f -static/js/2.d615869a.chunk.js.LICENSE.txt,1586351226562,74727db789fa0a696fe581244653adf4b10e75bb31caec1d6c628a68617665d6 -static/js/2.d615869a.chunk.js.map,1586351226563,4fb34988f2a2d4b754ec7dcee758f847177b39609b5f60369933984dd381ad0d -static/js/main.cbe32a5b.chunk.js,1586351226818,ada07cabc83d1ea1e695c59f4846ad42f8680a022c3214d032d4b408ac8995d3 -static/js/main.cbe32a5b.chunk.js.map,1586351226793,e4404e164e38a7a8076a839f65b7896ae35591ab73d10af4ae2b02fb3d5444de -static/js/runtime-main.891cac52.js,1586351226557,04a216b52283a30877d0643e87a750a2157bec4e8843f4dfcc1f02a9933e12b5 -static/js/runtime-main.891cac52.js.map,1586351226562,f1d775d637848326834d9ade23e34251001fdc050497240daafa4838523816c8 +404.html,1589741500917,b7bab6b83fa074653ff28c8d2a64135d3434575f70a12ab3d3ba8080461b9537 +asset-manifest.json,1589741598579,0fe5c3517bbbed4723702690ef79121134824309d10137468a3160ed48743fbc +index.html,1589741598560,f9c210a8f876813acc565d76eb1006d795ebbb41ed6b86fcba5525f5688163ab +precache-manifest.2d3ac30b3bbfa4e802a34120c1d73fe6.js,1589741598579,6afcdd1ed0d36c1b7f86da75683f128d6c34d8f81857f8f2db3f4961ef99024e +static/css/main.6e34eb25.chunk.css,1589741598582,b099acc63a98e7798231bd04084ea7e1e5bf7d6b1798667b0c9b300439a516fb +manifest.json,1589741500935,ed7b98046be74c7d1476b73ebb8cd1f00c2b34443af1525af60b9dd20be9fb9a +service-worker.js,1589741598579,c8f1abb2061b4fa705064245a206146573094ad62e78c41d02c6931160877cbc +robots.txt,1589741500959,2544ca049f223a42bff01f72ad930a5edba75bbb7199d0f8430a02ff5aca16ec +static/css/main.6e34eb25.chunk.css.map,1589741598637,463248e53c58fd776db145fcd4af644e5fc706fd19bdcc132460068c3fcf7646 +static/js/2.c183699c.chunk.js.LICENSE.txt,1589741598645,32b777c978b6723e67c966318c313ffad088e946cb6d0aa81a614b3be78bbeb2 +favicon.ico,1589741500919,a7f9959c242eab6cdf79ddb2d1d2a4112a7c7ba3ecc911ddf7bf7b1fff54a07d +static/js/runtime-main.607af0bd.js,1589741598638,9ac65e3334fa4069d5ff94c6167ebd3612e70694c6e7d5fee98e1f9147652f1e +static/js/runtime-main.607af0bd.js.map,1589741598637,5a22a82da7b266b2fcce68dbfbbe24cb2fcfd1b5d2406381f6c09e02efb97ca2 +static/js/main.7ec9fa39.chunk.js,1589741598650,8b21c449e07e05a05224aa272d53770ed28b3c5959cb1bb5f0c696005b673cf1 +static/js/main.7ec9fa39.chunk.js.map,1589741598638,1fb0211fbb70a43ae6fdbeed0efe42bc21ff211cb370b8b6877d538bf5a0c444 +static/js/2.c183699c.chunk.js,1589741598596,989a748d56c8d49bedd28db04de19815d51a505015169b57985662e7636b6e36 +static/js/2.c183699c.chunk.js.map,1589741598639,20044844c6522e4695680d000c627982b781fa7ff84bc3d4fa14ffc30a710a96 diff --git a/compforge/public/index.html b/compforge/public/index.html index d81bd2979e07f1a0aa67808dc6059c5aaeccac10..289402a7a45264cc2fed15113947a323b7f2ec7f 100644 --- a/compforge/public/index.html +++ b/compforge/public/index.html @@ -27,7 +27,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - <title> Automatically Generated Cyber Security Compliance Engine </title> + <title> CompForge </title> </head> <body> diff --git a/compforge/src/Components/AppHeader.react.jsx b/compforge/src/Components/AppHeader.react.jsx index 3103ce805a4788c0eb1339960b62eb82f37e70b6..fc1f34029c662f95ff0d6ad5d132db169dfef904 100644 --- a/compforge/src/Components/AppHeader.react.jsx +++ b/compforge/src/Components/AppHeader.react.jsx @@ -51,22 +51,20 @@ const AppMenu = (props) => { <div className={'menuitems'}> {props.isAuthenticated && <h3> Navigation </h3>} - {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/'}><MenuItem ><DashboardIcon style={iconStyle} /> DashBoard</MenuItem></Link>} + {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/'}><MenuItem name="dashboardButton"><DashboardIcon style={iconStyle} /> DashBoard</MenuItem></Link>} - {props.isAuthenticated && <MenuItem onClick={props.toggleModalState} > <AssignmentIcon style={iconStyle} /> Create Form </MenuItem>} + {props.isAuthenticated && <MenuItem name="createFormButton" onClick={props.toggleModalState} > <AssignmentIcon style={iconStyle} /> Create Form </MenuItem>} - {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/mysubmissions'}><MenuItem ><AccountCircleIcon style={iconStyle} />My Submissions</MenuItem></Link>} + {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/mysubmissions'}><MenuItem name="viewMySubmissionsButton" ><AccountCircleIcon style={iconStyle} />My Submissions</MenuItem></Link>} - {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/partnerssubmissions'}><MenuItem ><PeopleIcon style={iconStyle} />Partner Submissions</MenuItem></Link>} + {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/partnerssubmissions'}><MenuItem name="viewPartnerSubmissionsButton"><PeopleIcon style={iconStyle} />Partner Submissions</MenuItem></Link>} {props.isAuthenticated && <h3> Settings </h3>} {!props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/login'}><MenuItem > <AccountCircleIcon style={{marginRight: 8}} /> Log In</MenuItem></Link>} {!props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/signup'}><MenuItem > <PeopleIcon style={{marginRight: 8}} /> Sign Up</MenuItem></Link>} - - {props.isAuthenticated && <Link style={{ textDecoration: 'none', color: '#444' }} to={'/account'}><MenuItem ><PeopleIcon style={iconStyle} />My Account</MenuItem></Link>} - {props.isAuthenticated && <MenuItem onClick={props.logout}> <PowerSettingsNewIcon style={iconStyle} /> Logout</MenuItem>} + {props.isAuthenticated && <MenuItem name="logoutButton" onClick={props.logout}> <PowerSettingsNewIcon style={iconStyle} /> Logout</MenuItem>} </div> <div style={{fontSize: 16}} onClick={props.handleClose} className='closemenu'> <KeyboardArrowUpIcon style={{position: 'relative', top: 7}} /> close menu <KeyboardArrowUpIcon style={{position: 'relative', top: 7}} /> diff --git a/compforge/src/Components/ConfirmDeletion.react.jsx b/compforge/src/Components/ConfirmDeletion.react.jsx index a3162925df12de0f794b8e1b513c52959d40f70c..a2b680c5f6366abcc4863031ddd53b41db46710b 100644 --- a/compforge/src/Components/ConfirmDeletion.react.jsx +++ b/compforge/src/Components/ConfirmDeletion.react.jsx @@ -19,14 +19,14 @@ function ConfirmDelete(props) { <DialogTitle id="alert-dialog-title">{"Confirm deletion"}</DialogTitle> <DialogContent> <DialogContentText id="alert-dialog-description"> - Are you sure you want to delete "{props.doc.title}"? + Are you sure you want to delete this? </DialogContentText> </DialogContent> <DialogActions> - <Button onClick={props.toggleConfirmModal} color="primary"> + <Button name="cancelDelete" onClick={props.toggleConfirmModal} color="primary"> Cancel </Button> - <Button onClick={()=>{ props.confirmDelete(props.type, props.doc) }} color="secondary" autoFocus> + <Button name="confirmDelete" onClick={()=>{ props.confirmDelete(props.type, props.doc) }} color="secondary" autoFocus> Confirm </Button> </DialogActions> diff --git a/compforge/src/Components/Login.react.jsx b/compforge/src/Components/Login.react.jsx index eca28619b40ac3bf64acd61038fa3bfeb677892e..e9e70b58880031b68e1f1601f9c4c739dfc563b5 100644 --- a/compforge/src/Components/Login.react.jsx +++ b/compforge/src/Components/Login.react.jsx @@ -126,7 +126,7 @@ const Login = (props) => { <Typography component="p" className={classes.password}> <span style={{ marginRight: 6 }}>Don't have an account? </span> - <Button variant="outlined" size='small' style={{ fontSize: 10 }} color="primary" > <Link to={'/signup'}>Sign up</Link> </Button> + <Button name="toSignUpButton" variant="outlined" size='small' style={{ fontSize: 10 }} color="primary" > <Link to={'/signup'}>Sign up</Link> </Button> </Typography> <Typography component="p" className={classes.password}> diff --git a/compforge/src/Components/Signup.react.jsx b/compforge/src/Components/Signup.react.jsx index c3367a4fc8268ca132b337745a91e2a268c62128..e0e1fb9a7e376331df3a81ccdb31fb845f41e2bf 100644 --- a/compforge/src/Components/Signup.react.jsx +++ b/compforge/src/Components/Signup.react.jsx @@ -70,7 +70,7 @@ const Signup = (props) => { } if (isAuthenticated) { - return <Redirect to="/userhome" />; + return <Redirect to="/" />; } return (<Container component="main" style={{ marginBottom: 100, marginTop: 100, paddingLeft: 0, paddingRight: 0 }} maxWidth="xs"> @@ -87,7 +87,7 @@ const Signup = (props) => { fullWidth id="username" label="Display Name" - name="Display Name" + name="displayName" onChange={(ev) => { handleChange(ev, 'displayName') }} /> <TextField @@ -118,7 +118,7 @@ const Signup = (props) => { <Typography component="p" className={classes.password}> <span style={{ marginRight: 6 }}>Already have an account? </span> - <Button variant="outlined" size='small' style={{ fontSize: 10 }} color="primary" > <Link to={'/login'}>Login</Link> </Button> + <Button name="toSignInButton" variant="outlined" size='small' style={{ fontSize: 10 }} color="primary" > <Link to={'/login'}>Sign In</Link> </Button> </Typography> {createError?.isError && ( @@ -132,6 +132,7 @@ const Signup = (props) => { </Typography> )} <Button + name="signUpButton" disabled={false} type="button" fullWidth diff --git a/compforge/src/Components/SubmitFormModal.react.jsx b/compforge/src/Components/SubmitFormModal.react.jsx index b652d9b261d20160ddef7c9b2a8b23e990c75e6c..800a4e36c0d0593b1b6007d0c175905f70ce2e9e 100644 --- a/compforge/src/Components/SubmitFormModal.react.jsx +++ b/compforge/src/Components/SubmitFormModal.react.jsx @@ -69,15 +69,15 @@ function SubmitFormModal(props) { let az = a.trim(); az = capitalize(az); - return (<Button onClick={(e)=>{onSelectAnswer(e, q , qindex)}} style={{ marginRight: 8 }} + return (<Button name="answer" onClick={(e)=>{onSelectAnswer(e, q , qindex)}} style={{ marginRight: 8 }} variant={q?.selectedanswer !== az ? "outlined" : "contained"} color={q?.selectedanswer == az ? "secondary" : "primary"} key={qindex + aindex + 4324}> {az} </Button>) }); return (<div style={{ width: "60%", margin: 'auto', paddingBottom: 16, borderBottom: '1px solid #999' }} key={qindex}> - <div style={{ marginTop: 16 }}> <span> Question {`${qindex + 1}`} : </span> {q.question} </div> - <div style={{ marginTop: 8 }}> <span> Answers: </span> {answers} </div> + <div name="submitQuestion" style={{ marginTop: 16 }}> <span> Question {`${qindex + 1}`} : </span> {q.question} </div> + <div name="submitAnswers" style={{ marginTop: 8 }}> <span> Answers: </span> {answers} </div> <TextField style={{width: '100%'}} variant="outlined" @@ -110,6 +110,7 @@ function SubmitFormModal(props) { <Button style={{ textAlign: 'center' }} onClick={props.toggleModalState } > Cancel </Button> <Button + name="submitButton" onClick={() => { props.submitFS(qForm) }} style={{ color: 'green', marginLeft: 50, textAlign: 'center' }} > {`Submit`} diff --git a/compforge/src/Components/SubsScreen.react.jsx b/compforge/src/Components/SubsScreen.react.jsx index 58a45a871e73891fc1e88e18d505ada96ac0515d..9363e8b20e01f760cee869eb527d969bb776bac8 100644 --- a/compforge/src/Components/SubsScreen.react.jsx +++ b/compforge/src/Components/SubsScreen.react.jsx @@ -13,6 +13,7 @@ import TableRow from '@material-ui/core/TableRow'; import Paper from '@material-ui/core/Paper'; import moment from 'moment'; import ViewSubModal from './ViewSubModal.react'; +import ConfirmDeletion from './ConfirmDeletion.react'; import Loader from './Loader.react'; //Icons @@ -34,8 +35,21 @@ const SubsScreen = (props) => { const classes = useStyles(); const [openModal, setOpenModal] = React.useState(false); + const [openConfirmModal, setOpenConfirmModal] = React.useState(false); const [selectedEl, setSelectedEl] = React.useState(false); + const confirmDelete = (type, doc) => { + dispatch(removeSubOrForm(type, doc.docid, true)); + setOpenConfirmModal(!openConfirmModal) + } + + const toggleConfirmModal = (doc) => { + if(doc) { + setSelectedEl(doc); + } + setOpenConfirmModal(!openConfirmModal); + } + const toggleModalState = (el) => { if (el && openModal === false) { setSelectedEl(el); @@ -66,14 +80,13 @@ const SubsScreen = (props) => { <TableCell align="left">{el.submittedbyname}</TableCell> <TableCell align="left">{el.submittedbyemail}</TableCell> <TableCell align="right"><div style={{padding: 16, paddingRight: 0}}> - <VisibilityIcon onClick={() => {toggleModalState(el)}} + <VisibilityIcon name="viewSubmissionButton" onClick={() => {toggleModalState(el)}} style={{ cursor: 'pointer', color: '#3498DB', fontSize: 16}} /> - - {/*/This is set to false to be disabled , you may enablde later if requires, make sure you import the correct action in dispatch*/} - {false && userId === el.createdbyid && - <DeleteIcon onClick={() => { dispatch(removeSubOrForm('submission', el.docid)) }} + + {userId === el.submittedbyid && + <DeleteIcon name="deleteSubmissionButton" onClick={() => { toggleConfirmModal(el) }} style={{ fontSize: 16, marginLeft: 8, cursor: 'pointer', color: '#E74C3C' }} />} - </div> + </div> </TableCell> </TableRow>); });; @@ -81,7 +94,7 @@ const SubsScreen = (props) => { return (<> <div className='dashboard dashboard--table' > {`${props.mySubs ? 'My' : 'Partners'}`} Form Submissions </div> <TableContainer className={'udbpaper-mui'} component={Paper}> - <Table className={classes.table} size="small" aria-label="a dense table"> + <Table name="formSubmissionsTable" className={classes.table} size="small" aria-label="a dense table"> <TableHead> <TableRow> <TableCell>Title</TableCell> @@ -97,24 +110,28 @@ const SubsScreen = (props) => { </TableBody> </Table> </TableContainer> + {openModal && <ViewSubModal open={openModal} selectedTemplate={selectedEl} toggleModalState={toggleModalState} />} - </>); + + {openConfirmModal && <ConfirmDeletion + open={openConfirmModal} + doc={selectedEl} + type={'submission'} + toggleConfirmModal={toggleConfirmModal} + confirmDelete={confirmDelete} + />} + </>); } - if (!formsubs || formsubs.length === 0) { - return (props.mySubs ? (<div className='dashboard dashboard--table' > You do not have any submissions to any forms yet. </div>) - : (<div className='dashboard dashboard--table' > Partneres have not submitted any forms yet. </div>) - - ); + return (<div className='dashboard dashboard--table' > You have not {props.mySubs ? "made" : "received"} any submissions yet. </div>); } }; - function mapStateToProps(state) { return { formsubs: state.form.formsubs, @@ -125,6 +142,4 @@ function mapStateToProps(state) { } } - - export default connect(mapStateToProps)(SubsScreen); \ No newline at end of file diff --git a/compforge/src/Components/TemplateModal.react.jsx b/compforge/src/Components/TemplateModal.react.jsx index 619ba2153d7affd3a3b18f246be6d96bef6746d4..bbdb749818ff33f9b29de231850259793d42d6ec 100644 --- a/compforge/src/Components/TemplateModal.react.jsx +++ b/compforge/src/Components/TemplateModal.react.jsx @@ -167,7 +167,7 @@ function TemplateModal(props) { id="Question" helperText={'Insert the question text here.'} label="Question" - name="Question" + name="question" value={newQuestion.question} onChange={(evt) => onQuestionChange('question', evt.target.value)} /> @@ -182,13 +182,14 @@ function TemplateModal(props) { onChange={(evt) => onQuestionChange('answers', evt.target.value)} /> - <Button style={{ width: 100, color: 'green', display: 'block' }} onClick={addOption}> Add an entry </Button> + <Button name="addEntry" style={{ width: 100, color: 'green', display: 'block' }} onClick={addOption}> Add an entry </Button> </div> </Container> <div>{renderedQuestions}</div> <div className='newformbuttons'> <Button style={{ textAlign: 'center' }} onClick={() => { setNewQuestion({ question: '', answers: '' }); resetState(); props.toggleModalState() }} > Cancel </Button> <Button + name="submit" onClick={() => { setNewQuestion({ question: '', answers: '' }); props.addNewForm(formState, 'template') }} disabled={formState.title.length < 2 && formState.questions.length < 1} style={{ color: 'green', marginLeft: 50, textAlign: 'center' }} > diff --git a/compforge/src/Components/UserDashboard.react.jsx b/compforge/src/Components/UserDashboard.react.jsx index a7a3af3dbc98fc28c53d23df4dbd78613f75bd97..9bea1f669586e83e388aea02427befc86359c610 100644 --- a/compforge/src/Components/UserDashboard.react.jsx +++ b/compforge/src/Components/UserDashboard.react.jsx @@ -38,7 +38,6 @@ const UserDashboard = (props) => { const [openModal, setOpenModal] = React.useState(false); const [openSubModal, setOpenSubModal] = React.useState(false); const [openConfirmModal, setOpenConfirmModal] = React.useState(false); - const [selectedEl, setSelectedEl] = React.useState(false); const submitFS = (sfObj, formDoc) => { @@ -71,7 +70,7 @@ const UserDashboard = (props) => { setSelectedEl(doc); } setOpenConfirmModal(!openConfirmModal); - } + } const toggleSubModal = (el) => { if (el && openSubModal === false) { @@ -113,14 +112,14 @@ const UserDashboard = (props) => { {<TableCell align="left">{el.sharewith.length !== 0 ? el.sharewith.toString() : '-'}</TableCell>} <TableCell style={{ minWidth: 90 }} align="right"> <div style={{padding: 16, paddingRight: 0}}> - <VisibilityIcon onClick={() => toggleModalState(el)} + <VisibilityIcon name="viewFormButton" onClick={() => toggleModalState(el)} style={{ cursor: 'pointer', color: '#3498DB', fontSize: 16}} /> - <ContactMailIcon onClick={() => toggleSubModal(el)} + <ContactMailIcon name="submitFormButton" onClick={() => toggleSubModal(el)} style={{ fontSize: 16, cursor: 'pointer', color: '#138D75', marginLeft: 8 }} /> {userId === el.createdbyid && - <DeleteIcon onClick={() => { toggleConfirmModal(el) }} + <DeleteIcon name="deleteFormButton" onClick={() => { toggleConfirmModal(el) }} style={{ fontSize: 16, marginLeft: 8, cursor: 'pointer', color: '#E74C3C' }} />} </div> </TableCell> @@ -130,7 +129,7 @@ const UserDashboard = (props) => { return (<> <div className='dashboard dashboard--table' >Form Templates DashBoard </div> <TableContainer className={'udbpaper-mui'} component={Paper}> - <Table className={classes.table} size="small" aria-label="a dense table"> + <Table name="dashboardTable" className={classes.table} size="small" aria-label="a dense table"> <TableHead> <TableRow> <TableCell>Title</TableCell> @@ -153,6 +152,7 @@ const UserDashboard = (props) => { selectedTemplate={selectedEl} toggleModalState={toggleModalState} />} + {openConfirmModal && <ConfirmDeletion open={openConfirmModal} doc={selectedEl} @@ -176,7 +176,6 @@ const UserDashboard = (props) => { }; - function mapStateToProps(state) { return { loading: state.form.loading, @@ -187,6 +186,4 @@ function mapStateToProps(state) { } } - - export default connect(mapStateToProps)(UserDashboard); \ No newline at end of file diff --git a/compforge/src/Components/ViewSubModal.react.jsx b/compforge/src/Components/ViewSubModal.react.jsx index 9671ed8355451da1dfcdccffa12ecc6a97610d07..b9fbef290e295c4888991c7ccb81954a97e490c1 100644 --- a/compforge/src/Components/ViewSubModal.react.jsx +++ b/compforge/src/Components/ViewSubModal.react.jsx @@ -60,7 +60,7 @@ function ViewTemplateModal(props) { </Container> <div className='newformbuttons'> - <Button style={{ textAlign: 'center' }} onClick={ props.toggleModalState } > Done </Button> + <Button name="doneButton" style={{ textAlign: 'center' }} onClick={ props.toggleModalState } > Done </Button> </div> </div> ); diff --git a/compforge/src/Components/ViewTemplateModal.react.jsx b/compforge/src/Components/ViewTemplateModal.react.jsx index c5344569bce5f398a6276c6cfc0e16593de7bae2..0aa3347066929c8dbd4daae814f4c303301b4123 100644 --- a/compforge/src/Components/ViewTemplateModal.react.jsx +++ b/compforge/src/Components/ViewTemplateModal.react.jsx @@ -33,23 +33,23 @@ function ViewTemplateModal(props) { let renderedQuestions = formData.questions.map((el, i) => { let answers = el.answers.map((el, i) => { - return (<Button style={{ marginRight: 8 }} variant="outlined" color="primary" key={i + 4324}> {el} </Button>) + return (<Button name="answer" style={{ marginRight: 8 }} variant="outlined" color="primary" key={i + 4324}> {el} </Button>) }); return (<div style={{ width: "60%", margin: 'auto', paddingBottom: 16, borderBottom: '1px solid #999' }} key={i}> - <div style={{ marginTop: 16 }}> <span> Question: </span> {el.question} </div> - <div style={{ marginTop: 8 }}> <span> Answers: </span> {answers} </div> + <div name="viewQuestion" style={{ marginTop: 16 }}> <span> Question: </span> {el.question} </div> + <div name="viewAnswers" style={{ marginTop: 8 }}> <span> Answers: </span> {answers} </div> </div>); }); const body = ( <div style={modalStyle} className={classes.paper}> - <h2 style={{ textAlign: 'center', textDecoration: 'underline' }}>{formData.title}</h2> + <h2 name="formTitle" style={{ textAlign: 'center', textDecoration: 'underline' }}>{formData.title}</h2> <Container component="main" maxWidth="md"> <div> - <h3>Description</h3> + <h3 name="formDescription">Description</h3> <p style={{borderBottom: '1px solid #999', padding: '16px 16px 32px 16px'}}> {formData.description} </p> </div> @@ -58,7 +58,7 @@ function ViewTemplateModal(props) { </Container> <div className='newformbuttons'> - <Button style={{ textAlign: 'center' }} onClick={ props.toggleModalState } > Done </Button> + <Button name="doneButton" style={{ textAlign: 'center' }} onClick={ props.toggleModalState } > Done </Button> </div> </div> ); diff --git a/compforge/src/actions/form.actions.js b/compforge/src/actions/form.actions.js index 034e2ab0b1f296b0196cd77fbd1becec960086ce..171be515748f2dec32244336cbe60bb1a1b21bcb 100644 --- a/compforge/src/actions/form.actions.js +++ b/compforge/src/actions/form.actions.js @@ -183,9 +183,15 @@ export const addFormSubsOrTemplate = (fbdoc, type) => dispatch => { }; -export const removeSubOrForm = (type, docid) => dispatch => { +export const removeSubOrForm = (type, docid, isSub = false) => dispatch => { myFirebase.firestore().collection(type).doc(docid).delete().then(() => { - dispatch(fetchForms(type, false)); + if (isSub) + { + dispatch(fetchSub(true)); + } + else { + dispatch(fetchForms(type, false)); + } }).catch((err) => { dispatch(formsError(err)); });