text: // Settimeout
  // Promise
  // HTTP status codes
  
  import { uuidv4 } from "./utils";
  
  const delay = 3000;
  
  export function register(profile) {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        profile.userId = uuidv4();
  
        localStorage.setItem("profile", JSON.stringify(profile));
  
        return resolve({
          status: 200,
          data: {
            message: "Your profile has been created successfully.",
            profile: {
              email: profile.email,
              username: profile.username,
              userId: profile.userId,
            },
          },
        });
      }, delay);
    });
  }
  
  export function login(profile) {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        const _profile = JSON.parse(localStorage.getItem("profile"));
  
        if (
          _profile.username === profile.username &&
          _profile.password === profile.password
        ) {
          return resolve({
            status: 200,
            data: {
              message: "You are logged in successfully.",
              profile: {
                email: _profile.email,
                username: _profile.username,
                userId: _profile.userId,
              },
            },
          });
        }
  
        return reject({
          status: 401,
          data: {
            message: "Your username and/or password is wrong.",
            profile: {},
          },
        });
      }, delay);
    });
  }
  