/** * Reusable notice listing what must be completed before booking (store, customer address, item weights). * Renders as a list for clarity. Use on landing, order ship page, and service-quotes. */ import { __ } from '@wordpress/i18n'; import { Notice, Icon } from '@wordpress/components'; import { cautionFilled } from '@wordpress/icons'; import type { InternationalMissing } from '../utils'; export interface BookingPrereqsNoticeProps { /** Missing store/collection address fields (e.g. from validateAddresses). */ storeMissing: string[]; /** Missing customer/shipping address fields (e.g. from validateAddresses). */ customerMissing: string[]; /** When delivery is international: grouped by Settings vs products (link shown in front of each group). */ internationalMissing?: InternationalMissing | null; /** Whether every order line item has a weight (only relevant when orderId is set). */ orderHasWeight: boolean; /** Order ID for "edit order" links; null when there is no order (e.g. landing page). */ orderId: number | null; /** URL to the plugin settings page. */ settingsUrl: string; /** Function to build the WooCommerce edit-order URL. Omit when orderId is null (e.g. landing page). */ getEditOrderUrl?: (orderId: number) => string; } const emptyInternational: InternationalMissing = { settings: [], products: [] }; export default function BookingPrereqsNotice({ storeMissing, customerMissing, internationalMissing = emptyInternational, orderHasWeight, orderId, settingsUrl, getEditOrderUrl, }: BookingPrereqsNoticeProps) { const hasStoreIssues = storeMissing.length > 0; const hasCustomerIssues = customerMissing.length > 0; const intl = internationalMissing ?? emptyInternational; const hasInternationalSettings = intl.settings.length > 0; const hasInternationalProducts = intl.products.length > 0; const hasWeightIssues = orderId != null && !orderHasWeight; const items: React.ReactNode[] = []; const listItemStyle = { display: 'flex', alignItems: 'flex-start', gap: 8, marginBottom: 4 }; if (hasStoreIssues) { items.push(