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 { useActiveCoffees } from '../../coffee-abonnements/hooks/getActiveCoffees'
|
||||||
import { changeSubscriptionStatus, editSubscriptionContent } from '../hooks/editAbo'
|
import { changeSubscriptionStatus, editSubscriptionContent } from '../hooks/editAbo'
|
||||||
import ConfirmActionModal from '../../components/modals/ConfirmActionModal'
|
import ConfirmActionModal from '../../components/modals/ConfirmActionModal'
|
||||||
|
import { getOrderPackError, packsToCapsules } from '../../coffee-abonnements/lib/orderRules'
|
||||||
|
|
||||||
type UiLifecycleStatus = 'issued' | 'ongoing' | 'finished' | 'pause' | 'cancelled'
|
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.')
|
setContentError('Please select at least one coffee with quantity greater than 0.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (draftTotalPacks < 6) {
|
const orderPackError = getOrderPackError(draftTotalPacks)
|
||||||
setContentError('Total must be at least 6 packs (60 capsules).')
|
if (orderPackError) {
|
||||||
|
setContentError(orderPackError)
|
||||||
return
|
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="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">
|
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
{coffeesLoading ? (
|
{coffeesLoading ? (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user