diff --git a/.gitignore b/.gitignore index 5d58495..d98f035 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,7 @@ next-env.d.ts .env # docker -.postgres-data \ No newline at end of file +.postgres-data + +# IDES +.idea \ No newline at end of file diff --git a/README.md b/README.md index e215bc4..c6222f7 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,47 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). +# 💚 Jupiter finance, seu gerenciador de finanças inteligente. -## Getting Started +O Jupiter Finance foi desenvolvido com auxilio da full stack week, do Felipe Rocha, e sofreu algumas mudanças para torná-lo único e feito com carinho por mim, Wesley. 💚 -First, run the development server: +--- -```bash -npm run dev -# or -yarn dev -# or -pnpm dev -# or -bun dev -``` +## 💚 Funcionalidades + +- [x] Você pode adicionar transações com base na sua data atual, transações futuras (com o date picker), e adicionar transações da datas passadas. +- [x] Você pode deletar transações +- [x] Você pode editar transações (nome, valor, data, etc) +- [x] Validações de segurança adicionadas, você pode obter os dados apenas se você estiver autenticado, e se aqueles dados forem seus. +- [ ] Dashboard pra gerenciar usuários, orgs, webhooks, e mais. (Apenas pra desenvolvimento e pra administração apenas, em produção.) +- [ ] Adicionar novos meios de autenticação além do clerk (auth js, por exemplo). +- [x] Adicionar logs de clicks, page views, web records, e mais, usando o PostHog. +- [ ] Adicionar WebHooks do discord, etc +- [ ] Adicionar organizações no login (originalmente clerk, deve ser implementado do zero se for auth js. A logica deve ser feita o mais genérica o possível em caso do uso de outros métodos de login.). -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +--- -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. +## 💚 Como contribuir -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. +Para contribuir, você pode clonar o repositório e seguir os seguintes passos: -## Learn More +### 1. Clonando repositório + +```bash +git clone https://github.com/neopromic/jupiter-finance.git +``` -To learn more about Next.js, take a look at the following resources: +### 2. Obtendo variáveis de ambiente de desenvolvimento -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. +- 1. Primeiro, você deve ter o docker instalado em sua máquina, ou criar um banco de testes grátis na [neon](https://neon.tech). +- 2. Em seu `.env`, cole a string de conexão obtida no [neon.tech](https://neon.tech), ou use `"postgresql://postgres:password@localhost:5432/finance-ai"` do docker. +- 3. Caso prefira usar o docker, suba o container (pois o docker compose já está configurado no projeto), usando `docker compose up -d`. +- 4. Crie um projeto no clerk, e obtenha as credenciais. +- 5. Crie uma conta no PostHog e adicione as credenciais. +- Pronto! Credenciais adicionadas! 💚 -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! +### 3. Crie uma branch nova e comece a contribuir! -## Deploy on Vercel +- 1. Crie uma nova branch (`git branch feat/name-of-the-feat && git checkout feat/name-of-the-feat`) +- 2. Quando for fazer Pull Request, envie pra comparação com a branch de **`dev`**(desenvolvimento)! Nós lançamos primeiro na dev, e depois fazemos merge na main, quando tiver um bom número de mudanças. -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. +--- -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. +#### Criado por Wesley Souza, com carinho. 💚 diff --git a/app/(authenticated)/transactions/_columns/index.tsx b/app/(authenticated)/transactions/_columns/index.tsx index 242b2d3..5530e02 100644 --- a/app/(authenticated)/transactions/_columns/index.tsx +++ b/app/(authenticated)/transactions/_columns/index.tsx @@ -1,13 +1,12 @@ "use client"; -import { ColumnDef } from "@tanstack/react-table"; -import { Transactions } from "@prisma/client"; +import type { ColumnDef } from "@tanstack/react-table"; +import type { Transactions } from "@prisma/client"; import TransactionTypeBadge from "../_components/type-badge"; -import { Button } from "@/app/_components/ui/button"; -import { TrashIcon } from "lucide-react"; import { TRANSACTION_PAYMENT_METHOD_MAP } from "@/app/_constants/transaction"; import { TRANSACTION_CATEGORY_MAP } from "@/app/_constants/transaction"; import EditTransactionButton from "../_components/edit-transaction-button"; +import DeleteTransactionButton from "../_components/delete-transaction-button"; export const transactionsColumns: ColumnDef[] = [ { @@ -44,7 +43,7 @@ export const transactionsColumns: ColumnDef[] = [ header: "Data", cell: ({ row: { original: transaction } }) => { return ( -

