First commit
This commit is contained in:
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}</>;
|
||||
}
|
||||
Reference in New Issue
Block a user