redux action infrastructure

This commit is contained in:
Lachlan Kermode
2018-12-17 15:56:46 +00:00
parent 45c41dc352
commit 795acac7ca
5 changed files with 34 additions and 8 deletions

View File

@@ -1,9 +1,10 @@
import React from 'react'
import PropTypes from 'prop-types'
import Spinner from './Spinner'
import copy from '../../js/data/copy.json'
const CardSource = ({ source, language, isLoading, error }) => {
const CardSource = ({ source, isLoading, onClickHandler }) => {
function renderIconText(type) {
switch(type) {
@@ -29,7 +30,7 @@ const CardSource = ({ source, language, isLoading, error }) => {
{isLoading
? <Spinner/>
: (
<div className="source-row">
<div className="source-row" onClick={() => onClickHandler(source)}>
<i className="material-icons source-icon">
{renderIconText(source.type)}
</i>
@@ -40,4 +41,13 @@ const CardSource = ({ source, language, isLoading, error }) => {
)
}
CardSource.propTypes = {
source: PropTypes.shape({
id: PropTypes.string.isRequired,
type: PropTypes.string
}),
isLoading: PropTypes.bool,
onClickHandler: PropTypes.func.isRequired,
}
export default CardSource