Added teams pages. Refactored hooks.

This commit is contained in:
Mike Cao 2024-01-28 18:33:40 -08:00
parent a2c202fa36
commit 9448aa3ab5
136 changed files with 387 additions and 287 deletions

View file

@ -3,7 +3,7 @@ import { canDeleteTeam, canUpdateTeam, canViewTeam } from 'lib/auth';
import { useAuth, useValidate } from 'lib/middleware';
import { NextApiRequestQueryBody } from 'lib/types';
import { NextApiResponse } from 'next';
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
import { methodNotAllowed, notFound, ok, unauthorized } from 'next-basics';
import { deleteTeam, getTeamById, updateTeam } from 'queries';
import * as yup from 'yup';
@ -44,9 +44,13 @@ export default async (
return unauthorized(res);
}
const user = await getTeamById(teamId, { includeTeamUser: true });
const team = await getTeamById(teamId, { includeTeamUser: true });
return ok(res, user);
if (!team) {
return notFound(res);
}
return ok(res, team);
}
if (req.method === 'POST') {