diff --git a/src/pages/inbox/components/DirectMessageButton/DirectMessageButton.tsx b/src/pages/inbox/components/DirectMessageButton/DirectMessageButton.tsx index 8fd610398c..0214838277 100644 --- a/src/pages/inbox/components/DirectMessageButton/DirectMessageButton.tsx +++ b/src/pages/inbox/components/DirectMessageButton/DirectMessageButton.tsx @@ -16,7 +16,7 @@ interface DirectMessageButtonProps { } /** - * CHECK IF NEED TO DELETE + * CHECK IF NEED TO DELETE THIS FILE. */ const DirectMessageButton: FC = (props) => { diff --git a/src/pages/inbox/components/DirectMessageButton/components/DirectMessageModal/DirectMessageModal.module.scss b/src/pages/inbox/components/DirectMessageButton/components/DirectMessageModal/DirectMessageModal.module.scss index 43be3e5158..39a66234b8 100644 --- a/src/pages/inbox/components/DirectMessageButton/components/DirectMessageModal/DirectMessageModal.module.scss +++ b/src/pages/inbox/components/DirectMessageButton/components/DirectMessageModal/DirectMessageModal.module.scss @@ -7,6 +7,7 @@ max-height: 29.25rem; border-radius: 0; box-shadow: 0 0.25rem 0.9375rem var(--drop-shadow); + height: 37rem; :global(.modal__header-wrapper--with-modal-padding) { .modalHeader { @@ -20,7 +21,7 @@ } .modalContent { - padding: 0; + //padding: 0; } .modalCloseWrapper { @@ -31,6 +32,7 @@ @include tablet { max-width: unset; max-height: unset; + height: 100%; } } @@ -56,6 +58,28 @@ align-items: center; } +// .control { +// background-color: var(--secondaryBackground); +// color: var(--primaryText); +// } + +// .menuList { +// background-color: var(--tertiaryFill); +// } + +// .option { +// color: var(--primaryText); +// } + +// .indicatorsContainer { +// display: none; +// } + +// .singleValue { +// background-color: var(--secondaryBackground); +// color: var(--primaryText); +// } + .infoText { margin: 1rem 0; padding: 0 1rem; @@ -82,3 +106,12 @@ .userItem { padding: 0.375rem 1.75rem; } + +.optionWrapper { + display: flex; + align-items: center; +} + +.userAvatar { + margin-right: 0.75rem; +} diff --git a/src/pages/inbox/components/DirectMessageButton/components/DirectMessageModal/DirectMessageModal.tsx b/src/pages/inbox/components/DirectMessageButton/components/DirectMessageModal/DirectMessageModal.tsx index e0580fe58d..d50fce30b1 100644 --- a/src/pages/inbox/components/DirectMessageButton/components/DirectMessageModal/DirectMessageModal.tsx +++ b/src/pages/inbox/components/DirectMessageButton/components/DirectMessageModal/DirectMessageModal.tsx @@ -8,14 +8,18 @@ import React, { useState, } from "react"; import { useDispatch } from "react-redux"; -import { Modal } from "@/shared/components"; +import Select from "react-select"; +import { Modal, UserAvatar } from "@/shared/components"; import { KeyboardKeys } from "@/shared/constants"; import { useDMUserChatChannel } from "@/shared/hooks/useCases"; +import useThemeColor from "@/shared/hooks/useThemeColor"; +import { SearchIcon } from "@/shared/icons"; import { DMUser } from "@/shared/interfaces"; -import { Loader } from "@/shared/ui-kit"; +import { Button, Loader } from "@/shared/ui-kit"; import { emptyFunction } from "@/shared/utils"; import { inboxActions } from "@/store/states"; import { DirectMessageUserItem, SearchInput } from "./components"; +import { selectorStyles } from "./components/selectorStyles"; import { useDMUsers } from "./hooks"; import styles from "./DirectMessageModal.module.scss"; @@ -34,8 +38,9 @@ const DirectMessageModal: FC = (props) => { groupMessage = false, } = props; const dispatch = useDispatch(); + const { getThemeColor } = useThemeColor(); const listRef = useRef(null); - const [searchText, setSearchText] = useState(""); + //const [searchText, setSearchText] = useState(""); const [activeItemIndex, setActiveItemIndex] = useState(null); const { loading: areDMUsersLoading, @@ -50,48 +55,50 @@ const DirectMessageModal: FC = (props) => { resetDMUserChatChannel, error: isChannelLoadedWithError, } = useDMUserChatChannel(); - const filteredDMUsers = useMemo(() => { - if (!searchText) { - return dmUsers; - } - const lowerCasedSearchText = searchText.toLowerCase(); + // const filteredDMUsers = useMemo(() => { + // if (!searchText) { + // return dmUsers; + // } - return dmUsers.filter((item) => - item.userName.toLowerCase().startsWith(lowerCasedSearchText), - ); - }, [dmUsers, searchText]); - const totalUsersAmount = filteredDMUsers.length; + // const lowerCasedSearchText = searchText.toLowerCase(); - const handleArrowUp = useCallback(() => { - setActiveItemIndex((currentIndex) => { - if (totalUsersAmount === 0) { - return null; - } - if (currentIndex === null) { - return totalUsersAmount - 1; - } + // return dmUsers.filter((item) => + // item.userName.toLowerCase().startsWith(lowerCasedSearchText), + // ); + // }, [dmUsers, searchText]); - const nextIndex = currentIndex - 1; + //const totalUsersAmount = filteredDMUsers.length; - return nextIndex < 0 ? totalUsersAmount - 1 : nextIndex; - }); - }, [totalUsersAmount]); + // const handleArrowUp = useCallback(() => { + // setActiveItemIndex((currentIndex) => { + // if (totalUsersAmount === 0) { + // return null; + // } + // if (currentIndex === null) { + // return totalUsersAmount - 1; + // } - const handleArrowDown = useCallback(() => { - setActiveItemIndex((currentIndex) => { - if (totalUsersAmount === 0) { - return null; - } - if (currentIndex === null) { - return 0; - } + // const nextIndex = currentIndex - 1; + + // return nextIndex < 0 ? totalUsersAmount - 1 : nextIndex; + // }); + // }, [totalUsersAmount]); - const nextIndex = currentIndex + 1; + // const handleArrowDown = useCallback(() => { + // setActiveItemIndex((currentIndex) => { + // if (totalUsersAmount === 0) { + // return null; + // } + // if (currentIndex === null) { + // return 0; + // } - return nextIndex >= totalUsersAmount ? 0 : nextIndex; - }); - }, [totalUsersAmount]); + // const nextIndex = currentIndex + 1; + + // return nextIndex >= totalUsersAmount ? 0 : nextIndex; + // }); + // }, [totalUsersAmount]); const handleUserItemClick = (item: DMUser) => { fetchDMUserChatChannel(item.uid); @@ -104,13 +111,13 @@ const DirectMessageModal: FC = (props) => { } setActiveItemIndex(null); - setSearchText(""); + //setSearchText(""); resetDMUserChatChannel(); }, [isOpen]); - useEffect(() => { - setActiveItemIndex(null); - }, [searchText]); + // useEffect(() => { + // setActiveItemIndex(null); + // }, [searchText]); useEffect(() => { if (activeItemIndex !== null) { @@ -119,60 +126,60 @@ const DirectMessageModal: FC = (props) => { } }, [activeItemIndex]); - useEffect(() => { - if (!isOpen) { - return; - } - - const handler = (event: KeyboardEvent) => { - const key = event.key as KeyboardKeys; - - switch (key) { - case KeyboardKeys.ArrowUp: - handleArrowUp(); - break; - case KeyboardKeys.ArrowDown: - handleArrowDown(); - break; - default: - break; - } - }; - - window.addEventListener("keyup", handler); - - return () => { - window.removeEventListener("keyup", handler); - }; - }, [isOpen, handleArrowUp, handleArrowDown]); - - useEffect(() => { - if (!isOpen) { - return; - } - - const handler = (event: KeyboardEvent) => { - const key = event.key as KeyboardKeys; - - if (key !== KeyboardKeys.Enter) { - return; - } - - const item = filteredDMUsers.find( - (dmUser, index) => index === activeItemIndex, - ); - - if (item) { - handleUserItemClick(item); - } - }; - - window.addEventListener("keyup", handler); - - return () => { - window.removeEventListener("keyup", handler); - }; - }, [isOpen, activeItemIndex, filteredDMUsers]); + // useEffect(() => { + // if (!isOpen) { + // return; + // } + + // const handler = (event: KeyboardEvent) => { + // const key = event.key as KeyboardKeys; + + // switch (key) { + // case KeyboardKeys.ArrowUp: + // handleArrowUp(); + // break; + // case KeyboardKeys.ArrowDown: + // handleArrowDown(); + // break; + // default: + // break; + // } + // }; + + // window.addEventListener("keyup", handler); + + // return () => { + // window.removeEventListener("keyup", handler); + // }; + // }, [isOpen, handleArrowUp, handleArrowDown]); + + // useEffect(() => { + // if (!isOpen) { + // return; + // } + + // const handler = (event: KeyboardEvent) => { + // const key = event.key as KeyboardKeys; + + // if (key !== KeyboardKeys.Enter) { + // return; + // } + + // const item = filteredDMUsers.find( + // (dmUser, index) => index === activeItemIndex, + // ); + + // if (item) { + // handleUserItemClick(item); + // } + // }; + + // window.addEventListener("keyup", handler); + + // return () => { + // window.removeEventListener("keyup", handler); + // }; + // }, [isOpen, activeItemIndex, filteredDMUsers]); useEffect(() => { if (dmUserChatChannel) { @@ -195,37 +202,75 @@ const DirectMessageModal: FC = (props) => { ); } - if (totalUsersAmount === 0) { + if (dmUsers.length === 0) { return

No users found

; } + const options = dmUsers.map((user) => ({ + value: user.userName, + user: user, + label: ( +
+ + {user.userName} +
+ ), + })); + return ( -
    - {filteredDMUsers.map((item, index) => { - const isActive = index === activeItemIndex; - - return ( -
  • setActiveItemIndex(index)} - onMouseDown={(event) => event.preventDefault()} - onClick={() => handleUserItemClick(item)} - > - -
  • - ); - })} -
+ <> +