-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connected submit to backend; added reusable modal for messages
Fixes #2
- Loading branch information
Showing
9 changed files
with
125 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { OPEN_MODAL, CLOSE_MODAL } from '../constants/actionTypes'; | ||
|
||
export const openModal = (message) => { | ||
return { | ||
type: OPEN_MODAL, | ||
isOpen: true, | ||
message: message | ||
}; | ||
}; | ||
|
||
export const closeModal = () => { | ||
return { | ||
type: CLOSE_MODAL, | ||
isOpen: false, | ||
message: '' | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react' | ||
import Popup from 'reactjs-popup' | ||
import { connect } from 'react-redux' | ||
import { closeModal } from '../../actions/modalPopup'; | ||
|
||
const mapStateToProps = state => { | ||
return { | ||
modal: state.modal | ||
}} | ||
|
||
function ModalPopup({modal, dispatch}) { | ||
|
||
const popupStyle = { | ||
content: { | ||
position: "relative", | ||
background: "rgb(255, 255, 255)", | ||
width: "400px", | ||
margin: "auto", | ||
border: "10px solid #25646a", | ||
fontSize: "1.5rem", | ||
fontWeight: "1.5rem", | ||
padding: "5px", | ||
borderRadius: "4px", | ||
height: "200px", | ||
textAlign: "center", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center" | ||
} | ||
} | ||
const close = () => { | ||
return dispatch(closeModal()); | ||
} | ||
|
||
|
||
return ( | ||
<Popup | ||
contentStyle={popupStyle.content} | ||
open={modal.isOpen} | ||
onClose={() => {close()}}> | ||
<div className='popup'> | ||
<p className='close-button' onClick={() => close()}> | ||
× | ||
</p> | ||
<p className="popup-message">{modal.message}</p> | ||
</div> | ||
</Popup> | ||
) | ||
} | ||
|
||
export default connect(mapStateToProps)(ModalPopup); | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const GET_VICTIMS_REQUEST = 'GET_VICTIMS_REQUEST'; | ||
export const OPEN_MODAL = 'OPEN_MODAL'; | ||
export const CLOSE_MODAL = 'CLOSE_MODAL'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { combineReducers } from 'redux'; | ||
import victims from './victims'; | ||
import modal from './modalPopup'; | ||
|
||
export default combineReducers({ | ||
victims, | ||
modal | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const initialState = { | ||
isOpen: false, | ||
message: '' | ||
} | ||
|
||
const modal = (state = initialState, action) => { | ||
switch(action.type) { | ||
case 'OPEN_MODAL': | ||
return {isOpen: true, message: action.message} | ||
case 'CLOSE_MODAL': | ||
return {isOpen: false, message: action.message} | ||
default: | ||
return {isOpen: false, message: ''} | ||
} | ||
|
||
} | ||
|
||
export default modal; |