Repository navigation
refactor(admin): modernização da ux do portal e controles em linha - #16
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Atualiza a UX/visual do portal (admin) e da vitrine pública, incluindo navegação mobile com bottom tabs e um fluxo global de edição rápida de produtos (modal) acessível diretamente do catálogo/produto quando a sessão admin estiver válida.
Changes:
- Introduz
AdminProductModalglobal + gatilhos de edição inline (comisAdminvindo da sessão). - Moderniza UI pública (home, catálogo, PDP, carrinho) e adiciona
BottomTabBarno mobile. - Refatora fluxo do WhatsApp (picker/estado) e ajusta componentes de header/footer + CSS amplo.
Reviewed changes
Copilot reviewed 24 out of 26 changed files in this pull request and generated 19 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/create-svg-favicon.js | Script para gerar app/icon.svg a partir de PNG (base64 + clip-path). |
| components/whatsapp-float-widget.js | Widget WhatsApp com novo visual e estado do picker vindo do CatalogProvider. |
| components/whatsapp-attendant-picker.js | Picker com classes vg-*, overflow lock via body.style, e lista sem shuffle. |
| components/site-header.js | Header com marca textual, badge de carrinho e novo drawer mobile vg-*. |
| components/site-footer.js | Footer redesenhado com link destacado para Instagram e grid simplificado. |
| components/providers/catalog-provider.js | Adiciona isAdmin, estado global do WhatsApp picker e do editor de produto (modal). |
| components/providers/app-providers.js | Propaga isAdmin para CatalogProvider. |
| components/product-detail-actions.js | Atualiza ações do PDP (layout + toasts) e classes vg-*. |
| components/product-card.js | Novo card vg-* com CTA WhatsApp e botão inline “Editar” quando isAdmin. |
| components/icons.js | Adiciona ícones (Home/Book/User) para navegação inferior. |
| components/catalog-page-content.js | Novo layout de catálogo (search/sort/pills) e resultados em grid “stacked”. |
| components/bottom-tab-bar.js | Nova barra inferior mobile com badge de carrinho e link admin opcional. |
| components/app-shell.js | Injeta BottomTabBar e AdminProductModal globalmente. |
| components/admin/managers/admin-service-manager.js | Simplifica gerenciamento de atendimento (remove seção de canais). |
| components/admin/managers/admin-products-manager.js | Remove editor embutido e passa a abrir AdminProductModal via openEditModal. |
| components/admin/managers/admin-categories-manager.js | Refatora para edição focada (um departamento por vez) + deleção. |
| components/admin/admin-product-modal.js | Novo slideover global para criação/edição de produtos + galeria upload. |
| components/admin/admin-login-form.js | Login admin redesenhado (“portal seguro”) com revelar senha e estado “esqueceu”. |
| components/admin/admin-dashboard.js | Dashboard admin redesenhado (cards/módulos) e topbar. |
| app/produto/[id]/page.js | PDP redesenhada com galeria, tabs e botão inline de edição (admin). |
| app/page.js | Home redesenhada (hero/categorias/destaques/banner WhatsApp). |
| app/layout.js | Deriva isAdmin via cookie de sessão e injeta nos providers. |
| app/globals.css | Grande atualização de estilos vg-*, bottom nav, drawer, admin slideover, etc. |
| app/carrinho/page.js | Carrinho redesenhado (lista + preview da mensagem + sticky checkout). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return; | ||
| } | ||
|
|
||
| if (!link) return; |
There was a problem hiding this comment.
handleSelectAttendant returns early when the selected attendant has an invalid phone (!link) without any user feedback. This leaves the picker open and looks like a broken click. Consider restoring a warning toast (and/or disabling attendants with invalid phones in the picker) so the user understands what happened.
| if (!link) return; | |
| if (!link) { | |
| showToast({ | |
| type: "warning", | |
| title: "Contato indisponível", | |
| message: "Este atendente não possui WhatsApp configurado.", | |
| }); | |
| return; | |
| } |
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const imgPath = path.join(process.cwd(), 'public/li-rilko-icon-page.png'); | ||
| const imgData = fs.readFileSync(imgPath); | ||
| const base64 = imgData.toString('base64'); | ||
|
|
||
| const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 192"> | ||
| <defs> | ||
| <clipPath id="circleView"> | ||
| <circle cx="96" cy="96" r="96" /> | ||
| </clipPath> | ||
| </defs> | ||
| <image width="192" height="192" href="data:image/png;base64,${base64}" clip-path="url(#circleView)" preserveAspectRatio="xMidYMid slice" /> | ||
| </svg>`; | ||
|
|
||
| fs.writeFileSync(path.join(process.cwd(), 'app/icon.svg'), svg); | ||
| console.log('App Icon SVG created successfully!'); |
There was a problem hiding this comment.
This script generates app/icon.svg but it isn’t referenced by any npm script or documented, so it’s easy for the committed favicon to drift from the source PNG. Consider adding an npm script (e.g., generate:favicon) and/or documenting when it should be run (and whether app/icon.svg should be committed).
| return ( | ||
| <> | ||
| <div className="vg-modal-backdrop" onClick={closeEditModal} /> | ||
| <div className="vg-admin-slideover"> | ||
| <div className="vg-slideover-header"> | ||
| <div> | ||
| <h2>{isNew ? "Novo Produto" : "Editar Produto"}</h2> | ||
| <span className="vg-slideover-id">PRODUCT ID: #{productForm.id.split("-").pop().substring(0,6).toUpperCase()}</span> | ||
| </div> | ||
| <button className="vg-slideover-close" onClick={closeEditModal} aria-label="Fechar"> | ||
| × | ||
| </button> | ||
| </div> |
There was a problem hiding this comment.
AdminProductModal renders a modal/slideover without role="dialog"/aria-modal and doesn’t handle Escape-to-close or focus management. The codebase already has an accessible modal pattern (components/admin/admin-modal.js)—consider reusing it or adding the same accessibility behaviors here so keyboard/screen-reader users can operate the editor.
| <main className="app-shell has-bottom-nav">{children}</main> | ||
| <SiteFooter /> | ||
| {!isAdminRoute && <MobileCartBar />} | ||
| {!isAdminRoute && <WhatsAppFloatWidget />} | ||
| <BottomTabBar /> |
There was a problem hiding this comment.
has-bottom-nav is applied unconditionally, but BottomTabBar is hidden on /admin routes. On mobile this still adds extra bottom padding to admin pages. Consider only adding has-bottom-nav (and rendering BottomTabBar) when !isAdminRoute so admin layouts don’t get an unnecessary 80px gap.
| <main className="app-shell has-bottom-nav">{children}</main> | |
| <SiteFooter /> | |
| {!isAdminRoute && <MobileCartBar />} | |
| {!isAdminRoute && <WhatsAppFloatWidget />} | |
| <BottomTabBar /> | |
| <main className={`app-shell${!isAdminRoute ? " has-bottom-nav" : ""}`}> | |
| {children} | |
| </main> | |
| <SiteFooter /> | |
| {!isAdminRoute && <MobileCartBar />} | |
| {!isAdminRoute && <WhatsAppFloatWidget />} | |
| {!isAdminRoute && <BottomTabBar />} |
|
|
||
| {state?.error ? <p className="admin-error">{state.error}</p> : null} | ||
| <button type="submit" className="vg-secure-submit" disabled={isPending}> | ||
| {isPending ? "ENTRANDO..." : "ENTRAR"} <span className="arrow">→]</span> |
There was a problem hiding this comment.
There’s a stray ] in the submit button arrow (→]), which looks like a typo in the UI. Remove the extra bracket (or replace with a proper icon/arrow).
| {isPending ? "ENTRANDO..." : "ENTRAR"} <span className="arrow">→]</span> | |
| {isPending ? "ENTRANDO..." : "ENTRAR"} <span className="arrow">→</span> |
| @@ -36,8 +40,7 @@ export default function WhatsAppFloatWidget() { | |||
| } | |||
|
|
|||
| if (action.mode === "picker") { | |||
| setPendingMessage(message); | |||
| setIsPickerOpen(true); | |||
| openWhatsAppPicker(message); | |||
| return; | |||
| } | |||
|
|
|||
| @@ -49,13 +52,8 @@ export default function WhatsAppFloatWidget() { | |||
| }); | |||
| } | |||
There was a problem hiding this comment.
attendantFlow and handleClick are now unused (the UI calls openWhatsAppPicker directly). This leaves dead code and an unused import (resolveAttendantFlow). Either wire the UI back to handleClick or remove the unused flow/handler to avoid confusion.
| <span className="vg-price-main">{formatCurrency(priceCash)}</span> | ||
| <span className="vg-price-alt">ou {formatCurrency(priceInstallment)} à vista</span> |
There was a problem hiding this comment.
The price label is inconsistent: priceInstallment is shown with the text “à vista”. This will display the installment price but label it as cash price. Swap the label/value so priceCash is the “à vista” amount and priceInstallment is the “a prazo” amount.
| <span className="vg-price-main">{formatCurrency(priceCash)}</span> | |
| <span className="vg-price-alt">ou {formatCurrency(priceInstallment)} à vista</span> | |
| <span className="vg-price-main">{formatCurrency(priceCash)} à vista</span> | |
| <span className="vg-price-alt">ou {formatCurrency(priceInstallment)} a prazo</span> |
| import { useActionState } from "react"; | ||
| import { useActionState, useState } from "react"; | ||
| import { adminLoginAction } from "@/app/admin/actions"; | ||
| import { IconUser, IconHome } from "@/components/icons"; |
There was a problem hiding this comment.
IconHome is imported but never used. Please remove unused imports to keep the module tidy.
| import { IconUser, IconHome } from "@/components/icons"; | |
| import { IconUser } from "@/components/icons"; |
| import { useEffect, useMemo, useRef, useState } from "react"; | ||
| import { useCatalog } from "@/components/providers/catalog-provider"; | ||
| import { useToast } from "@/components/providers/toast-provider"; | ||
| import { formatCurrencyInput, formatCurrencyInputForEdit, parseCurrencyInputToNumber } from "@/lib/admin-input-formatters"; | ||
| import { IconPhoto, IconClose } from "@/components/icons"; |
There was a problem hiding this comment.
Several imports are unused (useRef, IconPhoto, IconClose). Removing them reduces bundle size slightly and avoids confusion during future edits.
| import { useEffect, useMemo, useRef, useState } from "react"; | |
| import { useCatalog } from "@/components/providers/catalog-provider"; | |
| import { useToast } from "@/components/providers/toast-provider"; | |
| import { formatCurrencyInput, formatCurrencyInputForEdit, parseCurrencyInputToNumber } from "@/lib/admin-input-formatters"; | |
| import { IconPhoto, IconClose } from "@/components/icons"; | |
| import { useEffect, useMemo, useState } from "react"; | |
| import { useCatalog } from "@/components/providers/catalog-provider"; | |
| import { useToast } from "@/components/providers/toast-provider"; | |
| import { formatCurrencyInput, formatCurrencyInputForEdit, parseCurrencyInputToNumber } from "@/lib/admin-input-formatters"; |
| async function handleToggleVisibility(product) { | ||
| if (isProcessing) return; | ||
| setIsProcessing(true); | ||
| const result = await toggleProductVisibility(product.id, product.isVisible !== false); | ||
| setIsProcessing(false); | ||
|
|
||
| async function handleRemoveImage(image, index) { | ||
| const result = await deleteProductImage(productForm.id, image.id); | ||
| if (!result.ok) { | ||
| showToast({ | ||
| type: "warning", | ||
| title: "Erro ao excluir imagem", | ||
| message: result.error || "Não foi possível excluir a imagem.", | ||
| }); | ||
| return; | ||
| showToast({ type: "warning", title: "Erro", message: result.error }); | ||
| } | ||
|
|
||
| setProductImages((prev) => prev.filter((_, currentIndex) => currentIndex !== index).map(normalizeImageItem)); | ||
| } | ||
|
|
||
| function moveImageToPrimary(index) { | ||
| setProductImages((prev) => { | ||
| if (index <= 0 || index >= prev.length) { | ||
| return prev; | ||
| } | ||
|
|
||
| const next = [...prev]; | ||
| const [selected] = next.splice(index, 1); | ||
| next.unshift(selected); | ||
| return next.map(normalizeImageItem); | ||
| }); | ||
| } | ||
|
|
||
| async function handleSaveProduct(event) { | ||
| event.preventDefault(); | ||
| const payload = buildProductPayload(); | ||
| const validationError = validatePayload(payload); | ||
|
|
||
| if (validationError) { | ||
| showToast({ | ||
| type: "warning", | ||
| title: "Dados inválidos", | ||
| message: validationError, | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| setIsSubmitting(true); | ||
|
|
||
| try { | ||
| if (editingProductId) { | ||
| const result = await updateProduct(editingProductId, payload); | ||
| if (!result.ok) { | ||
| showToast({ | ||
| type: "warning", | ||
| title: "Erro ao salvar", | ||
| message: result.error || "Não foi possível atualizar o produto.", | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| showToast({ | ||
| type: "success", | ||
| title: "Produto atualizado", | ||
| message: "As informações do produto foram salvas.", | ||
| }); | ||
| return; | ||
| } | ||
|
|
||
| const result = await addProduct(payload); | ||
| if (!result.ok) { | ||
| showToast({ | ||
| type: "warning", | ||
| title: "Erro ao criar produto", | ||
| message: result.error || "Não foi possível criar o produto.", | ||
| }); | ||
| return; | ||
| } | ||
| async function handleToggleAvailability(product) { | ||
| if (isProcessing) return; | ||
| setIsProcessing(true); | ||
| const result = await toggleProductAvailability(product.id, product.isAvailable !== false); | ||
| setIsProcessing(false); |
There was a problem hiding this comment.
toggleProductVisibility only takes (productId) (it reads current state from productMap), but this call passes a second argument that is ignored. Same for toggleProductAvailability. Remove the extra parameter (or update the provider signature) to avoid misleading future changes.
9420329 to
c7ee6c2
Compare
c7ee6c2 to
eea3744
Compare
eea3744 to
3ac204f
Compare
3ac204f to
6bb9a2c
Compare
- feat(admin): login redesenhado com estética 'Vanguard Secure Portal'. - feat(catalog): introduzido 'AdminProductModal' global para edição rápida de produtos. - ui(admin): simplificadas as abas de gerenciamento de Produtos, Categorias e Atendimento. - fix(mobile): padding condicional no Footer e BottomTabBar condicionada a rotas não-admin. - fix(mobile): admin topbar responsivo com flex-wrap e breakpoint mobile. - refactor(footer): link dinâmico focado no Instagram (@lirilkoimportscentro). - fix(ui): favicon migrado para icon.svg com clip-path circular nativo. - fix(a11y): role=dialog, aria-modal e Escape-to-close no AdminProductModal. - fix(ui): corrigido label de preço (à vista / a prazo) na página de produto. - chore: removidas importações e código morto. - chore: adicionado script npm generate:favicon.
6bb9a2c to
6a2d604
Compare
[skip ci]