diff --git a/src/components/auth/AuthChecker.module.scss b/src/components/auth/AuthChecker.module.scss index 8d58056..b943c6a 100644 --- a/src/components/auth/AuthChecker.module.scss +++ b/src/components/auth/AuthChecker.module.scss @@ -1,3 +1,3 @@ .spinner { min-height: 100vh; -} \ No newline at end of file +} diff --git a/src/components/auth/login/LoginForm.tsx b/src/components/auth/login/LoginForm.tsx index 284dfc1..7255302 100644 --- a/src/components/auth/login/LoginForm.tsx +++ b/src/components/auth/login/LoginForm.tsx @@ -23,9 +23,10 @@ interface ILoginFormState { } class LoginForm extends React.Component { - public static defaultProps: Partial = { - loginSuccessfulCallback: () => { return; }, + loginSuccessfulCallback: () => { + return; + }, }; constructor(props: LoginFormProps) { @@ -58,23 +59,21 @@ class LoginForm extends React.Component { prefix={} placeholder="E-mail" disabled={this.state.isSubmitting} - />, + /> )} {getFieldDecorator("password", { validateTrigger: this.state.formValidateTrigger, - rules: [ - { required: true, message: "Wachtwoord mag niet leeg zijn" }, - ], + rules: [{ required: true, message: "Wachtwoord mag niet leeg zijn" }], })( } placeholder="Wachtwoord" disabled={this.state.isSubmitting} - />, + /> )} @@ -113,7 +112,8 @@ class LoginForm extends React.Component { }); const loginDetails: ILoginDetails = values; - Firebase.auth().signInWithEmailAndPassword(loginDetails.username, loginDetails.password) + Firebase.auth() + .signInWithEmailAndPassword(loginDetails.username, loginDetails.password) .then(({ user }) => { notification.success({ message: "Succesvol ingelogd!", @@ -139,7 +139,9 @@ class LoginForm extends React.Component { }); break; default: - notification.error({ message: "Er ging iets fout bij het inloggen, probeer later opnieuw" }); + notification.error({ + message: "Er ging iets fout bij het inloggen, probeer later opnieuw", + }); } this.setState({ isSubmitting: false, diff --git a/src/components/auth/login/LoginPage.module.scss b/src/components/auth/login/LoginPage.module.scss index 9130d40..ed92a1a 100644 --- a/src/components/auth/login/LoginPage.module.scss +++ b/src/components/auth/login/LoginPage.module.scss @@ -7,7 +7,8 @@ height: auto; } -.layout, .row { +.layout, +.row { min-height: 100vh; max-width: 100vw; } diff --git a/src/components/auth/login/LoginPage.tsx b/src/components/auth/login/LoginPage.tsx index 819371a..166b79e 100644 --- a/src/components/auth/login/LoginPage.tsx +++ b/src/components/auth/login/LoginPage.tsx @@ -11,7 +11,6 @@ import styles from "./LoginPage.module.scss"; type LoginPageProps = AnyRouteComponentProps; class LoginPage extends React.Component { - constructor(props: LoginPageProps) { super(props); diff --git a/src/components/containers/AppContainer.module.scss b/src/components/containers/AppContainer.module.scss index af0a770..a9e9955 100644 --- a/src/components/containers/AppContainer.module.scss +++ b/src/components/containers/AppContainer.module.scss @@ -61,10 +61,13 @@ } &LogoutButton { - i, span { + i, + span { color: white; } - &:hover, &:active, &:focus { + &:hover, + &:active, + &:focus { border-color: white !important; } } diff --git a/src/components/containers/AppContainer.tsx b/src/components/containers/AppContainer.tsx index 33643c0..31ca48e 100644 --- a/src/components/containers/AppContainer.tsx +++ b/src/components/containers/AppContainer.tsx @@ -22,7 +22,6 @@ interface IMenuItem { } class AppContainer extends React.Component { - private menuItems: IMenuItem[] = [ { route: routes.planningsRoute, iconType: "calendar" }, { route: routes.studentsRoute, iconType: "team" }, @@ -62,12 +61,14 @@ class AppContainer extends React.Component -
+
Logo - {!this.state.isSiderCollapsed && -

Student Planner

- } + {!this.state.isSiderCollapsed &&

Student Planner

}
{this.renderMenuItems()} -
+

{this.getUserEmail()}

@@ -92,27 +97,21 @@ class AppContainer extends React.Component
- + -

- {this.state.activeMenuItem.route.title} -

+

{this.state.activeMenuItem.route.title}

-
- {this.renderRoutes()} -
+
{this.renderRoutes()}
- + ); } @@ -168,7 +167,8 @@ class AppContainer extends React.Component { notification.success({ message: "Succesvol uitgelogd!", diff --git a/src/components/departments/DepartmentsFormModal.tsx b/src/components/departments/DepartmentsFormModal.tsx index 5594c0c..8ac1277 100644 --- a/src/components/departments/DepartmentsFormModal.tsx +++ b/src/components/departments/DepartmentsFormModal.tsx @@ -31,7 +31,6 @@ interface IDepartmentFormModalState { } class DepartmentFormModal extends React.Component { - private capacityKeysId = 0; private capacityPerEducationFieldName: keyof Department = "capacityPerEducation"; private educationIdFieldName: keyof IDepartmentEducationCapacity = "educationId"; @@ -59,9 +58,11 @@ class DepartmentFormModal extends React.Component { - this.props.form.getFieldDecorator(`${this.capacityPerEducationFieldName}[${capacityFieldId}].${this.educationIdFieldName}`, { - initialValue: departmentToEdit.capacityPerEducation[capacityFieldId].educationId, - }); - this.props.form.getFieldDecorator(`${this.capacityPerEducationFieldName}[${capacityFieldId}].${this.capacityFieldName}`, { - initialValue: departmentToEdit.capacityPerEducation[capacityFieldId].capacity, - }); + this.props.form.getFieldDecorator( + `${this.capacityPerEducationFieldName}[${capacityFieldId}].${this.educationIdFieldName}`, + { + initialValue: departmentToEdit.capacityPerEducation[capacityFieldId].educationId, + } + ); + this.props.form.getFieldDecorator( + `${this.capacityPerEducationFieldName}[${capacityFieldId}].${this.capacityFieldName}`, + { + initialValue: departmentToEdit.capacityPerEducation[capacityFieldId].capacity, + } + ); }); } } @@ -97,12 +104,13 @@ class DepartmentFormModal extends React.Component - {getFieldDecorator(`${this.capacityPerEducationFieldName}[${capacityFieldId}].${this.educationIdFieldName}`, { - validateTrigger: this.state.formValidateTrigger, - rules: [ - { required: true, message: "Kies een opleiding" }, - ], - })( + {getFieldDecorator( + `${this.capacityPerEducationFieldName}[${capacityFieldId}].${this.educationIdFieldName}`, + { + validateTrigger: this.state.formValidateTrigger, + rules: [{ required: true, message: "Kies een opleiding" }], + } + )( , + )} - {getFieldDecorator(`${this.capacityPerEducationFieldName}[${capacityFieldId}].${this.capacityFieldName}`, { - validateTrigger: this.state.formValidateTrigger, - rules: [ - { required: true, message: "Vul een capaciteit in" }, - ], - })( + {getFieldDecorator( + `${this.capacityPerEducationFieldName}[${capacityFieldId}].${this.capacityFieldName}`, + { + validateTrigger: this.state.formValidateTrigger, + rules: [{ required: true, message: "Vul een capaciteit in" }], + } + )( , + /> )} - +
@@ -200,7 +197,9 @@ class DepartmentFormModal extends React.Component{education.name} + + {education.name} + ); } @@ -242,10 +241,11 @@ class DepartmentFormModal extends React.Component("name")], color.hex === undefined ? color : color.hex, - values[nameof("capacityPerEducation")], + values[nameof("capacityPerEducation")] ); - this.props.submitDepartment(department) + this.props + .submitDepartment(department) .then(() => { this.handleClose(); }) diff --git a/src/components/departments/DepartmentsPage.tsx b/src/components/departments/DepartmentsPage.tsx index 1627bc4..e13027a 100644 --- a/src/components/departments/DepartmentsPage.tsx +++ b/src/components/departments/DepartmentsPage.tsx @@ -21,7 +21,6 @@ interface IDepartmentsPageState { } export default class DepartmentsPage extends React.Component { - private unsubscribeFromDepartments: () => void; constructor(props: DepartmentsPageProps) { @@ -37,7 +36,9 @@ export default class DepartmentsPage extends React.Component { return; }; + this.unsubscribeFromDepartments = () => { + return; + }; this.openAddDepartmentModal = this.openAddDepartmentModal.bind(this); this.closeAddDepartmentModal = this.closeAddDepartmentModal.bind(this); @@ -55,13 +56,12 @@ export default class DepartmentsPage extends React.Component { - this.setState({ - areEducationsFetching: false, - educations, - }); + EducationsRepository.getEducationsByName().then((educations) => { + this.setState({ + areEducationsFetching: false, + educations, }); + }); } public componentWillUnmount(): void { diff --git a/src/components/departments/DepartmentsTable.tsx b/src/components/departments/DepartmentsTable.tsx index bd9cc1f..dad5095 100644 --- a/src/components/departments/DepartmentsTable.tsx +++ b/src/components/departments/DepartmentsTable.tsx @@ -14,7 +14,6 @@ interface IDepartmentsTableProps { } class DepartmentsTable extends React.Component { - private columns: Array> = [ { title: "", @@ -91,17 +90,8 @@ class DepartmentsTable extends React.Component { /> - -
); }); @@ -264,7 +275,12 @@ class PlanningsPage extends React.Component -
+
{departmentsRows}
@@ -272,18 +288,19 @@ class PlanningsPage extends React.Component { + return this.state.departments.map((department) => { const totalCapacity = department.totalCapacity; const studentsWithDepartment = students.filter((student) => { - return student.internship !== undefined - && student.internship.departmentId === department.id; + return student.internship !== undefined && student.internship.departmentId === department.id; }); const usedCapacity = studentsWithDepartment.length; const departmentLine = ( {department.name}   - ({usedCapacity}/{totalCapacity}) + + ({usedCapacity}/{totalCapacity}) + ); const educationLines = this.state.educations.map((education) => { @@ -307,7 +324,6 @@ class PlanningsPage extends React.Component ); }); - return departmentsRows; } private handleContextMenu(event: React.SyntheticEvent): void { @@ -392,13 +408,12 @@ class PlanningsPage extends React.Component { - this.loadNotPlannedStudents(); - notification.success({ - message: "Stage succesvol verwijderd", - }); + StudentsRepository.removeInternshipForStudent(student).then(() => { + this.loadNotPlannedStudents(); + notification.success({ + message: "Stage succesvol verwijderd", }); + }); } private openAddInternshipModal(student: Student): void { @@ -530,10 +545,6 @@ class PlanningsPage extends React.Component education.id === educationId); - } } export default PlanningsPage; diff --git a/src/components/schools/SchoolInternshipSummaryModal.tsx b/src/components/schools/SchoolInternshipSummaryModal.tsx index ec90271..3fd7ad7 100644 --- a/src/components/schools/SchoolInternshipSummaryModal.tsx +++ b/src/components/schools/SchoolInternshipSummaryModal.tsx @@ -29,8 +29,10 @@ interface ISchoolInternshipSummaryModalState { selectedEndDate: moment.Moment | undefined; } -class SchoolInternshipSummaryModal extends React.Component { - +class SchoolInternshipSummaryModal extends React.Component< + SchoolInternshipSummaryModalProps, + ISchoolInternshipSummaryModalState +> { constructor(props: SchoolInternshipSummaryModalProps) { super(props); @@ -61,34 +63,49 @@ class SchoolInternshipSummaryModal extends React.Component("selectedStartDate"), { initialValue: this.state.selectedStartDate }); - this.props.form.getFieldDecorator(nameof("selectedEndDate"), { initialValue: this.state.selectedEndDate }); + this.props.form.getFieldDecorator(nameof("selectedStartDate"), { + initialValue: this.state.selectedStartDate, + }); + this.props.form.getFieldDecorator(nameof("selectedEndDate"), { + initialValue: this.state.selectedEndDate, + }); } if (nextProps.selectedSchool !== undefined) { this.setState({ areStudentsLoading: true }); - StudentsRepository.getPlannedStudentsForSchool(nextProps.selectedSchool) - .then((students) => { - this.setState({ - studentsWithInternship: students, - areStudentsLoading: false, - }); + StudentsRepository.getPlannedStudentsForSchool(nextProps.selectedSchool).then((students) => { + this.setState({ + studentsWithInternship: students, + areStudentsLoading: false, }); + }); } } } public render(): React.ReactNode { - const studentsFullyInPeriod = studentsPlannedFullyInRange(this.state.studentsWithInternship, this.state.selectedStartDate, this.state.selectedEndDate); - const studentsPartiallyInPeriod = studentsPlannedPartiallyInRange(this.state.studentsWithInternship, this.state.selectedStartDate, this.state.selectedEndDate); + const studentsFullyInPeriod = studentsPlannedFullyInRange( + this.state.studentsWithInternship, + this.state.selectedStartDate, + this.state.selectedEndDate + ); + const studentsPartiallyInPeriod = studentsPlannedPartiallyInRange( + this.state.studentsWithInternship, + this.state.selectedStartDate, + this.state.selectedEndDate + ); const totalStudentsCount = studentsFullyInPeriod.length + studentsPartiallyInPeriod.length; const totalInternshipDaysCount = [...studentsFullyInPeriod, ...studentsPartiallyInPeriod] - .map((student) => student.getInternshipNumberOfDaysInRange(this.state.selectedStartDate, this.state.selectedEndDate)) + .map((student) => + student.getInternshipNumberOfDaysInRange(this.state.selectedStartDate, this.state.selectedEndDate) + ) .reduce((sum, days) => sum + days, 0); const totalInternshipHoursCount = [...studentsFullyInPeriod, ...studentsPartiallyInPeriod] - .map((student) => student.getInternshipNumberOfHoursInRange(this.state.selectedStartDate, this.state.selectedEndDate)) + .map((student) => + student.getInternshipNumberOfHoursInRange(this.state.selectedStartDate, this.state.selectedEndDate) + ) .reduce((sum, hours) => sum + hours, 0); const { getFieldDecorator } = this.props.form; @@ -115,7 +132,7 @@ class SchoolInternshipSummaryModal extends React.Component, + /> )} @@ -126,13 +143,20 @@ class SchoolInternshipSummaryModal extends React.Component { - const startDate = this.props.form.getFieldValue(nameof("selectedStartDate")); - if (isMomentDayAfterOrTheSameAsOtherDay(endDate || undefined, startDate)) { + const startDate = this.props.form.getFieldValue( + nameof("selectedStartDate") + ); + if ( + isMomentDayAfterOrTheSameAsOtherDay( + endDate || undefined, + startDate + ) + ) { return callback(); } return callback(false); }, - message: "Deze datum mag niet eerder dan de \"van\" datum zijn", + message: 'Deze datum mag niet eerder dan de "van" datum zijn', }, ], })( @@ -141,35 +165,40 @@ class SchoolInternshipSummaryModal extends React.Component, + /> )} - {this.state.selectedStartDate !== undefined && this.state.selectedEndDate !== undefined && this.state.selectedEndDate.isSameOrAfter(this.state.selectedStartDate) && - - -

- Totalen voor geselecteerde periode: -

-

- {totalStudentsCount} {totalStudentsCount === 1 ? "student" : "studenten"},  - {totalInternshipDaysCount} {totalInternshipDaysCount === 1 ? "stage dag" : "stage dagen"},  - {totalInternshipHoursCount} {totalInternshipHoursCount === 1 ? "stage uur" : "stage uren "} - - - -

-
-
- - {this.renderStudentsFullyInPeriod(studentsFullyInPeriod)} + {this.state.selectedStartDate !== undefined && + this.state.selectedEndDate !== undefined && + this.state.selectedEndDate.isSameOrAfter(this.state.selectedStartDate) && ( + + +

+ Totalen voor geselecteerde periode: +

+

+ {totalStudentsCount} {totalStudentsCount === 1 ? "student" : "studenten"} + ,  + {totalInternshipDaysCount}{" "} + {totalInternshipDaysCount === 1 ? "stage dag" : "stage dagen"},  + {totalInternshipHoursCount}{" "} + {totalInternshipHoursCount === 1 ? "stage uur" : "stage uren "} + + + +

+

- {this.renderStudentsNotFullyInPeriod(studentsPartiallyInPeriod)} -
-
- } + + {this.renderStudentsFullyInPeriod(studentsFullyInPeriod)} +
+ {this.renderStudentsNotFullyInPeriod(studentsPartiallyInPeriod)} +
+ + )} ); @@ -202,8 +231,14 @@ class SchoolInternshipSummaryModal extends React.Component @@ -211,12 +246,12 @@ class SchoolInternshipSummaryModal extends React.Component - {student.internship!.startDate.format("DD/MM/YY")} - {student.internship!.endDate.format("DD/MM/YY")} + {student.internship!.startDate.format("DD/MM/YY")} -{" "} + {student.internship!.endDate.format("DD/MM/YY")} {internshipDays} {internshipDays === 1 ? "dag" : "dagen"} -   - ({internshipHours} {internshipHours === 1 ? "uur" : "uren"}) +   ({internshipHours} {internshipHours === 1 ? "uur" : "uren"}) @@ -224,8 +259,14 @@ class SchoolInternshipSummaryModal extends React.Component @@ -233,12 +274,14 @@ class SchoolInternshipSummaryModal extends React.Component - {student.internship!.startDate.format("DD/MM/YY")} - {student.internship!.endDate.format("DD/MM/YY")} + {student.internship!.startDate.format("DD/MM/YY")} -{" "} + {student.internship!.endDate.format("DD/MM/YY")} - {internshipDays}/{student.internshipNumberOfDays} {internshipDays === 1 ? "dag" : "dagen"} -   - ({internshipHours}/{student.internship!.hours} {internshipHours === 1 ? "uur" : "uren"}) + {internshipDays}/{student.internshipNumberOfDays}{" "} + {internshipDays === 1 ? "dag" : "dagen"} +   ({internshipHours}/{student.internship!.hours}{" "} + {internshipHours === 1 ? "uur" : "uren"}) @@ -248,8 +291,9 @@ class SchoolInternshipSummaryModal extends React.Component - Voor studenten die gedeeltelijk in de geselecteerde periode zitten, werden niet alle ingegeven uren meegeteld! - Stel een stage van 10 dagen (50 uren in totaal) die voor 5 dagen in de gekozen periode zit, dan zal deze maar voor 25 uren worden meegeteld. + Voor studenten die gedeeltelijk in de geselecteerde periode zitten, werden niet alle ingegeven uren + meegeteld! Stel een stage van 10 dagen (50 uren in totaal) die voor 5 dagen in de gekozen periode zit, + dan zal deze maar voor 25 uren worden meegeteld. ); } @@ -265,11 +309,17 @@ class SchoolInternshipSummaryModal extends React.Component("selectedStartDate")]: { - value: this.props.form.getFieldValue(nameof("selectedStartDate")), + value: this.props.form.getFieldValue( + nameof("selectedStartDate") + ), errors: undefined, }, [nameof("selectedEndDate")]: { @@ -279,7 +329,10 @@ class SchoolInternshipSummaryModal extends React.Component("selectedStartDate"), nameof("selectedEndDate")]); + this.props.form.validateFieldsAndScroll([ + nameof("selectedStartDate"), + nameof("selectedEndDate"), + ]); } } @@ -288,5 +341,7 @@ class SchoolInternshipSummaryModal extends React.Component()(SchoolInternshipSummaryModal); +const WrappedSchoolInternshipSummaryModal = Form.create()( + SchoolInternshipSummaryModal +); export default WrappedSchoolInternshipSummaryModal; diff --git a/src/components/schools/SchoolsFormModal.tsx b/src/components/schools/SchoolsFormModal.tsx index 1eb5add..9702f8c 100644 --- a/src/components/schools/SchoolsFormModal.tsx +++ b/src/components/schools/SchoolsFormModal.tsx @@ -23,7 +23,6 @@ interface ISchoolsFormModalState { } class SchoolsFormModal extends React.Component { - constructor(props: SchoolFormModalProps) { super(props); @@ -39,10 +38,7 @@ class SchoolsFormModal extends React.Component = { name: this.props.schoolToEdit.name, }; @@ -69,15 +65,8 @@ class SchoolsFormModal extends React.Component {getFieldDecorator("name", { validateTrigger: this.state.formValidateTrigger, - rules: [ - { required: true, message: "Naam mag niet leeg zijn" }, - ], - })( - , - )} + rules: [{ required: true, message: "Naam mag niet leeg zijn" }], + })()} @@ -108,11 +97,10 @@ class SchoolsFormModal extends React.Component("name")], - ); + const school = new School(values[nameof("name")]); - this.props.submitSchool(school) + this.props + .submitSchool(school) .then(() => { this.handleClose(); }) diff --git a/src/components/schools/SchoolsPage.tsx b/src/components/schools/SchoolsPage.tsx index bf8a72c..caa72cc 100644 --- a/src/components/schools/SchoolsPage.tsx +++ b/src/components/schools/SchoolsPage.tsx @@ -23,7 +23,6 @@ interface ISchoolsPageState { } export default class SchoolsPage extends React.Component { - private unsubscribeFromSchool: () => void; constructor(props: SchoolsPageProps) { @@ -39,7 +38,9 @@ export default class SchoolsPage extends React.Component { return; }; + this.unsubscribeFromSchool = () => { + return; + }; this.openAddSchoolModal = this.openAddSchoolModal.bind(this); this.closeAddSchoolModal = this.closeAddSchoolModal.bind(this); @@ -57,14 +58,12 @@ export default class SchoolsPage extends React.Component { - this.setState({ educations }); - }); - DepartmentsRepository.getDepartmentsByName() - .then((departments) => { - this.setState({ departments }); - }); + EducationsRepository.getEducationsByName().then((educations) => { + this.setState({ educations }); + }); + DepartmentsRepository.getDepartmentsByName().then((departments) => { + this.setState({ departments }); + }); } public componentWillUnmount(): void { diff --git a/src/components/schools/SchoolsTable.tsx b/src/components/schools/SchoolsTable.tsx index c4033f3..98afd3e 100644 --- a/src/components/schools/SchoolsTable.tsx +++ b/src/components/schools/SchoolsTable.tsx @@ -24,7 +24,6 @@ interface ISchoolsTableState { } class SchoolsTable extends React.Component { - private columns: Array> = [ { title: "Naam", @@ -88,9 +87,7 @@ class SchoolsTable extends React.Component this.handleOpenInternshipSummary(school); - return ( - Bekijk stages - ); + return Bekijk stages; } private renderActions(school: School): React.ReactNode { @@ -109,17 +106,8 @@ class SchoolsTable extends React.Component - -