Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciek246 committed Mar 4, 2020
2 parents e5d3548 + 1d667b9 commit a7e64e2
Show file tree
Hide file tree
Showing 56 changed files with 708 additions and 27,945 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import",
[
"@babel/plugin-transform-runtime",
{
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
/build/
/dist/
/node_modules/
/src/alinka.db

output.docx
123 changes: 123 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"prop-types": "^15.7.2",
"react": "16.8.6",
"react-dom": "16.8.6",
"react-router-dom": "^5.1.2",
"react-final-form": "^6.3.3",
"react-final-form-arrays": "^3.1.1",
"sequelize": "5.21.2",
Expand All @@ -48,9 +49,11 @@
"@babel/core": "^7.5.5",
"@babel/node": "^7.5.5",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"@babel/preset-react": "^7.0.0",
"@loadable/component": "^5.12.0",
"@svgr/webpack": "^4.3.3",
"@testing-library/react": "^9.3.2",
"babel-core": "^7.0.0-bridge.0",
Expand Down
5 changes: 5 additions & 0 deletions src/components/Dashboard/Children/Children.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

const Children = () => <div>Szukajka dzieci</div>;

export default Children;
19 changes: 14 additions & 5 deletions src/components/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import React from "react";
import { Route, withRouter, Switch } from "react-router-dom";
import styles from "./Dashboard.scss";
import ProgressBar from "./ProgressBar/ProgressBar";
import FormSteps from "./Form/FormSteps";
import routes from "../../routing/routes";

const Dashboard = () => {
return (
<div className={styles.Dashboard}>
<div className={styles.Wrapper}>
<ProgressBar />
<FormSteps />
<Switch>
{routes.map((route, index) => (
<Route
key={index}
index={route.id}
path={route.path}
render={() => route.component}
exact={route.exact}
/>
))}
</Switch>
</div>
</div>
);
};

export default Dashboard;
export default withRouter(Dashboard);
17 changes: 14 additions & 3 deletions src/components/Dashboard/Form/Applicants/Applicants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useState } from "react";
import PropTypes from "prop-types";

import { useFormState } from "react-final-form";
Expand All @@ -13,6 +13,9 @@ const Applicants = ({ reasonsList, disabilityList }) => {
* and as a reason choose disability that can be engage with other
* @returns {bool}
*/

const [chosenParent, setChosenParent] = useState("WYBIERZ_WNIOSEK");

const getSecondReasonDisabled = () => {
const actualValues = useFormState().values;
const joinableDisabilitylist = Array.from(
Expand All @@ -29,6 +32,13 @@ const Applicants = ({ reasonsList, disabilityList }) => {
);
};

const getOptions = () => {
const parentItem = reasonsList.find(el => el.value === chosenParent);
return disabilityList.filter(
disability => !parentItem.excludedDisabilities.includes(disability.value)
);
};

return (
<div className={`FormContent ${styles.Applicants}`}>
<FieldWrapper
Expand Down Expand Up @@ -61,19 +71,20 @@ const Applicants = ({ reasonsList, disabilityList }) => {
componentSize="large"
component="select"
options={reasonsList}
onChange={event => setChosenParent(event.target.value)}
/>
<FieldWrapper
name={`applicant.reason`}
componentSize="extraLarge"
component="select"
options={disabilityList}
options={getOptions()}
/>
<FieldWrapper
name={`applicant.secondReason`}
componentSize="extraLarge"
component="select"
disabled={getSecondReasonDisabled()}
options={disabilityList}
options={getOptions()}
/>
<FieldWrapper
name={`applicant.period`}
Expand Down
55 changes: 29 additions & 26 deletions src/components/Dashboard/Form/DocumentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Form } from "react-final-form";
import styles from "./DocumentForm.scss";
import arrayMutators from "final-form-arrays";
import PropTypes from "prop-types";
import ProgressBar from "../ProgressBar/ProgressBar";
import Button from "../../Button/Button";

export default class DocumentForm extends Component {
Expand Down Expand Up @@ -49,34 +50,36 @@ export default class DocumentForm extends Component {
const { page, values } = this.state;
const activePage = React.Children.toArray(children)[page];
const isLastPage = page === React.Children.count(children) - 1;
console.log(`Actual form data: ${JSON.stringify(values, 0, 2)}`);

return (
<Form
mutators={{
...arrayMutators
}}
initialValues={values}
validate={this.validate}
onSubmit={this.handleSubmit}
>
{({ handleSubmit, submitting }) => (
<form className={styles.Form} onSubmit={handleSubmit}>
<FormHeader page={this.state.page} />
{activePage}
<div className={styles.buttons}>
{page > 0 && <Button onClick={this.previous}>wróć</Button>}
{isLastPage ? (
<Button type="submit" disabled={submitting}>
utwórz dokument
</Button>
) : (
<Button type="submit">dalej</Button>
)}
</div>
</form>
)}
</Form>
<React.Fragment>
<ProgressBar />
<Form
mutators={{
...arrayMutators
}}
initialValues={values}
validate={this.validate}
onSubmit={this.handleSubmit}
>
{({ handleSubmit, submitting }) => (
<form className={styles.Form} onSubmit={handleSubmit}>
<FormHeader page={this.state.page} />
{activePage}
<div className={styles.buttons}>
{page > 0 && <Button onClick={this.previous}>wróć</Button>}
{isLastPage ? (
<Button type="submit" disabled={submitting}>
utwórz dokument
</Button>
) : (
<Button type="submit">dalej</Button>
)}
</div>
</form>
)}
</Form>
</React.Fragment>
);
}
}
Expand Down
Loading

0 comments on commit a7e64e2

Please sign in to comment.