import { User } from "@/types/types";

export const POST_EXPERTISE_REQUIRED_MESSAGE =
  "کاربر گرامی برای ثبت پست باید تخصص کاربری خود را مشخص کنید";

export const EXPERTISE_EDIT_PATH = "/settings/edit/expertise";

export function userHasExpertise(user?: User | null): boolean {
  return Boolean(user?.expertise?.trim());
}

export function buildExpertiseEditUrl(returnPath?: string): string {
  if (!returnPath || !returnPath.startsWith("/") || returnPath.startsWith("//")) {
    return EXPERTISE_EDIT_PATH;
  }
  return `${EXPERTISE_EDIT_PATH}?redirect=${encodeURIComponent(returnPath)}`;
}
