Skip to content

Commit

Permalink
Merge pull request #72 from cepdnaclk/main
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
KATTA-00 authored Jan 29, 2024
2 parents c9d6261 + 42fcddb commit 5ebeaa2
Show file tree
Hide file tree
Showing 56 changed files with 5,247 additions and 2,626 deletions.
17 changes: 9 additions & 8 deletions code/backend/src/controllers/login.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ class LoginController {
}

const email = loginReq.userName;
const manager = await ManagerModel.findOne({ email });
const manager = await ManagerModel.findOne({
teamId: loginReq.teamId,
email: email,
});
console.log(300);
console.log(manager);

console.log(manager?.isVerified);

if (manager?.isVerified == "pending" || manager?.isVerified == "rejected") {
throw new Error(HttpMsg.MANAGER_NOT_VERIFIED);
}




try {
// create refresh token
const refreshToken = createRefreshTokenManager(loginReq, role);
Expand Down Expand Up @@ -84,9 +89,6 @@ class LoginController {
loginReq.password
);




if (!isMatch) {
throw new Error(HttpMsg.PASSWORD_INCORRECT);
}
Expand All @@ -97,7 +99,6 @@ class LoginController {
throw new Error(HttpMsg.PLAYER_NOT_VERIFIED);
}


try {
// create refresh token
const refreshToken = createRefreshToken(loginReq, role);
Expand Down
48 changes: 35 additions & 13 deletions code/backend/src/controllers/manager.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Manager, ManagerResponse, ManagerTeamResponse } from "../models/manager.model";
import {
Manager,
ManagerResponse,
ManagerTeamResponse,
ManagersArrayResponse,
} from "../models/manager.model";
import TeamModel from "../db/team.schema";
import managerService from "../services/manager.service";
import managersInTeamService from "../services/managers.in.team.service";
Expand Down Expand Up @@ -92,15 +97,15 @@ class ManagerController {
// check the manager exits in that team
const managerExists = await managerService.checkManagerExistsInTeam(
managerEmail,
teamId
teamId
);

const newManagerExists = await managerService.checkManagerExistsInTeam(
newManagerEmail,
teamId
);

if (newManagerExists){
if (newManagerExists) {
throw new Error("New Manager already exists in the team");
}

Expand Down Expand Up @@ -176,34 +181,51 @@ class ManagerController {
}

// get all the teamPlayers with their details
async getPlayers(teamId: string): Promise<{ [jerseyId: number]: TeamPlayerResponse }>{

try{
async getPlayers(
teamId: string
): Promise<{ [jerseyId: number]: TeamPlayerResponse }> {
try {
const response = await managersInTeamService.getPlayersInTeam(teamId);
// console.log(response);
return response;
}catch(error) {
} catch (error) {
console.error(error);
throw error;
}
}

// get all the teamManagers with their details
async getManagers(teamId: string): Promise<Array<ManagersArrayResponse>> {
try {
const response = await managersInTeamService.getManagersInTeam(teamId);
// console.log(response);
return response;
} catch (error) {
console.error(error);
throw error;
}
}

//get Team Analytics
async getTeamAnalytics(teamId: string, duration:string): Promise<AnalyticsSummaryTeam> {

async getTeamAnalytics(
teamId: string,
duration: string
): Promise<AnalyticsSummaryTeam> {
// 'Last Week' , 'Last Month' , 'All Time'
let durationNumber: number = 0;

if (duration == "All Time"){
if (duration == "All Time") {
durationNumber = Date.now();
} else if (duration == "Last Month"){
} else if (duration == "Last Month") {
durationNumber = 30 * 24 * 60 * 60 * 1000;
} else if (duration == "Last Week"){
} else if (duration == "Last Week") {
durationNumber = 7 * 24 * 60 * 60 * 1000;
}
try {
const response = await managersInTeamService.getTeamAnalytics(teamId, durationNumber);
const response = await managersInTeamService.getTeamAnalytics(
teamId,
durationNumber
);
return response;
} catch (error) {
console.error(error);
Expand Down
Loading

0 comments on commit 5ebeaa2

Please sign in to comment.