-
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.
creating modal and user dropdown menu
- Loading branch information
Showing
13 changed files
with
253 additions
and
14 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
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,57 @@ | ||
import * as Dialog from '@radix-ui/react-dialog'; | ||
import { cn } from '../../app/utils/cn'; | ||
import { Cross2Icon } from '@radix-ui/react-icons'; | ||
|
||
interface ModalProps { | ||
open: boolean; | ||
children: React.ReactNode; | ||
title: string; | ||
rightAction?: React.ReactNode; | ||
onClose?(): void; | ||
} | ||
|
||
export function Modal({ open, title, children, rightAction, onClose }: ModalProps) { | ||
return ( | ||
<Dialog.Root open={open} onOpenChange={onClose}> | ||
<Dialog.Portal> | ||
<Dialog.Overlay | ||
className={cn( | ||
"fixed inset-0 bg-black/80 backdrop-blur-sm z-50", | ||
"data-[state=open]:animate-overlay-show" | ||
)} | ||
/> | ||
|
||
<Dialog.Content | ||
className={cn( | ||
"fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 p-6 space-y-10 bg-white rounded-2xl z-[51] shadow-[0px_11px_20px_0px_rgba(0,0,0,0.10)] w-full max-w-[400px] outline-none", | ||
"data-[state=open]:animate-content-show" | ||
)} | ||
> | ||
<header className="h-12 flex items-center justify-between text-gray-800"> | ||
|
||
<button | ||
className="w-12 h-12 flex items-center justify-center outline-none" | ||
onClick={onClose} | ||
> | ||
<Cross2Icon className="w-6 h-6" /> | ||
</button> | ||
|
||
<span className="text-lg tracking-[-1px] font-bold"> | ||
{title} | ||
</span> | ||
|
||
<div className="w-12 h-12 flex items-center justify-center"> | ||
{rightAction} | ||
</div> | ||
|
||
</header> | ||
|
||
<div> | ||
{children} | ||
</div> | ||
</Dialog.Content> | ||
</Dialog.Portal> | ||
</Dialog.Root> | ||
); | ||
} | ||
|
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
89 changes: 89 additions & 0 deletions
89
frontend/src/view/pages/Dashboard/components/Transactions/FiltersModal/index.tsx
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,89 @@ | ||
import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons"; | ||
import { Modal } from "../../../../../components/Modal"; | ||
import { Button } from "../../../../../components/Button"; | ||
import { useFiltersModal } from "./useFiltersModal"; | ||
import { cn } from "../../../../../../app/utils/cn"; | ||
|
||
interface FiltersModalProps { | ||
open: boolean; | ||
onClose(): void; | ||
} | ||
|
||
const mockedAccounts = [ | ||
{ | ||
id: '123', | ||
name: 'Nubank', | ||
}, | ||
{ | ||
id: '456', | ||
name: 'XP Investimentos', | ||
}, | ||
{ | ||
id: '789', | ||
name: 'Dinheiro', | ||
}, | ||
]; | ||
|
||
export function FiltersModal({ open, onClose }: FiltersModalProps) { | ||
const { | ||
selectedBankAccountId, | ||
handleSelectBankAccount, | ||
selectedYear, | ||
handleChangeYear, | ||
} = useFiltersModal(); | ||
|
||
return ( | ||
<Modal open={open} onClose={onClose} title="Filtros"> | ||
<div> | ||
<span className="text-lg tracking-[-1px] font-bold text-gray-800"> | ||
Conta | ||
</span> | ||
<div className="space-y-2 mt-2"> | ||
{mockedAccounts.map(account => ( | ||
<button | ||
key={account.id} | ||
onClick={() => handleSelectBankAccount(account.id)} | ||
className={cn( | ||
"p-2 rounded-2xl w-full text-left hover:bg-gray-50 transition-colors", | ||
account.id === selectedBankAccountId && "!bg-gray-200", | ||
)} | ||
> | ||
{account.name} | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
|
||
<div className="mt-10 text-gray-800"> | ||
<span className="text-lg tracking-[-1px] font-bold"> | ||
Ano | ||
</span> | ||
<div className="mt-2 w-52 flex items-center justify-between"> | ||
<button | ||
className="w-12 h-12 flex items-center justify-center" | ||
onClick={() => handleChangeYear(-1)} | ||
> | ||
<ChevronLeftIcon className="w-6 h-6" /> | ||
|
||
</button> | ||
<div className="flex-1 text-center"> | ||
<span className="text-sm font-medium tracking-[-0.5px]"> | ||
{selectedYear} | ||
</span> | ||
</div> | ||
|
||
<button | ||
className="w-12 h-12 flex items-center justify-center" | ||
onClick={() => handleChangeYear(1)} | ||
> | ||
<ChevronRightIcon className="w-6 h-6" /> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<Button className="w-full mt-10"> | ||
Aplicar Filtros | ||
</Button> | ||
</Modal> | ||
); | ||
} |
25 changes: 25 additions & 0 deletions
25
frontend/src/view/pages/Dashboard/components/Transactions/FiltersModal/useFiltersModal.ts
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,25 @@ | ||
import { useState } from "react"; | ||
|
||
export function useFiltersModal() { | ||
const [selectedBankAccountId, setSelectedBankAccountId] = useState<null | string>(null); | ||
const [selectedYear, setSelectedYear] = useState(new Date().getFullYear()); | ||
|
||
function handleSelectBankAccount(bankAccountId: string) { | ||
setSelectedBankAccountId(prevState => ( | ||
prevState === bankAccountId | ||
? null | ||
: bankAccountId | ||
)); | ||
} | ||
|
||
function handleChangeYear(step: number) { | ||
setSelectedYear(prevState => prevState + step); | ||
} | ||
|
||
return { | ||
handleSelectBankAccount, | ||
selectedBankAccountId, | ||
selectedYear, | ||
handleChangeYear, | ||
}; | ||
} |
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
14 changes: 14 additions & 0 deletions
14
frontend/src/view/pages/Dashboard/components/Transactions/useTransactionsController.ts
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,12 +1,26 @@ | ||
import { useState } from "react"; | ||
import { useDashboard } from "../DashboardContext/useDashboard"; | ||
|
||
export function useTransactionsController() { | ||
const { areValuesVisible } = useDashboard(); | ||
|
||
const [isFiltersModalOpen, setIsFiltersModalOpen] = useState(true); | ||
|
||
function handleOpenFiltersModal() { | ||
setIsFiltersModalOpen(true); | ||
} | ||
|
||
function handleCloseFiltersModal() { | ||
setIsFiltersModalOpen(false); | ||
} | ||
|
||
return { | ||
areValuesVisible, | ||
transactions: [], | ||
isInitialLoading: false, | ||
isLoading: false, | ||
handleOpenFiltersModal, | ||
handleCloseFiltersModal, | ||
isFiltersModalOpen, | ||
}; | ||
} |
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 |
---|---|---|
|
@@ -25,6 +25,7 @@ export function Dashboard() { | |
</main> | ||
|
||
<Fab /> | ||
|
||
</div> | ||
</DashboardProvider> | ||
); | ||
|
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