@gsb-core/react-social
v0.1.0
Published
GSB react-social package
Readme
@gsb-core/react-social
GSB React Social package for group management and social features.
Features
- Group Management: Create, update, and delete groups
- Member Management: Add, remove, and manage group members
- Moderation: Add/remove moderators and block/unblock users
- Invitations: Send and manage group invitations
- Join Requests: Handle join requests for private groups
- Subscription Limits: Enforce group creation limits based on user subscription
Installation
npm install @gsb-core/react-socialUsage
Import the package
import { GroupService, SclGroup, SclRequest } from "@gsb-core/react-social";Basic Group Operations
// Create a new group
const newGroup = await GroupService.createGroup(
"My Group",
"A description of my group",
false, // isPublic
);
// Get user's groups
const userGroups = await GroupService.getUserGroups();
// Search for groups
const searchResults = await GroupService.searchGroups("search term");
// Get group by ID
const group = await GroupService.getGroupById("group-id");Member Management
// Invite users to a group
const invitations = await GroupService.inviteUsersToGroup(
"group-id",
["[email protected]", "[email protected]"],
"Join our group!",
);
// Remove a member
await GroupService.removeMember("group-id", "user-id");
// Add a moderator
await GroupService.addModerator("group-id", "user-id");Join Requests
// Send a join request
const request = await GroupService.sendJoinRequest(
"group-id",
"I would like to join this group",
);
// Accept a request
await GroupService.acceptRequestOrInvitation("request-id");
// Decline a request
await GroupService.declineRequestOrInvitation("request-id");Types
SclGroup
Main group entity with properties like:
title,description,isPublicowner,members,moderators,blockedtags,requests,logs
SclRequest
Represents join requests and invitations with:
type(Invitation or Join)status(Pending, Accepted, Declined)group_id,email
SclComment
Group comments with support for:
- Nested replies
- Author information
- Group association
Dependencies
@gsb-core/gsb-core: Core GSB types and utilities@gsb-core/react-saas: SaaS-specific services (EntityService, AuthService, AccountService)
License
MIT
