Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Stormgate1998 committed Sep 22, 2023
2 parents 4462073 + 2d58a8e commit 1acd7e3
Show file tree
Hide file tree
Showing 25 changed files with 497 additions and 118 deletions.
16 changes: 16 additions & 0 deletions src/v2/api/Controllers/TeamController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ public async Task<ActionResult<IEnumerable<DtoTeam>>> GetByEventID(long eventId)
}
}

[HttpGet("event/{eventId}/user/{userid}")]
public async Task<ActionResult<IEnumerable<DtoTeam>>> GetUsersTeamsForEvent(long eventId, int userId)
{
Log.Information("Getting User {userid} Teams by event {eventId}", userId, eventId);
try
{
var teams = mapper.Map<IEnumerable<DtoTeam>>(await teamRepository.GetUsersTeamsByEventIdAsync(eventId, userId));
return new ActionResult<IEnumerable<DtoTeam>>(teams);
}
catch (NotFoundException<IEnumerable<Team>> ex)
{
Log.Information(ex.Message, "Event Not Found");
return NotFound(ex.Message);
}
}

[HttpGet("{teamId}")]
public async Task<ActionResult<DtoTeam>> GetByID(long teamId)
{
Expand Down
43 changes: 27 additions & 16 deletions src/v2/api/DataAccess/TeamRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface ITeamRepository
Task<Team> GetTeamByIdAsync(long id);
Task<IEnumerable<Team>> GetAllAsync();
Task<IEnumerable<Team>> GetByEventIdAsync(long eventID);
Task<IEnumerable<Team>> GetUsersTeamsByEventIdAsync(long eventID, int userId);
Task<bool> ExistsAsync(long id);
}

Expand All @@ -19,7 +20,7 @@ public class TeamRepository : ITeamRepository
private readonly AspenContext context;
private readonly IMapper mapper;
private readonly IPersonTeamAssoicationRepository personTeamAssociationRepository;


public TeamRepository(AspenContext context, IMapper mapper, IPersonTeamAssoicationRepository personTeamAssociationRepository)
{
Expand All @@ -28,7 +29,7 @@ public TeamRepository(AspenContext context, IMapper mapper, IPersonTeamAssoicati
this.personTeamAssociationRepository = personTeamAssociationRepository;
}



public async Task<bool> ExistsAsync(long id)
{
Expand Down Expand Up @@ -62,7 +63,7 @@ public async Task<Team> AddAsync(Team team)
throw new Exception("Person is already on another team in this event");
}
}

await context.Teams.AddAsync(dbTeam);
existingEvent.Teams.Add(dbTeam);

Expand All @@ -76,7 +77,7 @@ public async Task<Team> EditTeamAsync(Team team)
{
var dbTeam = mapper.Map<DbTeam>(team);
context.Update(dbTeam);
if(team.isArchived == true)
if (team.isArchived == true)
{
var teamMembers = await personTeamAssociationRepository.GetTeamMembersAsync(team.ID);

Expand All @@ -89,23 +90,23 @@ public async Task<Team> EditTeamAsync(Team team)
return team;
}

/* public async Task DeleteTeamAsync(Team team)
{
var dbTeam = mapper.Map<DbTeam>(team);
context.Update(dbTeam);
/* public async Task DeleteTeamAsync(Team team)
{
var dbTeam = mapper.Map<DbTeam>(team);
context.Update(dbTeam);
var teamMembers = await personTeamAssociationRepository.GetTeamMembersAsync(team.ID);
var teamMembers = await personTeamAssociationRepository.GetTeamMembersAsync(team.ID);
foreach (var member in teamMembers)
{
await personTeamAssociationRepository.DeleteAsync(member.ID, team.ID);
}
foreach (var member in teamMembers)
{
await personTeamAssociationRepository.DeleteAsync(member.ID, team.ID);
}
await context.SaveChangesAsync();
}
*/
await context.SaveChangesAsync();
}
*/

public async Task<IEnumerable<Team>> GetByEventIdAsync(long eventID)
{
Expand All @@ -118,4 +119,14 @@ public async Task<IEnumerable<Team>> GetByEventIdAsync(long eventID)
return mapper.Map<IEnumerable<DbTeam>, IEnumerable<Team>>(unArchivedTeams);
}

public async Task<IEnumerable<Team>> GetUsersTeamsByEventIdAsync(long eventID, int userId)
{
var teams = await context.PersonTeamAssociations
.Include(a => a.Team)
.Where(a => a.EventId == eventID && a.PersonId == userId)
.Select(a => a.Team) // Select the Team objects
.ToListAsync();

return mapper.Map<IEnumerable<DbTeam>, IEnumerable<Team>>(teams);
}
}
77 changes: 77 additions & 0 deletions src/v2/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/v2/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/react-query": "^1.2.9",
"axios": "^1.5.0",
"bootstrap": "^5.3.1",
"bootstrap-icons": "^1.11.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
Expand Down
14 changes: 14 additions & 0 deletions src/v2/client/src/assets/WideContainer.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import "./custom.scss";

@mixin make-container($padding-x: $container-padding-x) {
width: 100%;
padding-right: $padding-x;
padding-left: $padding-x;
margin-right: auto;
margin-left: auto;
max-width: 100em;
}

.customContainer {
@include make-container(-x)
}
3 changes: 2 additions & 1 deletion src/v2/client/src/assets/custom.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$primary: #673AB7;
$secondary: #FFA500;
$secondary: #8AB73A;
$info: #0089DB;
$success: #C3DD94;

@import "../../node_modules/bootstrap/scss/bootstrap.scss"
2 changes: 1 addition & 1 deletion src/v2/client/src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Link } from "react-router-dom"

export const NavBar = () => {
return (
<nav className="navbar navbar-expand-md navbar-light bg-primary shadow-lg">
<nav className="navbar navbar-expand-md navbar-light bg-primary shadow">
<div className="container-fluid">
<a className="navbar-brand text-white fw-bold" href="https://sanpetepantry.org/" target="_blank" rel="noreferrer">
Sanpete Food Bank
Expand Down
43 changes: 43 additions & 0 deletions src/v2/client/src/components/Spinner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@import "../assets/custom.scss";

.lds-ring {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}

.lds-ring div {
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid $primary;
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: $primary transparent transparent transparent;
}

.lds-ring div:nth-child(1) {
animation-delay: -0.45s;
}

.lds-ring div:nth-child(2) {
animation-delay: -0.3s;
}

.lds-ring div:nth-child(3) {
animation-delay: -0.15s;
}

@keyframes lds-ring {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}
9 changes: 9 additions & 0 deletions src/v2/client/src/components/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import "./Spinner.scss";

export const Spinner = () => {
return (
<div className="d-flex justify-content-center">
<div className="lds-ring"><div></div><div></div><div></div><div></div></div>
</div>
)
}
1 change: 1 addition & 0 deletions src/v2/client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BrowserRouter } from 'react-router-dom';
import { StrictMode } from 'react';
import "bootstrap"
import "./assets/custom.scss"
import "bootstrap-icons/font/bootstrap-icons.css"
import { createRoot } from 'react-dom/client'

const queryClient = getQueryClient();
Expand Down
9 changes: 9 additions & 0 deletions src/v2/client/src/models/Donation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface Donation {
id: number;
eventID: number;
teamID: number;
personID: number;
date: string;
amount: number;
isPending: boolean;
}
11 changes: 11 additions & 0 deletions src/v2/client/src/models/Event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

export interface Event {
date: Date;
title?: string;
location?: string;
description?: string;
mainImage?: string;
donationTarget: number;
isArchived?: boolean;
id: number;
}
11 changes: 11 additions & 0 deletions src/v2/client/src/models/Team.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface Team {
id: number;
description: string;
mainImage: string;
ownerId: number;
eventId: number;
name: string;
donationTarget: number;
isArchived: boolean;
welcomeMessage: string;
}
Loading

0 comments on commit 1acd7e3

Please sign in to comment.