Commit 9fe7a094 authored by Julio Guerra's avatar Julio Guerra

1st commit

parent da174b00
File added
node_modules
\ No newline at end of file
GENERATE_SOURCEMAP=false
\ No newline at end of file
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock\.json
FROM node:11.6
WORKDIR /home/auth-lala-react
COPY . .
RUN yarn
RUN yarn build
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br>
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `npm run build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
# auth-lala-react
\ No newline at end of file
{
"name": "auth-lala-react",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "react-scripts build",
"eject": "react-scripts eject",
"start": "react-scripts start",
"test": "react-scripts test"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"eslintConfig": {
"extends": "react-app"
},
"dependencies": {
"axios": "^0.18.0",
"classnames": "^2.2.6",
"crypto-js": "^3.1.9-1",
"csvtojson": "^2.0.8",
"http-proxy-middleware": "^0.19.1",
"lodash": "^4.17.11",
"prettyjson": "^1.2.1",
"query-string": "^6.2.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-dropzone": "^8.0.4",
"react-redux": "^6.0.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.5",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^0.84.0",
"styled-components": "^4.1.3",
"validator": "^10.11.0"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/uach.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>TrAC</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
import axios from "axios";
import {
ADMIN_GET_PROGRAMS,
ADMIN_GET_USERS,
ADMIN_LOGIN,
ADMIN_FETCH,
ADMIN_GET_TRACKING,
} from "../types";
export const adminGetUsers = () => async dispatch => {
const res = await axios.post("/admin/get_users");
dispatch({
type: ADMIN_GET_USERS,
payload: res.data,
});
};
export const adminGetPrograms = () => async dispatch => {
const res = await axios.post("/admin/get_programs");
dispatch({
type: ADMIN_GET_PROGRAMS,
payload: res.data,
});
};
export const adminGetTracking = () => async dispatch => {
const res = await axios.post("/admin/get_tracking");
dispatch({
type: ADMIN_GET_TRACKING,
payload: res.data,
});
};
export const adminLogin = ({ username, password }) => async dispatch => {
const res = await axios.post("/admin/login", { username, password });
dispatch({
type: ADMIN_LOGIN,
payload: res.data,
});
};
export const adminUserUpdate = data => async dispatch => {
const res = await axios.post("/admin/update_user", data);
dispatch({
type: ADMIN_GET_USERS,
payload: res.data,
});
};
export const adminProgramUpdate = data => async dispatch => {
const res = await axios.post("/admin/update_program", data);
dispatch({
type: ADMIN_GET_PROGRAMS,
payload: res.data,
});
};
export const adminFetch = () => async dispatch => {
const res = await axios.post("/admin/current_user");
dispatch({
type: ADMIN_FETCH,
payload: res.data,
});
};
export const adminImportUsers = data => async dispatch => {
const res = await axios.post("/admin/users_import", { data });
dispatch({
type: ADMIN_GET_USERS,
payload: res.data,
});
};
export const adminImportPrograms = data => async dispatch => {
const res = await axios.post("/admin/programs_import", { data });
dispatch({
type: ADMIN_GET_PROGRAMS,
payload: res.data,
});
};
export const adminLockUser = email => async dispatch => {
const res = await axios.post("/admin/lock_user", { email });
dispatch({
type: ADMIN_GET_USERS,
payload: res.data,
});
};
export const adminMailLockedUsers = () => async dispatch => {
await axios.post("/admin/mail_all_locked_users");
};
export const adminDeleteUser = email => async dispatch => {
const res = await axios.post("/admin/delete_user", { email });
dispatch({
type: ADMIN_GET_USERS,
payload: res.data,
});
};
export const adminDeleteProgram = ({ email, program }) => async dispatch => {
const res = await axios.post("/admin/delete_program", { email, program });
dispatch({
type: ADMIN_GET_PROGRAMS,
payload: res.data,
});
};
import axios from "axios";
import {
LOGIN_USER,
LOGOUT_USER,
LOADING,
CLEAR_ERROR,
REDIRECT,
FETCH_USER,
} from "../types";
export const fetchUser = callback => async dispatch => {
dispatch({
type: LOADING,
});
const res = await axios.post("/auth/current_user", { callback });
if (res.data.redirect) {
dispatch({
type: REDIRECT,
payload: res.data.redirect,
});
} else {
dispatch({
type: FETCH_USER,
payload: res.data,
});
}
};
export const loginUser = ({ email, password, callback }) => async dispatch => {
dispatch({
type: LOADING,
});
const res = await axios.post("/auth/login", { email, password, callback });
if (res.data.redirect) {
dispatch({
type: REDIRECT,
payload: res.data.redirect,
});
} else {
dispatch({
type: LOGIN_USER,
payload: res.data,
});
}
};
export const loginUserNoSession = ({
email,
password,
callback,
}) => async dispatch => {
dispatch({
type: LOADING,
});
const res = await axios.post("/auth/login/no_session", {
email,
password,
callback,
});
if (res.data.redirect) {
dispatch({
type: REDIRECT,
payload: res.data.redirect,
});
} else {
dispatch({
type: LOGIN_USER,
payload: res.data,
});
}
};
export const logoutUser = () => async dispatch => {
dispatch({
type: LOGOUT_USER,
});
axios.post("/auth/logout");
};
export const signupUser = ({ email, name, password }) => async dispatch => {
dispatch({
type: LOADING,
});
const res = await axios.post("/auth/signup", {
email,
name,
password,
});
dispatch({
type: LOGIN_USER,
payload: res.data,
});
};
export const recoverPassword = ({
email,
password,
unlockKey,
}) => async dispatch => {
dispatch({
type: LOADING,
});
const res = await axios.post("/auth/unlock", {
email,
password,
unlockKey,
});
dispatch({ type: LOGIN_USER, payload: res.data });
};
export const clearError = () => async dispatch => {
dispatch({
type: CLEAR_ERROR,
});
};
import {
adminGetPrograms,
adminGetUsers,
adminLogin,
adminFetch,
adminProgramUpdate,
adminUserUpdate,
adminImportPrograms,
adminImportUsers,
adminLockUser,
adminMailLockedUsers,
adminDeleteProgram,
adminDeleteUser,
adminGetTracking,
} from "./admin";
import {
fetchUser,
loginUser,
loginUserNoSession,
logoutUser,
signupUser,
recoverPassword,
clearError,
} from "./auth";
export {
fetchUser,
loginUser,
loginUserNoSession,
logoutUser,
signupUser,
recoverPassword,
clearError,
adminGetPrograms,
adminGetUsers,
adminLogin,
adminFetch,
adminProgramUpdate,
adminUserUpdate,
adminImportPrograms,
adminImportUsers,
adminLockUser,
adminMailLockedUsers,
adminDeleteProgram,
adminDeleteUser,
adminGetTracking,
};
import { has, get } from "lodash";
import React, { Component } from "react";
import { connect } from "react-redux";
import { Message } from "semantic-ui-react";
import { ADMIN_ERROR } from "../types";
export class componentName extends Component {
render() {
const { error } = this.props;
return (
<Message error hidden={!has(error, ADMIN_ERROR)}>
<Message.Header>Error!</Message.Header>
<Message.Content content={get(error, [ADMIN_ERROR], "")} />
</Message>
);
}
}
const mapStateToProps = ({ error }) => ({
error,
});
const mapDispatchToProps = {};
export default connect(
mapStateToProps,
mapDispatchToProps
)(componentName);
import classNames from "classnames";
import csv from "csvtojson";
import { isArray } from "lodash";
import React, { Component } from "react";
import Dropzone from "react-dropzone";
import { connect } from "react-redux";
import { Modal, TextArea, Form, Grid, Button, Icon } from "semantic-ui-react";
import { isJSON } from "validator";
import { adminImportPrograms } from "../actions";
import { Confirm } from "./";
class AdminImportPrograms extends Component {
constructor(props) {
super(props);
this.state = {
data: "",
open: false,
};
this.handleSubmit = this.handleSubmit.bind(this);
}
async handleSubmit() {
let { data } = this.state;
try {
if (isJSON(data) && isArray(JSON.parse(data))) {
data = JSON.parse(data);
console.log("json: ", data);
this.props.adminImportPrograms(data);
this.setState({ open: false, data: "" });
} else {
csv({
ignoreEmpty: true,
})
.fromString(data)
.then(
json => {
console.log("csv :", json);
this.props.adminImportPrograms(json);
this.setState({ open: false, data: "" });
},
error => {
console.error(error);
}
);
}
} catch (err) {
console.error(err);
}
}
render() {
const { open, data } = this.state;
return (
<Modal
open={open}
trigger={
<Button primary icon labelPosition="left">
<Icon name="calendar plus outline" />
Importar Programas
</Button>
}
onClose={() => this.setState({ open: false })}
onOpen={() => this.setState({ open: true })}
>
<Modal.Header>Importar Programas</Modal.Header>
<Modal.Content>
<Confirm
header="¿Está seguro que desea resetear la información a importar?"
content="La información en el area de texto será borrada"
onConfirm={() => {
this.setState({