diff --git a/src/v2/api/Controllers/TeamController.cs b/src/v2/api/Controllers/TeamController.cs index b3035365..f5293e69 100644 --- a/src/v2/api/Controllers/TeamController.cs +++ b/src/v2/api/Controllers/TeamController.cs @@ -49,6 +49,22 @@ public async Task>> GetByEventID(long eventId) } } + [HttpGet("event/{eventId}/user/{userid}")] + public async Task>> GetUsersTeamsForEvent(long eventId, int userId) + { + Log.Information("Getting User {userid} Teams by event {eventId}", userId, eventId); + try + { + var teams = mapper.Map>(await teamRepository.GetUsersTeamsByEventIdAsync(eventId, userId)); + return new ActionResult>(teams); + } + catch (NotFoundException> ex) + { + Log.Information(ex.Message, "Event Not Found"); + return NotFound(ex.Message); + } + } + [HttpGet("{teamId}")] public async Task> GetByID(long teamId) { diff --git a/src/v2/api/DataAccess/TeamRepository.cs b/src/v2/api/DataAccess/TeamRepository.cs index 5086e94d..8c530fdf 100644 --- a/src/v2/api/DataAccess/TeamRepository.cs +++ b/src/v2/api/DataAccess/TeamRepository.cs @@ -11,6 +11,7 @@ public interface ITeamRepository Task GetTeamByIdAsync(long id); Task> GetAllAsync(); Task> GetByEventIdAsync(long eventID); + Task> GetUsersTeamsByEventIdAsync(long eventID, int userId); Task ExistsAsync(long id); } @@ -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) { @@ -28,7 +29,7 @@ public TeamRepository(AspenContext context, IMapper mapper, IPersonTeamAssoicati this.personTeamAssociationRepository = personTeamAssociationRepository; } - + public async Task ExistsAsync(long id) { @@ -62,7 +63,7 @@ public async Task AddAsync(Team team) throw new Exception("Person is already on another team in this event"); } } - + await context.Teams.AddAsync(dbTeam); existingEvent.Teams.Add(dbTeam); @@ -76,7 +77,7 @@ public async Task EditTeamAsync(Team team) { var dbTeam = mapper.Map(team); context.Update(dbTeam); - if(team.isArchived == true) + if (team.isArchived == true) { var teamMembers = await personTeamAssociationRepository.GetTeamMembersAsync(team.ID); @@ -89,23 +90,23 @@ public async Task EditTeamAsync(Team team) return team; } - /* public async Task DeleteTeamAsync(Team team) - { - var dbTeam = mapper.Map(team); - context.Update(dbTeam); + /* public async Task DeleteTeamAsync(Team team) + { + var dbTeam = mapper.Map(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> GetByEventIdAsync(long eventID) { @@ -118,4 +119,14 @@ public async Task> GetByEventIdAsync(long eventID) return mapper.Map, IEnumerable>(unArchivedTeams); } + public async Task> 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>(teams); + } } diff --git a/src/v2/client/package-lock.json b/src/v2/client/package-lock.json index 5717fd11..ee4d0886 100644 --- a/src/v2/client/package-lock.json +++ b/src/v2/client/package-lock.json @@ -18,7 +18,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", @@ -5121,6 +5123,29 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.0.tgz", + "integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -5552,6 +5577,21 @@ "@popperjs/core": "^2.11.8" } }, + "node_modules/bootstrap-icons": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.11.1.tgz", + "integrity": "sha512-F0DDp7nKUX+x/QtpfRZ+XHFya60ng9nfdpdS59vDDfs4Uhuxp7zym/QavMsu/xx51txkoM9eVmpE7D08N35blw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ] + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -14297,6 +14337,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", @@ -21363,6 +21408,28 @@ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.8.1.tgz", "integrity": "sha512-9l850jDDPnKq48nbad8SiEelCv4OrUWrKab/cPj0GScVg6cb6NbCCt/Ulk26QEq5jP9NnGr04Bit1BHyV6r5CQ==" }, + "axios": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.0.tgz", + "integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -21694,6 +21761,11 @@ "integrity": "sha512-jzwza3Yagduci2x0rr9MeFSORjcHpt0lRZukZPZQJT1Dth5qzV7XcgGqYzi39KGAVYR8QEDVoO0ubFKOxzMG+g==", "requires": {} }, + "bootstrap-icons": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.11.1.tgz", + "integrity": "sha512-F0DDp7nKUX+x/QtpfRZ+XHFya60ng9nfdpdS59vDDfs4Uhuxp7zym/QavMsu/xx51txkoM9eVmpE7D08N35blw==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -27833,6 +27905,11 @@ } } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", diff --git a/src/v2/client/package.json b/src/v2/client/package.json index 8cd902fa..c98e7177 100644 --- a/src/v2/client/package.json +++ b/src/v2/client/package.json @@ -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", diff --git a/src/v2/client/src/assets/WideContainer.module.scss b/src/v2/client/src/assets/WideContainer.module.scss new file mode 100644 index 00000000..20400f97 --- /dev/null +++ b/src/v2/client/src/assets/WideContainer.module.scss @@ -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) +} \ No newline at end of file diff --git a/src/v2/client/src/assets/custom.scss b/src/v2/client/src/assets/custom.scss index d8cba774..3b4c27f4 100644 --- a/src/v2/client/src/assets/custom.scss +++ b/src/v2/client/src/assets/custom.scss @@ -1,5 +1,6 @@ $primary: #673AB7; -$secondary: #FFA500; +$secondary: #8AB73A; $info: #0089DB; +$success: #C3DD94; @import "../../node_modules/bootstrap/scss/bootstrap.scss" \ No newline at end of file diff --git a/src/v2/client/src/components/NavBar.tsx b/src/v2/client/src/components/NavBar.tsx index 933ee5f5..fc2882ed 100644 --- a/src/v2/client/src/components/NavBar.tsx +++ b/src/v2/client/src/components/NavBar.tsx @@ -2,7 +2,7 @@ import { Link } from "react-router-dom" export const NavBar = () => { return ( -