refactor(backend): add status constants and update code to use them
- Create constants/statuses.js with MATCH_STATUS, SUGGESTION_STATUS - Update routes/dashboard.js to use MATCH_STATUS - Update routes/matches.js to use MATCH_STATUS - Update routes/events.js to use SUGGESTION_STATUS - Update services/matching.js to use SUGGESTION_STATUS - Update tests to use constants
This commit is contained in:
@@ -8,6 +8,7 @@ const router = express.Router();
|
||||
const { authenticate } = require('../middleware/auth');
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const { getEventsOnlineCounts } = require('../socket');
|
||||
const { MATCH_STATUS } = require('../constants');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
@@ -101,7 +102,7 @@ router.get('/', authenticate, async (req, res, next) => {
|
||||
{ user1Id: userId },
|
||||
{ user2Id: userId },
|
||||
],
|
||||
status: 'accepted',
|
||||
status: MATCH_STATUS.ACCEPTED,
|
||||
},
|
||||
include: {
|
||||
user1: {
|
||||
@@ -219,7 +220,7 @@ router.get('/', authenticate, async (req, res, next) => {
|
||||
const incomingRequests = await prisma.match.findMany({
|
||||
where: {
|
||||
user2Id: userId,
|
||||
status: 'pending',
|
||||
status: MATCH_STATUS.PENDING,
|
||||
},
|
||||
include: {
|
||||
user1: {
|
||||
@@ -298,7 +299,7 @@ router.get('/', authenticate, async (req, res, next) => {
|
||||
const outgoingRequests = await prisma.match.findMany({
|
||||
where: {
|
||||
user1Id: userId,
|
||||
status: 'pending',
|
||||
status: MATCH_STATUS.PENDING,
|
||||
},
|
||||
include: {
|
||||
user2: {
|
||||
|
||||
Reference in New Issue
Block a user