-
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
Showing
25 changed files
with
460 additions
and
206 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
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 |
---|---|---|
|
@@ -22,4 +22,4 @@ export function Router() { | |
</Routes> | ||
</BrowserRouter> | ||
); | ||
} | ||
} |
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,8 @@ | ||
export interface BankAccount { | ||
id: string; | ||
name: string; | ||
initialBalance: number; | ||
type: 'CHECKING' | 'INVESTMENT' | 'CASH'; | ||
color: string; | ||
currentBalance: number; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { create } from "./create"; | ||
import { getAll } from "./getAll"; | ||
import { update } from "./update"; | ||
|
||
export const bankAccountsService = { | ||
create, | ||
getAll, | ||
update, | ||
}; |
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,14 @@ | ||
import { httpClient } from '../httpClient' | ||
|
||
export interface UpdateBankAccountParams { | ||
name: string; | ||
initialBalance: number; | ||
color: string; | ||
type: 'CHECKING' | 'INVESTMENT' | 'CASH'; | ||
} | ||
|
||
export async function update(params: UpdateBankAccountParams) { | ||
const { data } = await httpClient.put('/bank-accounts', params) | ||
|
||
return data | ||
} |
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 |
---|---|---|
@@ -1,33 +1,56 @@ | ||
import { CrossCircledIcon } from "@radix-ui/react-icons"; | ||
import { NumericFormat } from "react-number-format"; | ||
import { cn } from "../../app/utils/cn"; | ||
import { CrossCircledIcon } from '@radix-ui/react-icons' | ||
import { cn } from '../../app/utils/cn' | ||
import CurrencyInput from 'react-currency-input-field' | ||
|
||
interface InputCurrencyProps { | ||
error?: string; | ||
value?: string | number; | ||
onChange?(value: string): void; | ||
error?: string | ||
value?: string | number | ||
defaultValue: string | number | ||
className?: string | ||
onChange(value?: string): void | ||
} | ||
|
||
export function InputCurrency({ error, value, onChange }: InputCurrencyProps) { | ||
export function InputCurrency({ | ||
error, value, onChange, className, defaultValue | ||
}: InputCurrencyProps) { | ||
|
||
function handleTransform(value: string) { | ||
return value.length === 0 ? '0' : value | ||
} | ||
|
||
return ( | ||
<div> | ||
<NumericFormat | ||
thousandSeparator="." | ||
<div className={cn( | ||
error && 'relative top-4' | ||
)}> | ||
<CurrencyInput | ||
groupSeparator="." | ||
decimalSeparator="," | ||
decimalScale={2} | ||
value={value} | ||
onChange={event => onChange?.(event.target.value)} | ||
defaultValue={defaultValue} | ||
onValueChange={(value) => onChange(value)} | ||
transformRawValue={handleTransform} | ||
className={cn( | ||
"text-gray-800 text-[32px] font-bold tracking-[-1px] outline-none w-full", | ||
error && "text-red-900" | ||
'w-full text-gray-800 text-[32px] font-bold tracking-[-1px] outline-none', | ||
error && 'text-red-900', | ||
className | ||
)} | ||
/> | ||
|
||
{error && ( | ||
<div className="flex gap-2 items-center mt-2 text-red-900"> | ||
<div className="mt-2 flex gap-2 items-center text-red-900"> | ||
<CrossCircledIcon /> | ||
<span className="text-xs">{error}</span> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
) | ||
} | ||
|
||
InputCurrency.defaultProps = { | ||
value: null, | ||
defaultValue: null, | ||
error: '', | ||
className: '', | ||
onChange: null, | ||
} |
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
Oops, something went wrong.