Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release 1.2.0] - Adding new features and bug fixes 💚 #9

Merged
merged 14 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ next-env.d.ts
.env

# docker
.postgres-data
.postgres-data

# IDES
.idea
57 changes: 34 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -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. 💚
13 changes: 5 additions & 8 deletions app/(authenticated)/transactions/_columns/index.tsx
Original file line number Diff line number Diff line change
@@ -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<Transactions>[] = [
{
Expand Down Expand Up @@ -44,7 +43,7 @@ export const transactionsColumns: ColumnDef<Transactions>[] = [
header: "Data",
cell: ({ row: { original: transaction } }) => {
return (
<p className="text-muted">
<p className="text-muted-foreground">
{new Date(transaction.date).toLocaleDateString("pt-BR", {
day: "2-digit",
month: "long",
Expand All @@ -71,9 +70,7 @@ export const transactionsColumns: ColumnDef<Transactions>[] = [
return (
<div className="flex items-center gap-2">
<EditTransactionButton transaction={transaction} />
<Button variant="ghost" size="icon">
<TrashIcon size={16} />
</Button>
<DeleteTransactionButton transactionId={transaction.id} />
</div>
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<Button variant="ghost" size="icon" onClick={handleClick}>
<TrashIcon size={16} />
</Button>
);
};

export default DeleteTransactionButton;
29 changes: 29 additions & 0 deletions app/_actions/delete-transactions/index.ts
Original file line number Diff line number Diff line change
@@ -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");
};
2 changes: 1 addition & 1 deletion app/_actions/upsert-transactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { db } from "@/app/_lib/prisma";
import { auth } from "@clerk/nextjs/server";
import {
import type {
TransactionCategory,
TransactionPaymentMethod,
TransactionType,
Expand Down
4 changes: 1 addition & 3 deletions app/_components/user-avatar-button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react-hooks/rules-of-hooks */
"use client";

import { redirect } from "next/navigation";
Expand All @@ -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();
Expand All @@ -28,8 +28,6 @@ const UserAvatarButton = () => {
return null;
}

const router = useRouter();

return (
<>
<DropdownMenu>
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "finance-ai",
"name": "jupiter-finance",
"version": "1.1.0",
"private": true,
"author": {
"email": "[email protected]",
"name": "Wesley Souza",
"url": "https://dev-wesleysouza.vercel.app/"
},
"scripts": {
"dev": "next dev",
"build": "prisma generate && prisma migrate deploy && next build",
Expand Down Expand Up @@ -113,4 +118,4 @@
"@semantic-release/github"
]
}
}
}
12 changes: 3 additions & 9 deletions public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.