View Order Block
The ViewOrder Component is a fully customizable order display component built with TypeScript. It provides a complete interface for viewing order details including status, order information, images, and customizable information rows with modern design patterns.
π Installationβ
npm install @nodeblocks/frontend-view-order-block
π Usageβ
import {ViewOrder} from '@nodeblocks/frontend-view-order-block';
- Basic Usage
- Advanced Usage
function BasicViewOrder() { const orderInfoRows = [ { label: 'Order ID', value: '#12345' }, { label: 'Customer', value: 'John Doe' }, { label: 'Date', value: '2024-01-15' }, { label: 'Total', value: '$199.99' } ]; return ( <ViewOrder headerLabel="" statusText="Processing" statusLabel="Current Status" titleLabel="" titleText="Premium Product Package" titleLink="#orders/12345" imageSrc="/img/icon.png" infoRows={orderInfoRows}> <ViewOrder.Header /> <ViewOrder.DetailsRow /> <ViewOrder.InfoRowList /> </ViewOrder> ); }
function AdvancedViewOrder() { const orderInfoRows = [ { label: 'π¦ Order ID', value: ( <span style={{ fontFamily: 'monospace', background: 'rgba(105, 124, 213, 0.1)', padding: '4px 8px', borderRadius: '6px', fontWeight: 'bold', }} > #ORD-2024-789 </span> ), }, { label: 'π€ Customer', value: ( <div style={{ display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap', }} > <div style={{ width: '32px', height: '32px', borderRadius: '50%', background: 'linear-gradient(135deg, rgb(105, 124, 213), rgb(85, 104, 193))', display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'white', fontSize: '14px', fontWeight: 'bold', }} > JD </div> <span style={{ fontWeight: '600', color: '#2c3e50', fontSize: '16px', }} > John Doe </span> </div> ), }, { label: 'π Order Date', value: ( <div style={{ background: 'linear-gradient(135deg, #e8f5e8, #f0f8f0)', padding: '8px 12px', borderRadius: '8px', border: '1px solid #4CAF50', color: '#2e7d32', fontWeight: 'bold', }} > January 15, 2024 </div> ), }, { label: 'π° Total Amount', value: ( <div style={{ fontSize: '24px', fontWeight: 'bold', color: '#27ae60', textShadow: '0 2px 4px rgba(39, 174, 96, 0.2)', }} > $1,299.99 </div> ), }, { label: 'π Shipping Address', value: ( <div style={{ background: 'rgba(52, 152, 219, 0.1)', padding: '12px', borderRadius: '8px', border: '1px solid #3498db', }} > <div style={{ fontWeight: 'bold', color: '#2980b9', fontSize: '16px', }} > Tokyo Office </div> <div style={{ fontSize: '14px', color: '#7f8c8d', marginTop: '4px', lineHeight: '1.4', }} > 1-1-1 Shibuya, Shibuya-ku </div> </div> ), }, { label: 'π Items', value: ( <div style={{display: 'flex', flexDirection: 'column', gap: '8px'}}> <div style={{ background: 'white', padding: '8px 12px', borderRadius: '6px', border: '1px solid rgba(105, 124, 213, 0.2)', display: 'flex', justifyContent: 'space-between', alignItems: 'center', }} > <span>π» MacBook Pro 16"</span> <span style={{fontWeight: 'bold', color: 'rgb(105, 124, 213)'}}>Γ1</span> </div> <div style={{ background: 'white', padding: '8px 12px', borderRadius: '6px', border: '1px solid rgba(105, 124, 213, 0.2)', display: 'flex', justifyContent: 'space-between', alignItems: 'center', }} > <span>β¨οΈ Magic Keyboard</span> <span style={{fontWeight: 'bold', color: 'rgb(105, 124, 213)'}}>Γ1</span> </div> </div> ), }, ]; return ( <ViewOrder headerLabel="π― Order #1" statusText="β Delivered" statusLabel="π Status" titleLabel="π·οΈ Order Details" titleText="Enterprise Technology Package" titleLink="#orders/ORD-2024-789" imageSrc="/img/icon.png" infoRows={orderInfoRows} > {({defaultBlocks, defaultBlockOrder}) => ({ blocks: { // Enhanced header with modern styling header: { ...defaultBlocks.header, props: { ...defaultBlocks.header.props, style: { background: 'rgba(255, 255, 255, 0.4)', color: 'black', padding: '32px', borderRadius: '20px 20px 0 0', marginBottom: '0', boxShadow: '0 -4px 20px rgba(0,0,0,0.1)', }, }, }, detailsRow: ( <> <div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', gap: '16px', }} > <ViewOrder.Title style={{fontSize: '22px', width: '100%'}} /> </div> <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'rgba(255, 255, 255, 0.4)', padding: '20px', border: '1px solid rgba(255, 255, 255, 0.6)', backdropFilter: 'blur(5px)', boxShadow: '0 -4px 20px rgba(0,0,0,0.1)', marginBottom: '20px', }} > <ViewOrder.Image style={{width: '100%', height: '100%', objectFit: 'contain'}} /> </div> </> ), status: { ...defaultBlocks.status, props: { ...defaultBlocks.status.props, style: { background: 'rgba(255, 255, 255, 0.95)', padding: '16px 24px', borderRadius: '50px', display: 'inline-flex', alignItems: 'center', gap: '12px', boxShadow: '0 -4px 20px rgba(0,0,0,0.1)', border: '2px solid #4CAF50', fontWeight: 'bold', fontSize: '16px', }, }, }, // Enhanced title styling title: { ...defaultBlocks.title, props: { ...defaultBlocks.title.props, style: { fontSize: '28px', fontWeight: 'bold', color: 'white', textDecoration: 'none', textShadow: '0 2px 4px rgba(0,0,0,0.3)', transition: 'all 0.3s ease', lineHeight: '1.2', }, }, }, // Enhanced image optimized for details row integration image: { ...defaultBlocks.image, props: { ...defaultBlocks.image.props, }, }, // Enhanced info row list with card layout infoRowList: { ...defaultBlocks.infoRowList, props: { ...defaultBlocks.infoRowList.props, style: { background: 'white', padding: '32px', borderRadius: '0 0 20px 20px', display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: '24px', boxShadow: '0 -4px 20px rgba(0,0,0,0.1)', }, }, }, }, blockOrder: defaultBlockOrder, })} </ViewOrder> ); }
π§ Props Referenceβ
Main Component Propsβ
Prop | Type | Default | Description |
---|---|---|---|
headerLabel | string | undefined | Label text for the order header section |
statusText | string | undefined | Text content for the order status display |
statusLabel | string | undefined | Label text for the status field |
titleLabel | string | undefined | Label text for the order title field |
titleText | string | undefined | Text content for the order title |
titleLink | string | undefined | URL link for the order title |
imageSrc | string | undefined | Source URL for the order image |
infoRows | Array<{label: string, value: ReactNode}> | undefined | Array of information rows to display |
className | string | undefined | Additional CSS class name for styling the container |
children | BlocksOverride | undefined | Custom block components to override default rendering |
Note: This component inherits all HTML div
element props.
Sub-Componentsβ
The ViewOrder component provides several sub-components for different sections. All sub-components receive their default values from the main component's context and can override these values through props.
ViewOrder.Headerβ
Container for the order header including title and status information.
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | From context | Custom content to override default header content |
className | string | undefined | Additional CSS class name for styling |
Note: This component inherits all HTML div
element props.
ViewOrder.DetailsRowβ
Container for the main order details including title and image.
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | From context | Custom content to override default details row content |
className | string | undefined | Additional CSS class name for styling |
Note: This component inherits all HTML div
element props.
ViewOrder.Statusβ
Displays the order status information.
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | From context | Custom content to override default status content |
className | string | undefined | Additional CSS class name for styling |
Note: This component inherits all HTML div
element props.
ViewOrder.Titleβ
Displays the order title as a clickable link.
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | From context | Custom content to override default title content |
className | string | undefined | Additional CSS class name for styling |
Note: This component inherits all HTML a
element props.
ViewOrder.Imageβ
Displays the order image.
Prop | Type | Default | Description |
---|---|---|---|
className | string | undefined | Additional CSS class name for styling |
src | string | From context | Source URL for the order image |
Note: This component inherits all HTML img
element props.
ViewOrder.InfoRowβ
Displays a single information row with label and value.
Prop | Type | Default | Description |
---|---|---|---|
label | ReactNode | Required | Label content for the information row |
value | ReactNode | Required | Value content for the information row |
className | string | undefined | Additional CSS class name for styling |
Note: This component inherits all HTML div
element props.
ViewOrder.InfoRowListβ
Container that displays multiple information rows from the infoRows array.
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | From context | Custom content to override default info rows rendering |
className | string | undefined | Additional CSS class name for styling |
Note: This component inherits all HTML div
element props.
π§ TypeScript Supportβ
Full TypeScript support with comprehensive type definitions:
import ViewOrder from '@nodeblocks/frontend-view-order-block';
import { ReactNode } from 'react';
interface OrderInfoRow {
label: string;
value: ReactNode;
}
interface ViewOrderProps {
headerLabel?: string;
statusText?: string;
statusLabel?: string;
titleLabel?: string;
titleText?: string;
titleLink?: string;
imageSrc?: string;
infoRows?: OrderInfoRow[];
className?: string;
children?: ReactNode;
}
interface CustomOrderData {
orderId: string;
customerName: string;
status: 'pending' | 'processing' | 'shipped' | 'delivered' | 'cancelled';
total: number;
items: {
id: string;
name: string;
quantity: number;
price: number;
}[];
shippingAddress: {
street: string;
city: string;
country: string;
};
}
const OrderDetailsView = () => {
const orderData: CustomOrderData = {
orderId: 'ORD-2024-001',
customerName: 'John Doe',
status: 'processing',
total: 299.99,
items: [
{ id: '1', name: 'Premium Headphones', quantity: 1, price: 199.99 },
{ id: '2', name: 'USB Cable', quantity: 2, price: 50.00 }
],
shippingAddress: {
street: '123 Main St',
city: 'New York',
country: 'USA'
}
};
const orderInfoRows: OrderInfoRow[] = [
{ label: 'Order ID', value: orderData.orderId },
{ label: 'Customer', value: orderData.customerName },
{ label: 'Total Amount', value: `$${orderData.total}` },
{ label: 'Items Count', value: orderData.items.length },
{
label: 'Shipping Address',
value: `${orderData.shippingAddress.street}, ${orderData.shippingAddress.city}, ${orderData.shippingAddress.country}`
}
];
return (
<ViewOrder
headerLabel="Order Information"
statusText={orderData.status.charAt(0).toUpperCase() + orderData.status.slice(1)}
statusLabel="Current Status"
titleLabel="Order Details"
titleText={`Order ${orderData.orderId}`}
titleLink={`/orders/${orderData.orderId}`}
imageSrc="/order-preview.jpg"
infoRows={orderInfoRows}
className="custom-order-view">
<ViewOrder.Header />
<ViewOrder.DetailsRow />
<ViewOrder.InfoRowList />
</ViewOrder>
);
};
Built with β€οΈ using React, TypeScript, and modern web standards.