feat: enhance chat sidebar with admin indicator and simplify user retrieval logic
This commit is contained in:
parent
d6c0e67bfd
commit
b7e1e964c3
3 changed files with 18 additions and 22 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Check, CheckCheck, Search, SquarePen } from "lucide-react";
|
||||
import { Check, CheckCheck, Crown, Search, SquarePen } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useCallback, useState } from "react";
|
||||
|
|
@ -159,15 +159,21 @@ export const ChatSidebar = ({
|
|||
)}
|
||||
onClick={() => handleChatSelection(chat.chatid)}
|
||||
>
|
||||
{chat.id === userId ? (
|
||||
<div className="flex size-10 items-center justify-center rounded-full bg-yellow-500 text-white text-xs">
|
||||
<Crown className="size-4" />
|
||||
</div>
|
||||
) : (
|
||||
<UserAvatar
|
||||
className="size-10"
|
||||
userId={chat.id}
|
||||
username={chat.username}
|
||||
/>
|
||||
)}
|
||||
|
||||
{isDesktop && (
|
||||
<div className="flex h-full max-w-28 flex-col text-left align-top">
|
||||
<span>{chat.username}</span>
|
||||
<span>{chat.id === userId ? "Admin Infoalloggi" : chat.username}</span>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{chat.etichette.map((etichetta) => (
|
||||
<Etichetta
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ export const usersRouter = createTRPCRouter({
|
|||
}),
|
||||
)
|
||||
.query(async ({ input }) => {
|
||||
return await getUserHandler({ db, id: input.id });
|
||||
return await getUserHandler(input.id);
|
||||
}),
|
||||
|
||||
getUsers: adminProcedure.query(async () => {
|
||||
|
|
@ -96,7 +96,7 @@ export const usersRouter = createTRPCRouter({
|
|||
return await editAnagraficaHandler({ ...input });
|
||||
}),
|
||||
getActiveUsersWithoutChat: adminProcedure.query(async () => {
|
||||
return await getActiveUserWithoutChatHandler({ db });
|
||||
return await getActiveUserWithoutChatHandler();
|
||||
}),
|
||||
|
||||
getUsersWChatInfo: adminProcedure.query(async () => {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import type { Etichette } from "~/schemas/public/Etichette";
|
|||
import type { Users, UsersId, UsersUpdate } from "~/schemas/public/Users";
|
||||
import type { UsersAnagraficaUpdate } from "~/schemas/public/UsersAnagrafica";
|
||||
import { getComuni, getNazioni } from "~/server/controllers/catasto.controller";
|
||||
import { db, type Querier } from "~/server/db";
|
||||
import { db } from "~/server/db";
|
||||
import { startsWithVowel, titleCase } from "~/utils/utils";
|
||||
|
||||
export const editAccountHandler = async ({
|
||||
|
|
@ -101,13 +101,7 @@ export const blockUserHandler = async (id: UsersId) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const getUserHandler = async ({
|
||||
db,
|
||||
id,
|
||||
}: {
|
||||
db: Querier;
|
||||
id: UsersId;
|
||||
}) => {
|
||||
export const getUserHandler = async (id: UsersId) => {
|
||||
try {
|
||||
const user = await db
|
||||
.selectFrom("users")
|
||||
|
|
@ -134,11 +128,7 @@ export type NonNullableUser = {
|
|||
username: NonNullable<string>;
|
||||
nome: string | null;
|
||||
};
|
||||
export const getActiveUserWithoutChatHandler = async ({
|
||||
db,
|
||||
}: {
|
||||
db: Querier;
|
||||
}) => {
|
||||
export const getActiveUserWithoutChatHandler = async () => {
|
||||
try {
|
||||
const users = await db
|
||||
.selectFrom("users")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue