Deploy rule, CRM enhancements, Company Employee category, bilingual, contacts module completion
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import { Router } from 'express';
|
||||
import { body, param } from 'express-validator';
|
||||
import multer from 'multer';
|
||||
import { contactsController } from './contacts.controller';
|
||||
import { authenticate, authorize } from '../../shared/middleware/auth';
|
||||
import { validate } from '../../shared/middleware/validation';
|
||||
import categoriesRouter from './categories.routes';
|
||||
|
||||
const router = Router();
|
||||
const upload = multer({ storage: multer.memoryStorage() });
|
||||
|
||||
// All routes require authentication
|
||||
router.use(authenticate);
|
||||
@@ -94,6 +97,15 @@ router.post(
|
||||
contactsController.merge
|
||||
);
|
||||
|
||||
// Get relationships for a contact
|
||||
router.get(
|
||||
'/:id/relationships',
|
||||
authorize('contacts', 'contacts', 'read'),
|
||||
param('id').isUUID(),
|
||||
validate,
|
||||
contactsController.getRelationships
|
||||
);
|
||||
|
||||
// Add relationship
|
||||
router.post(
|
||||
'/:id/relationships',
|
||||
@@ -103,10 +115,75 @@ router.post(
|
||||
body('toContactId').isUUID(),
|
||||
body('type').notEmpty(),
|
||||
body('startDate').isISO8601(),
|
||||
body('endDate').optional().isISO8601(),
|
||||
body('notes').optional(),
|
||||
validate,
|
||||
],
|
||||
contactsController.addRelationship
|
||||
);
|
||||
|
||||
// Update relationship
|
||||
router.put(
|
||||
'/:id/relationships/:relationshipId',
|
||||
authorize('contacts', 'contacts', 'update'),
|
||||
[
|
||||
param('id').isUUID(),
|
||||
param('relationshipId').isUUID(),
|
||||
body('type').optional(),
|
||||
body('startDate').optional().isISO8601(),
|
||||
body('endDate').optional().isISO8601(),
|
||||
body('notes').optional(),
|
||||
body('isActive').optional().isBoolean(),
|
||||
validate,
|
||||
],
|
||||
contactsController.updateRelationship
|
||||
);
|
||||
|
||||
// Delete relationship
|
||||
router.delete(
|
||||
'/:id/relationships/:relationshipId',
|
||||
authorize('contacts', 'contacts', 'delete'),
|
||||
[
|
||||
param('id').isUUID(),
|
||||
param('relationshipId').isUUID(),
|
||||
validate,
|
||||
],
|
||||
contactsController.deleteRelationship
|
||||
);
|
||||
|
||||
// Check for duplicates
|
||||
router.post(
|
||||
'/check-duplicates',
|
||||
authorize('contacts', 'contacts', 'read'),
|
||||
[
|
||||
body('email').optional().isEmail(),
|
||||
body('phone').optional(),
|
||||
body('mobile').optional(),
|
||||
body('taxNumber').optional(),
|
||||
body('commercialRegister').optional(),
|
||||
body('excludeId').optional().isUUID(),
|
||||
validate,
|
||||
],
|
||||
contactsController.checkDuplicates
|
||||
);
|
||||
|
||||
// Import contacts
|
||||
router.post(
|
||||
'/import',
|
||||
authorize('contacts', 'contacts', 'create'),
|
||||
upload.single('file'),
|
||||
contactsController.import
|
||||
);
|
||||
|
||||
// Export contacts
|
||||
router.get(
|
||||
'/export',
|
||||
authorize('contacts', 'contacts', 'read'),
|
||||
contactsController.export
|
||||
);
|
||||
|
||||
// Mount categories router
|
||||
router.use('/categories', categoriesRouter);
|
||||
|
||||
export default router;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user