diff --git a/package.json b/package.json index a24e5c1..b43d0bc 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,8 @@ "react-virtualized": "^9.1.0", "redux": "^3.5.2", "redux-thunk": "^2.1.0", - "toastr": "^2.1.2" + "toastr": "^2.1.2", + "material-ui": "^0.19.4" }, "engines": { "node": "6.11.1" diff --git a/src/common/components/form/checkbox.tsx b/src/common/components/form/checkbox.tsx new file mode 100644 index 0000000..88dcabd --- /dev/null +++ b/src/common/components/form/checkbox.tsx @@ -0,0 +1,26 @@ +import * as React from 'react'; +import Checkbox from 'material-ui/Checkbox'; + +export interface CheckboxComponentProps { + value: boolean; + label: string; + labelClassName: string; + name: string; + onChange: any; + wrapperClassName?: string; +} + +export const CheckboxComponent: React.StatelessComponent = (props) => { + return ( +
+ +
+ + + + ); +}; + +CheckboxComponent.displayName = 'CheckboxComponent'; diff --git a/src/common/components/form/index.ts b/src/common/components/form/index.ts index 16ee3b6..a37253c 100644 --- a/src/common/components/form/index.ts +++ b/src/common/components/form/index.ts @@ -10,3 +10,6 @@ export { export { SelectComponent, } from './select'; +export { + CheckboxComponent, +} from './checkbox'; diff --git a/src/common/components/form/specs/checkbox.spec.tsx b/src/common/components/form/specs/checkbox.spec.tsx new file mode 100644 index 0000000..c87a82d --- /dev/null +++ b/src/common/components/form/specs/checkbox.spec.tsx @@ -0,0 +1,47 @@ +import * as React from 'react'; +import { shallow } from 'enzyme'; +import { multilineTrim } from '../../../parse/multilineTrim'; +import { CheckboxComponent ,CheckboxComponentProps} from '../checkbox'; + +describe('CheckboxComponent', () => { + it('should be defined', () => { + // Arrange + const props: CheckboxComponentProps = { + name: '', + label: '', + value: true, + labelClassName : '', + onChange: () => { }, + }; + + // Act + const component = shallow( + , + ); + + // Assert + expect(component).not.to.be.undefined; + }); + + // it('should calls to onChange', () => { + // // Arrange + // const props: CheckboxComponentProps = { + // name: 'Test name',dd + // label: 'Test label', + // value: true, + // onChange: sinon.spy(), + // labelClassName: 'Test label class name' + // }; + + // // Act + // const component = shallow( + // , + // ); + + // component.find('input').simulate('change'); + + // // Assert + // expect(props.onChange.called).to.be.true; + // }); + +}); diff --git a/src/pages/admin/student/edit/components/editionUserPanel.tsx b/src/pages/admin/student/edit/components/editionUserPanel.tsx new file mode 100644 index 0000000..215917c --- /dev/null +++ b/src/pages/admin/student/edit/components/editionUserPanel.tsx @@ -0,0 +1,51 @@ +import * as React from 'react'; +import { Link } from 'react-router'; +import { StudentSummary } from '../../../../../model/studentSummary'; +import { InputComponent , CheckboxComponent} from '../../../../../common/components/form'; + +interface Props { + student: StudentSummary; +} + +export const EditionUserPanel: React.StatelessComponent = (props) => { + return ( +
+ + + + + +
+ ); +}; + +EditionUserPanel.displayName = 'EditionUserPanel'; +function newFunction(): any { + // WIP + return () => { }; +} diff --git a/src/pages/admin/student/edit/components/editionUserTrainingsPanel.tsx b/src/pages/admin/student/edit/components/editionUserTrainingsPanel.tsx new file mode 100644 index 0000000..4fec86f --- /dev/null +++ b/src/pages/admin/student/edit/components/editionUserTrainingsPanel.tsx @@ -0,0 +1,12 @@ +import * as React from 'react'; +import { Link } from 'react-router'; + +export const EditionUserTrainingsPanel: React.StatelessComponent<{}> = (props) => { + return ( +
+ User Trainings info +
+ ); +}; + +EditionUserTrainingsPanel.displayName = 'EditionUserTrainingsPanel'; diff --git a/src/pages/admin/student/edit/components/index.ts b/src/pages/admin/student/edit/components/index.ts new file mode 100644 index 0000000..d713709 --- /dev/null +++ b/src/pages/admin/student/edit/components/index.ts @@ -0,0 +1,3 @@ +export { TabContainer } from './tabContainer'; +export { EditionUserPanel } from './editionUserPanel'; +export { EditionUserTrainingsPanel } from './editionUserTrainingsPanel'; diff --git a/src/pages/admin/student/edit/components/tabContainer.tsx b/src/pages/admin/student/edit/components/tabContainer.tsx new file mode 100644 index 0000000..c94c69d --- /dev/null +++ b/src/pages/admin/student/edit/components/tabContainer.tsx @@ -0,0 +1,13 @@ +import * as React from 'react'; +import { Link } from 'react-router'; +const styles: any = require('./tabContainerStyles.scss'); + +export const TabContainer: React.StatelessComponent<{}> = (props) => { + return ( +
+ {props.children} +
+ ); +}; + +TabContainer.displayName = 'TabContainer'; diff --git a/src/pages/admin/student/edit/components/tabContainerStyles.scss b/src/pages/admin/student/edit/components/tabContainerStyles.scss new file mode 100644 index 0000000..88941e5 --- /dev/null +++ b/src/pages/admin/student/edit/components/tabContainerStyles.scss @@ -0,0 +1,5 @@ +.tabContainerPanel { + padding: 24px; + background-color: #f9f9f9; + padding-bottom: 30px; +} diff --git a/src/pages/admin/student/edit/page.tsx b/src/pages/admin/student/edit/page.tsx index 64337be..b13e8df 100644 --- a/src/pages/admin/student/edit/page.tsx +++ b/src/pages/admin/student/edit/page.tsx @@ -2,32 +2,74 @@ import * as React from 'react'; import { Link } from 'react-router'; import { adminRouteEnums } from '../../../../common/routeEnums/admin'; import { StudentSummary } from '../../../../model/studentSummary'; +import { withStyles } from 'material-ui/styles'; +import Tabs, { Tab } from 'material-ui/Tabs'; +import { TabContainer, EditionUserPanel, EditionUserTrainingsPanel } from './components'; +import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; +const styles: any = require('./pageStyles.scss'); -interface Props { +interface Props { student: StudentSummary; getStudent: (id: string) => void; studentId: string; } -export class EditStudentPage extends React.Component { - public componentDidMount() { - const studentId: string = this.props.studentId; - this.props.getStudent(studentId); +interface State { + value: number; +} + +export class EditStudentPage extends React.Component { + constructor() { + super(); + this.state = { + value: 0, + }; + } + public componentDidMount() { + const studentId: string = this.props.studentId; + this.props.getStudent(studentId); + } + + private handleChange = (event, value) => { + this.setState({ value }); } - public render() { - return ( -
- Student name: {this.props.student.fullname} -
- Email: {this.props.student.email} -
- Is Active?: {this.props.student.isActive ? 'Yes' : 'No'} -
- Back to student list - Back to Dashboard - + public render() { + const { value } = this.state; + + return ( +
+ +
+

{this.props.student.fullname}

+ + + + + + + + + + + + + + +
+
+
+ +
+
+ +
+ + Back to student list + Back to Dashboard
- ); +
+
+ ); } } diff --git a/src/pages/admin/student/edit/pageStyles.scss b/src/pages/admin/student/edit/pageStyles.scss new file mode 100644 index 0000000..c5a4551 --- /dev/null +++ b/src/pages/admin/student/edit/pageStyles.scss @@ -0,0 +1,11 @@ +.tabHeader { + color: black!important; + background-color: #ddd !important; +} + +.saveButton +{ + padding-top:10px; + padding-bottom: 10px; +} + diff --git a/src/rest-api/helpers.ts b/src/rest-api/helpers.ts index 62dacf2..f798834 100644 --- a/src/rest-api/helpers.ts +++ b/src/rest-api/helpers.ts @@ -1,10 +1,10 @@ const methodBase = { mode: 'cors' as RequestMode, credentials: 'include' as RequestCredentials, - headers: { + headers: new Headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', - }, + }), }; export const formatURL = (url) => (`${process.env.BASE_API_URL}${url}`);