Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fb8d680
refactor: clarify auth submit loading state
lexmarcos May 13, 2026
cb69a6f
fix: load recharts components on client
lexmarcos May 13, 2026
f4b06e1
fix: stabilize warehouse client hydration
lexmarcos May 13, 2026
4e90669
refactor: improve batch model state handling
lexmarcos May 13, 2026
a1bda71
fix: refine stock movement draft routing
lexmarcos May 13, 2026
2a0c17f
refactor: split product image dropzone states
lexmarcos May 13, 2026
b5277af
refactor: redesign batch views
lexmarcos May 13, 2026
5165966
refactor: redesign product views
lexmarcos May 13, 2026
372aee9
refactor: redesign catalog setup views
lexmarcos May 13, 2026
4368587
refactor: redesign sales views
lexmarcos May 13, 2026
fab1e77
refactor: redesign stock movement views
lexmarcos May 13, 2026
ae65ff5
refactor: redesign system admin views
lexmarcos May 13, 2026
c50fd23
refactor: redesign transfer views
lexmarcos May 13, 2026
0d7f096
chore: add react doctor report
lexmarcos May 13, 2026
6c81bc2
refactor: replace individual dynamic component imports with a central…
lexmarcos May 13, 2026
9c10510
feat: implement image processing lock for product forms and fix curre…
lexmarcos May 13, 2026
5860e5d
refactor: modernize product detail UI with fixed bottom bar and restr…
lexmarcos May 13, 2026
081b2ca
feat: implement IndexedDB for stock movement draft storage and retrieval
lexmarcos May 13, 2026
e2ee461
chore: update CLAUDE.md with additional guidelines and formatting rules
lexmarcos May 14, 2026
cabfbbb
refactor: remove stock movement detail components and related tests
lexmarcos May 14, 2026
0fd5ef4
feat: implement stock movements detail page with model and view compo…
lexmarcos May 14, 2026
d92f543
feat: enhance mobile menu animations and add stock movement detail mo…
lexmarcos May 14, 2026
f0be1bd
feat(stock-movements): track draft runtime recovery
lexmarcos May 20, 2026
a9e3725
feat(products): add AI prompt image generation
lexmarcos May 20, 2026
b123d1f
fix(company): render uploaded logo previews
lexmarcos May 20, 2026
10f5eb8
feat(stock-movements): show submit progress overlay
lexmarcos May 20, 2026
55486eb
feat: mover geracao de prompts para pagina
lexmarcos May 20, 2026
9ea8543
fix: recuperar toque ao voltar do share no pwa
lexmarcos May 20, 2026
2597c99
fix: retornar para lista apos share no ios pwa
lexmarcos May 20, 2026
373906f
fix: bloquear share de arquivo no ios pwa
lexmarcos May 20, 2026
094e1ac
test: clean up stock movement debounce timers
lexmarcos May 21, 2026
e4bd454
fix: preserve product image removal state
lexmarcos May 21, 2026
ac3f201
fix: autofill prompt price from latest batch
lexmarcos May 21, 2026
10a9cab
fix: type prompt share cleanup callbacks
lexmarcos May 21, 2026
a05f312
feat: add production clarity tracking
lexmarcos May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .claude/settings.local.json

This file was deleted.

11 changes: 10 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
Next.js 15, TS, Tailwind CSS, shadcn/ui.

## Architecture (MVVM)

- Structure: Every page needs `.model.ts` (logic), `.view.tsx` (pure JSX), `.types.ts` (interfaces), `.schema.ts` (Zod), and `page.tsx` (ViewModel).
- Responsibilities: NO JSX in models. NO state/hooks/logic in views.
- Forms: Validate with Zod schemas and `react-hook-form`.

## Code Style

- Types: Explicit everywhere. No `any`.
- Endpoints: Always check `docs/endpoints/` before making API calls.
- Functions: 4-20 lines. Split if longer.
Expand All @@ -26,23 +28,27 @@ Next.js 15, TS, Tailwind CSS, shadcn/ui.
- Wrap third-party libs behind a thin interface owned by this project.

## Components & UI

- Base: `/components/ui` using Tailwind + lucide-react (strokeWidth 2 or 2.5).
- Breadcrumbs: Use `useBreadcrumb` hook ONLY in child routes (e.g., `/products/[id]/edit`).
- Composites: Use standard wrappers `<PageContainer>`, `<PageHeader>`, `<FixedBottomBar>`.
- Feedback: Always handle loading (`<LoadingState>`), errors (`<ErrorState>`), and no-data (`<EmptyState>`), and format forms with `<FormSection>`.

## Responsive & Design System

