Skip to content

Commit

Permalink
Small code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael committed Mar 7, 2021
1 parent 0d9ebed commit 1619b3c
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 78 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Rafael Barea Hidalgo

## Inicialización pre-mejora

Para lanzar el proyecto:

- Instalar las dependecias del proyecto ejecutando el comando **`npm install`** en una terminal en la carpeta del proyecto.
- Tras instalra las dependecias iniciar el servidor en modo desarrollador con el comando **`npm start`**.
- El servidor se abrirá en la dirección [http://localhost:3000](http://localhost:3000)
8 changes: 4 additions & 4 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';
import React from "react";
import { render } from "@testing-library/react";
import App from "./App";

test('renders learn react link', () => {
test("renders learn react link", () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
Expand Down
133 changes: 71 additions & 62 deletions src/components/Central.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import Stepper from '@material-ui/core/Stepper';
import Step from '@material-ui/core/Step';
import StepLabel from '@material-ui/core/StepLabel';
import Button from '@material-ui/core/Button';
import Typography from '@material-ui/core/Typography';
import Stepper from "@material-ui/core/Stepper";
import Step from "@material-ui/core/Step";
import StepLabel from "@material-ui/core/StepLabel";
import Button from "@material-ui/core/Button";
import Typography from "@material-ui/core/Typography";

/*
function Central(props: any) {
Expand Down Expand Up @@ -169,90 +169,99 @@ interface ICentralProps {
setActiveStep: (arg0: number) => void;
}

interface ICentralState {

}
interface ICentralState {}

class Centrals extends React.Component<ICentralProps, ICentralState> {
steps = ['Seleccionar oficina', 'Seleccionar Área', 'Datos del interesado', 'Datos del representante', 'Otros datos'];
steps = [
"Seleccionar oficina",
"Seleccionar Área",
"Datos del interesado",
"Datos del representante",
"Otros datos",
];

constructor(props: ICentralProps) {
super(props);
}

isStepOptional(step: number) {
return step === 3
return step === 3;
}

handleNext= ()=> {
console.log(this.props)
handleNext = () => {
console.log(this.props);
this.props.setActiveStep(this.props.current + 1);
console.log(this.props.current)
console.log(this.props.current);
};

handleBack=()=>{
handleBack = () => {
this.props.setActiveStep(this.props.current - 1);
};
getStepContent(step: number) {
switch (step) {
case 0:
return 'Select campaign settings...';
return "Select campaign settings...";
case 1:
return 'What is an ad group anyways?';
return "What is an ad group anyways?";
case 2:
return 'This is the bit I really care about!';
case 3:
return '3!';
case 4:
return '4!';
return "This is the bit I really care about!";
case 3:
return "3!";
case 4:
return "4!";
default:
return 'Unknown step';
return "Unknown step";
}
}
render() {
return(
return (
<div>
<Stepper activeStep={this.props.current}>
{this.steps.map((label, index) => {
const stepProps: { completed?: boolean } = {};
const labelProps: { optional?: React.ReactNode } = {};
if (this.isStepOptional(index)) {
labelProps.optional = <Typography variant="caption">Opcional</Typography>;
}
return (
<Step key={label} {...stepProps}>
<StepLabel {...labelProps}>{label}</StepLabel>
</Step>
);
})}
</Stepper>
<div>
{this.props.current === this.steps.length ? (
<Stepper activeStep={this.props.current}>
{this.steps.map((label, index) => {
const stepProps: { completed?: boolean } = {};
const labelProps: { optional?: React.ReactNode } = {};
if (this.isStepOptional(index)) {
labelProps.optional = (
<Typography variant="caption">Opcional</Typography>
);
}
return (
<Step key={label} {...stepProps}>
<StepLabel {...labelProps}>{label}</StepLabel>
</Step>
);
})}
</Stepper>
<div>
<Typography>
Has completado todos los pasos
</Typography>
</div>
) : (
<div>
<Typography>{this.getStepContent(this.props.current)}</Typography>
<div>
<Button disabled={this.props.current === 0} onClick={this.handleBack}>
Volver
</Button>
<Button
variant="contained"
color="primary"
onClick={this.handleNext}
>
{this.props.current === this.steps.length - 1 ? 'Finish' : 'Next'}
</Button>
</div>
{this.props.current === this.steps.length ? (
<div>
<Typography>Has completado todos los pasos</Typography>
</div>
) : (
<div>
<Typography>{this.getStepContent(this.props.current)}</Typography>
<div>
<Button
disabled={this.props.current === 0}
onClick={this.handleBack}
>
Volver
</Button>
<Button
variant="contained"
color="primary"
onClick={this.handleNext}
>
{this.props.current === this.steps.length - 1
? "Finish"
: "Next"}
</Button>
</div>
</div>
)}
</div>
)}
</div>
</div>
)
</div>
);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ function Header(props: IHeaderProps) {
<div className={props.classes.cabecera}>
<div className={props.classes.central}>
<div className={props.classes.logo}></div>
<div className={props.classes.right}>
</div>
<div className={props.classes.right}></div>
</div>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
12 changes: 6 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
document.getElementById("root")
);

// If you want your app to work offline and load faster, you can change
Expand Down
1 change: 0 additions & 1 deletion src/styledComponents/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ import injectSheet from 'react-jss'
import Header from '../components/Header'
import classes from './Header-jss.ts'


export default injectSheet(classes)(Header)

0 comments on commit 1619b3c

Please sign in to comment.