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

doc(demo) update demo and licence #386

Merged
merged 3 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 AXA France
Copyright (c) 2018 Axa France IARD / Axa France VIE

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4,944 changes: 3,540 additions & 1,404 deletions examples/demo/package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@
"babel-eslint": "9.0.0",
"bootstrap": "^4.2.1",
"classnames": "^2.2.6",
"cuid": "^2.1.4",
"moment": "^2.23.0",
"mw.validation": "^1.0.9",
"cuid": "^2.1.6",
"moment": "^2.24.0",
"mw.validation": "^1.0.15",
"outy": "^0.1.2",
"rc-slider": "^8.6.4",
"react": "^16.7.0",
"rc-slider": "^8.7.1",
"react": "^16.9.0",
"react-datepicker": "^1.8.0",
"react-dom": "^16.7.0",
"react-dom": "^16.9.0",
"react-dropzone": "^7.0.1",
"react-modal": "^3.8.1",
"react-router-dom": "^4.3.1",
"react-modal": "^3.10.1",
"react-router-dom": "^4.4.0",
"react-scripts": "2.1.1",
"react-select": "^2.2.0",
"react-select": "^2.4.4",
"recompose": "^0.30.0"
},
"scripts": {
Expand All @@ -76,11 +76,11 @@
"not op_mini all"
],
"devDependencies": {
"concurrently": "^4.0.1",
"express": "^4.16.4",
"node-sass": "^4.11.0",
"nodemon": "^1.18.9",
"stylelint-config-standard": "^18.2.0"
"concurrently": "^4.1.2",
"express": "^4.17.1",
"node-sass": "^4.12.0",
"nodemon": "^1.19.2",
"stylelint-config-standard": "^18.3.0"
},
"homepage": ".",
"proxy": "http://localhost:5000",
Expand Down
73 changes: 29 additions & 44 deletions examples/demo/src/Home/Home.container.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,33 @@
import Home from './Home';
import fetchDevis from './Home.service';
import { LoaderModes } from '@axa-fr/react-toolkit-all';
import {
lifecycle,
compose,
withStateHandlers,
setDisplayName,
withProps
} from 'recompose';

import React, {useState, useEffect} from 'react';
import withCustomFetch from '../withCustomFetch';
import withLoader from "../withLoader";

const HomeWithLoader = withLoader(Home);

const HomeContainer = (props) => {
const { fetch } = props;

const [state, setState] = useState({
loading: true,
items: []
});

useEffect(() => {
const init = async () => {
const items = await fetchDevis(fetch)();
setState({
loading: false,
items: items
guillaumechervetaxa marked this conversation as resolved.
Show resolved Hide resolved
});
};
init();
},[]);

return (<HomeWithLoader {...state} />);

};

const withInitState = lifecycle({
state: {
loading: true,
items: []
}
});

const withInitData = withStateHandlers(() => ({}), {
init: (state, props) => items => ({
items,
loading: false
})
});

const withFetchData = lifecycle({
async componentDidMount() {
const { init, fetch } = this.props;
const items = await fetchDevis(fetch)();
init(items);
}
});

const withLoaderMode = withProps(({ loading }) => ({
loaderMode: loading ? LoaderModes.get : LoaderModes.none
}));

const enhance = compose(
setDisplayName('EnhancedHome'),
withInitState,
withInitData,
withCustomFetch(fetch),
withFetchData,
withLoaderMode
);

export default enhance(Home);
export default withCustomFetch(fetch)(HomeContainer);
8 changes: 0 additions & 8 deletions examples/demo/src/New/New.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
SelectInput,
DateInput,
Button,
SliderInput,
} from '@axa-fr/react-toolkit-all';
import './New.scss';
import {
Expand Down Expand Up @@ -100,13 +99,6 @@ const New = ({ fields, onChange, hasSubmit, onSubmit }) => (
messageType="error"
/>
</section>
<section className="af-panel__content">
<SliderInput
className="af-form__slider"
name="testslider"
onChange={onChange}
/>
</section>
</article>
<Button
classModifier="hasiconRight confirm"
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/src/withCustomFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const withCustomFetch = fetch => Component => props => {
fetch={customFetch(fetch)(props.environment.apiUrl)}
/>
);
}
};

export default (fetch = undefined) =>
compose(
Expand Down
9 changes: 9 additions & 0 deletions examples/demo/src/withLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {LoaderModes} from "@axa-fr/react-toolkit-loader";
import React from "react";

const withLoader = (Component) => ({loading, ...otherProps}) => {
guillaumechervetaxa marked this conversation as resolved.
Show resolved Hide resolved
const loaderMode= loading ? LoaderModes.get : LoaderModes.none;
return (<Component loaderMode={loaderMode} {...otherProps} />);
};

export default withLoader;
45 changes: 12 additions & 33 deletions package-lock.json

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

Loading