Skip to content

Commit

Permalink
fix order of job controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
Anoushka21 committed Dec 25, 2024
1 parent 67973a1 commit b0641f5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/controllers/jobsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ const resetJobsFilters = async (req, res) => {
}
};

const getCategories = async (req, res) => {
try {
const categories = await Job.distinct('category', {});

// Sort categories alphabetically
categories.sort((a, b) => a.localeCompare(b));

res.status(200).json({ categories });
} catch (error) {
console.error('Error fetching categories:', error);
res.status(500).json({ message: 'Failed to fetch categories' });
}
};
// Controller to fetch job details by ID
const getJobById = async (req, res) => {
const { id } = req.params;
Expand Down Expand Up @@ -202,19 +215,7 @@ const deleteJob = async (req, res) => {
}
};

const getCategories = async (req, res) => {
try {
const categories = await Job.distinct('category', {});

// Sort categories alphabetically
categories.sort((a, b) => a.localeCompare(b));

res.status(200).json({ categories });
} catch (error) {
console.error('Error fetching categories:', error);
res.status(500).json({ message: 'Failed to fetch categories' });
}
};

// Export controllers as a plain object
module.exports = {
Expand Down

0 comments on commit b0641f5

Please sign in to comment.