Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

591 B
Raw Blame
"use server";
import prisma from "@/lib/db";
import { handleError } from "@/lib/utils";
import { requireUser } from "../shared";
import { STAGE_DETAIL_INCLUDE, sortStages } from "./shared";

export const getJobStages = async (
  jobId: string,
): Promise<any | undefined> => {
  try {
    const user = await requireUser();
    const stages = await prisma.jobStage.findMany({
      where: { jobId, Job: { userId: user.id } },
      include: STAGE_DETAIL_INCLUDE,
    });
    return sortStages(stages);
  } catch (error) {
    return handleError(error, "Failed to fetch job stages. ");
  }
};