import users from "./users.json"
let userid =100

export interface User {
    id: number;
    email: string;
    username: string;
    name:string;
    last_name: string;
    phone:string
}
export async function getUser(id:number){
    return users.find(u=>u.id===id)
}
export async function getUsers(){
    return users
}
export async function createUser(u:User){
    u.id= userid++
    return users.push(u)
}
export async function updateUser(u:User){
    const user = await getUser(u.id)
    if(!user)
        return user
    user.phone = u.phone
    return user
}