Skip to content

Commit

Permalink
support group message: init
Browse files Browse the repository at this point in the history
  • Loading branch information
roienatan committed Dec 8, 2023
1 parent 2ee7382 commit b5cbb55
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ interface DirectMessageButtonProps {
}>;
}

/**
* CHECK IF NEED TO DELETE
*/

const DirectMessageButton: FC<DirectMessageButtonProps> = (props) => {
const { className, isMobileVersion = false, ButtonComponent } = props;
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ interface DirectMessageModalProps {
isOpen: boolean;
onClose: () => void;
isMobileVersion?: boolean;
groupMessage?: boolean;
}

const DirectMessageModal: FC<DirectMessageModalProps> = (props) => {
const { isOpen, onClose, isMobileVersion = false } = props;
const {
isOpen,
onClose,
isMobileVersion = false,
groupMessage = false,
} = props;
const dispatch = useDispatch();
const listRef = useRef<HTMLUListElement>(null);
const [searchText, setSearchText] = useState("");
Expand Down Expand Up @@ -235,6 +241,7 @@ const DirectMessageModal: FC<DirectMessageModalProps> = (props) => {
value={searchText}
onChange={setSearchText}
autoFocus
multiple={groupMessage}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ interface SearchInputProps {
value: string;
onChange: (text: string) => void;
autoFocus?: boolean;
multiple?: boolean;
}

const SearchInput: FC<SearchInputProps> = (props) => {
const { className, value, onChange, autoFocus } = props;
const { className, value, onChange, autoFocus, multiple } = props;

const handleInputChange: ChangeEventHandler<HTMLInputElement> = (event) => {
onChange(event.target.value);
Expand All @@ -27,6 +28,7 @@ const SearchInput: FC<SearchInputProps> = (props) => {
onChange={handleInputChange}
placeholder="Search"
autoFocus={autoFocus}
multiple={multiple}
/>
</div>
</div>
Expand Down
9 changes: 2 additions & 7 deletions src/pages/inbox/components/HeaderContent/HeaderContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import React, { FC } from "react";
import classNames from "classnames";
import { useIsTabletView } from "@/shared/hooks/viewport";
import { InboxIcon } from "@/shared/icons";
import { DirectMessageButton } from "../DirectMessageButton";
import { HeaderContent_v04 } from "../HeaderContent_v04";
import { InboxFilterButton } from "../InboxFilterButton";
import { PlusButton } from "./components";
import NewDirectMessageButton from "../NewDirectMessageButton/NewDirectMessageButton";
import styles from "./HeaderContent.module.scss";

interface HeaderContentProps {
Expand Down Expand Up @@ -34,10 +32,7 @@ const HeaderContent: FC<HeaderContentProps> = (props) => {
</div>
<div className={styles.actionButtonsWrapper}>
{/* <InboxFilterButton /> */}
<DirectMessageButton
isMobileVersion={isMobileVersion}
ButtonComponent={PlusButton}
/>
<NewDirectMessageButton isMobileVersion={isMobileVersion} />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import classNames from "classnames";
import { useIsTabletView } from "@/shared/hooks/viewport";
import { InboxIcon } from "@/shared/icons";
import { getPluralEnding } from "@/shared/utils";
import { DirectMessageButton } from "../DirectMessageButton";
import { PlusButton } from "../HeaderContent/components";
import { InboxFilterButton } from "../InboxFilterButton";
import NewDirectMessageButton from "../NewDirectMessageButton/NewDirectMessageButton";
import styles from "./HeaderContent_v04.module.scss";

interface HeaderContentProps {
Expand Down Expand Up @@ -33,11 +31,7 @@ const HeaderContent_v04: FC<HeaderContentProps> = (props) => {
</div>
<div className={styles.actionButtonsWrapper}>
{/* <InboxFilterButton /> */}
<DirectMessageButton
className={styles.directMessageButton}
isMobileVersion={isMobileVersion}
ButtonComponent={PlusButton}
/>
<NewDirectMessageButton isMobileVersion={isMobileVersion} />
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { FC, useMemo, useState } from "react";
import { InboxAction } from "@/shared/constants";
import { useModal } from "@/shared/hooks";
import { MenuItem as Item } from "@/shared/interfaces";
import { DesktopMenu, MobileMenu } from "@/shared/ui-kit";
import { DirectMessageModal } from "../DirectMessageButton/components";
import { PlusButton } from "../HeaderContent/components";

interface NewDirectMessageButton {
isMobileVersion?: boolean;
className?: string;
}

const NewDirectMessageButton: FC<NewDirectMessageButton> = (props) => {
const { isMobileVersion, className } = props;
const {
isShowing: isDirectMessageModalOpen,
onOpen: onDirectMessageModalOpen,
onClose: onDirectMessageModalClose,
} = useModal(false);
const [groupMessage, setGroupMessage] = useState(false);

const items: Item[] = useMemo(
() => [
{
id: InboxAction.NewDirectMessage,
text: "Direct message",
onClick: () => {
setGroupMessage(false);
onDirectMessageModalOpen();
},
},
{
id: InboxAction.NewGroupMessage,
text: "Group message",
onClick: () => {
setGroupMessage(true);
onDirectMessageModalOpen();
},
},
],
[groupMessage],
);

const triggerEl = <PlusButton />;
const menuProps = {
className,
triggerEl,
items,
};
const Menu = isMobileVersion ? MobileMenu : DesktopMenu;

return (
<>
<Menu {...menuProps} />
<DirectMessageModal
isOpen={isDirectMessageModalOpen}
onClose={onDirectMessageModalClose}
isMobileVersion={isMobileVersion}
groupMessage={groupMessage}
/>
</>
);
};

export default NewDirectMessageButton;
4 changes: 4 additions & 0 deletions src/shared/constants/inboxAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum InboxAction {
NewDirectMessage = "new-direct-message",
NewGroupMessage = "new-group-message",
}
1 change: 1 addition & 0 deletions src/shared/constants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ export * from "./systemDiscussionMessage";
export * from "./theme";
export * from "./docChange";
export * from "./files";
export * from "./inboxAction";

0 comments on commit b5cbb55

Please sign in to comment.