- Layout: Mobile First -> Tablet (`md:`) -> Desktop (`max-w-7xl`).
- Sidebar Fix: Any `fixed` full-width element MUST include `md:ml-[240px]` to clear the sidebar.
- Theme: Dark-only brutalism. Background `#0A0A0A`, surfaces `#171717`, borders `neutral-800`.
- Accents: Primary `#2563EB`, Success `#059669`, Warning `#F59E0B`, Error `#E11D48`.
- Geometry & Interaction: 4px border radius everywhere. No shadows. No `rounded-full`. No animations (instant hover changes). Bold titles.

## Data Fetching

- Libraries: `swr` for caching + `ky` for HTTP requests.
- Encapsulation: All `useSWR` and `ky.get/.post` calls must be inside standard hooks in `.model.ts`.

## Tests

- Scope: Unit test `.model.ts` files ONLY.
- Workflow: Always ask to create model tests immediately after finishing a page implementation.
- Runner: Vitest (`pnpm test`).
Expand All @@ -53,5 +59,8 @@ Next.js 15, TS, Tailwind CSS, shadcn/ui.
self-validating, timely.

## Workflow & Commands
- Commands: `pnpm dev` (Dev), `pnpm test` (Test), `pnpm build` (Build).

- `pnpm test` (Test), `pnpm build` (Build).
- Automation defaults: email `pass@pass.com` / pw `test123`.
- Só faça a build (`pnpm build`) quando for solicitado. Não quebre essa regra
- Só rode o `pnpm dev` quando for solicitado. Não quebre essa regra
4 changes: 4 additions & 0 deletions app/(pages)/batches/[id]/batches-detail.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ describe("formatCentsTotal", () => {
expect(formatCentsTotal(1000, 5)).toMatch(/R\$\s?50,00/);
});

it("does not prefix the formatted total value", () => {
expect(formatCentsTotal(2000, 2)).not.toContain("Total:");
});

it("returns dash when price is null", () => {
expect(formatCentsTotal(null, 10)).toBe("-");
});
Expand Down
2 changes: 1 addition & 1 deletion app/(pages)/batches/[id]/batches-detail.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const formatCentsTotal = (
quantity: number,
): string => {
if (unitCents === null || unitCents === undefined) return "-";
return `Total: ${formatCentsToBRL(unitCents * quantity)}`;
return formatCentsToBRL(unitCents * quantity);
};

export const computeMarginLabel = (
Expand Down
44 changes: 22 additions & 22 deletions app/(pages)/batches/[id]/edit/batches-edit.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from "react";
import { useMemo } from "react";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { useRouter } from "next/navigation";
Expand All @@ -9,6 +9,18 @@ import type { BatchEditResponse } from "./batches-edit.types";
import type { Batch } from "../../batches.types";
import { useBreadcrumb } from "@/components/breadcrumb";

const DEFAULT_BATCH_EDIT_FORM_VALUES: BatchEditFormData = {
productId: "",
warehouseId: "",
quantity: 1,
batchCode: "",
manufacturedDate: "",
expirationDate: "",
costPrice: undefined,
sellingPrice: undefined,
notes: "",
};

export const mapBatchToFormValues = (batch: Batch): BatchEditFormData => ({
productId: batch.productId,
warehouseId: batch.warehouseId,
Expand All @@ -23,21 +35,6 @@ export const mapBatchToFormValues = (batch: Batch): BatchEditFormData => ({

export const useBatchEditModel = (batchId: string) => {
const router = useRouter();
const form = useForm<BatchEditFormData>({
resolver: zodResolver(batchEditSchema),
defaultValues: {
productId: "",
warehouseId: "",
quantity: 1,
batchCode: "",
manufacturedDate: "",
expirationDate: "",
costPrice: undefined,
sellingPrice: undefined,
notes: "",
},
});

const { data, isLoading } = useSWR<BatchEditResponse>(
batchId ? `batches/${batchId}` : null,
async (url: string) => {
Expand All @@ -47,6 +44,15 @@ export const useBatchEditModel = (batchId: string) => {
);

const batch = data?.data || null;
const formValues = useMemo(
() => (batch ? mapBatchToFormValues(batch) : DEFAULT_BATCH_EDIT_FORM_VALUES),
[batch],
);
const form = useForm<BatchEditFormData>({
resolver: zodResolver(batchEditSchema),
defaultValues: DEFAULT_BATCH_EDIT_FORM_VALUES,
values: formValues,
});

useBreadcrumb({
title: batch?.batchNumber || batch?.batchCode || "Carregando...",
Expand All @@ -55,12 +61,6 @@ export const useBatchEditModel = (batchId: string) => {
subsection: "Edição",
});

useEffect(() => {
if (batch) {
form.reset(mapBatchToFormValues(batch));
}
}, [batch, form]);

const onSubmit = async (values: BatchEditFormData) => {
try {
const { api } = await import("@/lib/api");
Expand Down
Loading
Loading