veza/apps/web/src/services/userService.ts

63 lines
3.3 KiB
TypeScript
Raw Normal View History

import { User } from '../types';
const MOCK_PROFILE: User = {
id: 'u1',
username: 'Cyber_Producer',
email: 'demo@veza.io',
first_name: 'Alex',
last_name: 'Mercer',
avatar: 'https://picsum.photos/id/237/200/200',
banner: 'https://picsum.photos/id/238/1200/400',
roles: ['PRODUCER', 'VERIFIED'],
status: 'online',
joinDate: '2023-01-01',
tier: 'Pro',
stats: { followers: 1250, following: 300, tracks: 15, plays: 45000 },
bio: 'Synthwave producer and sound designer based in Tokyo. Creating neon-drenched soundscapes for the digital age.',
location: 'Tokyo, Japan',
socials: { twitter: '@cyber_prod', instagram: '@cyber_beats' },
website: 'www.cyberprod.com'
2026-01-07 18:39:21 +00:00
} as unknown as User;
const MOCK_USERS_LIST: User[] = [
MOCK_PROFILE,
2026-01-07 18:39:21 +00:00
{ id: 'u2', username: 'Sarah Connor', first_name: 'Sarah', last_name: 'Connor', email: 'sarah@skynet.com', avatar: 'https://picsum.photos/id/64/100/100', roles: ['ARTIST'], status: 'dnd', joinDate: '2024-01-15', tier: 'Enterprise', stats: { followers: 5000, following: 10, tracks: 5, plays: 20000 }, lastLogin: '1 day ago' } as unknown as User,
{ id: 'u3', username: 'Bot_User_99', first_name: 'Bot', last_name: 'Account', email: 'bot@spam.com', avatar: 'https://picsum.photos/id/10/100/100', roles: [], status: 'offline', joinDate: '2023-12-20', tier: 'Free', stats: { followers: 0, following: 5000, tracks: 0, plays: 0 }, lastLogin: '3 days ago' } as unknown as User,
{ id: 'u4', username: 'Admin_Dave', first_name: 'Dave', last_name: 'Bowman', email: 'dave@veza.io', avatar: 'https://picsum.photos/id/30/100/100', roles: ['ADMIN'], status: 'online', joinDate: '2022-05-01', tier: 'Enterprise', stats: { followers: 100, following: 0, tracks: 0, plays: 0 }, lastLogin: 'Now' } as unknown as User,
{ id: 'u5', username: 'Neon_Pulse', first_name: 'Jenny', last_name: 'K', email: 'jen@synth.fm', avatar: 'https://picsum.photos/id/55/100/100', roles: ['PRODUCER'], status: 'idle', joinDate: '2023-08-10', tier: 'Pro', stats: { followers: 320, following: 150, tracks: 8, plays: 1200 }, lastLogin: '5 hours ago' } as unknown as User,
];
export const userService = {
getProfile: async (id: string) => {
await new Promise(resolve => setTimeout(resolve, 400));
// In a real app, fetch specific user. Here we return the main mock or find in list
const found = MOCK_USERS_LIST.find(u => u.id === id);
return { profile: found || { ...MOCK_PROFILE, id } };
},
getProfileByUsername: async (username: string) => {
await new Promise(resolve => setTimeout(resolve, 400));
return { profile: { ...MOCK_PROFILE, username } };
},
updateProfile: async (_id: string, data: any) => {
await new Promise(resolve => setTimeout(resolve, 1000));
return { profile: { ...MOCK_PROFILE, ...data } };
},
getProfileCompletion: async (_id: string) => {
return { completion_percentage: 85, missing_fields: ['phone'] };
},
list: async (params?: { search?: string; role?: string }) => {
await new Promise(resolve => setTimeout(resolve, 600));
let users = [...MOCK_USERS_LIST];
if (params?.search) {
const q = params.search.toLowerCase();
users = users.filter(u => u.username.toLowerCase().includes(q) || u.email.toLowerCase().includes(q));
}
return { users };
}
};