diff --git a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx index 1b0d45e8d..b9267b17b 100644 --- a/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx +++ b/packages/uiweb/src/lib/components/chat/ChatProfile/ChatProfile.tsx @@ -31,10 +31,10 @@ import 'react-toastify/dist/ReactToastify.min.css'; -const Options = ({ options, setOptions, isGroup, chatInfo, groupInfo, setGroupInfo,theme }: OptionProps) => { +const Options = ({ options, setOptions, isGroup, chatInfo, groupInfo, setGroupInfo, theme }: OptionProps) => { const DropdownRef = useRef(null); const [modal, setModal] = useState(false); - + useClickAway(DropdownRef, () => { setOptions(false); }); @@ -42,59 +42,65 @@ const Options = ({ options, setOptions, isGroup, chatInfo, groupInfo, setGroupIn const ShowModal = () => { setModal(true); } + console.log(groupInfo?.rules?.chat, "groupInfooo") - if (groupInfo && isGroup){ + if (groupInfo && isGroup) { return (
- + { + (groupInfo?.rules?.chat?.conditions || groupInfo?.rules?.entry?.conditions) && ( + + ) + } - {groupInfo?.isPublic && - ()} + {groupInfo?.isPublic && + ()} setOptions(true)}> - - - {options && - ( - - - - - Group Info - - - )} - - {modal && - ()} + + + {options && + ( + + + + + Group Info + + + )} + + {modal && + ()}
) - } else { - return null } - }; + } else { + return null + } +}; + - -export const ChatProfile: React.FC = ({ chatId, style }: {chatId: string, style: "Info" | "Preview"}) => { +export const ChatProfile: React.FC = ({ chatId, style }: { chatId: string, style: "Info" | "Preview" }) => { const theme = useContext(ThemeContext); const { account, env } = useChatData(); const { getGroupByID } = useGetGroupByID(); const { fetchUserChatProfile } = useChatProfile(); const [isGroup, setIsGroup] = useState(false); - const [options, setOptions] = useState(false); - const [chatInfo, setChatInfo ] = useState(); - const [groupInfo, setGroupInfo ] = useState(); - const [ensName, setEnsName ] = useState(''); + const [options, setOptions] = useState(false); + const [chatInfo, setChatInfo] = useState(); + const [groupInfo, setGroupInfo] = useState(); + const [ensName, setEnsName] = useState(''); const isMobile = useMediaQuery(device.tablet); const l1ChainId = allowedNetworks[env].includes(1) ? 1 : 5; const provider = new ethers.providers.InfuraProvider(l1ChainId, InfuraAPIKey); @@ -102,13 +108,13 @@ export const ChatProfile: React.FC = ({ chatId, style }: {chatId: const fetchProfileData = async () => { - if(isValidETHAddress(chatId)){ + if (isValidETHAddress(chatId)) { const ChatProfile = await fetchUserChatProfile({ profileId: chatId }); setChatInfo(ChatProfile); setGroupInfo(null); setIsGroup(false); } else { - const GroupProfile = await getGroupByID({ groupId : chatId}) + const GroupProfile = await getGroupByID({ groupId: chatId }) setGroupInfo(GroupProfile); setChatInfo(null); setIsGroup(true); @@ -116,44 +122,44 @@ export const ChatProfile: React.FC = ({ chatId, style }: {chatId: } const getName = async (chatId: string) => { - if(isValidETHAddress(chatId)){ - const result = await resolveNewEns(chatId, provider); - // if(result) - setEnsName(result); - } + if (isValidETHAddress(chatId)) { + const result = await resolveNewEns(chatId, provider); + // if(result) + setEnsName(result); + } } - useEffect(()=> { - if(!chatId) return; + useEffect(() => { + if (!chatId) return; fetchProfileData(); getName(chatId); - },[chatId, account, env]) + }, [chatId, account, env]) if (chatId && style === 'Info') { return ( {chatInfo || groupInfo ? ( + ?.toString()} height="48px" maxHeight="48px" width='48px' borderRadius="100%" /> ) : ()} - + - {isGroup ? groupInfo?.groupName : ensName ? `${ensName} (${isMobile ? shortenText(chatInfo?.did?.split(':')[1] ?? '', 4, true) : chatId})`: chatInfo ? shortenText(chatInfo.did?.split(':')[1] ?? '', 6, true) : shortenText(chatId,6, true)} - + {isGroup ? groupInfo?.groupName : ensName ? `${ensName} (${isMobile ? shortenText(chatInfo?.did?.split(':')[1] ?? '', 4, true) : chatId})` : chatInfo ? shortenText(chatInfo.did?.split(':')[1] ?? '', 6, true) : shortenText(chatId, 6, true)} + - + {/* {!isGroup && @@ -161,10 +167,10 @@ export const ChatProfile: React.FC = ({ chatId, style }: {chatId: } */} - + + - - + ) } else { return null;