Add order validation for subscription packs and update display message
This commit is contained in:
parent
646c399ae9
commit
1e258e4db0
@ -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() {
|
||||
<div className="mt-4 rounded-md border border-gray-200 bg-white/90 p-4">
|
||||
<div className="flex items-center justify-between gap-2 flex-wrap mb-3">
|
||||
<h3 className="text-sm font-semibold text-gray-900">{t('autofix.ke24abf9c')}</h3>
|
||||
<p className="text-xs text-gray-600">Selected packs: {draftTotalPacks} (minimum 6)</p>
|
||||
<p className="text-xs text-gray-600">Selected: {draftTotalPacks} packs ({packsToCapsules(draftTotalPacks)} capsules) · minimum 6 packs</p>
|
||||
</div>
|
||||
|
||||
{coffeesLoading ? (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user