Skip to content

Commit

Permalink
feat: add shopping cart validations and translations
Browse files Browse the repository at this point in the history
  • Loading branch information
brolag committed Feb 23, 2025
1 parent 20ba395 commit 0de1b51
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion apps/web/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,5 +349,6 @@
"share_product": "Share product",
"farm_details": "Farm details",
"no_favorite_products": "No favorite products yet",
"click_to_upload": "Click to upload"
"click_to_upload": "Click to upload",
"no_collectibles_found": "No collectibles found"
}
3 changes: 2 additions & 1 deletion apps/web/public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,6 @@
"share_product": "Compartir producto",
"farm_details": "Detalles de la granja",
"no_favorite_products": "Aún no hay productos favoritos",
"click_to_upload": "Haz clic para subir"
"click_to_upload": "Haz clic para subir",
"no_collectibles_found": "No se encontraron coleccionables"
}
3 changes: 2 additions & 1 deletion apps/web/public/locales/pt/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,6 @@
"total": "Total",
"checkout": "Finalizar compra"
},
"click_to_upload": "Clique para fazer upload"
"click_to_upload": "Clique para fazer upload",
"no_collectibles_found": "Nenhum colecionável encontrado"
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@ export default function OrderReview({
<Button
onClick={() => setIsCurrencySelectorOpen(true)}
className="w-full bg-white border border-gray-300 text-black mt-6 h-14"
disabled={isProcessing}
disabled={isProcessing || cartItems.length === 0}
>
{t("change_currency")}
</Button>

<Button
onClick={handleProceedToPayment}
className="w-full bg-yellow-400 hover:bg-yellow-500 text-black mt-6 h-14"
disabled={isProcessing}
className={`w-full bg-yellow-400 hover:bg-yellow-500 text-black mt-6 h-14 ${cartItems.length === 0 ? "opacity-50 cursor-not-allowed" : ""}`}
disabled={isProcessing || cartItems.length === 0}
>
{isProcessing ? t("processing_payment") : t("proceed_to_payment")}
</Button>
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/app/shopping-cart/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ export default function ShoppingCart() {
<button
type="button"
onClick={() => handleCheckout()}
className="w-full py-3.5 px-4 bg-surface-secondary-default rounded-lg border border-surface-secondary-defaul flex justify-center items-center"
className={`w-full py-3.5 px-4 bg-surface-secondary-default rounded-lg border border-surface-secondary-defaul flex justify-center items-center ${!hasItems ? "opacity-50 cursor-not-allowed" : ""}`}
disabled={!hasItems}
>
<span className="text-[#1F1F20] text-base font-normal">
{t("buy_button")}
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/cartSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export function CartSidebar({
<Button
variant="primary"
onClick={onCheckout}
className="w-full h-12 text-base font-semibold"
className={`w-full h-12 text-base font-semibold ${!basePrice || basePrice <= 0 ? "opacity-50 cursor-not-allowed" : ""}`}
disabled={!basePrice || basePrice <= 0}
>
{checkoutLabel}
</Button>
Expand Down

0 comments on commit 0de1b51

Please sign in to comment.