Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepanshuMishraa committed Oct 23, 2024
1 parent f552516 commit dcdfb8e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
26 changes: 14 additions & 12 deletions src/actions/job.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export const createJob = withSession<
workMode,
description,
hasSalaryRange,
hasExperiencerange,
hasExperienceRange,
companyId,
hasExpiryDate,
expiryDate,
maxSalary,
Expand All @@ -81,7 +82,8 @@ export const createJob = withSession<
userId: auth.user.id,
title,
description,
hasExperiencerange,
hasExperienceRange,
companyId,
minExperience,
expiryDate,
hasExpiryDate,
Expand Down Expand Up @@ -148,7 +150,7 @@ export const getAllJobs = withSession<
companyName: true,
city: true,
companyBio: true,
hasExperiencerange: true,
hasExperienceRange: true,
minExperience: true,
maxExperience: true,
hasExpiryDate: true,
Expand Down Expand Up @@ -288,7 +290,7 @@ export const getJobById = withServerActionAsyncCatcher<
companyLogo: true,
category: true,
city: true,
hasExperiencerange: true,
hasExperienceRange: true,
expiryDate: true,
hasExpiryDate: true,
minExperience: true,
Expand Down Expand Up @@ -416,7 +418,7 @@ export const toggleDeleteJobById = withServerActionAsyncCatcher<
},
select: {
deleted: true,
deletedAt: true,
// deletedAt: true,
},
});

Expand All @@ -425,15 +427,15 @@ export const toggleDeleteJobById = withServerActionAsyncCatcher<
}

const isNowDeleted = !job.deleted;
const deletedAt = isNowDeleted ? new Date() : null;
// const deletedAt = isNowDeleted ? new Date() : null;

const updatedJob = await prisma.job.update({
where: {
id: id,
},
data: {
deleted: isNowDeleted,
deletedAt: deletedAt,
// deletedAt: deletedAt,
},
});

Expand Down Expand Up @@ -497,14 +499,14 @@ export async function updateExpiredJobs() {
});
}
export const deleteOldDeltedJobs = async () => {
const twoWeeksAgo = new Date(Date.now() - 14 * 24 * 60 * 60 * 1000);
// const twoWeeksAgo = new Date(Date.now() - 14 * 24 * 60 * 60 * 1000);

await prisma.job.deleteMany({
where: {
deleted: true,
deletedAt: {
lte: twoWeeksAgo,
},
// deletedAt: {
// lte: twoWeeksAgo,
// },
},
});
};
Expand Down Expand Up @@ -589,7 +591,7 @@ export async function GetBookmarkByUserId() {
companyName: true,
city: true,
companyBio: true,
hasExperiencerange: true,
hasExperienceRange: true,
minExperience: true,
maxExperience: true,
hasExpiryDate: true,
Expand Down
5 changes: 3 additions & 2 deletions src/lib/validators/jobs.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const JobPostSchema = z
message: 'Curreny is required',
}),
skills: z.array(z.string()).optional(),
companyId: z.string(),
category: z.string(),
companyEmail: z.string().email('Invalid email').min(1, 'Email is required'),
companyBio: z.string().min(1, 'Company Bio is required'),
Expand All @@ -30,7 +31,7 @@ export const JobPostSchema = z
.number({ message: 'Max salary must be a number' })
.nonnegative()
.optional(),
hasExperiencerange: z.boolean(),
hasExperienceRange: z.boolean(),
minExperience: z.coerce
.number({ message: 'Min Experience must be a number' })
.nonnegative()
Expand Down Expand Up @@ -90,7 +91,7 @@ export const JobPostSchema = z
}
}

if (data.hasExperiencerange) {
if (data.hasExperienceRange) {
if (!data.minExperience) {
return ctx.addIssue({
message: 'Minimum Experience is required ',
Expand Down

0 comments on commit dcdfb8e

Please sign in to comment.