All Collaborators Component
Overview
The AllCollaborators component displays a list of collaborators based on search filters and pagination. It integrates semantic search and filtering capabilities to retrieve and display collaborators in a card-based layout.
Key Features
- Collaborator List:
- Displays a list of collaborators, including their organization name, contact person, email, industry, and country.
- Semantic Search:
- Retrieves results using semantic search when a search query is provided.
- Filtering:
- Filters collaborators by industry, country, and search queries.
- Pagination:
- Allows navigation through multiple pages of collaborators.
- Invite Collaborators:
- Includes functionality to invite collaborators using the
InviteCollaboratorcomponent.
- Includes functionality to invite collaborators using the
- Loading and Empty State:
- Displays a spinner during data loading and a message when no collaborators match the filters.
Props
| Prop Name | Type | Description |
|---|---|---|
industry | string | The industry filter applied to the collaborators list. |
country | string | The country filter applied to the collaborators list. |
pageNumber | number | The current page number for pagination. |
setPageNumber | Dispatch<SetStateAction<number>> | Function to update the current page number. |
semanticSearch | string | Search query for semantic search. |
toggleFilters | () => void | Function to adjust or reset the applied filters. |
totalCollaborators | number | Total number of collaborators retrieved. |
setTotalCollaborators | Dispatch<SetStateAction<number>> | Function to update the total number of collaborators retrieved. |
State Management
| State Variable | Type | Description |
|---|---|---|
collaborators | SupplierProfileInfo[] | List of collaborators fetched from the API. |
isLoading | boolean | Indicates whether data is currently being loaded. |
Data Fetching
-
Filters:
- The component constructs a query string based on the filters provided (
industry,country,pageNumber,semanticSearch).
- The component constructs a query string based on the filters provided (
-
API Endpoints:
- Default search:
/rifbid-collaborate/collaborators - Semantic search:
/rifbid-collaborate/collaborators/semantic_search
- Default search:
-
Token Authentication:
- Uses the token retrieved from the
useAuthhook to authenticate API requests.
- Uses the token retrieved from the
-
Error Handling:
- Logs errors in the console for debugging purposes.
Component Structure
Collaborator Cards
- Details Displayed:
- Organization Name
- Contact Person
- Industry
- Country
- Footer:
- Includes the
InviteCollaboratorcomponent for inviting collaborators.
- Includes the
Pagination
- Uses the
Paginationcomponent to navigate through multiple pages of collaborators.
Behavior
Loading State
- Displays a spinner while fetching data from the API.
Empty State
- Shows a message with an option to adjust filters when no collaborators match the current filters.
Success State
- Displays collaborators in a grid layout with their respective details and invite functionality.
InviteCollaborators Component
Key Features
- Dialog Interface:
- Utilizes a dialog-based interface for a smooth user experience.
- Message Customization:
- Allows users to write a personalized message before sending the invitation.
- Email Integration:
- Sends an email invitation to the selected collaborator via the RifBid API.
- Loading State:
- Displays a spinner while the request is being processed.
- Error Handling:
- Provides feedback using toast notifications for both success and error scenarios.
Props
| Prop Name | Type | Description |
|---|---|---|
collaborator | SupplierProfileInfo | Information about the collaborator being invited. |
State Management
| State Variable | Type | Description |
|---|---|---|
assistanceRequested | boolean | Indicates whether the user has opted to send an invitation. |
message | string | The custom message written by the user. |
isLoading | boolean | Tracks the loading state during the request submission. |
Invite Flow
- Initial Dialog:
- Prompts the user to confirm if they want to invite the collaborator.
- Message Input:
- If confirmed, presents a text area for the user to write a custom message.
- Submit Invitation:
- Sends the message along with collaborator and supplier details to the API.