Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/usequery #568

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
fix:minor change
Paribesh01 committed Nov 3, 2024
commit abfd631c12e247afa49ea6fd88bd81df8fa7a496
7 changes: 2 additions & 5 deletions src/actions/job.action.ts
Original file line number Diff line number Diff line change
@@ -191,22 +191,19 @@ export const getRecommendedJobs = withServerActionAsyncCatcher<
const { id } = result;

const job = await prisma.job.findUnique({
where: { id }, // Ensure params.id is available
where: { id },
select: {
id: true,
category: true,
// Add any other fields you need from the job
},
});

if (!job) {
throw new Error('Job not found');
}

// Use the category from the fetched job
const { category } = job;

// Fetch the latest three jobs excluding the current job and in the same category
const jobs = await prisma.job.findMany({
where: {
category: category,
@@ -252,7 +249,7 @@ export const getRecommendedJobs = withServerActionAsyncCatcher<
orderBy: {
postedAt: 'desc',
},
take: 3, // Fallback to showing latest 3 jobs from other categories
take: 3,
select: {
id: true,
type: true,
4 changes: 0 additions & 4 deletions src/components/RecentJobs.tsx
Original file line number Diff line number Diff line change
@@ -5,10 +5,6 @@ import { useQuery } from '@tanstack/react-query';
import { useSession } from 'next-auth/react';

export default function RecentJobs() {
// const [recentJobs, getUserBookmarks] = await Promise.all([
// await getRecentJobs(),
// await GetUserBookmarksId(),
// ]);
const session = useSession();

const { data } = useQuery({