Skip to content

Commit

Permalink
Project-wide prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Van Renterghem committed Nov 21, 2019
1 parent 4dff7d0 commit 07e24d0
Show file tree
Hide file tree
Showing 37 changed files with 490 additions and 482 deletions.
2 changes: 1 addition & 1 deletion src/components/auth/AuthChecker.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.spinner {
min-height: 100vh;
}
}
20 changes: 11 additions & 9 deletions src/components/auth/login/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ interface ILoginFormState {
}

class LoginForm extends React.Component<LoginFormProps, ILoginFormState> {

public static defaultProps: Partial<LoginFormProps> = {
loginSuccessfulCallback: () => { return; },
loginSuccessfulCallback: () => {
return;
},
};

constructor(props: LoginFormProps) {
Expand Down Expand Up @@ -58,23 +59,21 @@ class LoginForm extends React.Component<LoginFormProps, ILoginFormState> {
prefix={<Icon type="user" />}
placeholder="E-mail"
disabled={this.state.isSubmitting}
/>,
/>
)}
</FormItem>

<FormItem>
{getFieldDecorator<ILoginDetails>("password", {
validateTrigger: this.state.formValidateTrigger,
rules: [
{ required: true, message: "Wachtwoord mag niet leeg zijn" },
],
rules: [{ required: true, message: "Wachtwoord mag niet leeg zijn" }],
})(
<Input
type="password"
prefix={<Icon type="lock" />}
placeholder="Wachtwoord"
disabled={this.state.isSubmitting}
/>,
/>
)}
</FormItem>

Expand Down Expand Up @@ -113,7 +112,8 @@ class LoginForm extends React.Component<LoginFormProps, ILoginFormState> {
});

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!",
Expand All @@ -139,7 +139,9 @@ class LoginForm extends React.Component<LoginFormProps, ILoginFormState> {
});
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,
Expand Down
3 changes: 2 additions & 1 deletion src/components/auth/login/LoginPage.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
height: auto;
}

