update view message
This commit is contained in:
parent
4dddbca827
commit
6a482dd05f
|
|
@ -1,4 +1,4 @@
|
||||||
import { ActionIcon, Box, Paper, Textarea, Tooltip } from "@mantine/core";
|
import { ActionIcon, Box, Paper, Tooltip } from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { IconEye, IconEyeOff, IconTrash } from "@tabler/icons-react";
|
import { IconEye, IconEyeOff, IconTrash } from "@tabler/icons-react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
|
@ -37,63 +37,59 @@ export default function Message({ data, onDelete }: IMessageProps) {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Tooltip label={data.recipient_type === 1 ? "Personal" : "Group"}>
|
||||||
shadow="xs"
|
<Paper
|
||||||
radius="md"
|
shadow="xs"
|
||||||
p="xs"
|
radius="md"
|
||||||
withBorder
|
p="xs"
|
||||||
className={`flex items-center relative gap-3 w-full transition-all duration-300 ${
|
withBorder
|
||||||
animation ? "animate-pulse !bg-blue-100" : ""
|
className={`flex items-center relative gap-3 w-full transition-all duration-300 ${
|
||||||
}`}
|
animation ? "animate-pulse !bg-blue-100" : ""
|
||||||
>
|
}`}
|
||||||
<div className="flex items-center w-full flex-col">
|
>
|
||||||
<Box className="flex items-center justify-between w-full">
|
<div className="flex items-center w-full flex-col">
|
||||||
<div className="text-xs font-bold">
|
<Box className="flex items-center justify-between w-full">
|
||||||
{data.recipient.length > 0 && <span>{data.recipient}</span>}
|
<div className="text-xs font-bold">
|
||||||
</div>
|
{data.recipient_name.length > 0 && (
|
||||||
<span className="text-xs">
|
<span>{data.recipient_name}</span>
|
||||||
{dayjs(data.time).format("HH:mm D/M/YYYY")}
|
)}
|
||||||
</span>
|
</div>
|
||||||
</Box>
|
<span className="text-xs">
|
||||||
|
{dayjs(data.time).format("HH:mm D/M/YYYY")}
|
||||||
<Box className="w-full flex items-center">
|
</span>
|
||||||
<Textarea
|
|
||||||
defaultValue={`${
|
|
||||||
data.sender.split("@")[0] || ""
|
|
||||||
}: ${messageContent}`}
|
|
||||||
value={`${data.sender.split("@")[0] || ""}: ${messageContent}`}
|
|
||||||
className="flex-1"
|
|
||||||
variant="unstyled"
|
|
||||||
readOnly
|
|
||||||
/>
|
|
||||||
<Box className="flex gap-2">
|
|
||||||
<Tooltip label="View">
|
|
||||||
<ActionIcon onClick={toggle} variant="light" size="sm">
|
|
||||||
{show ? <IconEyeOff size={16} /> : <IconEye size={16} />}
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip label="Delete">
|
|
||||||
<ActionIcon
|
|
||||||
onClick={onDelete}
|
|
||||||
variant="light"
|
|
||||||
size="sm"
|
|
||||||
color="red"
|
|
||||||
>
|
|
||||||
<IconTrash size={16} />
|
|
||||||
</ActionIcon>
|
|
||||||
</Tooltip>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
|
||||||
|
|
||||||
{/* <Box className="flex items-center justify-start w-full">
|
<Box className="w-full flex items-center gap-2">
|
||||||
<span className="text-xs text-left">
|
<div className="text-xs w-full min-h-[60px] py-2 break-words">
|
||||||
{data.sender.split("@")[0]
|
<span className="font-bold">{data.sender_name || ""}:</span>{" "}
|
||||||
? `From: ${data.sender.split("@")[0]}`
|
<span className="text-sm whitespace-pre-wrap break-all max-w-[300px]">
|
||||||
: ""}
|
{messageContent}
|
||||||
</span>
|
</span>
|
||||||
</Box> */}
|
</div>
|
||||||
</div>
|
|
||||||
</Paper>
|
<Box className="flex gap-2">
|
||||||
|
<Tooltip label="View">
|
||||||
|
<ActionIcon onClick={toggle} variant="light" size="sm">
|
||||||
|
{show ? <IconEyeOff size={16} /> : <IconEye size={16} />}
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip label="Delete">
|
||||||
|
<ActionIcon
|
||||||
|
onClick={onDelete}
|
||||||
|
variant="light"
|
||||||
|
size="sm"
|
||||||
|
color="red"
|
||||||
|
>
|
||||||
|
<IconTrash size={16} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
</Paper>
|
||||||
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
LoadingOverlay,
|
LoadingOverlay,
|
||||||
ScrollAreaAutosize,
|
ScrollAreaAutosize,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
useMantineColorScheme
|
useMantineColorScheme,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure, useViewportSize } from "@mantine/hooks"; // 🔥 thêm cái này
|
import { useDisclosure, useViewportSize } from "@mantine/hooks"; // 🔥 thêm cái này
|
||||||
import { IconDotsVertical } from "@tabler/icons-react";
|
import { IconDotsVertical } from "@tabler/icons-react";
|
||||||
|
|
@ -22,7 +22,7 @@ function MainPage() {
|
||||||
const { height } = useViewportSize(); // lấy kích thước cửa sổ
|
const { height } = useViewportSize(); // lấy kích thước cửa sổ
|
||||||
const [clickMessage, setClickMessage] = useState<IMessage | null>(null);
|
const [clickMessage, setClickMessage] = useState<IMessage | null>(null);
|
||||||
|
|
||||||
const {colorScheme} = useMantineColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
const viewport = viewportRef.current;
|
const viewport = viewportRef.current;
|
||||||
|
|
@ -96,7 +96,11 @@ function MainPage() {
|
||||||
return (
|
return (
|
||||||
<Box className="flex flex-col !overflow-hidden h-full">
|
<Box className="flex flex-col !overflow-hidden h-full">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<header className={`px-4 py-2 flex items-center justify-between sticky top-0 border-b z-10 ${colorScheme === 'dark' ? '': 'border-gray-100 pb-2 bg-white'}`}>
|
<header
|
||||||
|
className={`px-4 py-2 flex items-center justify-between sticky top-0 border-b z-10 ${
|
||||||
|
colorScheme === "dark" ? "" : "border-gray-100 pb-2 bg-white"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
{/* <Tooltip label="Mail">
|
{/* <Tooltip label="Mail">
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
@ -112,7 +116,7 @@ function MainPage() {
|
||||||
</Tooltip> */}
|
</Tooltip> */}
|
||||||
|
|
||||||
<Avatar radius="sm" src={"./assets/icon-1.png"} />
|
<Avatar radius="sm" src={"./assets/icon-1.png"} />
|
||||||
{/*
|
{/*
|
||||||
<div className="text-xl font-semibold">Zulip Notes</div> */}
|
<div className="text-xl font-semibold">Zulip Notes</div> */}
|
||||||
|
|
||||||
<Settings
|
<Settings
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,23 @@ declare global {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// interface IMessage {
|
||||||
|
// id: number;
|
||||||
|
// sender: string;
|
||||||
|
// time: number;
|
||||||
|
// message: string;
|
||||||
|
// recipient:string
|
||||||
|
// }
|
||||||
|
|
||||||
interface IMessage {
|
interface IMessage {
|
||||||
id: number;
|
id: number;
|
||||||
sender: string;
|
|
||||||
time: number;
|
|
||||||
message: string;
|
message: string;
|
||||||
recipient:string
|
sender_email: string;
|
||||||
|
sender_name: string;
|
||||||
|
recipient_email: null | string;
|
||||||
|
recipient_name: string;
|
||||||
|
recipient_type: 1 | 2;
|
||||||
|
time: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IEmail {
|
interface IEmail {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue