import React from "react";
import { useSocialComments, useSocialStyle } from "@replyke/comments-social-react-native";
import { showMessage } from "react-native-flash-message";
const CommentSectionWithCallbacks = ({ entityId }: { entityId: string }) => {
const styleConfig = useSocialStyle();
const callbacks = {
loginRequiredCallback: () => {
showMessage({
message: "Login Required",
description: "Please log in to interact with the comment section.",
type: "warning",
});
},
usernameRequiredCallback: () => {
showMessage({
message: "Username Required",
description: "Please set up a username to continue.",
type: "warning",
});
},
commentTooShortCallback: () => {
showMessage({
message: "Comment Too Short",
description: "Your comment must contain at least one character.",
type: "warning",
});
},
currentUserClickCallback: () => {
console.log("Navigating to current user's profile...");
},
otherUserClickCallback: (userId) => {
console.log(`Navigating to profile of user with ID: ${userId}`);
},
userCantBeMentionedCallback: (user) => {
showMessage({
message: "User Can't Be Mentioned",
description: `${user.name} cannot be mentioned because they don't have a username set.",
type: "warning",
});
},
};
const { CommentSectionProvider, CommentsFeed, NewCommentForm } = useSocialComments({
entityId,
styleConfig,
callbacks,
});
return (
<CommentSectionProvider>
<CommentsFeed />
<NewCommentForm />
</CommentSectionProvider>
);
};
export default CommentSectionWithCallbacks;