import {UserType} from "@/lib/backend/appwrite_types";
import {redirect} from "next/navigation";
import {CLIENTS_DASHBOARD_URL, LOGIN_URL, PATIENT_DASHBOARD_URL} from "@/lib/constants";
import {useAuth} from "@/lib/hooks/useAuth";

export async function useIsAdmin() {
    const {userProfile} = await useAuth();
    if (userProfile) {
        switch (userProfile.userType) {
            case UserType.ADMIN:
                return;
            case UserType.PATIENT:
                redirect(PATIENT_DASHBOARD_URL)
                return;
            default:
                redirect(CLIENTS_DASHBOARD_URL)
        }
    } else {
        redirect(LOGIN_URL)
    }
}