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.
TypeScript ai-agentai-resume-analyzerapplication-trackerapplication-tracking-systematscareerjob-applicationjob-automationjob-huntingjob-searchjob-seeker-toolsjob-trackerjob-trackingjobsearchjobseekersmcpollamaresumeresume-reviewself-hosted
Move util functions from dashboard actions
Khuram Niaz6faa27dd9bd2
diff --git a/src/actions/dashboard.actions.ts b/src/actions/dashboard.actions.tsindex 86021a3..26305e2 100644--- a/src/actions/dashboard.actions.ts+++ b/src/actions/dashboard.actions.ts@@ -1,4 +1,5 @@import prisma from "@/lib/db";+import { calculatePercentageDifference, getLast7Days } from "@/lib/utils";import { getCurrentUser } from "@/utils/user.utils";import { Prisma } from "@prisma/client";import { addMinutes, format, subDays } from "date-fns";@@ -41,21 +42,6 @@ export const getJobsAppliedForPeriod = async (}};-const calculatePercentageDifference = (- value1: number,- value2: number-): number | null => {- if (value1 === 0 && value2 === 0) {- return 0;- }- if (value1 === 0) {- return value2 !== 0 ? 100 : 0;- }-- const difference = ((value2 - value1) / Math.abs(value1)) * 100;- return Math.round(difference);-};-export const getRecentJobs = async (): Promise<any | undefined> => {try {const user = await getCurrentUser();@@ -88,17 +74,6 @@ export const getRecentJobs = async (): Promise<any | undefined> => {}};-// Helper function to get an array of dates for the last 7 days-const getLast7Days = (dateType = "PP") => {- const dates = [];- for (let i = 6; i >= 0; i--) {- const date = new Date();- date.setDate(date.getDate() - i);- dates.push(format(date, dateType));- }- return dates;-};-export const getActivityDataForPeriod = async (): Promise<any | undefined> => {try {const user = await getCurrentUser();diff --git a/src/lib/utils.ts b/src/lib/utils.tsindex 1fcfb3a..1dacdf8 100644--- a/src/lib/utils.ts+++ b/src/lib/utils.ts@@ -1,5 +1,5 @@import { type ClassValue, clsx } from "clsx";-import { parse } from "date-fns";+import { format, parse } from "date-fns";import { NextApiRequest } from "next";import { twMerge } from "tailwind-merge";@@ -81,3 +81,28 @@ export const formatElapsedTime = (ms: number) => {return `${hours > 0 ? `${hours}h ` : ""}${minutes}m ${seconds}s`;};++export const calculatePercentageDifference = (+ value1: number,+ value2: number+): number | null => {+ if (value1 === 0 && value2 === 0) {+ return 0;+ }+ if (value1 === 0) {+ return value2 !== 0 ? 100 : 0;+ }++ const difference = ((value2 - value1) / Math.abs(value1)) * 100;+ return Math.round(difference);+};++export const getLast7Days = (dateType = "PP") => {+ const dates = [];+ for (let i = 6; i >= 0; i--) {+ const date = new Date();+ date.setDate(date.getDate() - i);+ dates.push(format(date, dateType));+ }+ return dates;+};