Skip to main content
Version: v4

Join Protected Group

Overview

CometChatJoinGroup is a Component used to set up a screen that shows the functionality to join a password protected group, featuring the functionality to join a password-protected group, where users can join a single password-protected group at a time.

Image

The Groups component is composed of the following BaseComponents:

ComponentsDescription
cometchat-buttonThis component represents a button with optional icon and text.
cometchat-labelThis component provides descriptive information about the associated UI element.
cometchat-inputThis component allows users to enter or provide data or information within a web form or interface.

Usage

Integration

The following code snippet illustrates how you can directly incorporate the Join Group component into your Application.

import React from "react";
import { createComponent } from "@lit-labs/react";
import { CometChatJoinGroup } from "@cometchat/chat-uikit-react";

const JoinProtectedGroupDemo = () => {
const [chatGroup, setChatGroup] = React.useState<
CometChat.Group | undefined
>();

React.useEffect(() => {
CometChat.getGroup("uid").then((group) => {
setChatGroup(group);
});
}, []);

const JoinGroup = createComponent({
tagName: "cometchat-join-group",
elementClass: CometChatJoinGroup,
react: React,
});

return <JoinGroup group={chatGroup} />;
};

export default JoinProtectedGroupDemo;

Actions

Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

1. joinClick

The joinClick action is activated when you click the join Group button. This returns the join groups.

You can override this action using the following code snippet.

JoinProtectedGroupDemo.tsx
import React from "react";
import { createComponent } from "@lit-labs/react";
import { CometChatJoinGroup } from "@cometchat/chat-uikit-react";

const JoinProtectedGroupDemo = () => {
const [chatGroup, setChatGroup] = React.useState<
CometChat.Group | undefined
>();

React.useEffect(() => {
CometChat.getGroup("uid").then((group) => {
setChatGroup(group);
});
}, []);

const JoinGroup = createComponent({
tagName: "cometchat-join-group",
elementClass: CometChatJoinGroup,
react: React,
});

function handleJoinClick(group: CometChat.Group, password: string): void {
console.log("Your Custom on join click actions");
}

return <JoinGroup group={chatGroup} joinClick={handleJoinClick} />;
};

export default JoinProtectedGroupDemo;
2. errorCallback

This action doesn't change the behavior of the component but rather listens for any errors that occur in the Groups component.

JoinProtectedGroupDemo.tsx
import React from "react";
import { createComponent } from "@lit-labs/react";
import { CometChatJoinGroup } from "@cometchat/chat-uikit-react";

const JoinProtectedGroupDemo = () => {
const [chatGroup, setChatGroup] = React.useState<
CometChat.Group | undefined
>();

React.useEffect(() => {
CometChat.getGroup("uid").then((group) => {
setChatGroup(group);
});
}, []);

const JoinGroup = createComponent({
tagName: "cometchat-join-group",
elementClass: CometChatJoinGroup,
react: React,
});

const handleOnError = () => {
console.log("error");
};

return <JoinGroup group={chatGroup} errorCallback={handleOnError} />;
};

export default JoinProtectedGroupDemo;

Filters

Filters allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

The Join Group component does not have any exposed filters.

Events

Events are emitted by a Component. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

Events emitted by the Join Group component is as follows.

EventDescription
ccGroupMemberJoinedTriggers when the user joined a protected group successfully
const ccGroupMemberJoined = CometChatGroupEvents.ccGroupMemberJoined.subscribe(
(item: IGroupMemberJoined) => {
//Your Code
}
);

ccGroupMemberJoined?.unsubscribe();

Customization

To fit your app's design requirements, you can customize the appearance of the Join Groups component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.

1. JoinGroup Style

You can set the JoinGroupStyle to the Join Group Component to customize the styling.

Image
JoinProtectedGroupDemo.tsx
import React from "react";
import { createComponent } from "@lit-labs/react";
import {
CometChatJoinGroup,
JoinGroupStyle,
} from "@cometchat/chat-uikit-react";

