Add dueDate to reminders, remove reminder from notes

Schema changes:
- Added dueDate field to companyReminders table
- Removed reminderDate and reminderSent from notes table

Backend changes:
- Updated company-reminder.service with dueDate handling
- Added getUpcomingReminders function for dashboard
- Simplified note.service (removed reminder logic)
- Updated validators and routes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
richardtekula
2025-12-01 11:21:54 +01:00
parent 947d1d9b99
commit ffaf916f5e
6 changed files with 82 additions and 113 deletions

View File

@@ -203,12 +203,11 @@ export const addCompanyNote = async (req, res) => {
try {
const userId = req.userId;
const { companyId } = req.params;
const { content, reminderAt } = req.body;
const { content } = req.body;
const note = await noteService.createNote(userId, {
content,
companyId,
reminderDate: reminderAt, // Map reminderAt to reminderDate
});
res.status(201).json({
@@ -229,11 +228,10 @@ export const addCompanyNote = async (req, res) => {
export const updateCompanyNote = async (req, res) => {
try {
const { noteId } = req.params;
const { content, reminderAt } = req.body;
const { content } = req.body;
const note = await noteService.updateNote(noteId, {
content,
reminderDate: reminderAt, // Map reminderAt to reminderDate
});
res.status(200).json({
@@ -291,9 +289,9 @@ export const getCompanyReminders = async (req, res) => {
export const createCompanyReminder = async (req, res) => {
try {
const { companyId } = req.params;
const { description, isChecked } = req.body;
const { description, dueDate, isChecked } = req.body;
const reminder = await companyReminderService.createReminder(companyId, { description, isChecked });
const reminder = await companyReminderService.createReminder(companyId, { description, dueDate, isChecked });
res.status(201).json({
success: true,
@@ -309,9 +307,9 @@ export const createCompanyReminder = async (req, res) => {
export const updateCompanyReminder = async (req, res) => {
try {
const { companyId, reminderId } = req.params;
const { description, isChecked } = req.body;
const { description, dueDate, isChecked } = req.body;
const reminder = await companyReminderService.updateReminder(companyId, reminderId, { description, isChecked });
const reminder = await companyReminderService.updateReminder(companyId, reminderId, { description, dueDate, isChecked });
res.status(200).json({
success: true,
@@ -365,3 +363,17 @@ export const getReminderCountsByCompany = async (_req, res) => {
res.status(error.statusCode || 500).json(errorResponse);
}
};
export const getUpcomingReminders = async (_req, res) => {
try {
const reminders = await companyReminderService.getUpcomingReminders();
res.status(200).json({
success: true,
count: reminders.length,
data: reminders,
});
} catch (error) {
const errorResponse = formatErrorResponse(error, process.env.NODE_ENV === 'development');
res.status(error.statusCode || 500).json(errorResponse);
}
};