Ken Schaefer
2 years ago
2 changed files with 122 additions and 32 deletions
@ -1,41 +1,55 @@
|
||||
import React, {useState} from "react"; |
||||
import React, { useState } from 'react'; |
||||
|
||||
import "./ExpenseForm.css"; |
||||
import './ExpenseForm.css'; |
||||
|
||||
const ExpenseForm = (props) => { |
||||
const [enteredTitle, setEnteredTitle] = useState(''); |
||||
const [enteredAmount, setEnteredAmount] = useState(''); |
||||
const [enteredDate, setEnteredDate] = useState(''); |
||||
const ExpenseForm = () => { |
||||
const [enteredTitle, setEnteredTitle] = useState(''); |
||||
const [enteredAmount, setEnteredAmount] = useState(''); |
||||
const [enteredDate, setEnteredDate] = useState(''); |
||||
|
||||
const titleChangeHandler = (event) => { |
||||
setEnteredTitle(event.target.value); |
||||
}; |
||||
const amountChangeHandler = (event) => { |
||||
setEnteredAmount(event.target.value); |
||||
}; |
||||
const dateChangeHandler = (event) => { |
||||
setEnteredDate(event.target.value); |
||||
}; |
||||
const titleChangeHandler = (event) => { |
||||
setEnteredTitle(event.target.value); |
||||
}; |
||||
|
||||
return <form> |
||||
<div className="new-expense__controls"> |
||||
<div className="new-expense__control"> |
||||
<label>Title</label> |
||||
<input type="text" onChange={titleChangeHandler} /> |
||||
</div> |
||||
<div className="new-expense__control"> |
||||
<label>Amount</label> |
||||
<input type="number" min="0.01" step="0.01" onChange={amountChangeHandler} /> |
||||
</div> |
||||
<div className="new-expense__control"> |
||||
<label>Date</label> |
||||
<input type="date" min="2019-01-01" max="2022-12-31" onChange={dateChangeHandler} /> |
||||
</div> |
||||
const amountChangeHandler = (event) => { |
||||
setEnteredAmount(event.target.value); |
||||
}; |
||||
|
||||
const dateChangeHandler = (event) => { |
||||
setEnteredDate(event.target.value); |
||||
}; |
||||
|
||||
return ( |
||||
<form> |
||||
<div className='new-expense__controls'> |
||||
<div className='new-expense__control'> |
||||
<label>Title</label> |
||||
<input type='text' onChange={titleChangeHandler} /> |
||||
</div> |
||||
<div className='new-expense__control'> |
||||
<label>Amount</label> |
||||
<input |
||||
type='number' |
||||
min='0.01' |
||||
step='0.01' |
||||
onChange={amountChangeHandler} |
||||
/> |
||||
</div> |
||||
<div className="new-expense__actions"> |
||||
<button type="submit">Add Expense</button> |
||||
<div className='new-expense__control'> |
||||
<label>Date</label> |
||||
<input |
||||
type='date' |
||||
min='2019-01-01' |
||||
max='2022-12-31' |
||||
onChange={dateChangeHandler} |
||||
/> |
||||
</div> |
||||
</div> |
||||
<div className='new-expense__actions'> |
||||
<button type='submit'>Add Expense</button> |
||||
</div> |
||||
</form> |
||||
} |
||||
); |
||||
}; |
||||
|
||||
export default ExpenseForm; |
Loading…
Reference in new issue