# Quest List Component

## Components Visuals &#x20;

{% tabs %}
{% tab title="Visual 1" %}

<figure><img src="https://1173113760-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYEKIeE9xnHLXuuwEs8zo%2Fuploads%2Fp9AVYbmLT4eLZWHsqOUd%2FTask%20list.png?alt=media&#x26;token=e6543f2c-5ffe-4cf4-bac4-2e3e53cbc7d5" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
To unlock early access to the component                                                           [**Get Access**](https://bijfwfnqtsj.typeform.com/to/eUXDpbuh)
{% endhint %}

## Installation

To install the `Quest react-native-sdk` into your project, follow these steps:

* Open your terminal/command prompt.
* Navigate to your project's root directory using the `cd` command if you're not already there.
* Run the following command to install the `quest-sdk` package using npm:

```jsx
npm install @questlabs/react-native-sdk
```

> This command will download and install the package and its dependencies into your project.

{% hint style="info" %}
Make sure your project has npm and Node.js installed, and that you have the necessary permissions to install packages in your project directory.
{% endhint %}

## Usage

### Root Component

* **Import the QuestProvider Component**: Import the `QuestProvider` component from the `@questlabs/react-sdk` package.

```jsx
import { QuestProvider } from '@questlabs/react-sdk';
```

* **Pass the Required Props**:  Pass the required props to the `QuestProvider`. The required props are `apiKey`,  `entityId,` `authenticationToken` and `fontFamily.`

{% hint style="info" %}
To load external fonts, please refer this doc to setup [expo-font](https://docs.expo.dev/versions/latest/sdk/font/) on your expo app.
{% endhint %}

### Component Usage

To integrate the `QuestList` component into your React native application, follow these steps.

* **Import useQuestList Hook:** Import the `useQuestList` component from the `@questlabs/react-sdk` package.
* **Import the QuestList Component**: Import the `QuestList` component from the `@questlabs/react-sdk` package.
* **Pass the Required Props**:  Pass the required props to the `useQuestList` .  The required props are `questId`, `questUserId`, and `userToken` or if user don't have quest User id then they  can pass own userId to get questUserId and Token.&#x20;

```typescript
import { useQuestList , QuestList } from "@questlabs/react-native-sdk";
```

{% hint style="info" %}
Don't not use QuestProvider and useQuestList Hook in same file
{% endhint %}

## Props of QuestList Component

The QuestList  component accepts the following props

<table><thead><tr><th width="192">Props Name</th><th width="126">Type</th><th width="106">Require</th><th>Details</th></tr></thead><tbody><tr><td>questId</td><td>string</td><td>optional</td><td>The unique identifier for the tutorial or quest.</td></tr><tr><td>questUserId</td><td>string</td><td>optional</td><td>The unique identifier of the user.</td></tr><tr><td>userToken</td><td>string</td><td>optional</td><td>An authentication token or API key necessary for accessing tutorial or quest data.</td></tr><tr><td> onClose</td><td>Function</td><td>optional</td><td>Create the function for onClose.</td></tr><tr><td>isModal</td><td>boolean</td><td>optional</td><td>Open as Modal.</td></tr><tr><td>actions</td><td>ICriteria[]</td><td>Require</td><td>In offline user need to provide the require filed data.</td></tr><tr><td>loading</td><td>boolean</td><td>optional</td><td>don't use in offline mode.</td></tr><tr><td>title</td><td>string</td><td>Require</td><td>Component title.</td></tr><tr><td>description</td><td>string</td><td>Require</td><td>Component Descroption.</td></tr><tr><td>onClick</td><td>Funtion</td><td>optional</td><td>when it offline the create own Funtion.</td></tr><tr><td>isOffline</td><td>boolean</td><td>optional</td><td>for verification.</td></tr><tr><td>campaignVariationId</td><td>string</td><td>optional</td><td>Id For verification.</td></tr><tr><td>onError</td><td>Function</td><td>optional</td><td>For Showing the Error.</td></tr><tr><td>showFooter </td><td>boolean</td><td>optional</td><td>user Want to show the footer or not</td></tr><tr><td>styleConfig</td><td>object</td><td>optional</td><td>An object containing Styling properties for styling various components within the get started process, including form, topbar, headings, descriptions,  and buttons.</td></tr></tbody></table>

## Style Props

```typescript
styleConfig {
  Form?: ViewStyle;
  Heading?: TextStyle;
  Description?: TextStyle;
  Footer?: {
    FooterStyle?: ViewStyle;
    FooterText?: TextStyle;
    FooterIcon?: TextStyle;
  };
  Card?: {
    title?: TextStyle;
    description?: TextStyle;
    stepText?: TextStyle;
  };
  TopBar?: ViewStyle;
}
```

### Example Usage

**App.js**

```typescript
import { SafeAreaView, StyleSheet, StatusBar } from "react-native";
import React, { useState } from "react";
import { QuestProvider } from "@questlabs/react-native-sdk";
import DemoComponent from "./DemoComponent";

export default function App() {
return (
    <SafeAreaView style={styles.container}>
      <StatusBar />
      <QuestProvider
        apiKey="Your-Api-Key"
        apiSecret="Your-Api-Secret"
        entityId="Your-Api-entityId"
        authenticationToken="Your-authentication-token" 
         fontFamily= "Your-Font-FamFamily"
         >
        
        <DemoComponent />
        
        </QuestProvider>
   
    </SafeAreaView>
  );
}
```

**DemoComponent.tsx**

```typescript
import React from "react";
import {questList,useQuestList} from "@questlabs/react-native-sdk";
const DemoComponent = () => {
  // const questList= useQuestList({
  //   questId: "Your-Quest_ID" ,
  //   userId:"5235trfet365try67ywry5"
  //   })

  const questList= useQuestList({
    questId: "Your-Quest_ID" ,
    questUserId: "Your-user-id",
    questToken: "Your-Token-id" 
    });
  return (
   <>
      <QuestList
        campaignVariationId={questList.campaignVariationId}
        // actions={questList.actions}
        actions={[
          {
            actionId: '123',
            completed: false,
            title: "First",
            description: "First discription",
            link: "https://google.com"

          },
          {
            actionId: '456',
            completed: false,
            title: "First",
            description: "First discription",
            link: "https://google.com"

          },
          {
            actionId: '789',
            completed: false,
            title: "First",
            description: "First discription",
            link: "https://google.com"

          },
          {
            actionId: '342',
            completed: false,
            title: "First",
            description: "First discription",
            link: "https://google.com"

          },
          {
            actionId: '4523',
            completed: false,
            title: "First",
            description: "First discription",
            link: "https://google.com"

          },
          {
            actionId: '5342',
            completed: false,
            title: "First",
            description: "First discription",
            link: "https://google.com"

          },
          {
            actionId: '1234',
            completed: false,
            title: "First",
            description: "First discription",
            link: "https://google.com"

          },
          {
            actionId: '3253',
            completed: false,
            title: "First",
            description: "First discription",
            link: "https://google.com"

          }
        ]}
        description={questList.description}
        title={questList.title}
        loading={questList.loading}
        questId={questList.questId}
        userToken={questList.userToken}
        questUserId={questList.questUserId}
        // showFooter={false}
        // onError={(err) => console.log(err)}
        // styleConfig={questList?.styleConfig}
        styleConfig={{
          Form: {
            backgroundColor: "lightgray"
          },
          TopBar: { backgroundColor: "orange" },

          Card: {
            title: {
              color: "yellow",

            },
            description: {
              color: "red"
            },
            stepText: {
              color: "blue"
            }
          }
        }}

      />
    </>
  );
};
export default DemoComponent;
```

## Demo

{% embed url="<https://www.loom.com/share/f7b83ed6d7b1447990159f59676cdf8c?sid=736b1a87-249b-448f-b6a4-d9f7098a198c>" %}
