|
|
@ -1,8 +1,8 @@ |
|
|
|
import React, {useState} from "react"; |
|
|
|
import React, { useState } from 'react'; |
|
|
|
|
|
|
|
|
|
|
|
import "./ExpenseForm.css"; |
|
|
|
import './ExpenseForm.css'; |
|
|
|
|
|
|
|
|
|
|
|
const ExpenseForm = (props) => { |
|
|
|
const ExpenseForm = () => { |
|
|
|
const [enteredTitle, setEnteredTitle] = useState(''); |
|
|
|
const [enteredTitle, setEnteredTitle] = useState(''); |
|
|
|
const [enteredAmount, setEnteredAmount] = useState(''); |
|
|
|
const [enteredAmount, setEnteredAmount] = useState(''); |
|
|
|
const [enteredDate, setEnteredDate] = useState(''); |
|
|
|
const [enteredDate, setEnteredDate] = useState(''); |
|
|
@ -10,32 +10,46 @@ const ExpenseForm = (props) => { |
|
|
|
const titleChangeHandler = (event) => { |
|
|
|
const titleChangeHandler = (event) => { |
|
|
|
setEnteredTitle(event.target.value); |
|
|
|
setEnteredTitle(event.target.value); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const amountChangeHandler = (event) => { |
|
|
|
const amountChangeHandler = (event) => { |
|
|
|
setEnteredAmount(event.target.value); |
|
|
|
setEnteredAmount(event.target.value); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const dateChangeHandler = (event) => { |
|
|
|
const dateChangeHandler = (event) => { |
|
|
|
setEnteredDate(event.target.value); |
|
|
|
setEnteredDate(event.target.value); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return <form> |
|
|
|
return ( |
|
|
|
<div className="new-expense__controls"> |
|
|
|
<form> |
|
|
|
<div className="new-expense__control"> |
|
|
|
<div className='new-expense__controls'> |
|
|
|
|
|
|
|
<div className='new-expense__control'> |
|
|
|
<label>Title</label> |
|
|
|
<label>Title</label> |
|
|
|
<input type="text" onChange={titleChangeHandler} /> |
|
|
|
<input type='text' onChange={titleChangeHandler} /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="new-expense__control"> |
|
|
|
<div className='new-expense__control'> |
|
|
|
<label>Amount</label> |
|
|
|
<label>Amount</label> |
|
|
|
<input type="number" min="0.01" step="0.01" onChange={amountChangeHandler} /> |
|
|
|
<input |
|
|
|
|
|
|
|
type='number' |
|
|
|
|
|
|
|
min='0.01' |
|
|
|
|
|
|
|
step='0.01' |
|
|
|
|
|
|
|
onChange={amountChangeHandler} |
|
|
|
|
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="new-expense__control"> |
|
|
|
<div className='new-expense__control'> |
|
|
|
<label>Date</label> |
|
|
|
<label>Date</label> |
|
|
|
<input type="date" min="2019-01-01" max="2022-12-31" onChange={dateChangeHandler} /> |
|
|
|
<input |
|
|
|
|
|
|
|
type='date' |
|
|
|
|
|
|
|
min='2019-01-01' |
|
|
|
|
|
|
|
max='2022-12-31' |
|
|
|
|
|
|
|
onChange={dateChangeHandler} |
|
|
|
|
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="new-expense__actions"> |
|
|
|
<div className='new-expense__actions'> |
|
|
|
<button type="submit">Add Expense</button> |
|
|
|
<button type='submit'>Add Expense</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</form> |
|
|
|
</form> |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default ExpenseForm; |
|
|
|
export default ExpenseForm; |