Skip to content

Commit c8a1241

Browse files
committed
minor bug fixes on create tab. Created data table heading.
Co-authored-by: Sal Saluga [email protected] Co-authored-by: Bianca Picasso [email protected] Co-authored-by: Huy Pham [email protected]
1 parent 6eeaa01 commit c8a1241

File tree

4 files changed

+54
-29
lines changed

4 files changed

+54
-29
lines changed

app/src/components/ContextAPIManager/CreateTab/CreateContainer.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DataTable from './components/DataTable';
77
import AddDataForm from './components/AddDataForm';
88
import AddContextForm from './components/AddContextForm';
99
import * as actions from '../../../redux/actions/actions';
10+
import { Typography } from '@mui/material';
1011

1112
const CreateContainer = () => {
1213
const defaultTableData = [{ key: 'Enter Key', value: 'Enter value' }];
@@ -73,7 +74,14 @@ const CreateContainer = () => {
7374
</Grid>
7475
<Divider orientation="vertical" variant="middle" flexItem />
7576
<Grid item>
76-
<DataTable target={tableState} />
77+
<Typography
78+
style={{ color: 'black' }}
79+
variant="h6"
80+
gutterBottom={true}
81+
>
82+
Context Data Table
83+
</Typography>
84+
<DataTable target={tableState} contextInput={contextInput} />
7785
</Grid>
7886
</Grid>
7987
</>

app/src/components/ContextAPIManager/CreateTab/components/AddContextForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const AddContextForm = ({
104104
<Button
105105
variant="contained"
106106
onClick={handleClick}
107-
disabled={btnDisabled ? true : false}
107+
disabled={btnDisabled}
108108
>
109109
Create
110110
</Button>

app/src/components/ContextAPIManager/CreateTab/components/AddDataForm.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ import { Typography } from '@mui/material';
66

77
const AddDataForm = ({ handleClickInputData, contextInput }) => {
88
//const [contextInput, setContextInput] = React.useState(null);
9-
const [dataContext, setDataContext] = React.useState({
10-
inputKey: '',
11-
inputValue: ''
12-
});
9+
const defaultInputData = {inputKey: '', inputValue: ''};
10+
const [dataContext, setDataContext] = React.useState(defaultInputData);
11+
12+
const saveData = () => {
13+
setDataContext(defaultInputData);
14+
handleClickInputData(contextInput, dataContext)
15+
}
1316

1417
const handleChange = e => {
1518
setDataContext(prevDataContext => {
@@ -23,7 +26,7 @@ const AddDataForm = ({ handleClickInputData, contextInput }) => {
2326
return (
2427
<Fragment>
2528
<Typography style={{ color: 'black' }} variant="h6" gutterBottom={true}>
26-
Add context data
29+
Add context data
2730
</Typography>
2831
<Box sx={{ display: 'flex', gap: 2 }}>
2932
<TextField
@@ -44,7 +47,7 @@ const AddDataForm = ({ handleClickInputData, contextInput }) => {
4447
/>
4548
<Button
4649
variant="contained"
47-
onClick={() => handleClickInputData(contextInput, dataContext)}
50+
onClick={saveData}
4851
>
4952
Save
5053
</Button>

app/src/components/ContextAPIManager/CreateTab/components/DataTable.tsx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import TableRow from '@mui/material/TableRow';
77
import Paper from '@mui/material/Paper';
88
import { styled } from '@mui/material/styles';
99
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
10+
import TableFooter from '@mui/material/TableFooter';
1011

1112
const StyledTableCell = styled(TableCell)(({ theme }) => ({
1213
[`&.${tableCellClasses.head}`]: {
@@ -28,27 +29,40 @@ const StyledTableRow = styled(TableRow)(({ theme }) => ({
2829
}
2930
}));
3031

31-
export default function DataTable({target}) {
32+
export default function DataTable({ target, contextInput }) {
3233
return (
33-
<TableContainer component={Paper}>
34-
<Table sx={{ width: '510px' }} aria-label="customized table">
35-
<TableHead>
36-
<TableRow>
37-
<StyledTableCell>Key</StyledTableCell>
38-
<StyledTableCell align="right">Value</StyledTableCell>
39-
</TableRow>
40-
</TableHead>
41-
<TableBody>
42-
{target.map((data, index) => (
43-
<StyledTableRow key={index}>
44-
<StyledTableCell component="th" scope="row">
45-
{data.key}
34+
<>
35+
<TableContainer component={Paper} sx={{ maxHeight: '350px' }}>
36+
<Table
37+
sx={{ width: '510px' }}
38+
aria-label="customized table"
39+
stickyHeader
40+
>
41+
<TableHead>
42+
<TableRow>
43+
{/* <StyledTableCell>Key</StyledTableCell> */}
44+
<StyledTableCell align="center" colSpan={3}>
45+
{contextInput ? contextInput.name : 'Context Name'}
4646
</StyledTableCell>
47-
<StyledTableCell align="right">{data.value}</StyledTableCell>
48-
</StyledTableRow>
49-
))}
50-
</TableBody>
51-
</Table>
52-
</TableContainer>
47+
</TableRow>
48+
</TableHead>
49+
<TableBody>
50+
{target.map((data, index) => (
51+
<StyledTableRow key={index}>
52+
<StyledTableCell component="th" scope="row">
53+
{data.key}
54+
</StyledTableCell>
55+
<StyledTableCell align="right">{data.value}</StyledTableCell>
56+
</StyledTableRow>
57+
))}
58+
</TableBody>
59+
{/* <TableFooter>
60+
<StyledTableCell align="center" colSpan={3}>
61+
{contextInput ? contextInput.name : 'Context Name'}
62+
</StyledTableCell>
63+
</TableFooter> */}
64+
</Table>
65+
</TableContainer>
66+
</>
5367
);
54-
}
68+
}

0 commit comments

Comments
 (0)