First commit
This commit is contained in:
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/versions
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env*
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
36
README.md
Normal file
36
README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
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).
|
||||
|
||||
## 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/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
|
||||
## 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/app/building-your-application/deploying) for more details.
|
||||
18
eslint.config.mjs
Normal file
18
eslint.config.mjs
Normal file
@@ -0,0 +1,18 @@
|
||||
import { defineConfig, globalIgnores } from "eslint/config";
|
||||
import nextVitals from "eslint-config-next/core-web-vitals";
|
||||
import nextTs from "eslint-config-next/typescript";
|
||||
|
||||
const eslintConfig = defineConfig([
|
||||
...nextVitals,
|
||||
...nextTs,
|
||||
// Override default ignores of eslint-config-next.
|
||||
globalIgnores([
|
||||
// Default ignores of eslint-config-next:
|
||||
".next/**",
|
||||
"out/**",
|
||||
"build/**",
|
||||
"next-env.d.ts",
|
||||
]),
|
||||
]);
|
||||
|
||||
export default eslintConfig;
|
||||
7
next.config.ts
Normal file
7
next.config.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
6107
package-lock.json
generated
Normal file
6107
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
26
package.json
Normal file
26
package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "auto-app",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "eslint"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "16.2.4",
|
||||
"pg": "^8.20.0",
|
||||
"react": "19.2.4",
|
||||
"react-dom": "19.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20",
|
||||
"@types/pg": "^8.20.0",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"eslint": "^9",
|
||||
"eslint-config-next": "16.2.4",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
1
public/file.svg
Normal file
1
public/file.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
||||
|
After Width: | Height: | Size: 391 B |
1
public/globe.svg
Normal file
1
public/globe.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
1
public/next.svg
Normal file
1
public/next.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
1
public/vercel.svg
Normal file
1
public/vercel.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
||||
|
After Width: | Height: | Size: 128 B |
1
public/window.svg
Normal file
1
public/window.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
||||
|
After Width: | Height: | Size: 385 B |
79
src/app/actions.ts
Normal file
79
src/app/actions.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
"use server";
|
||||
|
||||
import pool from "@/lib/db";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export async function createOS(formData: FormData) {
|
||||
const observacao = formData.get("observacao") as string;
|
||||
const previsao = formData.get("previsao") as string;
|
||||
|
||||
try {
|
||||
// Pegar o próximo numero_os
|
||||
const maxRes = await pool.query(`SELECT MAX(numero_os) as max_num FROM public.os`);
|
||||
let nextNumero = 1;
|
||||
if (maxRes.rows[0].max_num) {
|
||||
nextNumero = parseInt(maxRes.rows[0].max_num, 10) + 1;
|
||||
}
|
||||
|
||||
await pool.query(
|
||||
`INSERT INTO public.os
|
||||
(numero_os, data_abertura, observacao, previsao, fechada, created_at)
|
||||
VALUES
|
||||
($1, NOW(), $2, $3, false, NOW())`,
|
||||
[
|
||||
nextNumero,
|
||||
observacao || null,
|
||||
previsao ? new Date(previsao) : null
|
||||
]
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Erro ao criar OS:", error);
|
||||
throw new Error("Falha ao criar ordem de serviço");
|
||||
}
|
||||
|
||||
revalidatePath("/dashboard");
|
||||
revalidatePath("/tv");
|
||||
redirect("/dashboard");
|
||||
}
|
||||
|
||||
export async function validateAndSaveLicense(license: string) {
|
||||
const hash = process.env.LICENSE_HASH || "c7d2fdc0bafc21b291e11c132c08a446";
|
||||
|
||||
try {
|
||||
const response = await fetch("https://licencas.css-sistemas.com/consultalicenca", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ licenca: license, hash: hash }),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.ok && data.status === 1) {
|
||||
// Salvar no .env
|
||||
const envPath = path.join(process.cwd(), ".env");
|
||||
let envContent = fs.readFileSync(envPath, "utf-8");
|
||||
|
||||
if (envContent.includes("LICENSE_NUMBER=")) {
|
||||
envContent = envContent.replace(/LICENSE_NUMBER=.*/, `LICENSE_NUMBER=${license}`);
|
||||
} else {
|
||||
envContent += `\nLICENSE_NUMBER=${license}`;
|
||||
}
|
||||
|
||||
fs.writeFileSync(envPath, envContent);
|
||||
return { success: true };
|
||||
} else {
|
||||
return { success: false, message: "Licença inválida ou inativa." };
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Erro na validação da licença:", error);
|
||||
return { success: false, message: "Erro ao conectar com o servidor de licenças." };
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAppLicense() {
|
||||
return process.env.LICENSE_NUMBER || null;
|
||||
}
|
||||
62
src/app/dashboard/layout.tsx
Normal file
62
src/app/dashboard/layout.tsx
Normal file
@@ -0,0 +1,62 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
export default function DashboardLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<div className="dashboard-layout">
|
||||
<aside className="sidebar">
|
||||
<div className="sidebar-logo">AutoAPP</div>
|
||||
<nav style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
|
||||
<Link
|
||||
href="/dashboard"
|
||||
className={`nav-item ${pathname === '/dashboard' || pathname === '/dashboard/nova-os' ? 'active' : ''}`}
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<rect x="3" y="3" width="7" height="9"></rect>
|
||||
<rect x="14" y="3" width="7" height="5"></rect>
|
||||
<rect x="14" y="12" width="7" height="9"></rect>
|
||||
<rect x="3" y="16" width="7" height="5"></rect>
|
||||
</svg>
|
||||
Ordens de Serviço
|
||||
</Link>
|
||||
<Link
|
||||
href="/tv"
|
||||
target="_blank"
|
||||
className="nav-item"
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<rect x="2" y="7" width="20" height="15" rx="2" ry="2"></rect>
|
||||
<polyline points="17 2 12 7 7 2"></polyline>
|
||||
</svg>
|
||||
Painel de TV
|
||||
</Link>
|
||||
<div style={{ flex: 1 }}></div>
|
||||
<Link
|
||||
href="/login"
|
||||
className="nav-item"
|
||||
style={{ color: 'var(--accent-danger)' }}
|
||||
onClick={() => localStorage.removeItem("autoapp_auth")}
|
||||
>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path>
|
||||
<polyline points="16 17 21 12 16 7"></polyline>
|
||||
<line x1="21" y1="12" x2="9" y2="12"></line>
|
||||
</svg>
|
||||
Sair
|
||||
</Link>
|
||||
</nav>
|
||||
</aside>
|
||||
<main className="main-content">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
187
src/app/dashboard/nova-os/page.tsx
Normal file
187
src/app/dashboard/nova-os/page.tsx
Normal file
@@ -0,0 +1,187 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useState } from "react";
|
||||
import { createOS } from "@/app/actions";
|
||||
|
||||
export default function NovaOSPage() {
|
||||
const [file1, setFile1] = useState<File | null>(null);
|
||||
const [file2, setFile2] = useState<File | null>(null);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.currentTarget);
|
||||
|
||||
console.log("=== ENVIANDO NOVA OS ===");
|
||||
console.log("Observação:", formData.get("observacao"));
|
||||
console.log("Previsão:", formData.get("previsao"));
|
||||
console.log("Imagem 1:", formData.get("imagem1"));
|
||||
console.log("Imagem 2:", formData.get("imagem2"));
|
||||
console.log("========================");
|
||||
|
||||
// Chama a server action para salvar no banco de dados
|
||||
await createOS(formData);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="animate-fade-in">
|
||||
<div className="page-header" style={{ marginBottom: '1.5rem' }}>
|
||||
<div>
|
||||
<Link href="/dashboard" style={{ display: 'inline-flex', alignItems: 'center', gap: '0.5rem', color: 'var(--text-muted)', marginBottom: '0.5rem', fontSize: '0.875rem' }}>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<line x1="19" y1="12" x2="5" y2="12"></line>
|
||||
<polyline points="12 19 5 12 12 5"></polyline>
|
||||
</svg>
|
||||
Voltar
|
||||
</Link>
|
||||
<h2>Nova Ordem de Serviço</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="glass-panel" style={{ padding: '2rem', maxWidth: '600px' }}>
|
||||
<form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: '2rem' }}>
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
|
||||
<label htmlFor="observacao" style={{ fontSize: '0.875rem', fontWeight: 500, color: 'var(--text-secondary)' }}>
|
||||
Observações / Problema Relatado
|
||||
</label>
|
||||
<textarea
|
||||
id="observacao"
|
||||
name="observacao"
|
||||
rows={4}
|
||||
placeholder="Descreva o problema do veículo ou os serviços solicitados..."
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
|
||||
<label htmlFor="previsao" style={{ fontSize: '0.875rem', fontWeight: 500, color: 'var(--text-secondary)' }}>
|
||||
Previsão de Entrega
|
||||
</label>
|
||||
<input
|
||||
type="datetime-local"
|
||||
id="previsao"
|
||||
name="previsao"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))', gap: '1.5rem' }}>
|
||||
{/* Input Imagem 1 */}
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
|
||||
<label style={{ fontSize: '0.875rem', fontWeight: 500, color: 'var(--text-secondary)' }}>
|
||||
Imagem 1
|
||||
</label>
|
||||
<div style={{
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
border: `${file1 ? '2px dashed var(--accent-primary)' : '2px dashed var(--border-color)'}`,
|
||||
backgroundColor: file1 ? 'rgba(59, 130, 246, 0.05)' : 'var(--bg-tertiary)',
|
||||
borderRadius: 'var(--radius-lg)',
|
||||
padding: '2rem 1rem',
|
||||
cursor: 'pointer',
|
||||
transition: 'all var(--transition-fast)',
|
||||
textAlign: 'center'
|
||||
}}>
|
||||
<input
|
||||
type="file"
|
||||
id="imagem1"
|
||||
name="imagem1"
|
||||
accept="image/*"
|
||||
onChange={(e) => setFile1(e.target.files?.[0] || null)}
|
||||
style={{ opacity: 0, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', cursor: 'pointer', zIndex: 10 }}
|
||||
/>
|
||||
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke={file1 ? "var(--accent-primary)" : "var(--text-muted)"} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ marginBottom: '1rem' }}>
|
||||
{file1 ? (
|
||||
<>
|
||||
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
|
||||
<polyline points="22 4 12 14.01 9 11.01"></polyline>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
||||
<circle cx="8.5" cy="8.5" r="1.5"></circle>
|
||||
<polyline points="21 15 16 10 5 21"></polyline>
|
||||
</>
|
||||
)}
|
||||
</svg>
|
||||
<div style={{ color: file1 ? 'var(--text-primary)' : 'var(--text-secondary)', fontWeight: 500, fontSize: '0.875rem', wordBreak: 'break-all' }}>
|
||||
{file1 ? file1.name : "Clique para selecionar a imagem"}
|
||||
</div>
|
||||
{!file1 && (
|
||||
<div style={{ fontSize: '0.75rem', color: 'var(--text-muted)', marginTop: '0.5rem' }}>
|
||||
Formatos: JPG, PNG, GIF
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Input Imagem 2 */}
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
|
||||
<label style={{ fontSize: '0.875rem', fontWeight: 500, color: 'var(--text-secondary)' }}>
|
||||
Imagem 2
|
||||
</label>
|
||||
<div style={{
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
border: `${file2 ? '2px dashed var(--accent-primary)' : '2px dashed var(--border-color)'}`,
|
||||
backgroundColor: file2 ? 'rgba(59, 130, 246, 0.05)' : 'var(--bg-tertiary)',
|
||||
borderRadius: 'var(--radius-lg)',
|
||||
padding: '2rem 1rem',
|
||||
cursor: 'pointer',
|
||||
transition: 'all var(--transition-fast)',
|
||||
textAlign: 'center'
|
||||
}}>
|
||||
<input
|
||||
type="file"
|
||||
id="imagem2"
|
||||
name="imagem2"
|
||||
accept="image/*"
|
||||
onChange={(e) => setFile2(e.target.files?.[0] || null)}
|
||||
style={{ opacity: 0, position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', cursor: 'pointer', zIndex: 10 }}
|
||||
/>
|
||||
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke={file2 ? "var(--accent-primary)" : "var(--text-muted)"} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ marginBottom: '1rem' }}>
|
||||
{file2 ? (
|
||||
<>
|
||||
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
|
||||
<polyline points="22 4 12 14.01 9 11.01"></polyline>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
||||
<circle cx="8.5" cy="8.5" r="1.5"></circle>
|
||||
<polyline points="21 15 16 10 5 21"></polyline>
|
||||
</>
|
||||
)}
|
||||
</svg>
|
||||
<div style={{ color: file2 ? 'var(--text-primary)' : 'var(--text-secondary)', fontWeight: 500, fontSize: '0.875rem', wordBreak: 'break-all' }}>
|
||||
{file2 ? file2.name : "Clique para selecionar a imagem"}
|
||||
</div>
|
||||
{!file2 && (
|
||||
<div style={{ fontSize: '0.75rem', color: 'var(--text-muted)', marginTop: '0.5rem' }}>
|
||||
Formatos: JPG, PNG, GIF
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '1rem', borderTop: '1px solid var(--border-color)', paddingTop: '1.5rem' }}>
|
||||
<button type="submit" className="btn-primary" onClick={() => console.log('Botão clicado!')}>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ marginRight: '0.5rem' }}>
|
||||
<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"></path>
|
||||
<polyline points="17 21 17 13 7 13 7 21"></polyline>
|
||||
<polyline points="7 3 7 8 15 8"></polyline>
|
||||
</svg>
|
||||
Salvar OS
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
99
src/app/dashboard/page.tsx
Normal file
99
src/app/dashboard/page.tsx
Normal file
@@ -0,0 +1,99 @@
|
||||
import Link from "next/link";
|
||||
import pool from "@/lib/db";
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
async function getOpenServiceOrders() {
|
||||
try {
|
||||
const res = await pool.query(`
|
||||
SELECT
|
||||
o.id,
|
||||
o.numero_os,
|
||||
o.data_abertura,
|
||||
o.fechada,
|
||||
s.status,
|
||||
o.totalproduto,
|
||||
o.totalservico
|
||||
FROM public.os o
|
||||
LEFT JOIN public.os_status s ON o.id_status = s.id
|
||||
WHERE o.fechada = false
|
||||
ORDER BY o.data_abertura DESC
|
||||
LIMIT 100
|
||||
`);
|
||||
return res.rows;
|
||||
} catch (error) {
|
||||
console.error("Database Error:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export default async function DashboardPage() {
|
||||
const orders = await getOpenServiceOrders();
|
||||
|
||||
return (
|
||||
<div className="animate-fade-in">
|
||||
<div className="page-header">
|
||||
<div>
|
||||
<h2>Ordens de Serviço</h2>
|
||||
<p style={{ color: 'var(--text-muted)' }}>Gerencie as ordens de serviço abertas no sistema</p>
|
||||
</div>
|
||||
<Link href="/dashboard/nova-os" className="btn-primary">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ marginRight: '0.5rem' }}>
|
||||
<line x1="12" y1="5" x2="12" y2="19"></line>
|
||||
<line x1="5" y1="12" x2="19" y2="12"></line>
|
||||
</svg>
|
||||
Nova OS
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="glass-panel" style={{ padding: '1rem', overflowX: 'auto' }}>
|
||||
{orders.length === 0 ? (
|
||||
<div style={{ textAlign: 'center', padding: '3rem 1rem', color: 'var(--text-muted)' }}>
|
||||
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" style={{ margin: '0 auto 1rem', opacity: 0.5 }}>
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
||||
<polyline points="14 2 14 8 20 8"></polyline>
|
||||
<line x1="16" y1="13" x2="8" y2="13"></line>
|
||||
<line x1="16" y1="17" x2="8" y2="17"></line>
|
||||
<polyline points="10 9 9 9 8 9"></polyline>
|
||||
</svg>
|
||||
<p>Nenhuma ordem de serviço aberta encontrada.</p>
|
||||
<p style={{ fontSize: '0.875rem', marginTop: '0.5rem' }}>Clique em "Nova OS" para criar uma.</p>
|
||||
</div>
|
||||
) : (
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse', textAlign: 'left' }}>
|
||||
<thead>
|
||||
<tr style={{ borderBottom: '1px solid var(--border-color)', color: 'var(--text-secondary)' }}>
|
||||
<th style={{ padding: '1rem', fontWeight: 500 }}>Nº OS</th>
|
||||
<th style={{ padding: '1rem', fontWeight: 500 }}>Data Abertura</th>
|
||||
<th style={{ padding: '1rem', fontWeight: 500 }}>Status</th>
|
||||
<th style={{ padding: '1rem', fontWeight: 500 }}>Total (R$)</th>
|
||||
<th style={{ padding: '1rem', fontWeight: 500 }}>Ação</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{orders.map((order) => (
|
||||
<tr key={order.id} style={{ borderBottom: '1px solid var(--border-color)' }}>
|
||||
<td style={{ padding: '1rem', fontWeight: 600, color: 'var(--text-primary)' }}>#{order.numero_os}</td>
|
||||
<td style={{ padding: '1rem', color: 'var(--text-secondary)' }}>
|
||||
{order.data_abertura ? new Date(order.data_abertura).toLocaleDateString('pt-BR') : '-'}
|
||||
</td>
|
||||
<td style={{ padding: '1rem' }}>
|
||||
<span className="status-badge status-open">
|
||||
{order.status || 'Aberta'}
|
||||
</span>
|
||||
</td>
|
||||
<td style={{ padding: '1rem', color: 'var(--text-secondary)' }}>
|
||||
{((parseFloat(order.totalproduto || '0') + parseFloat(order.totalservico || '0'))).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' })}
|
||||
</td>
|
||||
<td style={{ padding: '1rem' }}>
|
||||
<button style={{ color: 'var(--accent-primary)', fontSize: '0.875rem', fontWeight: 500 }}>Ver Detalhes</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
BIN
src/app/favicon.ico
Normal file
BIN
src/app/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
277
src/app/globals.css
Normal file
277
src/app/globals.css
Normal file
@@ -0,0 +1,277 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;800&display=swap');
|
||||
|
||||
:root {
|
||||
/* Color Palette - Premium Dark Theme */
|
||||
--bg-primary: #0f172a;
|
||||
--bg-secondary: #1e293b;
|
||||
--bg-tertiary: #334155;
|
||||
--bg-glass: rgba(30, 41, 59, 0.7);
|
||||
|
||||
--text-primary: #f8fafc;
|
||||
--text-secondary: #cbd5e1;
|
||||
--text-muted: #94a3b8;
|
||||
|
||||
--accent-primary: #3b82f6;
|
||||
--accent-hover: #2563eb;
|
||||
--accent-success: #10b981;
|
||||
--accent-warning: #f59e0b;
|
||||
--accent-danger: #ef4444;
|
||||
|
||||
--border-color: rgba(255, 255, 255, 0.1);
|
||||
--border-focus: rgba(59, 130, 246, 0.5);
|
||||
|
||||
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
||||
--shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
--shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
|
||||
--shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
|
||||
|
||||
--radius-sm: 0.25rem;
|
||||
--radius-md: 0.5rem;
|
||||
--radius-lg: 0.75rem;
|
||||
--radius-xl: 1rem;
|
||||
--radius-full: 9999px;
|
||||
|
||||
--transition-fast: 150ms ease;
|
||||
--transition-normal: 300ms ease;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Outfit', sans-serif;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--accent-primary);
|
||||
text-decoration: none;
|
||||
transition: color var(--transition-fast);
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: var(--accent-hover);
|
||||
}
|
||||
|
||||
button {
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
input, textarea, select {
|
||||
font-family: inherit;
|
||||
background-color: var(--bg-primary);
|
||||
border: 1px solid var(--border-color);
|
||||
color: var(--text-primary);
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: var(--radius-md);
|
||||
outline: none;
|
||||
transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
input:focus, textarea:focus, select:focus {
|
||||
border-color: var(--accent-primary);
|
||||
box-shadow: 0 0 0 3px var(--border-focus);
|
||||
}
|
||||
|
||||
/* Utilities */
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 0 1.5rem;
|
||||
}
|
||||
|
||||
.glass-panel {
|
||||
background: var(--bg-glass);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-glass);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--accent-primary);
|
||||
color: white;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: var(--radius-md);
|
||||
font-weight: 500;
|
||||
transition: background-color var(--transition-fast), transform var(--transition-fast);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: var(--accent-hover);
|
||||
color: white;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.btn-primary:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: var(--radius-full);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.status-open {
|
||||
background-color: rgba(59, 130, 246, 0.1);
|
||||
color: var(--accent-primary);
|
||||
border: 1px solid rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
|
||||
.status-closed {
|
||||
background-color: rgba(16, 185, 129, 0.1);
|
||||
color: var(--accent-success);
|
||||
border: 1px solid rgba(16, 185, 129, 0.2);
|
||||
}
|
||||
|
||||
/* Layouts */
|
||||
.dashboard-layout {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 260px;
|
||||
background-color: var(--bg-secondary);
|
||||
border-right: 1px solid var(--border-color);
|
||||
padding: 2rem 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
font-family: 'Outfit', sans-serif;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 800;
|
||||
color: var(--accent-primary);
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: var(--radius-md);
|
||||
color: var(--text-secondary);
|
||||
transition: background-color var(--transition-fast), color var(--transition-fast);
|
||||
}
|
||||
|
||||
.nav-item:hover, .nav-item.active {
|
||||
background-color: var(--bg-tertiary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
flex: 1;
|
||||
padding: 2rem;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* Animations */
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(10px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.animate-fade-in {
|
||||
animation: fadeIn 0.4s ease forwards;
|
||||
}
|
||||
|
||||
/* Responsividade (Mobile) */
|
||||
@media (max-width: 768px) {
|
||||
.dashboard-layout {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
padding: 1rem;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 50;
|
||||
background-color: rgba(30, 41, 59, 0.95);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
margin-bottom: 1rem;
|
||||
text-align: left;
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.sidebar nav {
|
||||
flex-direction: row !important;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
white-space: nowrap;
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.page-header .btn-primary {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.login-panel {
|
||||
padding: 2rem 1.5rem;
|
||||
}
|
||||
|
||||
.tv-header h1 {
|
||||
font-size: 2rem !important;
|
||||
}
|
||||
|
||||
.tv-header h2 {
|
||||
font-size: 1.5rem !important;
|
||||
}
|
||||
|
||||
.tv-header div {
|
||||
font-size: 1rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
19
src/app/layout.tsx
Normal file
19
src/app/layout.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { Metadata } from "next";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "AutoAPP | Gestão de OS",
|
||||
description: "Sistema premium de gestão de Ordens de Serviço para oficina mecânica.",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="pt-BR">
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
68
src/app/login/login.css
Normal file
68
src/app/login/login.css
Normal file
@@ -0,0 +1,68 @@
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: radial-gradient(circle at center, var(--bg-secondary) 0%, var(--bg-primary) 100%);
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.login-panel {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
padding: 3rem 2rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.login-header {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.login-header h1 {
|
||||
color: var(--accent-primary);
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
.login-header p {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.login-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 1rem;
|
||||
width: 100%;
|
||||
font-size: 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.login-error {
|
||||
background-color: rgba(239, 68, 68, 0.1);
|
||||
color: var(--accent-danger);
|
||||
padding: 0.75rem;
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid rgba(239, 68, 68, 0.2);
|
||||
font-size: 0.875rem;
|
||||
text-align: center;
|
||||
}
|
||||
81
src/app/login/page.tsx
Normal file
81
src/app/login/page.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { validateAndSaveLicense, getAppLicense } from "../actions";
|
||||
import "./login.css";
|
||||
|
||||
export default function LoginPage() {
|
||||
const [license, setLicense] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const checkAuth = async () => {
|
||||
const auth = localStorage.getItem("autoapp_auth");
|
||||
const savedLicense = await getAppLicense();
|
||||
|
||||
if (savedLicense) {
|
||||
setLicense(savedLicense);
|
||||
// Se já tem licença e não foi explicitamente deslogado
|
||||
if (auth === "true") {
|
||||
router.push("/dashboard");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
checkAuth();
|
||||
}, [router]);
|
||||
|
||||
const handleLogin = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setLoading(true);
|
||||
setError("");
|
||||
|
||||
try {
|
||||
const result = await validateAndSaveLicense(license);
|
||||
if (result.success) {
|
||||
localStorage.setItem("autoapp_auth", "true");
|
||||
router.push("/dashboard");
|
||||
} else {
|
||||
setError(result.message || "Licença inválida.");
|
||||
}
|
||||
} catch (err) {
|
||||
setError("Ocorreu um erro ao validar a licença.");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="login-container">
|
||||
<div className="glass-panel login-panel animate-fade-in">
|
||||
<div className="login-header">
|
||||
<h1>AutoAPP</h1>
|
||||
<p>Ative sua licença para acessar o sistema</p>
|
||||
</div>
|
||||
|
||||
{error && <div className="login-error">{error}</div>}
|
||||
|
||||
<form onSubmit={handleLogin} className="login-form">
|
||||
<div className="form-group">
|
||||
<label htmlFor="license">Número da Licença</label>
|
||||
<input
|
||||
id="license"
|
||||
type="text"
|
||||
value={license}
|
||||
onChange={(e) => setLicense(e.target.value)}
|
||||
placeholder="Ex: 082663932"
|
||||
required
|
||||
disabled={loading}
|
||||
/>
|
||||
</div>
|
||||
<button type="submit" className="btn-primary login-btn" disabled={loading}>
|
||||
{loading ? "Validando..." : "Entrar"}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
142
src/app/page.module.css
Normal file
142
src/app/page.module.css
Normal file
@@ -0,0 +1,142 @@
|
||||
.page {
|
||||
--background: #fafafa;
|
||||
--foreground: #fff;
|
||||
|
||||
--text-primary: #000;
|
||||
--text-secondary: #666;
|
||||
|
||||
--button-primary-hover: #383838;
|
||||
--button-secondary-hover: #f2f2f2;
|
||||
--button-secondary-border: #ebebeb;
|
||||
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: var(--font-geist-sans);
|
||||
background-color: var(--background);
|
||||
}
|
||||
|
||||
.main {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
background-color: var(--foreground);
|
||||
padding: 120px 60px;
|
||||
}
|
||||
|
||||
.intro {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.intro h1 {
|
||||
max-width: 320px;
|
||||
font-size: 40px;
|
||||
font-weight: 600;
|
||||
line-height: 48px;
|
||||
letter-spacing: -2.4px;
|
||||
text-wrap: balance;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.intro p {
|
||||
max-width: 440px;
|
||||
font-size: 18px;
|
||||
line-height: 32px;
|
||||
text-wrap: balance;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.intro a {
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.ctas {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
max-width: 440px;
|
||||
gap: 16px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ctas a {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 40px;
|
||||
padding: 0 16px;
|
||||
border-radius: 128px;
|
||||
border: 1px solid transparent;
|
||||
transition: 0.2s;
|
||||
cursor: pointer;
|
||||
width: fit-content;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
a.primary {
|
||||
background: var(--text-primary);
|
||||
color: var(--background);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
a.secondary {
|
||||
border-color: var(--button-secondary-border);
|
||||
}
|
||||
|
||||
/* Enable hover only on non-touch devices */
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
a.primary:hover {
|
||||
background: var(--button-primary-hover);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
a.secondary:hover {
|
||||
background: var(--button-secondary-hover);
|
||||
border-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.main {
|
||||
padding: 48px 24px;
|
||||
}
|
||||
|
||||
.intro {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.intro h1 {
|
||||
font-size: 32px;
|
||||
line-height: 40px;
|
||||
letter-spacing: -1.92px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.logo {
|
||||
filter: invert();
|
||||
}
|
||||
|
||||
.page {
|
||||
--background: #000;
|
||||
--foreground: #000;
|
||||
|
||||
--text-primary: #ededed;
|
||||
--text-secondary: #999;
|
||||
|
||||
--button-primary-hover: #ccc;
|
||||
--button-secondary-hover: #1a1a1a;
|
||||
--button-secondary-border: #1a1a1a;
|
||||
}
|
||||
}
|
||||
13
src/app/page.tsx
Normal file
13
src/app/page.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default function Home() {
|
||||
const isLicensed = !!process.env.LICENSE_NUMBER;
|
||||
|
||||
if (isLicensed) {
|
||||
// Se já estiver licenciado, assume que pode entrar
|
||||
// O LoginPage ainda pode controlar a sessão via localStorage se necessário
|
||||
redirect('/dashboard');
|
||||
} else {
|
||||
redirect('/login');
|
||||
}
|
||||
}
|
||||
75
src/app/tv/page.tsx
Normal file
75
src/app/tv/page.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
import pool from "@/lib/db";
|
||||
import TVClientWrapper from "./tv-client-wrapper";
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const revalidate = 0;
|
||||
|
||||
async function getTVOrders() {
|
||||
try {
|
||||
const res = await pool.query(`
|
||||
SELECT
|
||||
o.numero_os,
|
||||
o.data_abertura,
|
||||
s.status
|
||||
FROM public.os o
|
||||
LEFT JOIN public.os_status s ON o.id_status = s.id
|
||||
WHERE o.fechada = false
|
||||
ORDER BY o.data_abertura DESC
|
||||
LIMIT 20
|
||||
`);
|
||||
return res.rows;
|
||||
} catch (error) {
|
||||
console.error("Database Error:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export default async function TVPage() {
|
||||
const orders = await getTVOrders();
|
||||
|
||||
return (
|
||||
<TVClientWrapper>
|
||||
<div style={{ padding: '2rem', minHeight: '100vh', backgroundColor: 'var(--bg-primary)' }}>
|
||||
<header className="tv-header" style={{ display: 'flex', flexWrap: 'wrap', gap: '1rem', justifyContent: 'space-between', alignItems: 'center', marginBottom: '3rem', paddingBottom: '1rem', borderBottom: '2px solid var(--border-color)' }}>
|
||||
<h1 style={{ fontSize: '3rem', color: 'var(--accent-primary)', fontFamily: 'Outfit, sans-serif' }}>AutoAPP</h1>
|
||||
<h2 style={{ fontSize: '2rem', color: 'var(--text-secondary)' }}>Painel de Atendimento</h2>
|
||||
<div style={{ fontSize: '1.5rem', color: 'var(--text-muted)' }}>
|
||||
{new Date().toLocaleDateString('pt-BR')}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{orders.length === 0 ? (
|
||||
<div style={{ textAlign: 'center', marginTop: '10rem' }}>
|
||||
<h2 style={{ fontSize: '3rem', color: 'var(--text-muted)' }}>Nenhuma Ordem de Serviço Aberta</h2>
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(min(100%, 320px), 1fr))', gap: '2rem' }}>
|
||||
{orders.map((order, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="glass-panel animate-fade-in"
|
||||
style={{
|
||||
padding: '2rem',
|
||||
borderLeft: '8px solid var(--accent-primary)',
|
||||
animationDelay: `${i * 0.1}s`
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '1rem' }}>
|
||||
<span style={{ fontSize: '3.5rem', fontWeight: 800, color: 'var(--text-primary)', lineHeight: 1 }}>
|
||||
#{order.numero_os}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: '1.5rem', color: 'var(--text-secondary)', marginBottom: '1.5rem' }}>
|
||||
{order.data_abertura ? new Date(order.data_abertura).toLocaleTimeString('pt-BR', { hour: '2-digit', minute: '2-digit' }) : '-'}
|
||||
</div>
|
||||
<div style={{ display: 'inline-block', padding: '0.5rem 1.5rem', borderRadius: '9999px', backgroundColor: 'rgba(59, 130, 246, 0.2)', color: 'var(--accent-primary)', fontSize: '1.5rem', fontWeight: 600 }}>
|
||||
{order.status || 'Em Atendimento'}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</TVClientWrapper>
|
||||
);
|
||||
}
|
||||
19
src/app/tv/tv-client-wrapper.tsx
Normal file
19
src/app/tv/tv-client-wrapper.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function TVClientWrapper({ children }: { children: React.ReactNode }) {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
// Refresh the page every 30 seconds
|
||||
const interval = setInterval(() => {
|
||||
router.refresh();
|
||||
}, 30000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [router]);
|
||||
|
||||
return <>{children}</>;
|
||||
}
|
||||
16
src/lib/db.ts
Normal file
16
src/lib/db.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Pool } from 'pg';
|
||||
|
||||
console.log('--- Tentando conectar ao banco ---');
|
||||
console.log('Host:', process.env.DB_HOST);
|
||||
console.log('User:', process.env.DB_USER);
|
||||
console.log('Password set:', !!process.env.DB_PASSWORD);
|
||||
|
||||
const pool = new Pool({
|
||||
user: process.env.DB_USER,
|
||||
host: process.env.DB_HOST,
|
||||
database: process.env.DB_NAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
port: Number(process.env.DB_PORT || 5435),
|
||||
});
|
||||
|
||||
export default pool;
|
||||
34
tsconfig.json
Normal file
34
tsconfig.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts",
|
||||
".next/dev/types/**/*.ts",
|
||||
"**/*.mts"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user