barsa d5ad8d3448 Remove Checkout Registration Module and Simplify Checkout Flow
- Deleted the CheckoutRegistrationModule and its associated components, streamlining the checkout process to require user authentication before proceeding.
- Updated the app.module.ts and router.config.ts to remove references to the CheckoutRegistrationModule.
- Refactored the checkout flow to utilize the AccountCheckoutContainer for handling user registration and checkout in a single-page flow.
- Enhanced the checkout store to eliminate guest info and registration states, focusing solely on authenticated user data.
- Standardized order types to PascalCase across the application for consistency.
- Updated relevant schemas and documentation to reflect the removal of guest checkout and the new authentication-first approach.
2025-12-23 13:21:29 +09:00

83 lines
2.7 KiB
TypeScript

/**
* Checkout Domain - Schemas
*
* Zod validation schemas for checkout flow.
* Supports authenticated checkout.
*/
import { z } from "zod";
// ============================================================================
// Order Type Schema
// ============================================================================
/**
* Checkout order types - uses PascalCase to match Salesforce/BFF contracts
* @see packages/domain/orders/contract.ts ORDER_TYPE for canonical values
*/
export const checkoutOrderTypeSchema = z.enum(["Internet", "SIM", "VPN"]);
/**
* @deprecated Use checkoutOrderTypeSchema instead. This alias exists for backwards compatibility.
*/
export const orderTypeSchema = checkoutOrderTypeSchema;
// ============================================================================
// Order Type Helpers
// ============================================================================
/**
* Convert legacy uppercase order type to PascalCase
* Used for migrating old localStorage data
*/
export function normalizeOrderType(value: string): z.infer<typeof checkoutOrderTypeSchema> | null {
const upper = value.toUpperCase();
switch (upper) {
case "INTERNET":
return "Internet";
case "SIM":
return "SIM";
case "VPN":
return "VPN";
default:
return null;
}
}
// ============================================================================
// Price Breakdown Schema
// ============================================================================
export const priceBreakdownItemSchema = z.object({
label: z.string(),
sku: z.string().optional(),
monthlyPrice: z.number().optional(),
oneTimePrice: z.number().optional(),
quantity: z.number().optional().default(1),
});
// ============================================================================
// Cart Item Schema
// ============================================================================
export const cartItemSchema = z.object({
orderType: orderTypeSchema,
planSku: z.string().min(1, "Plan SKU is required"),
planName: z.string().min(1, "Plan name is required"),
addonSkus: z.array(z.string()).default([]),
configuration: z.record(z.string(), z.unknown()).default({}),
pricing: z.object({
monthlyTotal: z.number().nonnegative(),
oneTimeTotal: z.number().nonnegative(),
breakdown: z.array(priceBreakdownItemSchema).default([]),
}),
});
// ============================================================================
// Inferred Types
// ============================================================================
export type OrderType = z.infer<typeof orderTypeSchema>;
export type PriceBreakdownItem = z.infer<typeof priceBreakdownItemSchema>;
export type CartItem = z.infer<typeof cartItemSchema>;