.layout, .row {
.layout,
.row {
min-height: 100vh;
max-width: 100vw;
}
1 change: 0 additions & 1 deletion src/components/auth/login/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import styles from "./LoginPage.module.scss";
type LoginPageProps = AnyRouteComponentProps;

class LoginPage extends React.Component<LoginPageProps> {

constructor(props: LoginPageProps) {
super(props);

Expand Down
7 changes: 5 additions & 2 deletions src/components/containers/AppContainer.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@
}

&LogoutButton {
i, span {
i,
span {
color: white;
}
&:hover, &:active, &:focus {
&:hover,
&:active,
&:focus {
border-color: white !important;
}
}
Expand Down
34 changes: 17 additions & 17 deletions src/components/containers/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ interface IMenuItem {
}

class AppContainer extends React.Component<AppContainerProps, IAppContainerState> {

private menuItems: IMenuItem[] = [
{ route: routes.planningsRoute, iconType: "calendar" },
{ route: routes.studentsRoute, iconType: "team" },
Expand Down Expand Up @@ -62,12 +61,14 @@ class AppContainer extends React.Component<AppContainerProps, IAppContainerState
trigger={null}
collapsed={this.state.isSiderCollapsed}
>
<div className={classNames(styles.siderContentWrapper, { [styles.siderContentWrapperCollapsed]: this.state.isSiderCollapsed })}>
<div
className={classNames(styles.siderContentWrapper, {
[styles.siderContentWrapperCollapsed]: this.state.isSiderCollapsed,
})}
>
<div className={styles.logoContainer}>
<img src={logo} alt="Logo" className={styles.logo} />
{!this.state.isSiderCollapsed &&
<p className={styles.logoText}>Student Planner</p>
}
{!this.state.isSiderCollapsed && <p className={styles.logoText}>Student Planner</p>}
</div>
<Menu
theme="dark"
Expand All @@ -76,7 +77,11 @@ class AppContainer extends React.Component<AppContainerProps, IAppContainerState
>
{this.renderMenuItems()}
</Menu>
<div className={classNames(styles.siderFooter, { [styles.siderFooterCollapsed]: this.state.isSiderCollapsed })}>
<div
className={classNames(styles.siderFooter, {
[styles.siderFooterCollapsed]: this.state.isSiderCollapsed,
})}
>
<Tooltip title={this.getUserEmail()} placement="right">
<p className={styles.siderFooterUsername}>{this.getUserEmail()}</p>
</Tooltip>
Expand All @@ -92,27 +97,21 @@ class AppContainer extends React.Component<AppContainerProps, IAppContainerState
</div>
</div>
</Layout.Sider>
<Layout
className={styles.contentLayout}
>
<Layout className={styles.contentLayout}>
<Layout.Header className={styles.header}>
<Icon
className={classNames("trigger", styles.triggerButton)}
type={this.state.isSiderCollapsed ? "menu-unfold" : "menu-fold"}
onClick={this.handleSiderCollapseToggle}
/>
<h1 className={styles.title}>
{this.state.activeMenuItem.route.title}
</h1>
<h1 className={styles.title}>{this.state.activeMenuItem.route.title}</h1>
</Layout.Header>
<Layout.Content className={styles.content}>
<div className={styles.innerContent}>
{this.renderRoutes()}
</div>
<div className={styles.innerContent}>{this.renderRoutes()}</div>
</Layout.Content>
</Layout>
</Layout>
</React.Fragment >
</React.Fragment>
);
}

Expand Down Expand Up @@ -168,7 +167,8 @@ class AppContainer extends React.Component<AppContainerProps, IAppContainerState
private handleLogout(event: React.FormEvent): void {
event.preventDefault();

Firebase.auth().signOut()
Firebase.auth()
.signOut()
.then(() => {
notification.success({
message: "Succesvol uitgelogd!",
Expand Down
100 changes: 50 additions & 50 deletions src/components/departments/DepartmentsFormModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ interface IDepartmentFormModalState {
}

class DepartmentFormModal extends React.Component<DepartmentFormModalProps, IDepartmentFormModalState> {

private capacityKeysId = 0;
private capacityPerEducationFieldName: keyof Department = "capacityPerEducation";
private educationIdFieldName: keyof IDepartmentEducationCapacity = "educationId";
Expand Down Expand Up @@ -59,9 +58,11 @@ class DepartmentFormModal extends React.Component<DepartmentFormModalProps, IDep

public componentDidUpdate(prevProps: DepartmentFormModalProps): void {
// Populate the form if it is just opened and if a department to edit is passed.
if (this.props.departmentToEdit !== undefined
&& this.props.isVisible === true
&& prevProps.isVisible === false) {
if (
this.props.departmentToEdit !== undefined &&
this.props.isVisible === true &&
prevProps.isVisible === false
) {
const { departmentToEdit } = this.props;
const idCount = (departmentToEdit.capacityPerEducation || []).length;
this.capacityKeysId = idCount;
Expand All @@ -76,12 +77,18 @@ class DepartmentFormModal extends React.Component<DepartmentFormModalProps, IDep
this.setState({ selectedColor: departmentToEdit.color });
this.props.form.setFieldsValue(fields);
capacityFieldIds.forEach((capacityFieldId) => {
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,
}
);
});
}
}
Expand All @@ -97,12 +104,13 @@ class DepartmentFormModal extends React.Component<DepartmentFormModalProps, IDep
<Row key={capacityFieldId} gutter={8} type="flex" justify="space-between" align="bottom">
<Col span={14}>
<FormItem label="Opleiding">
{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" }],
}
)(
<Select
disabled={this.state.isSubmitting}
loading={this.props.isEducationsLoading}
Expand All @@ -112,35 +120,31 @@ class DepartmentFormModal extends React.Component<DepartmentFormModalProps, IDep
optionFilterProp="children"
>
{educationSelectOptions}
</Select>,
</Select>
)}
</FormItem>
</Col>
<Col span={7}>
<FormItem label="Capaciteit">
{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" }],
}
)(
<InputNumber
className={styles.fullWidthInputField}
disabled={this.state.isSubmitting}
min={1}
/>,
/>
)}
</FormItem>
</Col>
<Col span={3}>
<FormItem>
<Tooltip title="Verwijderen">
<Button
icon="delete"
type="danger"
ghost={true}
onClick={deleletCapacityFunc}
/>
<Button icon="delete" type="danger" ghost={true} onClick={deleletCapacityFunc} />
</Tooltip>
</FormItem>
</Col>
Expand All @@ -165,33 +169,26 @@ class DepartmentFormModal extends React.Component<DepartmentFormModalProps, IDep
<FormItem label="Naam">
{getFieldDecorator<Department>("name", {
validateTrigger: this.state.formValidateTrigger,
rules: [
{ required: true, message: "Naam mag niet leeg zijn" },
],
})(
<Input
autoFocus={true}
disabled={this.state.isSubmitting}
/>,
)}
rules: [{ required: true, message: "Naam mag niet leeg zijn" }],
})(<Input autoFocus={true} disabled={this.state.isSubmitting} />)}
</FormItem>
<FormItem label="Kleur">
{getFieldDecorator<Department>("color", {
validateTrigger: this.state.formValidateTrigger,
rules: [
{ required: true, message: "Kies een kleur" },
],
})(
<CirclePicker color={this.state.selectedColor} onChange={this.handleColorChange} />,
)}
rules: [{ required: true, message: "Kies een kleur" }],
})(<CirclePicker color={this.state.selectedColor} onChange={this.handleColorChange} />)}
</FormItem>

<h4>Capaciteit per opleiding</h4>
<p>Max. aantal studenten per opleiding voor deze afdeling</p>
{capacitiesFormItems}
<Button type="dashed" onClick={this.handleAddCapacityField} className={styles.fullWidthInputField}>
<Button
type="dashed"
onClick={this.handleAddCapacityField}
className={styles.fullWidthInputField}
>
Voeg capaciteit toe
</Button>
</Button>
</Form>
</Modal>
</div>
Expand All @@ -200,7 +197,9 @@ class DepartmentFormModal extends React.Component<DepartmentFormModalProps, IDep

private renderEducationSelectOption(education: Education): React.ReactNode {
return (
<Select.Option key={education.id} value={education.id}>{education.name}</Select.Option>
<Select.Option key={education.id} value={education.id}>
{education.name}
</Select.Option>
);
}

Expand Down Expand Up @@ -242,10 +241,11 @@ class DepartmentFormModal extends React.Component<DepartmentFormModalProps, IDep
const department = new Department(
values[nameof<Department>("name")],
color.hex === undefined ? color : color.hex,
values[nameof<Department>("capacityPerEducation")],
values[nameof<Department>("capacityPerEducation")]
);

this.props.submitDepartment(department)
this.props
.submitDepartment(department)
.then(() => {
this.handleClose();
})
Expand Down
Loading

0 comments on commit 07e24d0

Please sign in to comment.