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

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