Consolida recepcoes, stock, equipamentos e identidade SGC
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Head, Link } from '@inertiajs/react';
|
||||
import { Head, Link, router } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
ArrowRight,
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
Search,
|
||||
ShieldCheck,
|
||||
Users,
|
||||
PackageCheck,
|
||||
Warehouse,
|
||||
} from 'lucide-react';
|
||||
import { PageTitle, Panel, Status } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -27,6 +29,10 @@ import {
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { money } from '@/types/procurement';
|
||||
import { previewPaths } from '@/lib/preview-navigation';
|
||||
import InventoryDemo from './inventory-demo';
|
||||
import { OperationsDemo } from '../stock/operations';
|
||||
import { EquipmentDemo } from '../equipment';
|
||||
|
||||
// Static examples only: this page never loads or submits business data.
|
||||
const requests = [
|
||||
@@ -108,19 +114,34 @@ const navigation = [
|
||||
{ id: 'quotes', title: 'Cotações', icon: Scale },
|
||||
{ id: 'conflicts', title: 'Conflitos de interesses', icon: ShieldCheck },
|
||||
{ id: 'orders', title: 'Ordens de compra', icon: FileText },
|
||||
{ id: 'receipts', title: 'Recepção e qualidade', icon: PackageCheck },
|
||||
{ id: 'stock', title: 'Stock e movimentos', icon: Warehouse },
|
||||
{ id: 'operations', title: 'Saídas e inventários', icon: Warehouse },
|
||||
{ id: 'equipment', title: 'Equipamentos e peças', icon: Warehouse },
|
||||
{ id: 'appearance', title: 'Cores e componentes', icon: Palette },
|
||||
];
|
||||
type Detail = { title: string; subtitle: string; rows: [string, string][] };
|
||||
export default function Preview() {
|
||||
const [screen, setScreen] = useState('overview');
|
||||
const navigationGroups = [
|
||||
{ title: 'Geral', ids: ['overview'] },
|
||||
{ title: 'Compras', ids: ['requests', 'suppliers', 'quotes', 'orders'] },
|
||||
{ title: 'Armazém', ids: ['receipts', 'stock', 'operations', 'equipment'] },
|
||||
{ title: 'Controlo', ids: ['conflicts'] },
|
||||
{ title: 'Apresentação', ids: ['appearance'] },
|
||||
];
|
||||
export default function Preview({
|
||||
initialScreen = 'overview',
|
||||
}: {
|
||||
initialScreen?: string;
|
||||
}) {
|
||||
const screen = initialScreen;
|
||||
const [search, setSearch] = useState('');
|
||||
const [menu, setMenu] = useState(false);
|
||||
const [detail, setDetail] = useState<Detail | null>(null);
|
||||
const title = navigation.find((n) => n.id === screen)?.title ?? 'Consulta';
|
||||
function navigate(id: string) {
|
||||
setScreen(id);
|
||||
setSearch('');
|
||||
setMenu(false);
|
||||
router.get(previewPaths[id] ?? '/consulta');
|
||||
}
|
||||
const filteredRequests = requests.filter((r) =>
|
||||
`${r.number} ${r.title} ${r.department}`
|
||||
@@ -205,13 +226,13 @@ export default function Preview() {
|
||||
className={`${menu ? 'flex' : 'hidden'} fixed inset-y-0 left-0 z-30 w-64 flex-col border-r bg-background p-5 lg:flex`}
|
||||
>
|
||||
<Link
|
||||
href="/consulta"
|
||||
href="/"
|
||||
className="mb-8 flex items-center gap-3 text-xl font-semibold"
|
||||
>
|
||||
<span className="grid size-9 place-items-center rounded-xl bg-teal-700 text-sm text-white">
|
||||
PF
|
||||
SGC
|
||||
</span>
|
||||
ProcuraFlow
|
||||
SGC
|
||||
</Link>
|
||||
<div className="mb-7 rounded-xl border bg-muted/30 p-4">
|
||||
<p className="flex items-center gap-2 text-sm font-semibold">
|
||||
@@ -222,20 +243,34 @@ export default function Preview() {
|
||||
Consulta livre · sem autenticação
|
||||
</p>
|
||||
</div>
|
||||
<nav className="space-y-2">
|
||||
{navigation.map((n) => (
|
||||
<button
|
||||
type="button"
|
||||
key={n.id}
|
||||
onClick={() => navigate(n.id)}
|
||||
aria-current={
|
||||
screen === n.id ? 'page' : undefined
|
||||
}
|
||||
className={`flex w-full items-center gap-3 rounded-lg px-3 py-3 text-left text-sm transition-colors ${screen === n.id ? 'bg-teal-50 font-medium text-teal-800 dark:bg-teal-950 dark:text-teal-200' : 'text-muted-foreground hover:bg-muted'}`}
|
||||
>
|
||||
<n.icon className="size-4" />
|
||||
{n.title}
|
||||
</button>
|
||||
<nav
|
||||
aria-label="Áreas da demonstração"
|
||||
className="space-y-4"
|
||||
>
|
||||
{navigationGroups.map((group) => (
|
||||
<div key={group.title}>
|
||||
<p className="mb-1 px-3 text-[10px] font-semibold tracking-widest text-muted-foreground uppercase">
|
||||
{group.title}
|
||||
</p>
|
||||
{navigation
|
||||
.filter((n) => group.ids.includes(n.id))
|
||||
.map((n) => (
|
||||
<Link
|
||||
href={previewPaths[n.id]}
|
||||
key={n.id}
|
||||
onClick={() => setMenu(false)}
|
||||
aria-current={
|
||||
screen === n.id
|
||||
? 'page'
|
||||
: undefined
|
||||
}
|
||||
className={`flex w-full items-center gap-3 rounded-lg px-3 py-3 text-left text-sm transition-colors ${screen === n.id ? 'bg-teal-50 font-medium text-teal-800 dark:bg-teal-950 dark:text-teal-200' : 'text-muted-foreground hover:bg-muted'}`}
|
||||
>
|
||||
<n.icon className="size-4" />
|
||||
{n.title}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</nav>
|
||||
<p className="mt-auto pt-8 text-xs leading-5 text-muted-foreground">
|
||||
@@ -287,7 +322,7 @@ export default function Preview() {
|
||||
</span>
|
||||
</div>
|
||||
<PageTitle
|
||||
eyebrow="ProcuraFlow · Demonstração"
|
||||
eyebrow="SGC · Demonstração"
|
||||
title={title}
|
||||
description="Explore os exemplos para verificar a organização, os ecrãs, as cores e a navegação. Os dados apresentados não pertencem à sua empresa."
|
||||
/>
|
||||
@@ -621,6 +656,11 @@ export default function Preview() {
|
||||
</div>
|
||||
</Panel>
|
||||
)}
|
||||
{(screen === 'receipts' || screen === 'stock') && (
|
||||
<InventoryDemo key={screen} screen={screen} />
|
||||
)}
|
||||
{screen === 'operations' && <OperationsDemo />}
|
||||
{screen === 'equipment' && <EquipmentDemo />}
|
||||
{screen === 'appearance' && (
|
||||
<>
|
||||
<Panel
|
||||
@@ -708,8 +748,8 @@ export default function Preview() {
|
||||
</>
|
||||
)}
|
||||
<footer className="py-4 text-xs text-muted-foreground">
|
||||
ProcuraFlow · Consulta pública de exemplos · Os
|
||||
processos reais permanecem no acesso autenticado.
|
||||
SGC · Consulta pública de exemplos · Os processos
|
||||
reais permanecem no acesso autenticado.
|
||||
</footer>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,344 @@
|
||||
import { useState } from 'react';
|
||||
import { InventoryNotice, ReceiptProgressTable } from '@/components/inventory';
|
||||
import { Panel, controlClass } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { quantity } from '@/types/inventory';
|
||||
import type { ReceiptProgress } from '@/types/inventory';
|
||||
|
||||
const progress: ReceiptProgress = {
|
||||
state: 'partial',
|
||||
has_divergences: true,
|
||||
lines: [
|
||||
{
|
||||
id: 1,
|
||||
description: 'Papel A4 de demonstração',
|
||||
unit: 'cx',
|
||||
purchase_type: 'consumable',
|
||||
ordered_milli: 10000,
|
||||
received_milli: 6000,
|
||||
accepted_milli: 5000,
|
||||
rejected_milli: 1000,
|
||||
delivery_pending_milli: 4000,
|
||||
acceptance_pending_milli: 5000,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
description: 'Tinteiro de demonstração',
|
||||
unit: 'un',
|
||||
purchase_type: 'consumable',
|
||||
ordered_milli: 3000,
|
||||
received_milli: 3000,
|
||||
accepted_milli: 3000,
|
||||
rejected_milli: 0,
|
||||
delivery_pending_milli: 0,
|
||||
acceptance_pending_milli: 0,
|
||||
},
|
||||
],
|
||||
};
|
||||
const examples = [
|
||||
{
|
||||
code: 'DEMO-A4',
|
||||
name: 'Papel A4 de demonstração',
|
||||
unit: 'cx',
|
||||
quantity_milli: 5000,
|
||||
warehouse: 'Armazém de demonstração',
|
||||
receipt: 'REC-DEMO-001',
|
||||
note: 'Uma caixa rejeitada por danos; só cinco caixas aceites entraram em stock.',
|
||||
},
|
||||
{
|
||||
code: 'DEMO-TINTA',
|
||||
name: 'Tinteiro de demonstração',
|
||||
unit: 'un',
|
||||
quantity_milli: 3000,
|
||||
warehouse: 'Armazém de demonstração',
|
||||
receipt: 'REC-DEMO-001',
|
||||
note: 'Três unidades recebidas e aceites integralmente.',
|
||||
},
|
||||
];
|
||||
|
||||
export default function InventoryDemo({
|
||||
screen,
|
||||
}: {
|
||||
screen: 'receipts' | 'stock';
|
||||
}) {
|
||||
const [search, setSearch] = useState('');
|
||||
const [detail, setDetail] = useState<(typeof examples)[number] | null>(
|
||||
null,
|
||||
);
|
||||
const [quality, setQuality] = useState('reservations');
|
||||
const [notice, setNotice] = useState(false);
|
||||
const visible = examples.filter((example) =>
|
||||
`${example.code} ${example.name}`
|
||||
.toLowerCase()
|
||||
.includes(search.toLowerCase()),
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<InventoryNotice />
|
||||
{screen === 'receipts' ? (
|
||||
<>
|
||||
<Panel
|
||||
title="OC-DEMO-001 · Recepção parcial"
|
||||
description="Exemplo fictício: seis caixas conferidas, cinco aceites e uma rejeitada. Existem quatro caixas por entregar."
|
||||
>
|
||||
<ReceiptProgressTable progress={progress} />
|
||||
<p className="mt-4 text-sm text-muted-foreground">
|
||||
Emitente: Comprador de exemplo · Recepção: Armazém
|
||||
de exemplo. São pessoas distintas.
|
||||
</p>
|
||||
</Panel>
|
||||
<Panel
|
||||
title="Conferência de qualidade"
|
||||
description="Experimente os campos. Este formulário é local, não é enviado e não confirma recepções reais."
|
||||
>
|
||||
<form
|
||||
className="space-y-4"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
setNotice(true);
|
||||
}}
|
||||
>
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="demo-guide">
|
||||
Guia fictícia
|
||||
</Label>
|
||||
<Input
|
||||
id="demo-guide"
|
||||
defaultValue="GR-DEMO-001"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="demo-received">
|
||||
Quantidade recebida
|
||||
</Label>
|
||||
<Input
|
||||
id="demo-received"
|
||||
type="number"
|
||||
min="0.001"
|
||||
step="0.001"
|
||||
defaultValue="6"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="demo-quality">
|
||||
Qualidade
|
||||
</Label>
|
||||
<select
|
||||
id="demo-quality"
|
||||
className={controlClass}
|
||||
value={quality}
|
||||
onChange={(event) =>
|
||||
setQuality(event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="compliant">
|
||||
Conforme
|
||||
</option>
|
||||
<option value="reservations">
|
||||
Conforme com reservas
|
||||
</option>
|
||||
<option value="nonconforming">
|
||||
Não conforme
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="demo-accepted">
|
||||
Quantidade aceite
|
||||
</Label>
|
||||
<Input
|
||||
id="demo-accepted"
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.001"
|
||||
defaultValue="5"
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="demo-location">
|
||||
Destino fictício
|
||||
</Label>
|
||||
<select
|
||||
id="demo-location"
|
||||
className={controlClass}
|
||||
>
|
||||
<option>Armazém de demonstração</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="demo-article">
|
||||
Artigo fictício
|
||||
</Label>
|
||||
<select
|
||||
id="demo-article"
|
||||
className={controlClass}
|
||||
>
|
||||
<option>
|
||||
DEMO-A4 · Papel A4 de demonstração
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="demo-divergence">
|
||||
Divergências
|
||||
</Label>
|
||||
<textarea
|
||||
id="demo-divergence"
|
||||
className={`${controlClass} h-24 py-3`}
|
||||
defaultValue="Uma caixa com danos na embalagem e humidade. Rejeitada e sem entrada em stock."
|
||||
/>
|
||||
</div>
|
||||
<Button>Pré-visualizar conferência fictícia</Button>
|
||||
{notice && (
|
||||
<p
|
||||
role="status"
|
||||
className="text-sm text-teal-700 dark:text-teal-400"
|
||||
>
|
||||
Demonstração local: nenhum dado foi
|
||||
guardado. No módulo autenticado, o servidor
|
||||
verifica quantidades, segregação e
|
||||
duplicações.
|
||||
</p>
|
||||
)}
|
||||
</form>
|
||||
</Panel>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Panel
|
||||
title="Existências fictícias"
|
||||
description="Somente quantidades aceites. Pesquise e abra os detalhes para rever a apresentação."
|
||||
>
|
||||
<Input
|
||||
aria-label="Pesquisar artigos fictícios"
|
||||
placeholder="Pesquisar código ou artigo de demonstração"
|
||||
value={search}
|
||||
onChange={(event) => setSearch(event.target.value)}
|
||||
className="mb-5 max-w-sm"
|
||||
/>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<thead className="border-b text-muted-foreground">
|
||||
<tr>
|
||||
<th className="pr-4 pb-3">Artigo</th>
|
||||
<th className="pr-4">Armazém</th>
|
||||
<th className="pr-4">Em stock</th>
|
||||
<th>Histórico</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{visible.map((example) => (
|
||||
<tr
|
||||
className="border-b last:border-0"
|
||||
key={example.code}
|
||||
>
|
||||
<td className="py-4 pr-4">
|
||||
<strong>{example.code}</strong>
|
||||
<p className="mt-1 text-muted-foreground">
|
||||
{example.name}
|
||||
</p>
|
||||
</td>
|
||||
<td className="pr-4">
|
||||
{example.warehouse}
|
||||
</td>
|
||||
<td className="pr-4">
|
||||
{quantity(
|
||||
example.quantity_milli,
|
||||
)}{' '}
|
||||
{example.unit}
|
||||
</td>
|
||||
<td>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
setDetail(example)
|
||||
}
|
||||
>
|
||||
Ver movimentos
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{visible.length === 0 && (
|
||||
<p className="py-5 text-sm text-muted-foreground">
|
||||
Nenhum exemplo corresponde à pesquisa.
|
||||
</p>
|
||||
)}
|
||||
</Panel>
|
||||
<Panel title="Histórico de entradas fictícias">
|
||||
<div className="space-y-3">
|
||||
{visible.map((example) => (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setDetail(example)}
|
||||
key={example.code}
|
||||
className="w-full rounded-lg border p-4 text-left text-sm"
|
||||
>
|
||||
<strong>
|
||||
+{quantity(example.quantity_milli)}{' '}
|
||||
{example.unit} · {example.code}
|
||||
</strong>
|
||||
<p className="mt-1 text-muted-foreground">
|
||||
{example.receipt} · OC-DEMO-001 · Guia
|
||||
GR-DEMO-001
|
||||
</p>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<p className="mt-4 text-xs text-muted-foreground">
|
||||
Os exemplos não correspondem a existências da
|
||||
empresa. Consulte Saídas e inventários para rever os
|
||||
novos exemplos fictícios.
|
||||
</p>
|
||||
</Panel>
|
||||
</>
|
||||
)}
|
||||
<Dialog
|
||||
open={detail !== null}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) setDetail(null);
|
||||
}}
|
||||
>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
{detail?.code} · Entrada fictícia
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
Histórico ilustrativo, sem acesso aos registos
|
||||
reais.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
{detail && (
|
||||
<div className="space-y-3 text-sm">
|
||||
<p>
|
||||
{detail.name} · +
|
||||
{quantity(detail.quantity_milli)} {detail.unit}
|
||||
</p>
|
||||
<p>{detail.receipt} · OC-DEMO-001 · GR-DEMO-001</p>
|
||||
<p>{detail.note}</p>
|
||||
<p>
|
||||
Confirmado por Armazém de exemplo, distinto do
|
||||
emitente.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user