Cleaning up unused imports, indentation, add some comments
This commit is contained in:
parent
f2dc1cbe4c
commit
e5a2c8f1d8
2 changed files with 106 additions and 136 deletions
32
src/App.css
32
src/App.css
|
@ -1,16 +1,10 @@
|
|||
.App {
|
||||
/*text-align: center;*/
|
||||
position:absolute;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-color: #1e1e1e;
|
||||
}
|
||||
|
||||
/*.App-Container {*/
|
||||
/* background-color: #102445;*/
|
||||
|
||||
/*}*/
|
||||
|
||||
.App-logo {
|
||||
height: 10em;
|
||||
pointer-events: none;
|
||||
|
@ -36,32 +30,6 @@
|
|||
flex-basis: 50%;
|
||||
}
|
||||
|
||||
/*@media (prefers-reduced-motion: no-preference) {*/
|
||||
/* .App-logo {*/
|
||||
/* animation: App-logo-spin infinite 20s linear;*/
|
||||
/* }*/
|
||||
/*}*/
|
||||
|
||||
/*.App-header {*/
|
||||
/* background-color: #282c34;*/
|
||||
/* min-height: 100vh;*/
|
||||
/* display: flex;*/
|
||||
/* flex-direction: column;*/
|
||||
/* align-items: center;*/
|
||||
/* justify-content: center;*/
|
||||
/* font-size: calc(10px + 2vmin);*/
|
||||
/* color: white;*/
|
||||
/*}*/
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
/*@keyframes App-logo-spin {*/
|
||||
/* from {*/
|
||||
/* transform: rotate(0deg);*/
|
||||
/* }*/
|
||||
/* to {*/
|
||||
/* transform: rotate(360deg);*/
|
||||
/* }*/
|
||||
/*}*/
|
||||
|
|
40
src/App.jsx
40
src/App.jsx
|
@ -5,7 +5,6 @@ import Box from '@mui/material/Box';
|
|||
import Paper from '@mui/material/Paper';
|
||||
import { ThemeProvider, createTheme } from '@mui/material/styles';
|
||||
import CssBaseline from '@mui/material/CssBaseline';
|
||||
import PropTypes from 'prop-types';
|
||||
import Tabs from '@mui/material/Tabs';
|
||||
import Tab from '@mui/material/Tab';
|
||||
import Typography from '@mui/material/Typography';
|
||||
|
@ -13,16 +12,10 @@ import Grid from '@mui/material/Grid';
|
|||
import TextField from '@mui/material/TextField';
|
||||
import ToggleButton from '@mui/material/ToggleButton';
|
||||
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
||||
import InputAdornment from '@mui/material/InputAdornment';
|
||||
import {OutlinedInput} from '@mui/material';
|
||||
import FormControl from '@mui/material/FormControl';
|
||||
import InputLabel from '@mui/material/InputLabel';
|
||||
import { NumericFormat } from 'react-number-format';
|
||||
import { FormattedNumber, IntlProvider } from 'react-intl';
|
||||
import Table from '@mui/material/Table';
|
||||
import TableBody from '@mui/material/TableBody';
|
||||
import TableCell from '@mui/material/TableCell';
|
||||
import TableContainer from '@mui/material/TableContainer';
|
||||
import TableHead from '@mui/material/TableHead';
|
||||
import TableRow from '@mui/material/TableRow';
|
||||
|
||||
|
@ -32,6 +25,7 @@ const darkTheme = createTheme({
|
|||
},
|
||||
});
|
||||
|
||||
// Formatter for salary input component
|
||||
const NumericFormatCustom = React.forwardRef(function NumericFormatCustom(
|
||||
props,
|
||||
ref,
|
||||
|
@ -57,19 +51,24 @@ const NumericFormatCustom = React.forwardRef(function NumericFormatCustom(
|
|||
);
|
||||
});
|
||||
|
||||
// Each calculator a separate component - only making postdoc for now
|
||||
function Postdoc(){
|
||||
// The different parts of the calculation and results stored as state
|
||||
const [experience, setExperience] = React.useState(0)
|
||||
const [hireDate, setHireDate] = React.useState('apr')
|
||||
const [salary, setSalary] = React.useState(64480);
|
||||
const [newSalary, setNewSalary] = React.useState(undefined);
|
||||
const [futureSalaries, setFutureSalaries] = React.useState(undefined);
|
||||
|
||||
// Status function for calculating new salary from old salary and other state
|
||||
// (lots of fun implicit dependencies in here but hey we can make a pure function later)
|
||||
const calculateNewSalary = (oldSalary) => {
|
||||
const multiplier_hire = hireDate === 'apr' ? 1.05 : 1.025
|
||||
const multiplier_exp = 1 + (experience / 20)
|
||||
return oldSalary * 1.05 * multiplier_hire * multiplier_exp;
|
||||
}
|
||||
|
||||
// Effect to update salary whenever any of the state values change
|
||||
React.useEffect(
|
||||
() => {
|
||||
setNewSalary(calculateNewSalary(salary))
|
||||
|
@ -86,7 +85,8 @@ function Postdoc(){
|
|||
)
|
||||
|
||||
|
||||
|
||||
// The logicless handlers that could just be an inline anonymous function but split
|
||||
// out just to show...
|
||||
const handleHireDate = (event) => {
|
||||
setHireDate(event.target.value);
|
||||
};
|
||||
|
@ -95,6 +95,7 @@ function Postdoc(){
|
|||
setSalary(event.target.value)
|
||||
}
|
||||
|
||||
// Standard react render blob
|
||||
return(
|
||||
<Box sx={{ flexGrow: 1 }}>
|
||||
<Grid container spacing={2} padding={5}>
|
||||
|
@ -118,7 +119,6 @@ function Postdoc(){
|
|||
<Typography fontWeight={"bold"} fontSize={'1.2em'}>
|
||||
Hiring Date
|
||||
</Typography>
|
||||
{/*<Typography fontStyle={"italic"}>As of April 4, 2023</Typography>*/}
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<ToggleButtonGroup
|
||||
|
@ -137,7 +137,6 @@ function Postdoc(){
|
|||
<Typography fontWeight={"bold"} fontSize={'1.2em'}>
|
||||
Salary Before Raise
|
||||
</Typography>
|
||||
{/*<Typography fontStyle={"italic"}></Typography>*/}
|
||||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<TextField
|
||||
|
@ -167,10 +166,9 @@ function Postdoc(){
|
|||
style="currency"
|
||||
/>
|
||||
</Typography>
|
||||
|
||||
|
||||
</>
|
||||
: undefined}
|
||||
: undefined
|
||||
}
|
||||
{futureSalaries !== undefined ?
|
||||
<Table size="small">
|
||||
<TableHead>
|
||||
|
@ -191,7 +189,8 @@ function Postdoc(){
|
|||
</TableRow>
|
||||
)}))}
|
||||
</Table>
|
||||
: undefined}
|
||||
: undefined
|
||||
}
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Box>
|
||||
|
@ -211,12 +210,14 @@ function App() {
|
|||
<ThemeProvider theme={darkTheme}>
|
||||
<CssBaseline />
|
||||
<div className="App">
|
||||
<Box className={"App-Container"}
|
||||
<Box
|
||||
className={"App-Container"}
|
||||
sx={{
|
||||
width: '80%',
|
||||
height: '90%',
|
||||
margin: '5% 10%'
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
<Paper elevation={3} sx={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
|
@ -225,6 +226,8 @@ function App() {
|
|||
<header className="App-header">
|
||||
<img src={logo} className="App-logo" alt="logo" />
|
||||
<h2 className={"title"}>Wage Calculator</h2>
|
||||
|
||||
{/* Tabs toggle between different calculators*/}
|
||||
<Tabs
|
||||
sx={{width: '100%'}}
|
||||
value={value}
|
||||
|
@ -237,10 +240,9 @@ function App() {
|
|||
<Tab value="sre" label="ASE / SR" />
|
||||
</Tabs>
|
||||
{value === 'postdoc' ?
|
||||
<Postdoc></Postdoc> : undefined
|
||||
<Postdoc></Postdoc>
|
||||
: undefined
|
||||
}
|
||||
|
||||
|
||||
</header>
|
||||
</Paper>
|
||||
</Box>
|
||||
|
|
Loading…
Reference in a new issue