> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wavebybemobi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Iframe

> How to use the web components through iframes

This guide explains how to integrate our web components using iframes. These components are designed to be easily embedded into any web application while maintaining consistent styling and behavior.

## Offers Grid Component

The Offers Grid component displays a collection of offer cards with various layout options and filtering capabilities.

<img src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/offers_grid_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=49aedd215d409f7797b3f41ecbb5bf95" width="1328" height="497" data-path="images/offers_grid_preview.png" />

### Integration

```html theme={null}
<iframe 
  src="https://wave-domain.com/offers?cardType=features&productId=123" 
  width="100%" 
  frameborder="0"
  id="offersGrid">
</iframe>
```

### Query Parameters

| Parameter      | Description                                                  | Example               |
| -------------- | ------------------------------------------------------------ | --------------------- |
| cardType       | Visual style of cards (text, hero, squared, features, topup) | `cardType=features`   |
| page           | Page number for pagination                                   | `page=1`              |
| pageSize       | Number of items per page                                     | `pageSize=12`         |
| productId      | Filter offers by product ID                                  | `productId=123`       |
| salesChannelId | Filter by sales channel                                      | `salesChannelId=456`  |
| billingType    | Filter by billing type (PREPAID/POSTPAID)                    | `billingType=PREPAID` |
| name           | Filter by offer name                                         | `name=Premium`        |
| metadata       | Filter by metadata fields                                    | `metadata.key=value`  |
| orderBy        | Field to sort by (createdAt/name)                            | `orderBy=createdAt`   |
| order          | Sort direction (ASC/DESC)                                    | `order=desc`          |

### Card Types

The component supports different card layouts through the `cardType` parameter:

1. **default**: Standard detailed card with hero, title, description, price, and features

<img id="default-card" src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/default_card_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=d0f0ba102786163cacd8e3369ac80c7c" width="321" height="576" data-path="images/default_card_preview.png" />

2. **text**: Simple text-based card with title and description

<img src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/text_card_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=406432a5f7cf50dd02be7f4a490c5e1a" width="316" height="233" data-path="images/text_card_preview.png" />

3. **hero**: Large card with prominent image

<img src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/hero_card_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=18b8b58f04645950fcca93ee950eea4a" width="666" height="260" data-path="images/hero_card_preview.png" />

4. **squared**: Compact square card with image

<img src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/squared_card_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=6244afe01cf50f4bda7619196a48b9be" width="196" height="196" data-path="images/squared_card_preview.png" />

5. **features**: Detailed card with feature list

<img src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/features_card_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=9301eeb18ee26935de813f13bdf8b60f" width="182" height="154" data-path="images/features_card_preview.png" />

6. **topup**: Special card for top-up offers

<img id="topup-card" src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/topup_card_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=64911746ceb3d3c0e03ab62ef2330c84" width="195" height="144" data-path="images/topup_card_preview.png" />

## Single Offer Card Component

Displays a single offer card using base64 encoded offer data.

### Integration

```html theme={null}
<iframe 
  src="https://wave-domain.com/offers?data=base64EncodedOfferData&cardType=features" 
  width="100%" 
  frameborder="0"
  id="singleOffer">
</iframe>
```

### Offer Object Structure

The offer object should follow this structure before base64 encoding:

```typescript theme={null}
interface Offer {
  id: string;
  name: string;
  description: string;
  billingType: "PREPAID" | "POSTPAID";
  pricing: {
    model: "STANDARD";
    properties: {
      price: string;
      currency: string;
      recurrence: "SPOT" | "DAILY" | "MONTHLY" | "WEEKLY" | "YEARLY";
      payInAdvance: boolean;
    };
  };
  product: {
    id: string;
    name: string;
    description: string;
    metadata: Record<string, string | number | boolean>;
  };
  features: string[];
  metadata: Record<string, string | number | boolean>;
  ctaLink?: string;
  bannerUrl?: string;
}
```

Example usage:

```javascript theme={null}
const offerData = {
  id: "123",
  name: "Premium Package",
  // ... other fields
};
const base64Data = btoa(JSON.stringify(offerData));
const iframeSrc = `https://wave-domain.com/offers?data=${base64Data}&cardType=features`;
```

## Product Page Component

Displays a complete product page with details and associated offers.

### Integration

```html theme={null}
<iframe 
  src="https://wave-domain.com/products/123" 
  width="100%" 
  frameborder="0"
  id="productPage">
</iframe>
```

The product page consists of three main sections:

1. Product Hero - Displays main product information
2. Product Features - Lists product features
3. Product Offers - Shows associated offers

<img className="border-2 border-gray-100 rounded-md" src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/product_page_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=8b25d35612c0868e45be207f49fa5906" width="834" height="901" data-path="images/product_page_preview.png" />

This component automatically fetches and displays all product information and related offers based on the provided product ID in the URL.

## Checkout Component

The Checkout component provides a complete purchase flow for offers. It can be integrated into any web application and maintains communication with the parent window for dynamic height adjustment.

### Integration

```html theme={null}
<iframe 
  src="https://wave-domain.com/offers/checkout/123" 
  width="100%" 
  frameborder="0"
  id="checkoutFlow">
</iframe>
```

### Component Flow

The checkout process consists of three main states:

1. Initial verification (required only when user is not logged in)
2. Order confirmation
3. Success message

#### Summary View

The summary view displays the offer details and purchase confirmation:

<img src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/checkout_summary_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=f8fc7f5478807ed298421aeed1e78abc" width="1340" height="571" data-path="images/checkout_summary_preview.png" />

#### Success View

After successful purchase, the component displays a confirmation message:

<img src="https://mintcdn.com/wavebybemobi/Si8KBvlATkRLVFU0/images/checkout_success_preview.png?fit=max&auto=format&n=Si8KBvlATkRLVFU0&q=85&s=7f214e6e70cd276c1e51c776e49c8927" width="1335" height="431" data-path="images/checkout_success_preview.png" />

### Offer Display in Checkout

The checkout component uses two specialized card types for displaying offer details:

* [Default Card](/offers_sdk/iframe#default-card)
* [Topup Card](/offers_sdk/iframe#topup-card)

### Integration with Offers

The checkout component can be accessed in several ways:

1. **From Offer Cards**: When users click the CTA button on any offer card, they are directed to the checkout flow for that specific offer.

2. **Direct URL**: Using the offer ID in the URL: `/offers/checkout/{offerId}`

3. **From Product Pages**: When browsing product offers, the CTA buttons link to the checkout component.

## Dynamic Height Adjustment

All components emit a `postMessage` event containing the scroll height. This allows for dynamic iframe height adjustment to prevent unwanted scrollbars.

```javascript theme={null}
window.addEventListener('message', function(e) {
  if (e.data && e.data.scrollHeight) {
    const iframe = document.querySelector('#myIframe');
    iframe.style.height = `${e.data.scrollHeight}px`;
  }
});
```

The component sends height updates on:

* Initial load
* State changes
* Content updates
* Error messages display

Remember to implement the height adjustment listener for all iframe integrations to ensure proper display without scrollbars.
