From 26a7ac60d8619d03992f8e8c5e337004faf12d70 Mon Sep 17 00:00:00 2001 From: Boris Proshin Date: Wed, 16 Aug 2023 17:14:24 +0300 Subject: [PATCH] feat: pinned chat category title --- src/components/Chats.tsx | 100 ++++++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 44 deletions(-) diff --git a/src/components/Chats.tsx b/src/components/Chats.tsx index 0da49af..fe09855 100644 --- a/src/components/Chats.tsx +++ b/src/components/Chats.tsx @@ -1,4 +1,4 @@ -import { ActionIcon, Flex, Menu } from "@mantine/core"; +import { ActionIcon, Flex, Menu, Text } from "@mantine/core"; import { IconDotsVertical, IconMessages, @@ -57,53 +57,65 @@ export function Chats({ search }: { search: string }) { } }; + const ChatItem = ({ chat }: { chat: Chat }) => ( + ({ + marginTop: 1, + "&:hover, &.active": { + backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.colors.gray[1], + }, + })} + > + + : } + color="teal" + chat={chat} + label={chat.description} + /> + + + + + + + + + : } + onClick={(event) => toggleChatPin(chat.id, event)} + > + {chat.pinned ? "Remove pin" : "Pin this"} + + + }>Edit + + + }> + Delete + + + + + + ); + return ( <> + {filteredChats - .sort((chat) => (chat.pinned ? -1 : 1)) + .filter((chat) => chat.pinned) .map((chat) => ( - ({ - marginTop: 1, - "&:hover, &.active": { - backgroundColor: theme.colorScheme === "dark" ? theme.colors.dark[6] : theme.colors.gray[1], - }, - })} - > - - : } - color="teal" - chat={chat} - label={chat.description} - /> - - - - - - - - - : } - onClick={(event) => toggleChatPin(chat.id, event)} - > - {chat.pinned ? "Remove pin" : "Pin this"} - - - }>Edit - - - }> - Delete - - - - - + + ))} + + + {filteredChats + .filter((chat) => !chat.pinned) + .map((chat) => ( + ))} );