Initial commit: EKAI v2 - Portal de Notícias IA (React + NestJS)
This commit is contained in:
24
frontend/.gitignore
vendored
Normal file
24
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
16
frontend/README.md
Normal file
16
frontend/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# React + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
|
||||
29
frontend/eslint.config.js
Normal file
29
frontend/eslint.config.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{js,jsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
ecmaFeatures: { jsx: true },
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
|
||||
},
|
||||
},
|
||||
])
|
||||
14
frontend/index.html
Normal file
14
frontend/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<title>EK[AI] - Eduardo Kislanski</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
3681
frontend/package-lock.json
generated
Normal file
3681
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
frontend/package.json
Normal file
32
frontend/package.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"dompurify": "^3.3.1",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
"react-quill-new": "^3.8.3",
|
||||
"react-router-dom": "^7.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@tailwindcss/vite": "^4.1.18",
|
||||
"@types/react": "^19.2.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"globals": "^16.5.0",
|
||||
"tailwindcss": "^4.1.18",
|
||||
"vite": "^7.3.1"
|
||||
}
|
||||
}
|
||||
BIN
frontend/public/avatar.jpg
Normal file
BIN
frontend/public/avatar.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 111 KiB |
1
frontend/public/vite.svg
Normal file
1
frontend/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
42
frontend/src/App.css
Normal file
42
frontend/src/App.css
Normal file
@@ -0,0 +1,42 @@
|
||||
#root {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: filter 300ms;
|
||||
}
|
||||
.logo:hover {
|
||||
filter: drop-shadow(0 0 2em #646cffaa);
|
||||
}
|
||||
.logo.react:hover {
|
||||
filter: drop-shadow(0 0 2em #61dafbaa);
|
||||
}
|
||||
|
||||
@keyframes logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
a:nth-of-type(2) .logo {
|
||||
animation: logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.read-the-docs {
|
||||
color: #888;
|
||||
}
|
||||
35
frontend/src/App.jsx
Normal file
35
frontend/src/App.jsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { useState } from 'react'
|
||||
import reactLogo from './assets/react.svg'
|
||||
import viteLogo from '/vite.svg'
|
||||
import './App.css'
|
||||
|
||||
function App() {
|
||||
const [count, setCount] = useState(0)
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<a href="https://vite.dev" target="_blank">
|
||||
<img src={viteLogo} className="logo" alt="Vite logo" />
|
||||
</a>
|
||||
<a href="https://react.dev" target="_blank">
|
||||
<img src={reactLogo} className="logo react" alt="React logo" />
|
||||
</a>
|
||||
</div>
|
||||
<h1>Vite + React</h1>
|
||||
<div className="card">
|
||||
<button onClick={() => setCount((count) => count + 1)}>
|
||||
count is {count}
|
||||
</button>
|
||||
<p>
|
||||
Edit <code>src/App.jsx</code> and save to test HMR
|
||||
</p>
|
||||
</div>
|
||||
<p className="read-the-docs">
|
||||
Click on the Vite and React logos to learn more
|
||||
</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
44
frontend/src/api.js
Normal file
44
frontend/src/api.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const BASE = '/api';
|
||||
|
||||
function headers() {
|
||||
const h = { 'Content-Type': 'application/json' };
|
||||
const token = localStorage.getItem('ekai_token');
|
||||
if (token) h['Authorization'] = `Bearer ${token}`;
|
||||
return h;
|
||||
}
|
||||
|
||||
async function api(path, opts = {}) {
|
||||
const res = await fetch(`${BASE}${path}`, { ...opts, headers: headers() });
|
||||
if (res.status === 401) { localStorage.removeItem('ekai_token'); window.location.href = '/admin/login'; return; }
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export const getNoticias = (page = 1, limit = 50) => api(`/noticias?page=${page}&limit=${limit}`);
|
||||
export const getNoticia = (id) => api(`/noticias/${id}`);
|
||||
export const createNoticia = (data) => api('/noticias', { method: 'POST', body: JSON.stringify(data) });
|
||||
export const updateNoticia = (id, data) => api(`/noticias/${id}`, { method: 'PUT', body: JSON.stringify(data) });
|
||||
export const deleteNoticia = (id) => api(`/noticias/${id}`, { method: 'DELETE' });
|
||||
|
||||
export const getHypes = () => api('/hypes');
|
||||
export const getHypesAll = () => api('/hypes/all');
|
||||
export const createHype = (data) => api('/hypes', { method: 'POST', body: JSON.stringify(data) });
|
||||
export const updateHype = (id, data) => api(`/hypes/${id}`, { method: 'PUT', body: JSON.stringify(data) });
|
||||
export const deleteHype = (id) => api(`/hypes/${id}`, { method: 'DELETE' });
|
||||
|
||||
export const getDica = () => api('/dica');
|
||||
export const getDicasAll = () => api('/dica/all');
|
||||
export const createDica = (data) => api('/dica', { method: 'POST', body: JSON.stringify(data) });
|
||||
export const updateDica = (id, data) => api(`/dica/${id}`, { method: 'PUT', body: JSON.stringify(data) });
|
||||
export const deleteDica = (id) => api(`/dica/${id}`, { method: 'DELETE' });
|
||||
|
||||
export const subscribe = (email) => api('/inscritos', { method: 'POST', body: JSON.stringify({ email }) });
|
||||
export const getInscritos = () => api('/inscritos');
|
||||
export const deleteInscrito = (id) => api(`/inscritos/${id}`, { method: 'DELETE' });
|
||||
|
||||
export const login = async (email, password) => {
|
||||
const res = await fetch(`${BASE}/auth/login`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, password }) });
|
||||
if (!res.ok) throw new Error('Login failed');
|
||||
const data = await res.json();
|
||||
localStorage.setItem('ekai_token', data.access_token);
|
||||
return data;
|
||||
};
|
||||
1
frontend/src/assets/react.svg
Normal file
1
frontend/src/assets/react.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
38
frontend/src/components/AdminLayout.jsx
Normal file
38
frontend/src/components/AdminLayout.jsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { useEffect } from 'react';
|
||||
import { Outlet, Link, useNavigate, useLocation } from 'react-router-dom';
|
||||
|
||||
export default function AdminLayout() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
if (!localStorage.getItem('ekai_token')) navigate('/admin/login');
|
||||
}, []);
|
||||
|
||||
const links = [
|
||||
{ to: '/admin', label: '📊 Dashboard' },
|
||||
{ to: '/admin/noticias', label: '📰 Notícias' },
|
||||
{ to: '/admin/hypes', label: '🔥 Hypes' },
|
||||
{ to: '/admin/dicas', label: '💡 Dicas' },
|
||||
{ to: '/admin/inscritos', label: '📧 Inscritos' },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[#0a0a0f] text-[#e0e0e0]">
|
||||
<header className="bg-[#12121a] border-b border-white/10 px-6 py-4 flex justify-between items-center">
|
||||
<div className="flex items-center gap-6">
|
||||
<Link to="/" className="text-lg font-extrabold">🧠 EK<span className="text-[#00c8ff]">[AI]</span> <span className="text-sm font-normal text-[#888]">Admin</span></Link>
|
||||
<nav className="flex gap-4">
|
||||
{links.map(l => (
|
||||
<Link key={l.to} to={l.to} className={`text-sm hover:text-[#00c8ff] transition ${location.pathname === l.to ? 'text-[#00c8ff]' : 'text-[#888]'}`}>{l.label}</Link>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
<button onClick={() => { localStorage.removeItem('ekai_token'); navigate('/admin/login'); }} className="text-sm text-[#888] hover:text-red-400">Sair</button>
|
||||
</header>
|
||||
<main className="max-w-5xl mx-auto p-6">
|
||||
<Outlet />
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
65
frontend/src/components/NeuralCanvas.jsx
Normal file
65
frontend/src/components/NeuralCanvas.jsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
export default function NeuralCanvas() {
|
||||
const ref = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const canvas = ref.current;
|
||||
const ctx = canvas.getContext('2d');
|
||||
let nodes = [];
|
||||
let animId;
|
||||
|
||||
function resize() {
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = document.body.scrollHeight;
|
||||
nodes = [];
|
||||
const num = Math.floor((canvas.width * canvas.height) / 25000);
|
||||
for (let i = 0; i < num; i++) {
|
||||
nodes.push({
|
||||
x: Math.random() * canvas.width,
|
||||
y: Math.random() * canvas.height,
|
||||
vx: (Math.random() - 0.5) * 0.2,
|
||||
vy: (Math.random() - 0.5) * 0.2,
|
||||
r: Math.random() * 2 + 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
ctx.strokeStyle = 'rgba(0, 200, 255, 0.06)';
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
for (let j = i + 1; j < nodes.length; j++) {
|
||||
const d = Math.hypot(nodes[i].x - nodes[j].x, nodes[i].y - nodes[j].y);
|
||||
if (d < 100) {
|
||||
ctx.globalAlpha = 1 - d / 100;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(nodes[i].x, nodes[i].y);
|
||||
ctx.lineTo(nodes[j].x, nodes[j].y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
nodes.forEach(n => {
|
||||
ctx.beginPath();
|
||||
ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2);
|
||||
ctx.fillStyle = 'rgba(0, 200, 255, 0.4)';
|
||||
ctx.fill();
|
||||
n.x += n.vx;
|
||||
n.y += n.vy;
|
||||
if (n.x < 0 || n.x > canvas.width) n.vx *= -1;
|
||||
if (n.y < 0 || n.y > canvas.height) n.vy *= -1;
|
||||
});
|
||||
animId = requestAnimationFrame(draw);
|
||||
}
|
||||
|
||||
resize();
|
||||
draw();
|
||||
window.addEventListener('resize', resize);
|
||||
const interval = setInterval(resize, 3000);
|
||||
return () => { cancelAnimationFrame(animId); window.removeEventListener('resize', resize); clearInterval(interval); };
|
||||
}, []);
|
||||
|
||||
return <canvas ref={ref} className="fixed top-0 left-0 w-full h-full z-0 pointer-events-none" />;
|
||||
}
|
||||
40
frontend/src/index.css
Normal file
40
frontend/src/index.css
Normal file
@@ -0,0 +1,40 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--color-dark: #0a0a0f;
|
||||
--color-dark-card: #12121a;
|
||||
--color-primary: #00c8ff;
|
||||
--color-text: #e0e0e0;
|
||||
--color-text-dim: #888;
|
||||
--color-border: rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: normal;
|
||||
font-weight: 400 800;
|
||||
font-display: swap;
|
||||
src: url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: #0a0a0f;
|
||||
color: #e0e0e0;
|
||||
margin: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
/* Rich text content */
|
||||
.rich-content p { margin-bottom: 12px; color: #888; font-size: 15px; line-height: 1.8; }
|
||||
.rich-content strong { color: #e0e0e0; }
|
||||
|
||||
/* Quill overrides for admin */
|
||||
.ql-toolbar { background: #1a1a2e !important; border-color: rgba(255,255,255,0.1) !important; }
|
||||
.ql-container { background: #12121a !important; border-color: rgba(255,255,255,0.1) !important; color: #e0e0e0 !important; min-height: 200px; }
|
||||
.ql-editor { color: #e0e0e0 !important; }
|
||||
.ql-snow .ql-stroke { stroke: #888 !important; }
|
||||
.ql-snow .ql-fill { fill: #888 !important; }
|
||||
.ql-snow .ql-picker-label { color: #888 !important; }
|
||||
31
frontend/src/main.jsx
Normal file
31
frontend/src/main.jsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
||||
import './index.css'
|
||||
import Home from './pages/Home'
|
||||
import AdminLogin from './pages/admin/Login'
|
||||
import AdminDashboard from './pages/admin/Dashboard'
|
||||
import AdminNoticias from './pages/admin/Noticias'
|
||||
import AdminNoticiaForm from './pages/admin/NoticiaForm'
|
||||
import AdminHypes from './pages/admin/Hypes'
|
||||
import AdminDicas from './pages/admin/Dicas'
|
||||
import AdminInscritos from './pages/admin/Inscritos'
|
||||
import AdminLayout from './components/AdminLayout'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')).render(
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/admin/login" element={<AdminLogin />} />
|
||||
<Route path="/admin" element={<AdminLayout />}>
|
||||
<Route index element={<AdminDashboard />} />
|
||||
<Route path="noticias" element={<AdminNoticias />} />
|
||||
<Route path="noticias/new" element={<AdminNoticiaForm />} />
|
||||
<Route path="noticias/:id" element={<AdminNoticiaForm />} />
|
||||
<Route path="hypes" element={<AdminHypes />} />
|
||||
<Route path="dicas" element={<AdminDicas />} />
|
||||
<Route path="inscritos" element={<AdminInscritos />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
)
|
||||
119
frontend/src/pages/Home.jsx
Normal file
119
frontend/src/pages/Home.jsx
Normal file
@@ -0,0 +1,119 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import NeuralCanvas from '../components/NeuralCanvas';
|
||||
import { getNoticias, getHypes, getDica, subscribe } from '../api';
|
||||
|
||||
export default function Home() {
|
||||
const [noticias, setNoticias] = useState([]);
|
||||
const [hypes, setHypes] = useState([]);
|
||||
const [dica, setDica] = useState(null);
|
||||
const [expanded, setExpanded] = useState(null);
|
||||
const [email, setEmail] = useState('');
|
||||
const [subMsg, setSubMsg] = useState('');
|
||||
const [page, setPage] = useState(1);
|
||||
const [totalPages, setTotalPages] = useState(1);
|
||||
|
||||
useEffect(() => {
|
||||
getNoticias(page, 50).then(r => { setNoticias(r.data || []); setTotalPages(r.pages || 1); });
|
||||
getHypes().then(r => setHypes(Array.isArray(r) ? r : []));
|
||||
getDica().then(r => setDica(r));
|
||||
}, [page]);
|
||||
|
||||
const handleSub = async (e) => {
|
||||
e.preventDefault();
|
||||
try { await subscribe(email); setSubMsg('✅ Inscrito com sucesso!'); setEmail(''); } catch { setSubMsg('Email já inscrito ou inválido'); }
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen">
|
||||
<NeuralCanvas />
|
||||
|
||||
{/* Header */}
|
||||
<header className="sticky top-0 z-50 border-b border-white/10" style={{ background: 'rgba(10,10,15,0.95)', backdropFilter: 'blur(10px)' }}>
|
||||
<nav className="max-w-[800px] mx-auto px-5 py-4 flex justify-between items-center">
|
||||
<a href="/" className="text-xl font-extrabold">🧠 EK<span className="text-[#00c8ff]">[AI]</span></a>
|
||||
<a href="#newsletter" className="bg-[#00c8ff] text-[#0a0a0f] px-5 py-2.5 rounded-lg font-semibold hover:opacity-90 transition">Inscrever-se</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
{/* Hero */}
|
||||
<section className="relative z-[1] py-16 text-center">
|
||||
<div className="max-w-[800px] mx-auto px-5">
|
||||
<img src="/avatar.jpg" alt="Eduardo Kislanski" className="w-24 h-24 rounded-full mx-auto mb-5 border-3 border-[#00c8ff] object-cover" style={{ boxShadow: '0 0 30px rgba(0,200,255,0.3)' }} />
|
||||
<h1 className="text-4xl font-extrabold mb-2">EK<span className="text-[#00c8ff]">[AI]</span></h1>
|
||||
<p className="text-[#888] mb-6">🧠 Seu Filtro Diário de IA</p>
|
||||
<form id="newsletter" onSubmit={handleSub} className="flex gap-3 max-w-md mx-auto mb-4">
|
||||
<input type="email" value={email} onChange={e => setEmail(e.target.value)} placeholder="Seu e-mail..." required className="flex-1 px-4 py-3 bg-[#12121a] border border-white/10 rounded-lg text-[#e0e0e0] text-base focus:outline-none focus:border-[#00c8ff]" />
|
||||
<button type="submit" className="bg-[#00c8ff] text-[#0a0a0f] px-6 py-3 rounded-lg font-semibold hover:opacity-90 transition">Inscrever</button>
|
||||
</form>
|
||||
{subMsg && <p className="text-sm text-[#00c8ff]">{subMsg}</p>}
|
||||
<p className="text-sm text-[#888]">Por <strong className="text-[#e0e0e0]">Eduardo Kislanski</strong></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Noticias */}
|
||||
<section className="relative z-[1] max-w-[800px] mx-auto px-5 py-10">
|
||||
<h2 className="text-xl font-bold text-center mb-6">📰 Notícias de <span className="text-[#00c8ff]">IA</span></h2>
|
||||
{noticias.map(n => (
|
||||
<article key={n.id} className={`bg-[#12121a] border rounded-2xl mb-5 overflow-hidden transition-all ${expanded === n.id ? 'border-[#00c8ff]' : 'border-white/10'}`} style={expanded === n.id ? { boxShadow: '0 0 30px rgba(0,200,255,0.15)' } : {}}>
|
||||
<div className="cursor-pointer relative" onClick={() => setExpanded(expanded === n.id ? null : n.id)}>
|
||||
<img src={n.imagem_url} alt="" className="w-full h-[200px] object-cover" />
|
||||
{n.categoria === 'destaque' && <div className="absolute top-4 left-4 bg-gradient-to-r from-[#00c8ff] to-[#0080ff] text-[#0a0a0f] px-3 py-1 rounded-md text-xs font-bold">🔥 Destaque</div>}
|
||||
<div className="p-5">
|
||||
<span className="text-[13px] text-[#00c8ff]">{new Date(n.data_publicacao + 'T12:00:00').toLocaleDateString('pt-BR', { month: 'short', day: 'numeric', year: 'numeric' })}</span>
|
||||
<h3 className="text-lg font-bold my-2 leading-snug">{n.titulo}</h3>
|
||||
{expanded !== n.id && <p className="text-sm text-[#888] mb-2">{n.preview}</p>}
|
||||
{expanded !== n.id && <span className="text-xs text-[#00c8ff] opacity-70">👆 Toque para ler</span>}
|
||||
</div>
|
||||
</div>
|
||||
{expanded === n.id && (
|
||||
<div className="px-5 pb-5 border-t border-white/10 rich-content" dangerouslySetInnerHTML={{ __html: n.conteudo }} />
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
|
||||
{/* Hype Tracker */}
|
||||
{hypes.length > 0 && (
|
||||
<section className="relative z-[1] py-10 border-t border-white/10" style={{ background: 'rgba(0,200,255,0.03)' }}>
|
||||
<div className="max-w-[800px] mx-auto px-5">
|
||||
<div className="text-center text-[#00c8ff] font-semibold text-sm mb-5">📊 HYPE TRACKER</div>
|
||||
<div className="bg-[#12121a] border border-white/10 rounded-2xl p-6">
|
||||
<h3 className="text-lg font-bold mb-4 text-[#00c8ff]">Tendências IA — Semana de 3-10 Fev 2026</h3>
|
||||
{hypes.map(h => (
|
||||
<div key={h.id} className="mb-3">
|
||||
<div className="flex justify-between text-sm mb-1">
|
||||
<span>{h.icone} <strong className="text-[#e0e0e0]">{h.nome}</strong></span>
|
||||
<span className="text-[#00c8ff]">{h.percentual}%</span>
|
||||
</div>
|
||||
<div className="w-full h-2 bg-white/5 rounded-full overflow-hidden">
|
||||
<div className="h-full bg-gradient-to-r from-[#00c8ff] to-[#0080ff] rounded-full transition-all" style={{ width: `${h.percentual}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Dica do Dia */}
|
||||
{dica && (
|
||||
<section className="relative z-[1] py-10 border-t border-white/10" style={{ background: 'rgba(0,200,255,0.03)' }}>
|
||||
<div className="max-w-[800px] mx-auto px-5">
|
||||
<div className="text-center text-[#00c8ff] font-semibold text-sm mb-5">🧠 DICA DO DIA</div>
|
||||
<div className="bg-[#12121a] border border-white/10 rounded-2xl p-6">
|
||||
<h3 className="text-lg font-bold mb-4 text-[#00c8ff]">{dica.titulo}</h3>
|
||||
<div className="rich-content" dangerouslySetInnerHTML={{ __html: dica.conteudo }} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="relative z-[1] py-10 text-center border-t border-white/10">
|
||||
<p className="mb-2">🧠 EK<span className="text-[#00c8ff]">[AI]</span></p>
|
||||
<p className="text-[#888] mb-2"><a href="https://aivertice.com" className="text-[#00c8ff]">AI Vertice</a></p>
|
||||
<p className="text-[#888]">© 2026 Eduardo Kislanski</p>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
36
frontend/src/pages/admin/Dashboard.jsx
Normal file
36
frontend/src/pages/admin/Dashboard.jsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { getNoticias, getInscritos, getHypesAll, getDicasAll } from '../../api';
|
||||
|
||||
export default function Dashboard() {
|
||||
const [stats, setStats] = useState({ noticias: 0, inscritos: 0, hypes: 0, dicas: 0 });
|
||||
|
||||
useEffect(() => {
|
||||
Promise.all([
|
||||
getNoticias(1, 1).then(r => r?.total || 0),
|
||||
getInscritos().then(r => Array.isArray(r) ? r.length : 0),
|
||||
getHypesAll().then(r => Array.isArray(r) ? r.length : 0),
|
||||
getDicasAll().then(r => Array.isArray(r) ? r.length : 0),
|
||||
]).then(([n, i, h, d]) => setStats({ noticias: n, inscritos: i, hypes: h, dicas: d }));
|
||||
}, []);
|
||||
|
||||
const cards = [
|
||||
{ label: '📰 Notícias', value: stats.noticias, color: '#00c8ff' },
|
||||
{ label: '📧 Inscritos', value: stats.inscritos, color: '#00ff88' },
|
||||
{ label: '🔥 Hypes', value: stats.hypes, color: '#ff6b35' },
|
||||
{ label: '💡 Dicas', value: stats.dicas, color: '#ffd700' },
|
||||
];
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold mb-6">Dashboard</h1>
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
|
||||
{cards.map(c => (
|
||||
<div key={c.label} className="bg-[#12121a] border border-white/10 rounded-xl p-6 text-center">
|
||||
<div className="text-3xl font-bold mb-2" style={{ color: c.color }}>{c.value}</div>
|
||||
<div className="text-sm text-[#888]">{c.label}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
51
frontend/src/pages/admin/Dicas.jsx
Normal file
51
frontend/src/pages/admin/Dicas.jsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { getDicasAll, createDica, updateDica, deleteDica } from '../../api';
|
||||
|
||||
export default function AdminDicas() {
|
||||
const [dicas, setDicas] = useState([]);
|
||||
const [form, setForm] = useState({ titulo: '', conteudo: '', data_publicacao: '', ativa: true });
|
||||
const [editing, setEditing] = useState(null);
|
||||
|
||||
const load = () => getDicasAll().then(r => setDicas(Array.isArray(r) ? r : []));
|
||||
useEffect(() => { load(); }, []);
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
if (editing) await updateDica(editing, form);
|
||||
else await createDica(form);
|
||||
setForm({ titulo: '', conteudo: '', data_publicacao: '', ativa: true });
|
||||
setEditing(null);
|
||||
load();
|
||||
};
|
||||
|
||||
const inputCls = "w-full px-4 py-3 bg-[#0a0a0f] border border-white/10 rounded-lg text-[#e0e0e0] focus:outline-none focus:border-[#00c8ff]";
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold mb-6">Dicas do Dia</h1>
|
||||
<form onSubmit={handleSubmit} className="space-y-3 mb-6 max-w-2xl">
|
||||
<input placeholder="Título" value={form.titulo} onChange={e => setForm(f => ({ ...f, titulo: e.target.value }))} className={inputCls} required />
|
||||
<textarea placeholder="Conteúdo (HTML)" value={form.conteudo} onChange={e => setForm(f => ({ ...f, conteudo: e.target.value }))} rows={5} className={inputCls} />
|
||||
<input type="date" value={form.data_publicacao} onChange={e => setForm(f => ({ ...f, data_publicacao: e.target.value }))} className={inputCls} />
|
||||
<div className="flex gap-3">
|
||||
<button type="submit" className="bg-[#00c8ff] text-[#0a0a0f] px-4 py-2 rounded-lg font-semibold">{editing ? 'Salvar' : 'Criar'}</button>
|
||||
{editing && <button type="button" onClick={() => { setEditing(null); setForm({ titulo: '', conteudo: '', data_publicacao: '', ativa: true }); }} className="text-[#888]">Cancelar</button>}
|
||||
</div>
|
||||
</form>
|
||||
<div className="space-y-3">
|
||||
{dicas.map(d => (
|
||||
<div key={d.id} className="bg-[#12121a] border border-white/10 rounded-xl p-4 flex justify-between items-center">
|
||||
<div>
|
||||
<h3 className="font-semibold">{d.titulo}</h3>
|
||||
<span className="text-xs text-[#888]">{d.data_publicacao}</span>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<button onClick={() => { setEditing(d.id); setForm(d); }} className="text-[#00c8ff] text-sm">Editar</button>
|
||||
<button onClick={async () => { if (confirm('Deletar?')) { await deleteDica(d.id); load(); } }} className="text-red-400 text-sm">Deletar</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
59
frontend/src/pages/admin/Hypes.jsx
Normal file
59
frontend/src/pages/admin/Hypes.jsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { getHypesAll, createHype, updateHype, deleteHype } from '../../api';
|
||||
|
||||
export default function AdminHypes() {
|
||||
const [hypes, setHypes] = useState([]);
|
||||
const [form, setForm] = useState({ nome: '', percentual: 50, icone: '🔥', ordem: 0, ativo: true });
|
||||
const [editing, setEditing] = useState(null);
|
||||
|
||||
const load = () => getHypesAll().then(r => setHypes(Array.isArray(r) ? r : []));
|
||||
useEffect(() => { load(); }, []);
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
if (editing) await updateHype(editing, form);
|
||||
else await createHype(form);
|
||||
setForm({ nome: '', percentual: 50, icone: '🔥', ordem: 0, ativo: true });
|
||||
setEditing(null);
|
||||
load();
|
||||
};
|
||||
|
||||
const edit = (h) => { setEditing(h.id); setForm(h); };
|
||||
const del = async (id) => { if (confirm('Deletar?')) { await deleteHype(id); load(); } };
|
||||
|
||||
const inputCls = "px-3 py-2 bg-[#0a0a0f] border border-white/10 rounded-lg text-[#e0e0e0] focus:outline-none focus:border-[#00c8ff]";
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold mb-6">Hype Tracker</h1>
|
||||
<form onSubmit={handleSubmit} className="flex flex-wrap gap-3 mb-6 items-end">
|
||||
<input placeholder="Nome" value={form.nome} onChange={e => setForm(f => ({ ...f, nome: e.target.value }))} className={inputCls + " flex-1"} required />
|
||||
<input placeholder="Ícone" value={form.icone} onChange={e => setForm(f => ({ ...f, icone: e.target.value }))} className={inputCls + " w-16"} />
|
||||
<div className="flex items-center gap-2">
|
||||
<input type="range" min="0" max="100" value={form.percentual} onChange={e => setForm(f => ({ ...f, percentual: +e.target.value }))} className="w-32" />
|
||||
<span className="text-[#00c8ff] font-bold w-12">{form.percentual}%</span>
|
||||
</div>
|
||||
<input type="number" placeholder="Ordem" value={form.ordem} onChange={e => setForm(f => ({ ...f, ordem: +e.target.value }))} className={inputCls + " w-20"} />
|
||||
<button type="submit" className="bg-[#00c8ff] text-[#0a0a0f] px-4 py-2 rounded-lg font-semibold">{editing ? 'Salvar' : 'Criar'}</button>
|
||||
{editing && <button type="button" onClick={() => { setEditing(null); setForm({ nome: '', percentual: 50, icone: '🔥', ordem: 0, ativo: true }); }} className="text-[#888] text-sm">Cancelar</button>}
|
||||
</form>
|
||||
<div className="space-y-3">
|
||||
{hypes.map(h => (
|
||||
<div key={h.id} className="bg-[#12121a] border border-white/10 rounded-xl p-4 flex justify-between items-center">
|
||||
<div className="flex items-center gap-3 flex-1">
|
||||
<span className="text-xl">{h.icone}</span>
|
||||
<span className="font-semibold">{h.nome}</span>
|
||||
<div className="flex-1 mx-4 h-2 bg-white/5 rounded-full overflow-hidden"><div className="h-full bg-[#00c8ff] rounded-full" style={{ width: `${h.percentual}%` }} /></div>
|
||||
<span className="text-[#00c8ff] font-bold">{h.percentual}%</span>
|
||||
<span className={`text-xs px-2 py-0.5 rounded ${h.ativo ? 'bg-green-500/20 text-green-400' : 'bg-red-500/20 text-red-400'}`}>{h.ativo ? 'Ativo' : 'Inativo'}</span>
|
||||
</div>
|
||||
<div className="flex gap-2 ml-4">
|
||||
<button onClick={() => edit(h)} className="text-[#00c8ff] text-sm hover:underline">Editar</button>
|
||||
<button onClick={() => del(h.id)} className="text-red-400 text-sm hover:underline">Deletar</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
35
frontend/src/pages/admin/Inscritos.jsx
Normal file
35
frontend/src/pages/admin/Inscritos.jsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { getInscritos, deleteInscrito } from '../../api';
|
||||
|
||||
export default function AdminInscritos() {
|
||||
const [inscritos, setInscritos] = useState([]);
|
||||
|
||||
const load = () => getInscritos().then(r => setInscritos(Array.isArray(r) ? r : []));
|
||||
useEffect(() => { load(); }, []);
|
||||
|
||||
const exportCSV = () => {
|
||||
const csv = 'email,ativo,data\n' + inscritos.map(i => `${i.email},${i.ativo},${i.created_at}`).join('\n');
|
||||
const blob = new Blob([csv], { type: 'text/csv' });
|
||||
const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'inscritos.csv'; a.click();
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex justify-between items-center mb-6">
|
||||
<h1 className="text-2xl font-bold">Inscritos ({inscritos.length})</h1>
|
||||
<button onClick={exportCSV} className="bg-[#00c8ff] text-[#0a0a0f] px-4 py-2 rounded-lg font-semibold text-sm">📥 Exportar CSV</button>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
{inscritos.map(i => (
|
||||
<div key={i.id} className="bg-[#12121a] border border-white/10 rounded-xl p-4 flex justify-between items-center">
|
||||
<div>
|
||||
<span className="font-semibold">{i.email}</span>
|
||||
<span className="text-xs text-[#888] ml-3">{new Date(i.created_at).toLocaleDateString('pt-BR')}</span>
|
||||
</div>
|
||||
<button onClick={async () => { if (confirm('Remover?')) { await deleteInscrito(i.id); load(); } }} className="text-red-400 text-sm">Remover</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
27
frontend/src/pages/admin/Login.jsx
Normal file
27
frontend/src/pages/admin/Login.jsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { login } from '../../api';
|
||||
|
||||
export default function AdminLogin() {
|
||||
const [email, setEmail] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
try { await login(email, password); navigate('/admin'); } catch { setError('Credenciais inválidas'); }
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-[#0a0a0f] flex items-center justify-center">
|
||||
<form onSubmit={handleSubmit} className="bg-[#12121a] border border-white/10 rounded-2xl p-8 w-full max-w-sm">
|
||||
<h1 className="text-2xl font-bold text-center mb-6">🧠 EK<span className="text-[#00c8ff]">[AI]</span> Admin</h1>
|
||||
{error && <p className="text-red-400 text-sm mb-4 text-center">{error}</p>}
|
||||
<input type="email" placeholder="Email" value={email} onChange={e => setEmail(e.target.value)} className="w-full mb-4 px-4 py-3 bg-[#0a0a0f] border border-white/10 rounded-lg text-[#e0e0e0] focus:outline-none focus:border-[#00c8ff]" />
|
||||
<input type="password" placeholder="Senha" value={password} onChange={e => setPassword(e.target.value)} className="w-full mb-6 px-4 py-3 bg-[#0a0a0f] border border-white/10 rounded-lg text-[#e0e0e0] focus:outline-none focus:border-[#00c8ff]" />
|
||||
<button type="submit" className="w-full bg-[#00c8ff] text-[#0a0a0f] py-3 rounded-lg font-semibold hover:opacity-90 transition">Entrar</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
54
frontend/src/pages/admin/NoticiaForm.jsx
Normal file
54
frontend/src/pages/admin/NoticiaForm.jsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useParams, useNavigate } from 'react-router-dom';
|
||||
import { getNoticia, createNoticia, updateNoticia } from '../../api';
|
||||
|
||||
export default function NoticiaForm() {
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const [form, setForm] = useState({ titulo: '', preview: '', conteudo: '', imagem_url: '', data_publicacao: '', categoria: 'normal', fonte: '', link_fonte: '' });
|
||||
|
||||
useEffect(() => {
|
||||
if (id) getNoticia(id).then(r => r && setForm(r));
|
||||
}, [id]);
|
||||
|
||||
const set = (k, v) => setForm(f => ({ ...f, [k]: v }));
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
if (id) await updateNoticia(id, form);
|
||||
else await createNoticia(form);
|
||||
navigate('/admin/noticias');
|
||||
};
|
||||
|
||||
const inputCls = "w-full px-4 py-3 bg-[#0a0a0f] border border-white/10 rounded-lg text-[#e0e0e0] focus:outline-none focus:border-[#00c8ff]";
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold mb-6">{id ? 'Editar' : 'Nova'} Notícia</h1>
|
||||
<form onSubmit={handleSubmit} className="space-y-4 max-w-2xl">
|
||||
<input placeholder="Título" value={form.titulo} onChange={e => set('titulo', e.target.value)} className={inputCls} required />
|
||||
<input placeholder="Preview" value={form.preview} onChange={e => set('preview', e.target.value)} className={inputCls} />
|
||||
<input placeholder="URL da imagem" value={form.imagem_url} onChange={e => set('imagem_url', e.target.value)} className={inputCls} />
|
||||
<div className="flex gap-4">
|
||||
<input type="date" value={form.data_publicacao} onChange={e => set('data_publicacao', e.target.value)} className={inputCls} />
|
||||
<select value={form.categoria} onChange={e => set('categoria', e.target.value)} className={inputCls}>
|
||||
<option value="normal">Normal</option>
|
||||
<option value="destaque">Destaque</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="flex gap-4">
|
||||
<input placeholder="Fonte" value={form.fonte || ''} onChange={e => set('fonte', e.target.value)} className={inputCls} />
|
||||
<input placeholder="Link fonte" value={form.link_fonte || ''} onChange={e => set('link_fonte', e.target.value)} className={inputCls} />
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-sm text-[#888] mb-1 block">Conteúdo (HTML)</label>
|
||||
<textarea value={form.conteudo} onChange={e => set('conteudo', e.target.value)} rows={12} className={inputCls + " font-mono text-sm"} />
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<button type="submit" className="bg-[#00c8ff] text-[#0a0a0f] px-6 py-3 rounded-lg font-semibold">Salvar</button>
|
||||
<button type="button" onClick={() => navigate('/admin/noticias')} className="bg-[#12121a] border border-white/10 px-6 py-3 rounded-lg text-[#888]">Cancelar</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
51
frontend/src/pages/admin/Noticias.jsx
Normal file
51
frontend/src/pages/admin/Noticias.jsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { getNoticias, deleteNoticia } from '../../api';
|
||||
|
||||
export default function AdminNoticias() {
|
||||
const [noticias, setNoticias] = useState([]);
|
||||
const [page, setPage] = useState(1);
|
||||
const [pages, setPages] = useState(1);
|
||||
|
||||
const load = () => getNoticias(page, 20).then(r => { setNoticias(r.data || []); setPages(r.pages || 1); });
|
||||
useEffect(() => { load(); }, [page]);
|
||||
|
||||
const handleDelete = async (id) => {
|
||||
if (!confirm('Deletar?')) return;
|
||||
await deleteNoticia(id);
|
||||
load();
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex justify-between items-center mb-6">
|
||||
<h1 className="text-2xl font-bold">Notícias</h1>
|
||||
<Link to="/admin/noticias/new" className="bg-[#00c8ff] text-[#0a0a0f] px-4 py-2 rounded-lg font-semibold text-sm">+ Nova</Link>
|
||||
</div>
|
||||
<div className="space-y-3">
|
||||
{noticias.map(n => (
|
||||
<div key={n.id} className="bg-[#12121a] border border-white/10 rounded-xl p-4 flex justify-between items-center">
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
{n.categoria === 'destaque' && <span className="text-xs bg-[#00c8ff] text-[#0a0a0f] px-2 py-0.5 rounded font-bold">Destaque</span>}
|
||||
<span className="text-xs text-[#888]">{n.data_publicacao}</span>
|
||||
</div>
|
||||
<h3 className="font-semibold">{n.titulo}</h3>
|
||||
</div>
|
||||
<div className="flex gap-2 ml-4">
|
||||
<Link to={`/admin/noticias/${n.id}`} className="text-[#00c8ff] text-sm hover:underline">Editar</Link>
|
||||
<button onClick={() => handleDelete(n.id)} className="text-red-400 text-sm hover:underline">Deletar</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{pages > 1 && (
|
||||
<div className="flex gap-2 mt-4 justify-center">
|
||||
{Array.from({ length: pages }, (_, i) => (
|
||||
<button key={i} onClick={() => setPage(i + 1)} className={`px-3 py-1 rounded ${page === i + 1 ? 'bg-[#00c8ff] text-[#0a0a0f]' : 'bg-[#12121a] text-[#888]'}`}>{i + 1}</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
12
frontend/vite.config.js
Normal file
12
frontend/vite.config.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': 'http://localhost:8103'
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user