From 1e258e4db09a6c46e536e7a98cfe65446ead970d Mon Sep 17 00:00:00 2001 From: seaznCode Date: Tue, 5 May 2026 22:11:18 +0200 Subject: [PATCH] Add order validation for subscription packs and update display message --- src/app/profile/subscriptions/page.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/profile/subscriptions/page.tsx b/src/app/profile/subscriptions/page.tsx index 228b9f8..8e3fec2 100644 --- a/src/app/profile/subscriptions/page.tsx +++ b/src/app/profile/subscriptions/page.tsx @@ -13,6 +13,7 @@ import FinanceInvoices from '../components/financeInvoices' import { useActiveCoffees } from '../../coffee-abonnements/hooks/getActiveCoffees' import { changeSubscriptionStatus, editSubscriptionContent } from '../hooks/editAbo' import ConfirmActionModal from '../../components/modals/ConfirmActionModal' +import { getOrderPackError, packsToCapsules } from '../../coffee-abonnements/lib/orderRules' type UiLifecycleStatus = 'issued' | 'ongoing' | 'finished' | 'pause' | 'cancelled' @@ -157,8 +158,9 @@ export default function ProfileSubscriptionsPage() { setContentError('Please select at least one coffee with quantity greater than 0.') return } - if (draftTotalPacks < 6) { - setContentError('Total must be at least 6 packs (60 capsules).') + const orderPackError = getOrderPackError(draftTotalPacks) + if (orderPackError) { + setContentError(orderPackError) return } @@ -425,7 +427,7 @@ export default function ProfileSubscriptionsPage() {

{t('autofix.ke24abf9c')}

-

Selected packs: {draftTotalPacks} (minimum 6)

+

Selected: {draftTotalPacks} packs ({packsToCapsules(draftTotalPacks)} capsules) ยท minimum 6 packs

{coffeesLoading ? (