Fix checkout summary rendering

This commit is contained in:
Tiago Yamamoto 2025-12-26 18:13:01 -03:00
parent ed4349a938
commit 803d371b59
2 changed files with 9 additions and 9 deletions

View file

@ -7,7 +7,7 @@ import { ordersService, CreateOrderRequest } from '../services/ordersService'
import { shippingService } from '../services/shippingService' import { shippingService } from '../services/shippingService'
import { apiClient } from '../services/apiClient' import { apiClient } from '../services/apiClient'
import { formatCurrency } from '../utils/format' import { formatCurrency } from '../utils/format'
import { ArrowLeft, CheckCircle2, Truck, Store } from 'lucide-react' import { ArrowLeft, CheckCircle, Truck } from 'lucide-react'
export function CheckoutPage() { export function CheckoutPage() {
const navigate = useNavigate() const navigate = useNavigate()
@ -38,8 +38,7 @@ export function CheckoutPage() {
async function fetchCompanyAddress() { async function fetchCompanyAddress() {
try { try {
// TODO: Use a proper service for this // TODO: Use a proper service for this
const res = await apiClient.get<any>('/v1/companies/me') const company = await apiClient.get<any>('/v1/companies/me')
const company = res.data
if (company) { if (company) {
setShipping(prev => ({ setShipping(prev => ({
...prev, ...prev,
@ -259,7 +258,7 @@ export function CheckoutPage() {
{/* Payment Method Selection */} {/* Payment Method Selection */}
<div className="rounded-lg bg-white p-6 shadow-sm"> <div className="rounded-lg bg-white p-6 shadow-sm">
<div className="mb-4 flex items-center gap-2"> <div className="mb-4 flex items-center gap-2">
<CheckCircle2 className="h-5 w-5 text-medicalBlue" /> <CheckCircle className="h-5 w-5 text-medicalBlue" />
<h2 className="text-lg font-semibold text-gray-800">Forma de Pagamento</h2> <h2 className="text-lg font-semibold text-gray-800">Forma de Pagamento</h2>
</div> </div>
@ -320,10 +319,11 @@ export function CheckoutPage() {
{Object.entries(groups).map(([vendorId, group]) => ( {Object.entries(groups).map(([vendorId, group]) => (
<div key={vendorId} className="border-b border-gray-100 pb-4 last:border-0 last:pb-0"> <div key={vendorId} className="border-b border-gray-100 pb-4 last:border-0 last:pb-0">
<p className="mb-2 text-sm font-medium text-gray-600">{group.vendorName}</p> <p className="mb-2 text-sm font-medium text-gray-600">{group.vendorName}</p>
<div key={item.id} className="flex justify-between text-sm"> {group.items.map(item => (
<span className="text-gray-800">{item.quantity}x {item.name}</span> <div key={item.id} className="flex justify-between text-sm">
<span className="text-gray-600">R$ {formatCurrency(item.quantity * item.unitPrice)}</span> <span className="text-gray-800">{item.quantity}x {item.name}</span>
</div> <span className="text-gray-600">R$ {formatCurrency(item.quantity * item.unitPrice)}</span>
</div>
))} ))}
{/* Shipping Options for this Vendor */} {/* Shipping Options for this Vendor */}

View file

@ -26,7 +26,7 @@ export interface CalculateShippingResponse {
} }
export const shippingService = { export const shippingService = {
getSettings: async (vendorId: string) => { getSettings: async (vendorId: string): Promise<ShippingSettings> => {
const response = await apiClient.get<ShippingSettings>(`/v1/shipping/settings/${vendorId}`) const response = await apiClient.get<ShippingSettings>(`/v1/shipping/settings/${vendorId}`)
return response return response
}, },