@mapotempo/fleet-ui
v0.0.80
Published
Fleet React Component
Downloads
264
Readme
fleet-ui
Fleet React Component
Install
npm install --save fleet-ui
Usage
import { createStore,
combineReducers,
applyMiddleware} from 'redux';
// fleet-ui import
import { LiveView } from 'fleet-ui';
import { fleetReducer } from 'fleet-ui';
import * as fleetActions from 'fleet-ui';
// CSS import
import 'bootstrap/dist/css/bootstrap.min.css';
import 'react-bootstrap-table-next/dist/react-bootstrap-table2.min.css';
import "react-datepicker/dist/react-datepicker.css";
import 'fleet-ui/dist/index.css';
const fleet_user = "sync_user_key";
const fleet_key = "XXXXXXXXXXXXXXXXX";
const fleet_host = 'http://urlToFleetApi.com'
const timeZone = 'Europe/Paris' //This parameter is optionnal by default it will take the user actual timezone
// Create and configure store (fleetReducer need to be on "fleet" root key)
const rootReducer = combineReducers({fleet: fleetReducer({ fleet_host, timeZone })});
const store = createStore(rootReducer, composeWithDevTools(applyMiddleware(thunk)));
// Dispatch connexion
store.dispatch(fleetActions.signInUsers([
{ syncUser: fleet_user, apiKey: fleet_key },
]));
class Example extends Component {
render() {
return (
<Provider store={store}>
<LiveView></LiveView>
</Provider>
);
}
}
Use faker
The fleet-ui contain api faker, to enable this feature add
REACT_APP_USE_FAKER=true
in .env or .env.local file.
Run locally
We need to run in both, in the root project and in the example folder
npm start
You can use this URL:
http://localhost:3001/example#date=2020-12-8&api_keys=abcdef123456&[email protected]&host=https://fleet.beta.mapotempo.com
NPM publish
Before publish check and update version in package.json
{
"name": "fleet-ui",
"version": "X.X.X",
...
}
Run the following command (maybe you will need to configure authentication before)
npm publish
This task need to be automated with CI/CD on every pushed git tag