diff --git a/README.md b/README.md
index dd66a96..917befb 100644
--- a/README.md
+++ b/README.md
@@ -6,15 +6,16 @@ The `@sirenapp/react-inbox` sdk is a comprehensive and customizable React UI kit
## 1. Installation
-You can install the react sdk from npm
+You can install the react sdk from npm
```bash
-npm @sirenapp/react-inbox
+npm install @sirenapp/react-inbox
```
+
or from yarn
```bash
-yarn @sirenapp/react-inbox
+yarn add @sirenapp/react-inbox
```
#### Prerequisites
@@ -22,7 +23,9 @@ yarn @sirenapp/react-inbox
- React v16.8+
## 2. Configuration
+
### 2.1 Initialization
+
Initialize the sdk with user token and recipient id. Wrap the provider around your App's root.
```js
@@ -37,15 +40,15 @@ const config = {
```
### 2.2 Configure notification inbox
+
Once the provider is configured, next step is to configure the notification inbox
Inbox is a paginated list view for displaying notifications.
```js
-import { SirenInbox } from '@sirenapp/react-inbox';
+import { SirenInbox } from "@sirenapp/react-inbox";
title - Title of the notification inbox
hideHeader - Toggle to hide or show the header section.
hideClearAll - Toggle to hide or show the clear all button.
customHeader - Custom header component. | InboxHeaderProps| { title: 'Notifications',
hideHeader: false,
hideClearAll: false,
customHeader: null } |
+cardProps | Props for customizing the notification cards.
hideDelete - Toggle to hide or show delete icon
hideAvatar - Toggle to hide or show the avatar.
disableAutoMarkAsRead - Toggle to disable or enable the markAsRead functionality on card click | CardProps | { hideDelete: false,
hideAvatar: false,
disableAutoMarkAsRead: false } |
customNotificationCard | Function for rendering custom notification cards | (notification)=> JSX Element | null |
onNotificationCardClick | Custom click handler for notification cards | (notification)=> void | ()=>null |
listEmptyComponent | Custom component for empty notification list | JSX Element | null |
-customHeader | Custom header component | JSX Element | null |
customFooter | Custom footer component | JSX Element | null |
customLoader | Custom loader component | JSX Element | null |
loadMoreComponent | Custom load more component | JSX Element | null |
@@ -76,6 +76,7 @@ customErrorWindow | Custom error window | JSX Element | null |
onError | Callback for handling errors | (error: SirenErrorType)=> void | null |
## 3. Customization
+
### 3.1 Themes
Here are the available theme options:
@@ -101,7 +102,7 @@ type ThemeProps = {
timerIcon?: string,
clearAllIcon?: string,
infiniteLoader?: string,
- windowShadowColor?: string
+ windowShadowColor?: string,
},
badgeStyle?: {
color?: string,
@@ -128,9 +129,10 @@ type ThemeProps = {
loadMoreButton: {
color?: string,
background?: string,
- }
+ },
};
```
+
### 3.2 Style options
Here are the custom style options for the notification inbox
@@ -187,6 +189,27 @@ Please note that the badgeStyle, window shadow and border props are only applica
}
```
+#### CardProps
+
+```js
+ type CardProps = {
+ hideDelete?: boolean;
+ hideAvatar?: boolean,
+ disableAutoMarkAsRead?: boolean,
+ };
+```
+
+#### InboxHeaderProps
+
+```js
+ type InboxHeaderProps = {
+ title?: string;
+ hideHeader?: boolean,
+ hideClearAll?: boolean,
+ customHeader?: JSX.Element | null,
+ };
+```
+
## 4. Hooks
`useSiren` is a hook that provides utility functions for modifying notifications.
@@ -229,43 +252,41 @@ function MyComponent() {
}
```
-#### useSiren functions
+### useSiren functions
-| Functions | Parameters | Type | Description |
-| ----------------------------- | ----------------- |---------| ----------------------------------------------------------- |
-| markNotificationsAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date. |
-| markAsRead | id | string | Set read status of a notification to true |
-| deleteNotification | id | string | Delete a notification by id |
-| deleteNotificationsByDate | startDate | ISO date string| Delete all notifications until given date |
-| markNotificationsAsViewed | startDate | ISO date string | Sets the viewed status of notifications to true until the given date |
+Functions | Parameters | Type | Description |
+----------|------------|-------|------------|
+markNotificationsAsReadByDate | startDate | ISO date string | Sets the read status of notifications to true until the given date |
+markAsRead | id | string | Set read status of a notification to true |
+deleteNotification | id | string | Delete a notification by id |
+deleteNotificationsByDate | startDate | ISO date string | Delete all notifications until given date |
+markNotificationsAsViewed | startDate | ISO date string |Sets the viewed status of notifications to true until the given date |
## 5. Error codes
Given below are all possible error codes thrown by sdk.
-| Error code | Description |
-| ------------------------- | ------------------------------------------------------------------|
-| INVALID_TOKEN | The token passed in the provider is invalid |
-| INVALID_RECIPIENT_ID | The recipient id passed in the provider is invalid |
-| TOKEN_VERIFICATION_FAILED | Verification of the given tokens has failed |
-| GENERIC_API_ERROR | Occurrence of an unexpected api error |
-| OUTSIDE_SIREN_CONTEXT | Attempting to invoke the functions outside the siren inbox context|
-| MISSING_PARAMETER | The required parameter is missing |
+Error code | Description |
+------------------------- | ------------------------------------------------------------------|
+INVALID_TOKEN | The token passed in the provider is invalid |
+INVALID_RECIPIENT_ID | The recipient id passed in the provider is invalid |
+TOKEN_VERIFICATION_FAILED | Verification of the given tokens has failed |
+GENERIC_API_ERROR | Occurrence of an unexpected api error |
+OUTSIDE_SIREN_CONTEXT | Attempting to invoke the functions outside the siren inbox context|
+MISSING_PARAMETER | The required parameter is missing |
## Example
Here's a basic example to help you get started
```js
-
-import React from 'react';
-import {SirenInbox,SirenProvider} from '@sirenapp/react-inbox';
+import React from "react";
+import { SirenInbox, SirenProvider } from "@sirenapp/react-inbox";
function App(): React.JSX.Element {
-
const config = {
- userToken: 'your_user_token',
- recipientId: 'your_recipient_id',
+ userToken: "your_user_token",
+ recipientId: "your_recipient_id",
};
return (
@@ -278,15 +299,21 @@ function App(): React.JSX.Element {
export default App;
export function MyContainer(): React.JSX.Element {
-
return (