Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added header #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"@material-ui/core": "^4.11.4",
"@material-ui/data-grid": "^4.0.0-alpha.31",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.58",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
4 changes: 4 additions & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import logo from './logo.svg';
import './App.css';
import { render } from '@testing-library/react';
import MyTable from './components/MyTable'
import Header from './components/Header'
import TeachersTable from './components/TeachersTable'

class App extends React.Component{
render(){
return(
<>
<Header/>
<MyTable/>
<TeachersTable/>
</>
);
}
Expand Down
42 changes: 42 additions & 0 deletions client/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';

const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
flexGrow: 1,
},
menuButton: {
marginRight: theme.spacing(2),
},
title: {
flexGrow: 1,
},
}),
);

export default function ButtonAppBar() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Твой текущий файл называется Header.tsx а компонент внутри ButtonAppBar, имя компонента должно совпадать с именем файла

Suggested change
export default function ButtonAppBar() {
export default function Header() {

const classes = useStyles();

return (
<div className={classes.root}>
<AppBar position="static">
<Toolbar>
<IconButton edge="start" className={classes.menuButton} color="inherit" aria-label="menu">
<MenuIcon />
</IconButton>
<Typography variant="h6" className={classes.title}>
News
</Typography>
<Button color="inherit">Login</Button>
</Toolbar>
</AppBar>
</div>
);
}
12 changes: 12 additions & 0 deletions client/src/components/TeacherService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const getRooms = () => {
return [
{ id: 1, roomNumber: 'A100' },
{ id: 2, roomNumber: 'A102' },
{ id: 3, roomNumber: 'A103' },
{ id: 4, roomNumber: 'A201' },
{ id: 5, roomNumber: 'A310' },
{ id: 6, roomNumber: 'A202' },
{ id: 7, roomNumber: 'A107' },
];
}
Comment on lines +1 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

отформатируй код, убери лишний return и добавь тип возвращаемого значения

Suggested change
export const getRooms = () => {
return [
{ id: 1, roomNumber: 'A100' },
{ id: 2, roomNumber: 'A102' },
{ id: 3, roomNumber: 'A103' },
{ id: 4, roomNumber: 'A201' },
{ id: 5, roomNumber: 'A310' },
{ id: 6, roomNumber: 'A202' },
{ id: 7, roomNumber: 'A107' },
];
}
export const getRooms = () => [
{ id: 1, roomNumber: 'A100' },
{ id: 2, roomNumber: 'A102' },
{ id: 3, roomNumber: 'A103' },
{ id: 4, roomNumber: 'A201' },
{ id: 5, roomNumber: 'A310' },
{ id: 6, roomNumber: 'A202' },
{ id: 7, roomNumber: 'A107' },
];


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавь пустую строку в конце файла

32 changes: 32 additions & 0 deletions client/src/components/TeachersTable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import { getRooms } from "./TeacherService"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Опусти на строчку ниже

import { DataGrid, GridColDef, GridValueGetterParams } from '@material-ui/data-grid';

const columns: GridColDef[] = [
{ field: 'id', headerName: 'KeyID', width: 150 },
{ field: 'roomNumber', headerName: 'Room Number', width: 150 },

{
field: 'qrCode',
headerName: 'QR Code',
description: 'This column get string qrCode using Keyid + number.',
sortable: false,
width: 160,
valueGetter: (params: GridValueGetterParams) =>
`${params.getValue(params.id, 'id') || ''}${
params.getValue(params.id, 'roomNumber') || ''
}`,
},

];

const rows = getRooms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const rows = getRooms
const rows = getRooms()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вообще тащите в UseEffects



export default function DataGridDemo() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid rows={getRooms()} columns={columns} pageSize={5} checkboxSelection />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<DataGrid rows={getRooms()} columns={columns} pageSize={5} checkboxSelection />
<DataGrid rows={rows} columns={columns} pageSize={5} checkboxSelection />

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно пожалуйста текстовое пояснение проблемы я не очень понял что не так у меня

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoldatovMikhaul у тебя выше на 23-ей строке уже есть переменная rows

</div>
);
}
7 changes: 7 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,13 @@
prop-types "^15.7.2"
reselect "^4.0.0"

"@material-ui/icons@^4.11.2":
version "4.11.2"
resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.11.2.tgz#b3a7353266519cd743b6461ae9fdfcb1b25eb4c5"
integrity sha512-fQNsKX2TxBmqIGJCSi3tGTO/gZ+eJgWmMJkgDiOfyNaunNaxcklJQFaFogYcFl0qFuaEz1qaXYXboa/bUXVSOQ==
dependencies:
"@babel/runtime" "^7.4.4"

"@material-ui/lab@^4.0.0-alpha.58":
version "4.0.0-alpha.58"
resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.58.tgz#c7ebb66f49863c5acbb20817163737caa299fafc"
Expand Down