mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-11 16:30:37 -07:00
Making Widgets Look Nice 1.0
This commit is contained in:
parent
c249a077cc
commit
131e34ca84
19 changed files with 349 additions and 177 deletions
54
src/components/AddIncome.js
Normal file
54
src/components/AddIncome.js
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import React, { useContext, useState } from 'react';
|
||||
import { AppContext } from '../context/AppContext';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
const AddExpenseForm = (props) => {
|
||||
const { dispatch } = useContext(AppContext);
|
||||
|
||||
const [name, setName] = useState('');
|
||||
const [cost, setCost] = useState('');
|
||||
|
||||
const onSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
const expense = {
|
||||
id: uuidv4(),
|
||||
name,
|
||||
cost: parseInt(cost),
|
||||
};
|
||||
|
||||
dispatch({
|
||||
type: 'ADD_EXPENSE',
|
||||
payload: expense,
|
||||
});
|
||||
|
||||
setName('');
|
||||
setCost('');
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit}>
|
||||
<div class='row'>
|
||||
<div class='col-lg-3'>
|
||||
<label for='cost'>Income</label>
|
||||
<input
|
||||
required='required'
|
||||
type='number'
|
||||
class='form-control'
|
||||
id='cost'
|
||||
value={cost}
|
||||
onChange={(event) => setCost(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class='row mt-3'>
|
||||
<div class='col-sm'>
|
||||
<button type='submit' class='btn btn-primary'>
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddExpenseForm;
|
||||
Loading…
Add table
Add a link
Reference in a new issue