import React from 'react'; import PropTypes from 'prop-types'; import { makeStyles } from '@material-ui/core/styles'; import { Grid, Box, Typography, Button } from '@material-ui/core'; const useStyles = makeStyles((theme) => ({ root: { width: '100%', }, paper: { width: '100%', marginBottom: theme.spacing(2), }, table: { minWidth: 750, }, visuallyHidden: { border: 0, clip: 'rect(0 0 0 0)', height: 1, margin: -1, overflow: 'hidden', padding: 0, position: 'absolute', top: 20, width: 1, }, underline: { "&&&:before": { borderBottom: "none" }, "&&:after": { borderBottom: "none" } }, button: { color: 'white', width: 150, height: 55 }, closeButton: { position: 'absolute', right: theme.spacing(1), top: theme.spacing(1), color: theme.palette.grey[500], }, headText: { fontSize: 14, float: "left", color: theme.palette.primary.main, fontWeight: "bold" }, })); function getDataString(data, fieldName) { return data[fieldName]; } function MkInfo(props) { const classes = useStyles(); const { infoData, displayFields, isNew = false, isEditable, currentTabName, actions } = props; const [editable, setEditable] = React.useState(isEditable !== undefined ? isEditable : true); // const [data, setData] = React.useState({}); const handleEdit = () => { setEditable(false) } // const handleUpdateData = (data) => { // console.log('handle update date:', data); // setData(data); // } return (
{isNew ? {/* handleUpdateData(d)} > */} : {!editable ? // handleUpdateData(d)} // >
: displayFields.map((d, i) => { return ( {d.label} {d.type === 'photo' ? // : {infoData !== undefined ? getDataString(infoData, d.fieldName) : ''}} ); })} {actions.map((a, i) => { if (currentTabName === 'account') { if (infoData.status === 'invited') { return ; } if (infoData.status === 'joined') { return ; } if (infoData.status === 'disabled') { return ; } if (infoData.status === 'requested') { if (editable) { return ; } else { return ; } } } else { if (editable) { if (a.action_type === 'edit') { console.log('type: ', a.action_type, 'editable: ', editable); return } if (a.action_type === 'delete') { return } } else { if (a.action_type === 'save') { return } if (a.action_type === 'cancel') { return } } } })} }
); } MkInfo.propTypes = { history: PropTypes.object, infoData: PropTypes.object, displayFields: PropTypes.array, isNew: PropTypes.bool, isEditable: PropTypes.bool, actions: PropTypes.any }; export default (MkInfo);