const JoinProtectedGroupDemo = () => {
const [chatGroup, setChatGroup] = React.useState<
CometChat.Group | undefined
>();

React.useEffect(() => {
CometChat.getGroup("uid").then((group) => {
setChatGroup(group);
});
}, []);

const JoinGroup = createComponent({
tagName: "cometchat-join-group",
elementClass: CometChatJoinGroup,
react: React,
});

const joinGroupStyle = new JoinGroupStyle({
background: "#d1b2ed",
joinButtonBackground: "#8625db",
joinButtonTextColor: "#000000",
passwordInputTextColor: "#000000",
titleTextColor: "#000000",
passwordInputPlaceholderTextColor: "#000000",
});

return <JoinGroup group={chatGroup} joinGroupStyle={joinGroupStyle} />;
};

export default JoinProtectedGroupDemo;

List of properties exposed by JoinGroupsStyle

PropertyDescriptionCode
borderUsed to set borderborder?: string,
borderRadiusUsed to set border radiusborderRadius?: string;
backgroundUsed to set background colourbackground?: string;
heightUsed to set heightheight?: string;
widthUsed to set widthwidth?: string;
boxShadowSets shadow effects around the elementboxShadow?: string;
titleTextFontSets the font style for the title texttitleTextFont?: string;
titleTextColorSets the color for the title texttitleTextColor?: string;
errorTextFontSets the font style for error messageserrorTextFont?: string;
errorTextColorSets the color for error messageserrorTextColor?: string;
passwordInputTextFontSets the font style for password inputpasswordInputTextFont?: string;
passwordInputTextColorSets the color for password input textpasswordInputTextColor?: string;
passwordInputPlaceholderTextFontSets the font style for password input placeholder textpasswordInputPlaceholderTextFont?: string;
passwordInputPlaceholderTextColorSets the color for password input placeholder textpasswordInputPlaceholderTextColor?: string;
passwordInputBackgroundSets the background color for password input fieldpasswordInputBackground?: string;
passwordInputBorderSets the border style for password input fieldpasswordInputBorder?: string;
passwordInputBorderRadiusSets the border radius for password input fieldpasswordInputBorderRadius?: string;
passwordInputBoxShadowSets shadow effects around the password input fieldpasswordInputBoxShadow?: string;
joinButtonTextFontSets the font style for the join buttonjoinButtonTextFont?: string;
joinButtonTextColorSets the color for the join button textjoinButtonTextColor?: string;
joinButtonBackgroundSets the background color for the join buttonjoinButtonBackground?: string;
joinButtonBorderRadiusSets the border radius for the join buttonjoinButtonBorderRadius?: string;
joinButtonBorderSets the border style for the join buttonjoinButtonBorder?: string;

Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

JoinProtectedGroupDemo.tsx
import React from "react";
import { createComponent } from "@lit-labs/react";
import { CometChatJoinGroup } from "@cometchat/chat-uikit-react";

const JoinProtectedGroupDemo = () => {
const [chatGroup, setChatGroup] = React.useState<
CometChat.Group | undefined
>();

React.useEffect(() => {
CometChat.getGroup("uid").then((group) => {
setChatGroup(group);
});
}, []);

const JoinGroup = createComponent({
tagName: "cometchat-join-group",
elementClass: CometChatJoinGroup,
react: React,
});

return (
<JoinGroup
group={chatGroup}
title="Your custom Title"
passwordInputPlaceholderText="Your Custom Placeholder Text"
joinButtonText="Your Custom Join Button Text"
/>
);
};

export default JoinProtectedGroupDemo;

Default:

Image

Custom:

Image
PropertyDescriptionCode
titleCustom title for the componenttitle='Your Custom Title'
joinButtonTextCustom text for the join group buttonjoinButtonText='Your Custom Join Group Button Text'
passwordInputPlaceholderTextCustom placeholder text for password input fieldpasswordInputPlaceholderText='Your Custom Password Input Placeholder Text'
errorTextCustom error state texterrorText='Your Custom Error Text'
groupused to set the groupgroup={chatGroup}

Advance

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.

the Join Group component does not offer any advanced functionalities beyond this level of customization.