-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d99bf9
commit 584d8a2
Showing
10 changed files
with
366 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/index.tsx":"1","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/App.tsx":"2","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/styles/global.ts":"3","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Header/index.tsx":"4","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Header/styles.ts":"5","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Dashboard/index.tsx":"6","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Dashboard/styles.ts":"7","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Summary/index.tsx":"8","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Summary/styles.ts":"9","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/TransactionsTable/index.tsx":"10","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/TransactionsTable/styles.ts":"11","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/services/api.ts":"12"},{"size":556,"mtime":1648952246282,"results":"13","hashOfConfig":"14"},{"size":262,"mtime":1648938300862,"results":"15","hashOfConfig":"14"},{"size":909,"mtime":1648944108002,"results":"16","hashOfConfig":"14"},{"size":324,"mtime":1648779011418,"results":"17","hashOfConfig":"14"},{"size":543,"mtime":1648943023772,"results":"18","hashOfConfig":"14"},{"size":263,"mtime":1648947003732,"results":"19","hashOfConfig":"14"},{"size":145,"mtime":1648937924902,"results":"20","hashOfConfig":"14"},{"size":800,"mtime":1648943380912,"results":"21","hashOfConfig":"14"},{"size":632,"mtime":1648943356142,"results":"22","hashOfConfig":"14"},{"size":948,"mtime":1648953717462,"results":"23","hashOfConfig":"14"},{"size":638,"mtime":1648948051382,"results":"24","hashOfConfig":"14"},{"size":106,"mtime":1648953563212,"results":"25","hashOfConfig":"14"},{"filePath":"26","messages":"27","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"16wifw6",{"filePath":"28","messages":"29","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"30","messages":"31","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"33","messages":"34","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"35","messages":"36","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"37","messages":"38","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"39","messages":"40","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"41","messages":"42","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"43","messages":"44","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"45","messages":"46","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"47","messages":"48","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"32"},{"filePath":"49","messages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/App.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/styles/global.ts",[],["51","52"],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Header/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Header/styles.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Dashboard/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Dashboard/styles.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Summary/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Summary/styles.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/TransactionsTable/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/TransactionsTable/styles.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/services/api.ts",[],{"ruleId":"53","replacedBy":"54"},{"ruleId":"55","replacedBy":"56"},"no-native-reassign",["57"],"no-negated-in-lhs",["58"],"no-global-assign","no-unsafe-negation"] | ||
[{"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/index.tsx":"1","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/App.tsx":"2","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/styles/global.ts":"3","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Header/index.tsx":"4","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Header/styles.ts":"5","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Dashboard/index.tsx":"6","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Dashboard/styles.ts":"7","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Summary/index.tsx":"8","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Summary/styles.ts":"9","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/TransactionsTable/index.tsx":"10","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/TransactionsTable/styles.ts":"11","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/services/api.ts":"12","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/NewTransactionModal/index.tsx":"13","/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/NewTransactionModal/styles.ts":"14"},{"size":1108,"mtime":1649204161600,"results":"15","hashOfConfig":"16"},{"size":894,"mtime":1649123706128,"results":"17","hashOfConfig":"16"},{"size":1511,"mtime":1649126788408,"results":"18","hashOfConfig":"16"},{"size":470,"mtime":1649013876991,"results":"19","hashOfConfig":"16"},{"size":543,"mtime":1648943023772,"results":"20","hashOfConfig":"16"},{"size":263,"mtime":1648947003732,"results":"21","hashOfConfig":"16"},{"size":145,"mtime":1648937924902,"results":"22","hashOfConfig":"16"},{"size":800,"mtime":1648943380912,"results":"23","hashOfConfig":"16"},{"size":632,"mtime":1648943356142,"results":"24","hashOfConfig":"16"},{"size":1393,"mtime":1649204195950,"results":"25","hashOfConfig":"16"},{"size":638,"mtime":1648948051382,"results":"26","hashOfConfig":"16"},{"size":106,"mtime":1648953563212,"results":"27","hashOfConfig":"16"},{"size":2582,"mtime":1649199540280,"results":"28","hashOfConfig":"16"},{"size":1719,"mtime":1649198533310,"results":"29","hashOfConfig":"16"},{"filePath":"30","messages":"31","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"16wifw6",{"filePath":"32","messages":"33","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"35","messages":"36","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"37","messages":"38","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"39","messages":"40","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"41","messages":"42","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"43","messages":"44","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"45","messages":"46","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"47","messages":"48","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"49","messages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"51","messages":"52","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"53","messages":"54","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"55","messages":"56","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"57","messages":"58","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/App.tsx",[],["59","60"],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/styles/global.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Header/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Header/styles.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Dashboard/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Dashboard/styles.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Summary/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/Summary/styles.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/TransactionsTable/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/TransactionsTable/styles.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/services/api.ts",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/NewTransactionModal/index.tsx",[],"/home/robsonnatanael/develop/ignite/chapter-II/dtmoney/src/components/NewTransactionModal/styles.ts",[],{"ruleId":"61","replacedBy":"62"},{"ruleId":"63","replacedBy":"64"},"no-native-reassign",["65"],"no-negated-in-lhs",["66"],"no-global-assign","no-unsafe-negation"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { FormEvent, useState } from 'react'; | ||
import Modal from 'react-modal'; | ||
import closeImg from '../../assets/close.svg'; | ||
import incomeImg from '../../assets/income.svg'; | ||
import outcomeImg from '../../assets/outcome.svg'; | ||
import { api } from '../../services/api'; | ||
import { Container, TransactionTypeContainer, RadioBox } from './styles'; | ||
|
||
interface NewTransactionModalProps { | ||
isOpen: boolean; | ||
onRequestClose: () => void; | ||
} | ||
|
||
export function NewTransactionModal({ isOpen, onRequestClose }: NewTransactionModalProps) { | ||
const [title, setTitle] = useState(''); | ||
const [value, setValue] = useState(0); | ||
const [category, setCategory] = useState(''); | ||
const [type, setType] = useState('deposit'); | ||
|
||
function handleCreateNewTransaction(event: FormEvent) { | ||
event.preventDefault(); | ||
|
||
const data = { | ||
title, | ||
value, | ||
category, | ||
type | ||
} | ||
|
||
api.post('/transactions', data); | ||
} | ||
|
||
return ( | ||
<Modal | ||
isOpen={isOpen} | ||
onRequestClose={onRequestClose} | ||
overlayClassName="react-modal-overlay" | ||
className="react-modal-content" | ||
> | ||
<button | ||
type='button' | ||
onClick={onRequestClose} | ||
className="react-modal-close" | ||
> | ||
<img src={closeImg} alt="Fechar modal" /> | ||
</button> | ||
|
||
<Container onSubmit={handleCreateNewTransaction}> | ||
<h2>Cadastrar transação</h2> | ||
|
||
<input | ||
placeholder='Título' | ||
value={title} | ||
onChange={event => setTitle(event.target.value)} | ||
/> | ||
|
||
<input | ||
type="number" | ||
placeholder='Valor' | ||
value={value} | ||
onChange={event => setValue(Number(event.target.value))} | ||
/> | ||
|
||
<TransactionTypeContainer> | ||
<RadioBox | ||
type="button" | ||
onClick={() => { setType('deposit'); }} | ||
isActive={type === 'deposit'} | ||
activeColor="green" | ||
> | ||
<img src={incomeImg} alt="Entrada" /> | ||
<span>Entrada</span> | ||
</RadioBox> | ||
|
||
<RadioBox | ||
type="button" | ||
onClick={() => { setType('withdraw'); }} | ||
isActive={type === 'withdraw'} | ||
activeColor="red" | ||
> | ||
<img src={outcomeImg} alt="Saída" /> | ||
<span>Saída</span> | ||
</RadioBox> | ||
</TransactionTypeContainer> | ||
|
||
<input | ||
placeholder='Categoria' | ||
value={category} | ||
onChange={event => setCategory(event.target.value)} | ||
/> | ||
|
||
<button type='submit'> | ||
Cadastrar | ||
</button> | ||
</Container> | ||
</Modal > | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import styled from "styled-components"; | ||
import { darken, transparentize } from "polished"; | ||
|
||
export const Container = styled.form` | ||
h2 { | ||
color: var(--text-title); | ||
font-size: 1.5rem; | ||
margin-bottom: 2rem; | ||
} | ||
input { | ||
width: 100%; | ||
padding: 0 1.5rem; | ||
height: 4rem; | ||
border-radius: 0.25rem; | ||
border: 1px solid #d7d7d7; | ||
background: #e7e9ee; | ||
font-weight: 400; | ||
font-size: 1rem; | ||
&::placeholder { | ||
color: var(--text-body); | ||
} | ||
& + input { | ||
margin-top: 1rem; | ||
} | ||
} | ||
button[type="submit"] { | ||
width: 100%; | ||
padding: 0 1.5rem; | ||
height: 4rem; | ||
background: var(--green); | ||
color: #fff; | ||
border-radius: 0.25rem; | ||
border: 0; | ||
font-size: 1rem; | ||
font-weight: 600; | ||
margin-top: 1.5rem; | ||
transition: filter 0.2s; | ||
&:hover { | ||
filter: brightness(0.9); | ||
} | ||
} | ||
`; | ||
|
||
export const TransactionTypeContainer = styled.div` | ||
margin: 1rem 0px; | ||
display: grid; | ||
grid-template-columns: 1fr 1fr; | ||
gap: 0.5rem; | ||
`; | ||
|
||
interface RadioBoxProps { | ||
isActive: boolean; | ||
activeColor: "green" | "red"; | ||
} | ||
|
||
const colors = { | ||
green: "#33cc95", | ||
red: "#e52e4d", | ||
}; | ||
|
||
export const RadioBox = styled.button<RadioBoxProps>` | ||
height: 4rem; | ||
border: 1px solid #d7d7d7; | ||
border-radius: 0.25rem; | ||
background: ${(props) => | ||
props.isActive | ||
? transparentize(0.9, colors[props.activeColor]) | ||
: "transparent"}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
transition: border-color 0.2s; | ||
&:hover { | ||
border-color: ${darken(0.1, "#d7d7d7")}; | ||
} | ||
img { | ||
width: 20px; | ||
height: 20px; | ||
} | ||
span { | ||
display: inline-block; | ||
margin-left: 1rem; | ||
font-size: 1rem; | ||
color: var(--text-title); | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.