Repository navigation
refactor(admin): modernização da ux do portal e controles em linha #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,68 +24,33 @@ export default function CartPage() { | |||||||||||||||
| function handleDecrease(item) { | ||||||||||||||||
| if (item.qty <= 1) { | ||||||||||||||||
| removeItem(item.id); | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "warning", | ||||||||||||||||
| title: "Item removido", | ||||||||||||||||
| message: `${item.name} foi removido do carrinho.`, | ||||||||||||||||
| }); | ||||||||||||||||
| showToast({ type: "warning", title: "Item removido", message: `${item.name} saiu do carrinho.` }); | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| decreaseItem(item.id, 1); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| function handleIncrease(item) { | ||||||||||||||||
| const added = addItem(item.id, 1); | ||||||||||||||||
| if (!added) { | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "warning", | ||||||||||||||||
| title: "Produto indisponível", | ||||||||||||||||
| message: `${item.name} não está disponível para aumentar quantidade agora.`, | ||||||||||||||||
| }); | ||||||||||||||||
| return; | ||||||||||||||||
| showToast({ type: "warning", title: "Produto indisponível", message: `${item.name} esgotado.` }); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| function handleRemove(item) { | ||||||||||||||||
| removeItem(item.id); | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "warning", | ||||||||||||||||
| title: "Item removido", | ||||||||||||||||
| message: `${item.name} saiu do carrinho.`, | ||||||||||||||||
| }); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| function handleClearCart() { | ||||||||||||||||
| clearCart(); | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "warning", | ||||||||||||||||
| title: "Carrinho limpo", | ||||||||||||||||
| message: "Todos os itens foram removidos.", | ||||||||||||||||
| }); | ||||||||||||||||
| showToast({ type: "warning", title: "Item removido", message: `${item.name} saiu.` }); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| function handleCheckoutClick(event) { | ||||||||||||||||
| event.preventDefault(); | ||||||||||||||||
|
|
||||||||||||||||
| if (items.length === 0) { | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "warning", | ||||||||||||||||
| title: "Carrinho vazio", | ||||||||||||||||
| message: "Adicione produtos antes de finalizar no WhatsApp.", | ||||||||||||||||
| }); | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
| if (items.length === 0) return; | ||||||||||||||||
|
|
||||||||||||||||
| const checkoutMessage = buildWhatsAppMessage(items, siteSettings); | ||||||||||||||||
| const action = resolveWhatsAppAttendantAction(attendants, checkoutMessage); | ||||||||||||||||
|
|
||||||||||||||||
| if (action.mode === "blocked") { | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "warning", | ||||||||||||||||
| title: "Atendimento indisponível", | ||||||||||||||||
| message: "Nenhum atendente com número válido foi configurado no admin.", | ||||||||||||||||
| }); | ||||||||||||||||
| showToast({ type: "warning", title: "Indisponível", message: "Nenhum atendente configurado." }); | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -96,11 +61,6 @@ export default function CartPage() { | |||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| openWhatsAppLink(action.link); | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "success", | ||||||||||||||||
| title: "Abrindo WhatsApp", | ||||||||||||||||
| message: `Resumo pronto para finalizar com ${action.attendant.name}.`, | ||||||||||||||||
| }); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| function handleClosePicker() { | ||||||||||||||||
|
|
@@ -110,109 +70,93 @@ export default function CartPage() { | |||||||||||||||
|
|
||||||||||||||||
| function handleSelectAttendant(attendant) { | ||||||||||||||||
| const link = buildAttendantWhatsAppLink(pendingMessage, attendant); | ||||||||||||||||
|
|
||||||||||||||||
| if (!link) { | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "warning", | ||||||||||||||||
| title: "Atendimento indisponível", | ||||||||||||||||
| message: "O número da atendente selecionada é inválido.", | ||||||||||||||||
| }); | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| if (!link) return; | ||||||||||||||||
| openWhatsAppLink(link); | ||||||||||||||||
| showToast({ | ||||||||||||||||
| type: "success", | ||||||||||||||||
| title: "Abrindo WhatsApp", | ||||||||||||||||
| message: `Resumo pronto para finalizar com ${attendant.name}.`, | ||||||||||||||||
| }); | ||||||||||||||||
| handleClosePicker(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| return ( | ||||||||||||||||
| <> | ||||||||||||||||
| <section className="section page-hero-small"> | ||||||||||||||||
| <section className="vg-cart-page"> | ||||||||||||||||
| <div className="shell-container"> | ||||||||||||||||
| <p className="kicker">Carrinho</p> | ||||||||||||||||
| <h1>Confira seus itens e finalize seu pedido.</h1> | ||||||||||||||||
| <p>Ajuste quantidades, veja o total e envie o pedido para atendimento no WhatsApp.</p> | ||||||||||||||||
| </div> | ||||||||||||||||
| </section> | ||||||||||||||||
|
|
||||||||||||||||
| <section className="section"> | ||||||||||||||||
| <div className="shell-container cart-grid"> | ||||||||||||||||
| <article className="cart-card reveal"> | ||||||||||||||||
| <div className="cart-card-header"> | ||||||||||||||||
| <h2>Seu carrinho</h2> | ||||||||||||||||
| {count > 0 && ( | ||||||||||||||||
| <button type="button" className="text-button danger" onClick={handleClearCart}> | ||||||||||||||||
| Limpar carrinho | ||||||||||||||||
| </button> | ||||||||||||||||
| <header className="vg-cart-header"> | ||||||||||||||||
| <h1 className="vg-cart-title">Revise seu Pedido</h1> | ||||||||||||||||
| {count > 0 && <button className="vg-filter-clear" onClick={clearCart}>Limpar tudo</button>} | ||||||||||||||||
| </header> | ||||||||||||||||
|
|
||||||||||||||||
| <div className="vg-cart-grid"> | ||||||||||||||||
| <div className="vg-cart-items-col"> | ||||||||||||||||
| {items.length === 0 ? ( | ||||||||||||||||
| <div className="vg-empty-state"> | ||||||||||||||||
| <p>Seu carrinho está vazio.</p> | ||||||||||||||||
| <TransitionLink className="btn btn-primary" href="/catalogo">Explorar Catálogo</TransitionLink> | ||||||||||||||||
| </div> | ||||||||||||||||
| ) : ( | ||||||||||||||||
| <ul className="vg-cart-list"> | ||||||||||||||||
| {items.map((item) => ( | ||||||||||||||||
| <li key={item.id} className="vg-cart-item"> | ||||||||||||||||
| <TransitionLink href={`/produto/${item.id}`} className="vg-cart-item-img"> | ||||||||||||||||
| <img src={item.image} alt={item.name} /> | ||||||||||||||||
| </TransitionLink> | ||||||||||||||||
|
|
||||||||||||||||
| <div className="vg-cart-item-info"> | ||||||||||||||||
| <div className="vg-cart-item-top"> | ||||||||||||||||
| <TransitionLink href={`/produto/${item.id}`} className="vg-cart-item-title"> | ||||||||||||||||
| {item.name} | ||||||||||||||||
| </TransitionLink> | ||||||||||||||||
| <button className="vg-cart-item-remove" onClick={() => handleRemove(item)}> | ||||||||||||||||
|
||||||||||||||||
| <button className="vg-cart-item-remove" onClick={() => handleRemove(item)}> | |
| <button | |
| type="button" | |
| className="vg-cart-item-remove" | |
| onClick={() => handleRemove(item)} | |
| aria-label={`Remover ${item.name}`} | |
| > |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleSelectAttendantreturns 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.