// Path: Frontend/src/lib/routes.ts

export type AppRole = "student" | "teacher";

export const isPublicRoute = (pathname: string) => pathname === "/" || pathname.startsWith("/auth/");

export const getDashboardHomeHref = (role: AppRole) => `/dashboard/${role}`;

export const getDashboardAssignmentsHref = (role: AppRole) => `${getDashboardHomeHref(role)}/assignments`;

export const getDashboardAssignmentCreateHref = (role: AppRole) => `${getDashboardHomeHref(role)}/assignment/create`;

export const getDashboardTeacherClosedAssignmentsHref = () => `/dashboard/teacher/assignments/closed`;

export const getDashboardClassroomsHref = (role: AppRole) => `${getDashboardHomeHref(role)}/classrooms`;

export const getDashboardTeacherClassroomHref = (classroomId: number | string, studentId?: number | string | null) => {
	const base = `${getDashboardClassroomsHref("teacher")}/${classroomId}`;
	return studentId ? `${base}?student=${studentId}` : base;
};

export const getDashboardMessagesHref = (role: AppRole) => `${getDashboardHomeHref(role)}/messages`;

export const getDashboardSettingsHref = (role: AppRole) => `${getDashboardHomeHref(role)}/settings`;

export const getDashboardPracticeHref = () => `${getDashboardHomeHref("student")}/practice`;

export const getDashboardProgressHref = () => `${getDashboardHomeHref("student")}/progress`;

export const getAssignmentReviewHref = (role: AppRole, assignmentId: number | string) => `/assignments/${role}/${assignmentId}`;

export const getTeacherAssignmentNextStepHref = (assignmentId: number | string, studentId?: number | string | null) => {
	const base = `/assignments/teacher/${assignmentId}/next-step`;
	return studentId ? `${base}?student=${studentId}` : base;
};

export const getTeacherAssignmentRedoPlanHref = (assignmentId: number | string, studentId?: number | string | null) => {
	const base = `/assignments/teacher/${assignmentId}/redo-plan`;
	return studentId ? `${base}?student=${studentId}` : base;
};

export const getAssignmentWorkHref = (assignmentId: number | string) => `/assignments/student/${assignmentId}/work`;

export const getDashboardMessageThreadHref = (role: AppRole, threadId: number | string) => `${getDashboardMessagesHref(role)}?thread=${threadId}`;

export const getPostAuthRedirectHref = (role: AppRole) => getDashboardHomeHref(role);