+

{new Date(transaction.date).toLocaleDateString("pt-BR", { day: "2-digit", month: "long", @@ -71,9 +70,7 @@ export const transactionsColumns: ColumnDef[] = [ return (

- +
); }, diff --git a/app/(authenticated)/transactions/_components/delete-transaction-button.tsx b/app/(authenticated)/transactions/_components/delete-transaction-button.tsx new file mode 100644 index 0000000..bf561b5 --- /dev/null +++ b/app/(authenticated)/transactions/_components/delete-transaction-button.tsx @@ -0,0 +1,23 @@ +import { deleteTransaction } from "@/app/_actions/delete-transactions"; +import { Button } from "@/app/_components/ui/button"; +import { TrashIcon } from "lucide-react"; + +interface IDeleteTransactionsButtonProps { + transactionId: string; +} + +const DeleteTransactionButton = ({ + transactionId, +}: IDeleteTransactionsButtonProps) => { + const handleClick = async () => { + await deleteTransaction({ transactionId }); + }; + + return ( + + ); +}; + +export default DeleteTransactionButton; diff --git a/app/_actions/delete-transactions/index.ts b/app/_actions/delete-transactions/index.ts new file mode 100644 index 0000000..92501c4 --- /dev/null +++ b/app/_actions/delete-transactions/index.ts @@ -0,0 +1,29 @@ +"use server"; + +import { db } from "@/app/_lib/prisma"; +import { auth } from "@clerk/nextjs/server"; +import { revalidatePath } from "next/cache"; + +interface IDeleteTransactions { + transactionId: string; +} + +export const deleteTransaction = async ({ + transactionId, +}: IDeleteTransactions) => { + const { userId } = await auth(); + + if (!userId) { + throw new Error("", { + cause: "You need log-in account to delete transactions.", + }); + } + + await db.transactions.delete({ + where: { + id: transactionId, + userId, + }, + }); + revalidatePath("/transactions"); +}; diff --git a/app/_actions/upsert-transactions/index.ts b/app/_actions/upsert-transactions/index.ts index 72ed5f6..25351e9 100644 --- a/app/_actions/upsert-transactions/index.ts +++ b/app/_actions/upsert-transactions/index.ts @@ -2,7 +2,7 @@ import { db } from "@/app/_lib/prisma"; import { auth } from "@clerk/nextjs/server"; -import { +import type { TransactionCategory, TransactionPaymentMethod, TransactionType, diff --git a/app/_components/user-avatar-button.tsx b/app/_components/user-avatar-button.tsx index e558108..7046c60 100644 --- a/app/_components/user-avatar-button.tsx +++ b/app/_components/user-avatar-button.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react-hooks/rules-of-hooks */ "use client"; import { redirect } from "next/navigation"; @@ -16,6 +15,7 @@ import { useRouter } from "next/navigation"; const UserAvatarButton = () => { const { user } = useUser(); const { signOut } = useClerk(); + const router = useRouter(); const handleLogout = async () => { await signOut(); @@ -28,8 +28,6 @@ const UserAvatarButton = () => { return null; } - const router = useRouter(); - return ( <> diff --git a/docker-compose.yml b/docker-compose.yml index a0cbfb7..1074b82 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,11 +3,11 @@ version: "3" services: postgres: image: postgres:latest - container_name: finance-ai-database + container_name: jupiter-finance-database environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: password - POSTGRES_DB: finance-ai + POSTGRES_DB: jupiter-finance ports: - "5432:5432" volumes: diff --git a/package.json b/package.json index 05866e3..41fbe12 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,12 @@ { - "name": "finance-ai", + "name": "jupiter-finance", "version": "1.1.0", "private": true, + "author": { + "email": "wesleysoouza007@gmail.com", + "name": "Wesley Souza", + "url": "https://dev-wesleysouza.vercel.app/" + }, "scripts": { "dev": "next dev", "build": "prisma generate && prisma migrate deploy && next build", @@ -113,4 +118,4 @@ "@semantic-release/github" ] } -} +} \ No newline at end of file diff --git a/public/logo.svg b/public/logo.svg index a3cc0ac..9abec54 100644 --- a/public/logo.svg +++ b/public/logo.svg @@ -1,10 +1,4 @@ - - - - - - - - - + + +