Big Updated, added some tests, added comments for all functions, I forgot the rest
This commit is contained in:
parent
d77271e4b7
commit
90a1059cc8
59 changed files with 1816 additions and 203 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import Basic from "@/components/modals/basic";
|
||||
import { Basic, Loading } from "@/components/modals/basic";
|
||||
import Wrapper from "@tensamin/user/wrapper";
|
||||
import {
|
||||
ContextMenu,
|
||||
|
|
@ -8,22 +8,52 @@ import {
|
|||
ContextMenuTrigger,
|
||||
} from "@tensamin/ui/cmp/context-menu";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { type User } from "@tensamin/user/context";
|
||||
|
||||
/**
|
||||
* Renders the conversation modal user preview card.
|
||||
* @param user Loaded user data.
|
||||
* @returns Conversation preview card JSX.
|
||||
*/
|
||||
function renderConversationUser(user: User) {
|
||||
return <Basic user={user} />;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the conversation modal user preview card skeleton while loading user data.
|
||||
* @returns Conversation preview card skeleton JSX.
|
||||
*/
|
||||
function renderConversationUserLoading() {
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a conversation context-menu entry for a specific user.
|
||||
* @param props Component props with selected user id.
|
||||
* @returns Conversation modal trigger and menu JSX.
|
||||
*/
|
||||
export default function ConversationModal(props: { userId: number }) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
/**
|
||||
* Navigates to the selected conversation in chat view.
|
||||
* @returns Void.
|
||||
*/
|
||||
const onConversationClick = () => {
|
||||
void navigate({ to: "/chat", search: { id: props.userId } });
|
||||
};
|
||||
|
||||
return (
|
||||
<ContextMenu>
|
||||
<ContextMenuTrigger>
|
||||
<div
|
||||
className="select-none cursor-pointer"
|
||||
onClick={() => {
|
||||
void navigate({ to: "/chat", search: { id: props.userId } });
|
||||
}}
|
||||
onClick={onConversationClick}
|
||||
>
|
||||
<Wrapper
|
||||
loading={renderConversationUserLoading()}
|
||||
userId={props.userId}
|
||||
component={(user) => <Basic user={user} />}
|
||||
component={renderConversationUser}
|
||||
/>
|
||||
</div>
|
||||
</ContextMenuTrigger>
|
||||
|
|
|
|||
Loading…
Reference in a new issue