fix and update
This commit is contained in:
@@ -79,6 +79,9 @@ export interface PublicUser {
|
||||
canViewUsers?: boolean;
|
||||
canViewUserDocuments?: boolean;
|
||||
hasPassword?: boolean;
|
||||
isVerified?: boolean;
|
||||
verificationIcon?: string | null;
|
||||
canVerifyUsers?: boolean;
|
||||
}
|
||||
|
||||
export interface AdminUser {
|
||||
@@ -92,6 +95,8 @@ export interface AdminUser {
|
||||
createdAt: string;
|
||||
roles: string[];
|
||||
directPermissions?: string[];
|
||||
isVerified?: boolean;
|
||||
verificationIcon?: string | null;
|
||||
}
|
||||
|
||||
export interface AdminRole {
|
||||
@@ -230,6 +235,8 @@ export interface FamilyInviteCandidate {
|
||||
phone?: string | null;
|
||||
username?: string | null;
|
||||
hasAvatar?: boolean;
|
||||
isVerified?: boolean;
|
||||
verificationIcon?: string | null;
|
||||
}
|
||||
|
||||
export async function searchFamilyInviteUsers(groupId: string, query: string, token?: string | null) {
|
||||
@@ -653,6 +660,8 @@ export interface FamilyMember {
|
||||
role: string;
|
||||
displayName: string;
|
||||
hasAvatar: boolean;
|
||||
isVerified?: boolean;
|
||||
verificationIcon?: string | null;
|
||||
}
|
||||
|
||||
export interface FamilyGroup {
|
||||
@@ -699,6 +708,8 @@ export interface ChatMessage {
|
||||
senderId: string;
|
||||
senderName: string;
|
||||
senderHasAvatar: boolean;
|
||||
senderIsVerified?: boolean;
|
||||
senderVerificationIcon?: string | null;
|
||||
type: string;
|
||||
content?: string;
|
||||
replyToId?: string;
|
||||
@@ -735,6 +746,8 @@ export interface ChatRoomMember {
|
||||
userId: string;
|
||||
displayName: string;
|
||||
hasAvatar: boolean;
|
||||
isVerified?: boolean;
|
||||
verificationIcon?: string | null;
|
||||
notificationsMuted: boolean;
|
||||
familyRole?: string;
|
||||
isChatCreator?: boolean;
|
||||
|
||||
30
apps/frontend/lib/family-chat.ts
Normal file
30
apps/frontend/lib/family-chat.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ChatRoom, createChatRoom, fetchChatRooms } from '@/lib/api';
|
||||
|
||||
export async function findOrCreateMemberChat(
|
||||
groupId: string,
|
||||
memberUserId: string,
|
||||
memberName: string,
|
||||
currentUserId: string,
|
||||
token: string
|
||||
): Promise<ChatRoom> {
|
||||
const response = await fetchChatRooms(groupId, token);
|
||||
const rooms = response.rooms ?? [];
|
||||
const existing = rooms.find(
|
||||
(room) =>
|
||||
room.type === 'GROUP' &&
|
||||
room.members.length === 2 &&
|
||||
room.members.some((member) => member.userId === memberUserId) &&
|
||||
room.members.some((member) => member.userId === currentUserId)
|
||||
);
|
||||
if (existing) return existing;
|
||||
return createChatRoom(groupId, memberName, [memberUserId], token);
|
||||
}
|
||||
|
||||
export function roomDisplayLabel(room: ChatRoom, currentUserId: string) {
|
||||
if (room.type === 'GENERAL') return room.name;
|
||||
if (room.members.length === 2) {
|
||||
const other = room.members.find((member) => member.userId !== currentUserId);
|
||||
if (other) return other.displayName;
|
||||
}
|
||||
return room.name;
|
||||
}
|
||||
4
apps/frontend/lib/family-defaults.ts
Normal file
4
apps/frontend/lib/family-defaults.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export function defaultFamilyGroupName(displayName: string) {
|
||||
const trimmed = displayName.trim();
|
||||
return trimmed ? `Семья пользователя ${trimmed}` : 'Семья пользователя';
|
||||
}
|
||||
47
apps/frontend/lib/verification-icons.tsx
Normal file
47
apps/frontend/lib/verification-icons.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
Award,
|
||||
BadgeCheck,
|
||||
Crown,
|
||||
Gem,
|
||||
Heart,
|
||||
Moon,
|
||||
ShieldCheck,
|
||||
Sparkles,
|
||||
Star,
|
||||
Sun,
|
||||
type LucideIcon
|
||||
} from 'lucide-react';
|
||||
|
||||
export const DEFAULT_VERIFICATION_ICON = 'badge-check';
|
||||
|
||||
export const VERIFICATION_ICON_OPTIONS = [
|
||||
{ slug: 'badge-check', name: 'Галочка', Icon: BadgeCheck },
|
||||
{ slug: 'star', name: 'Звезда', Icon: Star },
|
||||
{ slug: 'sparkles', name: 'Искры', Icon: Sparkles },
|
||||
{ slug: 'moon', name: 'Луна', Icon: Moon },
|
||||
{ slug: 'sun', name: 'Солнце', Icon: Sun },
|
||||
{ slug: 'crown', name: 'Корона', Icon: Crown },
|
||||
{ slug: 'gem', name: 'Драгоценность', Icon: Gem },
|
||||
{ slug: 'heart', name: 'Сердце', Icon: Heart },
|
||||
{ slug: 'award', name: 'Награда', Icon: Award },
|
||||
{ slug: 'shield-check', name: 'Щит', Icon: ShieldCheck }
|
||||
] as const;
|
||||
|
||||
export type VerificationIconSlug = (typeof VERIFICATION_ICON_OPTIONS)[number]['slug'];
|
||||
|
||||
const iconBySlug = Object.fromEntries(VERIFICATION_ICON_OPTIONS.map((option) => [option.slug, option.Icon])) as Record<
|
||||
VerificationIconSlug,
|
||||
LucideIcon
|
||||
>;
|
||||
|
||||
export function resolveVerificationIcon(slug?: string | null): VerificationIconSlug {
|
||||
if (slug && slug in iconBySlug) {
|
||||
return slug as VerificationIconSlug;
|
||||
}
|
||||
return DEFAULT_VERIFICATION_ICON;
|
||||
}
|
||||
|
||||
export function VerificationIconGlyph({ slug, className }: { slug?: string | null; className?: string }) {
|
||||
const Icon = iconBySlug[resolveVerificationIcon(slug)];
|
||||
return <Icon className={className} aria-hidden />;
|
||||
}
|
||||
Reference in New Issue
Block a user