Refactored queries.

This commit is contained in:
Mike Cao 2024-01-30 00:10:25 -08:00
parent 18e36aa7b3
commit b16f5cc067
67 changed files with 523 additions and 576 deletions

View file

@ -4,7 +4,7 @@ import { useAuth, useValidate } from 'lib/middleware';
import { NextApiRequestQueryBody } from 'lib/types';
import { NextApiResponse } from 'next';
import { methodNotAllowed, notFound, ok } from 'next-basics';
import { createTeamUser, getTeamByAccessCode, getTeamUser } from 'queries';
import { createTeamUser, findTeam, getTeamUser } from 'queries';
import * as yup from 'yup';
export interface TeamsJoinRequestBody {
accessCode: string;
@ -26,7 +26,11 @@ export default async (
if (req.method === 'POST') {
const { accessCode } = req.body;
const team = await getTeamByAccessCode(accessCode);
const team = await findTeam({
where: {
accessCode,
},
});
if (!team) {
return notFound(res, 'message.team-not-found');