import { FetchStateAndError, ID } from '../../../commonStateTypes/common'; import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport'; import { InvoicingCoupon } from '../../../entity/invoicing/coupon/couponState'; import { InvoicingFieldHelpByCode, InvoicingNamedOption, InvoicingSubscriptionLifecycleActionOption } from '../../../entity/invoicing/invoicingCommonPayload'; import { InvoicingCustomer } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerState'; import { InvoicingSubscription } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionState'; import { InvoicingProduct } from '../../../entity/invoicing/product/productState'; import { RootState } from '../../../rootStateTypes'; import { InvoicingSubscriptionFormLocalData } from './editInvoicingSubscriptionDetailViewState'; /** * Bundled view for the subscription create/edit form's save concern: the save * fetch state/error, the id of the subscription last saved, and — when an * `invoicingSubscriptionID` is passed (edit mode) — the existing subscription to * prefill the form. */ export interface EditInvoicingSubscriptionDetailView extends SelectorView { /** Config-owned; folded in so the screen reads one selector. */ subscriptionCommercialEditAllowedFromStatuses: string[]; subscriptionLifecycleActionOptions: InvoicingSubscriptionLifecycleActionOption[]; subscriptionMetadataEditAllowedFromStatuses: string[]; savedSubscriptionId?: ID; subscription?: InvoicingSubscription; } /** * The full data the subscription form screen needs in one selector: the draft * `localData` (seeded from the existing subscription in edit mode until the user * edits), the shipping-address label (from the shared Address screen), the * canonical billing-frequency value set, the raw option lists (customers, plans, * products, coupons), and the save state. The screen maps the raw lists/values * to its own option shapes, so this stays free of any web-components dependency. */ export interface InvoicingSubscriptionFormView extends SelectorView { /** Lifecycle action in flight, folded in from the record view. */ actionState: FetchStateAndError; /** Cancel reasons from `/1.0/config`, so the dialog hardcodes nothing. */ cancelReasonCodeOptions: InvoicingNamedOption[]; coupons: InvoicingCoupon[]; customers: InvoicingCustomer[]; /** * Backend help copy for this screen's field group, keyed by field code. * Folded in here so the screen never reaches for the config view itself. */ fieldHelp: InvoicingFieldHelpByCode; localData: InvoicingSubscriptionFormLocalData; mode: 'create' | 'edit'; /** * Loading the subscription, as distinct from this view's own `fetchState`, * which tracks the save. Folded in so a screen reads one selector. */ /** * Every request the page renders from, reduced to one state: the record and * the config behind its dropdowns, cancel reasons and field help. The page * holds a skeleton until this is `Completed`, so the form mounts once with * real values. */ pageFetchState: FetchStateAndError; plans: InvoicingProduct[]; products: InvoicingProduct[]; recordState: FetchStateAndError; /** Config-owned edit/lifecycle rules, folded in so the screen reads one selector. */ subscriptionCommercialEditAllowedFromStatuses: string[]; subscriptionLifecycleActionOptions: InvoicingSubscriptionLifecycleActionOption[]; subscriptionMetadataEditAllowedFromStatuses: string[]; savedSubscriptionId?: ID; shippingAddressLabel?: string; subscription?: InvoicingSubscription; } export declare const getEditInvoicingSubscriptionDetailViewState: (state: RootState, invoicingSubscriptionID?: ID) => EditInvoicingSubscriptionDetailView; export declare const getInvoicingSubscriptionFormView: (state: RootState, invoicingSubscriptionID?: ID) => InvoicingSubscriptionFormView;