import { DASHBOARD_URL } from "../Config";
import Analytics from "../Utils/Analytics";
import Navigation from "../Utils/Navigation";
import UserUtil from "../Utils/User";
import BaseModel from "../../Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
import Name from "../../Types/Name";
import User from "../../Models/DatabaseModels/User";
export default class LoginUtil {
    static login(value) {
        const user = BaseModel.fromJSON(value["user"], User);
        UserUtil.setEmail(user.email);
        UserUtil.setUserId(user.id);
        UserUtil.setName(user.name || new Name(""));
        if (user.timezone) {
            UserUtil.setSavedUserTimezone(user.timezone);
        }
        if (user.isMasterAdmin) {
            UserUtil.setIsMasterAdmin(user.isMasterAdmin);
        }
        else {
            UserUtil.setIsMasterAdmin(false);
        }
        if (user.profilePictureId) {
            UserUtil.setProfilePicId(user.profilePictureId);
        }
        Analytics.userAuth(user.email);
        // go to dashboard, user should be logged in.
        Navigation.navigate(DASHBOARD_URL);
    }
}
//# sourceMappingURL=Login.js.map