Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqueleite42 committed Nov 10, 2023
0 parents commit 05da18c
Show file tree
Hide file tree
Showing 62 changed files with 7,216 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

root = true

[*]
indent_style = tab
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yml]
indent_style = space
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NEXT_PUBLIC_API_URL=

DISCORD_LINK_AUTH=
34 changes: 34 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"root": true,
"plugins": [
"@typescript-eslint/eslint-plugin",
"eslint-plugin-import-helpers",
"prettier",
"react",
"react-hooks"
],
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"next"
],
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": false
}
],
"import-helpers/order-imports": [
"warn",
{
"newlinesBetween": "always",
"groups": ["module", ["parent", "sibling", "index"]],
"alphabetize": { "order": "asc", "ignoreCase": true }
}
]
}
}
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: tests

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Dependencies
run: yarn

- name: Run ESLint
run: yarn lint

- name: Test TypeScript Syntax
run: yarn type-check

- name: Build
run: yarn build
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# PWA
/public/sw.js
/public/workbox-*.js
/public/worker-*.js
/public/sw.js.map
/public/workbox-*.js.map
/public/worker-*.js.map
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["medkit", "tanstack", "toastify"]
}
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

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.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [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.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

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/deployment) for more details.
20 changes: 20 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/** @type {import('next').NextConfig} */

// eslint-disable-next-line @typescript-eslint/no-var-requires
const withPWA = require("next-pwa")({
dest: "public",
register: true,
skipWaiting: true,
});

const nextConfig = withPWA({
output: "export",
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
});

module.exports = nextConfig;
49 changes: 49 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "front",
"version": "0.1.0",
"private": true,
"dependencies": {
"@hookform/resolvers": "^3.3.1",
"@tanstack/react-query": "^4.35.3",
"@tanstack/react-query-devtools": "^4.35.3",
"clsx": "^2.0.0",
"cookies-next": "^4.0.0",
"daisyui": "^3.8.1",
"next": "latest",
"next-pwa": "^5.6.0",
"react": "latest",
"react-dom": "latest",
"react-hook-form": "^7.46.2",
"react-icons": "^4.11.0",
"react-toastify": "^9.1.3",
"recharts": "^2.9.3",
"yup": "^1.2.0"
},
"devDependencies": {
"@types/next-pwa": "^5.6.7",
"@types/node": "latest",
"@types/react": "latest",
"@types/react-dom": "latest",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"autoprefixer": "latest",
"eslint": "latest",
"eslint-config-next": "latest",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import-helpers": "^1.3.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"postcss": "latest",
"prettier": "^3.0.3",
"tailwindcss": "latest",
"typescript": "latest"
},
"scripts": {
"dev": "next dev -p 3001",
"build": "next build",
"start": "next start",
"lint": "eslint . --quiet",
"type-check": "tsc"
}
}
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icon-384x384.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logo-transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"theme_color": "#803b7e",
"background_color": "#f9daf4",
"display": "standalone",
"scope": "/",
"start_url": "/",
"name": "Econominhas",
"short_name": "econominhas",
"description": "Controle suas finanças",
"icons": [
{
"src": "/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/icon-256x256.png",
"sizes": "256x256",
"type": "image/png"
},
{
"src": "/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
1 change: 1 addition & 0 deletions public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/app/(private)/gastos/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use client";

import { budget } from "assets/data";
import { BudgetsCarousel } from "components/StoresCarousel";
import { getMonthId } from "utils/date";

export default function Documents() {
return (
<main className="min-h-[100dvh] w-full">
<section className="flex justify-center container-padding">
<h1 className="font-black text-xl">Gastos de Maio</h1>
</section>

<BudgetsCarousel budget={budget.budgets[getMonthId()]!} />
</main>
);
}
20 changes: 20 additions & 0 deletions src/app/(private)/template.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client";

import { useAuth } from "hooks/useAuth";
import { redirect, RedirectType } from "next/navigation";
import { ReactNode } from "react";

interface Props {
children: ReactNode;
}

const PrivateLayout: FC<Props> = ({ children }) => {
const auth = useAuth();
const { user } = auth;

if (user === null) redirect("/login", RedirectType.replace);

return <>{children}</>;
};

export default PrivateLayout;
5 changes: 5 additions & 0 deletions src/app/(public)/login/discord/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const DiscordLoading = () => {
return <div>Carregando...</div>;
};

export default DiscordLoading;
48 changes: 48 additions & 0 deletions src/app/(public)/login/discord/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"use client";

import { setCookie } from "cookies-next";
import { useRouter, useSearchParams } from "next/navigation";
import { useEffect, useState } from "react";

import Loading from "./loading";

const API_URL = process.env["NEXT_PUBLIC_API_URL"];

const Discord = () => {
const [token, setToken] = useState("");
const router = useRouter();
const searchParams = useSearchParams();
const code = searchParams.get("code");

useEffect(() => {
const tokenFetch = async () => {
try {
const response = await fetch(`${API_URL}/auth/discord`, {
method: "POST",
body: JSON.stringify({
code,
origin: window.location.href.split("?").shift()!,
}),
headers: {
"Content-Type": "application/json",
},
});
const data = await response.json();
const token = data.accessToken;

setToken(token);
} catch (error) {
console.log(error);
}
};

tokenFetch();
}, [code]);

if (!token) return <Loading />;

setCookie("token", token);
router.push("/");
};

export default Discord;
Loading

0 comments on commit 05da18c

Please sign in to comment.