Hide payment steps from the admin order status modal.
Admins can only choose fulfillment steps; payment status stays gateway-driven. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
c59ca4444f
commit
016dd0b081
@@ -5,6 +5,17 @@
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.paymentHint {
|
||||
margin: 0 0 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: rgba(var(--primary-rgb) / 0.06);
|
||||
border: 1px solid rgba(var(--primary-rgb) / 0.18);
|
||||
color: var(--text-muted);
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.stepOption {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -6,7 +6,10 @@ import { useToast } from '../context/ToastContext'
|
||||
import { useT } from '../i18n/useT'
|
||||
import { ApiError } from '../lib/api'
|
||||
import { updateOrder, type Order } from '../services/orderService'
|
||||
import type { OrderProcessStep } from '../services/settingsService'
|
||||
import {
|
||||
isSystemPaymentProcessStep,
|
||||
type OrderProcessStep,
|
||||
} from '../services/settingsService'
|
||||
import { defaultStepColorForId, normalizeStepColor, stepBadgeStyle } from '../utils/stepColors'
|
||||
import modalStyles from './VariationsModal.module.css'
|
||||
import styles from './OrderStepModal.module.css'
|
||||
@@ -71,6 +74,7 @@ export function OrderStepModal({
|
||||
|
||||
async function handleSelectStep(stepId: string) {
|
||||
if (!order || savingStepId) return
|
||||
if (isSystemPaymentProcessStep(stepId)) return
|
||||
|
||||
if (stepId === order.processStepId) {
|
||||
onClose()
|
||||
@@ -104,6 +108,8 @@ export function OrderStepModal({
|
||||
order.processStepLabel?.trim() ||
|
||||
currentStep?.label ||
|
||||
order.processStepId
|
||||
const selectableSteps = steps.filter((step) => !isSystemPaymentProcessStep(step.id))
|
||||
const paymentIsCurrent = isSystemPaymentProcessStep(order.processStepId)
|
||||
|
||||
return createPortal(
|
||||
<div
|
||||
@@ -151,8 +157,12 @@ export function OrderStepModal({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{paymentIsCurrent && (
|
||||
<p className={styles.paymentHint}>{t('orderStep.paymentHint')}</p>
|
||||
)}
|
||||
|
||||
<div className={styles.stepList} role="listbox" aria-label={t('orderStep.listAria')}>
|
||||
{steps.map((step, index) => {
|
||||
{selectableSteps.map((step, index) => {
|
||||
const selected = order.processStepId === step.id
|
||||
const saving = savingStepId === step.id
|
||||
const color = normalizeStepColor(step.color, defaultStepColorForId(step.id, index))
|
||||
@@ -178,7 +188,7 @@ export function OrderStepModal({
|
||||
})}
|
||||
</div>
|
||||
|
||||
{!steps.length && (
|
||||
{!selectableSteps.length && (
|
||||
<p className={styles.emptyText}>{t('orderStep.empty')}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1270,6 +1270,8 @@ const en = {
|
||||
'orderStep.empty': 'No order steps configured. Add steps in Store settings first.',
|
||||
'orderStep.updated': 'Order {orderNumber} step updated.',
|
||||
'orderStep.error': 'Unable to update order step.',
|
||||
'orderStep.paymentHint':
|
||||
'Payment status is set automatically by the payment gateway. Choose a fulfillment step below.',
|
||||
|
||||
'orderItems.title': 'Order items',
|
||||
'orderItems.customer': 'Customer',
|
||||
@@ -4143,6 +4145,8 @@ const fa: Record<MessageKey, string> = {
|
||||
'orderStep.empty': 'وضعیتی تعریف نشده است. ابتدا در تنظیمات فروشگاه وضعیتها را اضافه کنید.',
|
||||
'orderStep.updated': 'وضعیت سفارش {orderNumber} بهروزرسانی شد.',
|
||||
'orderStep.error': 'بهروزرسانی وضعیت سفارش ممکن نشد.',
|
||||
'orderStep.paymentHint':
|
||||
'وضعیت پرداخت فقط توسط درگاه پرداخت بهصورت خودکار تنظیم میشود. یکی از وضعیتهای آمادهسازی را انتخاب کنید.',
|
||||
|
||||
'orderItems.title': 'اقلام سفارش',
|
||||
'orderItems.customer': 'مشتری',
|
||||
|
||||
@@ -146,6 +146,16 @@ export interface SettingsResponse {
|
||||
settings: BusinessSettings
|
||||
}
|
||||
|
||||
/** Set by payment gateway only — not selectable in admin status change. */
|
||||
export const SYSTEM_PAYMENT_PROCESS_STEP_IDS = [
|
||||
'awaiting-payment',
|
||||
'payment-successful',
|
||||
] as const
|
||||
|
||||
export function isSystemPaymentProcessStep(stepId: string): boolean {
|
||||
return (SYSTEM_PAYMENT_PROCESS_STEP_IDS as readonly string[]).includes(stepId)
|
||||
}
|
||||
|
||||
export const DEFAULT_ORDER_PROCESS_STEPS: OrderProcessStep[] = [
|
||||
{
|
||||
id: 'awaiting-payment',
|
||||
|
||||
Reference in New Issue
Block a user