diff --git a/Resources/Views/Team/_team.leaf b/Resources/Views/Team/_team.leaf index dc105077..af45af80 100644 --- a/Resources/Views/Team/_team.leaf +++ b/Resources/Views/Team/_team.leaf @@ -49,10 +49,15 @@ #endif #if(teamMember.twitter): - + #endif + #if(teamMember.slack): + + + + #endif diff --git a/Sources/App/Context/HomeContext.swift b/Sources/App/Context/HomeContext.swift index 186b0a55..d1998f9f 100644 --- a/Sources/App/Context/HomeContext.swift +++ b/Sources/App/Context/HomeContext.swift @@ -116,6 +116,7 @@ struct TeamContext: Content { let role: String? let twitter: String? let linkedin: String? + let slack: String? let imageURL: String? } diff --git a/Sources/App/Features/Home/HomeRouteController.swift b/Sources/App/Features/Home/HomeRouteController.swift index 18306425..510dedba 100644 --- a/Sources/App/Features/Home/HomeRouteController.swift +++ b/Sources/App/Features/Home/HomeRouteController.swift @@ -24,10 +24,24 @@ struct HomeRouteController: RouteCollection { try await event.$days.load(on: req.db) - // We shuffle the team members array on each load request in order to remove any bias in the array. - // All volunteers are shown equally. + // Fetch team data from API to maintain consistency between web and mobile + let teamAPIController = TeamAPIController() + let teamResponse = try await teamAPIController.getTeam(req: req) + + // Convert API response to context format for the web template + let teamMembers = teamResponse.teamMembers.map { member in + TeamContext.TeamMember( + name: member.name, + role: member.role, + twitter: member.twitter, + linkedin: member.linkedin, + slack: member.slack, + imageURL: member.imageURL + ) + } + let context = TeamContext( - teamMembers: teamMembers.shuffled(), + teamMembers: teamMembers, event: EventContext(event: event) ) diff --git a/Sources/App/Features/Home/TeamMembers.swift b/Sources/App/Features/Home/TeamMembers.swift deleted file mode 100644 index 59caea5c..00000000 --- a/Sources/App/Features/Home/TeamMembers.swift +++ /dev/null @@ -1,72 +0,0 @@ -let teamMembers: [TeamContext.TeamMember] = [ - .init( - name: "Adam Rush", - role: "Founder and Host", - twitter: "https://twitter.com/Adam9Rush", - linkedin: "https://www.linkedin.com/in/swiftlyrush/", - imageURL: "/img/team/rush.jpg" - ), - .init( - name: "James Sherlock", - role: "Production Team Lead", - twitter: "https://twitter.com/JamesSherlouk", - linkedin: "https://www.linkedin.com/in/jamessherlockdeveloper/", - imageURL: "/img/team/sherlock.jpg" - ), - .init( - name: "Matthew Gallagher", - role: "Registration and Mobile App", - twitter: "https://twitter.com/pdamonkey", - linkedin: "https://www.linkedin.com/in/pdamonkey/", - imageURL: "/img/team/matt.jpg" - ), - .init( - name: "Adam Oxley", - role: nil, - twitter: "https://twitter.com/admoxly", - linkedin: "https://www.linkedin.com/in/adam-oxley-41183a82/", - imageURL: "/img/team/oxley.jpg" - ), - .init( - name: "Noam Efergan", - role: "Camera Operator and Social Media", - twitter: "https://twitter.com/No_Wham", - linkedin: "https://www.linkedin.com/in/noamefergan/", - imageURL: "/img/team/noam.jpg" - ), - .init( - name: "Kannan Prasad", - role: nil, - twitter: nil, - linkedin: "https://www.linkedin.com/in/kannanprasad/", - imageURL: "/img/team/kannan.jpg" - ), - .init( - name: "Muralidharan Kathiresan", - role: nil, - twitter: "https://twitter.com/Muralidharan_K", - linkedin: "https://www.linkedin.com/in/muralidharankathiresan/", - imageURL: "/img/team/mural.jpg" - ), - .init( - name: "Preeti Thombare", - role: nil, - twitter: nil, - linkedin: nil, - imageURL: "/img/team/preeti.jpg" - ), - .init( - name: "Paul Willis", - role: nil, - twitter: nil, - linkedin: "https://www.linkedin.com/in/paulrobertwillis/", - imageURL: "/img/team/paul.jpg" - ), - .init( - name: "Joe Williams", - role: "Camera Operator", - twitter: "https://twitter.com/joedub_dev", - linkedin: "https://www.linkedin.com/in/joe-williams-1676b871/", - imageURL: "/img/team/joe.jpg" - ), -] diff --git a/Sources/App/Features/Team/Controllers/TeamAPIController.swift b/Sources/App/Features/Team/Controllers/TeamAPIController.swift new file mode 100644 index 00000000..92a3ddc0 --- /dev/null +++ b/Sources/App/Features/Team/Controllers/TeamAPIController.swift @@ -0,0 +1,95 @@ +import Vapor + +struct TeamAPIController: RouteCollection { + func boot(routes: RoutesBuilder) throws { + routes.get(use: getTeam) + } + + @Sendable func getTeam(req: Request) async throws -> TeamResponse { + let teamMembers = [ + TeamMember( + name: "Adam Rush", + role: "Founder and Host", + twitter: "https://twitter.com/Adam9Rush", + linkedin: "https://www.linkedin.com/in/swiftlyrush/", + slack: "https://swiftleedsworkspace.slack.com/archives/D05RK6AAV29", + imageURL: "/img/team/rush.jpg" + ), + TeamMember( + name: "James Sherlock", + role: "Production Team Lead", + twitter: "https://twitter.com/JamesSherlouk", + linkedin: "https://www.linkedin.com/in/jamessherlockdeveloper/", + slack: "https://swiftleedsworkspace.slack.com/archives/D05RK6AAV29", + imageURL: "/img/team/sherlock.jpg" + ), + TeamMember( + name: "Matthew Gallagher", + role: "Registration and Mobile App", + twitter: "https://twitter.com/pdamonkey", + linkedin: "https://www.linkedin.com/in/pdamonkey/", + slack: "https://swiftleedsworkspace.slack.com/archives/D030PN528UA", + imageURL: "/img/team/matt.jpg" + ), + TeamMember( + name: "Adam Oxley", + role: nil, + twitter: "https://twitter.com/admoxly", + linkedin: "https://www.linkedin.com/in/adam-oxley-41183a82/", + slack: "https://swiftleedsworkspace.slack.com/team/U02DRL7KUCS", + imageURL: "/img/team/oxley.jpg" + ), + TeamMember( + name: "Noam Efergan", + role: "Camera Operator and Social Media", + twitter: "https://twitter.com/No_Wham", + linkedin: "https://www.linkedin.com/in/noamefergan/", + slack: "https://swiftleedsworkspace.slack.com/archives/D05RK6AAV29", + imageURL: "/img/team/noam.jpg" + ), + TeamMember( + name: "Kannan Prasad", + role: nil, + twitter: nil, + linkedin: "https://www.linkedin.com/in/kannanprasad/", + slack: "https://swiftleedsworkspace.slack.com/archives/D0477TRS28G", + imageURL: "/img/team/kannan.jpg" + ), + TeamMember( + name: "Muralidharan Kathiresan", + role: nil, + twitter: "https://twitter.com/Muralidharan_K", + linkedin: "https://www.linkedin.com/in/muralidharankathiresan/", + slack: "https://swiftleedsworkspace.slack.com/archives/D05RK6AAV29", + imageURL: "/img/team/mural.jpg" + ), + TeamMember( + name: "Preeti Thombare", + role: nil, + twitter: nil, + linkedin: nil, + slack: "https://swiftleedsworkspace.slack.com/archives/D05RK6AAV29", + imageURL: "/img/team/preeti.jpg" + ), + TeamMember( + name: "Paul Willis", + role: nil, + twitter: nil, + linkedin: "https://www.linkedin.com/in/paulrobertwillis/", + slack: "https://swiftleedsworkspace.slack.com/archives/D05RK6AAV29", + imageURL: "/img/team/paul.jpg" + ), + TeamMember( + name: "Joe Williams", + role: "Camera Operator", + twitter: "https://twitter.com/joedub_dev", + linkedin: "https://www.linkedin.com/in/joe-williams-1676b871/", + slack: "https://swiftleedsworkspace.slack.com/archives/C05N7JZE2NP", + imageURL: "/img/team/joe.jpg" + ), + ] + + // Shuffle the team members to avoid bias, just like the web page does + return TeamResponse(teamMembers: teamMembers.shuffled()) + } +} diff --git a/Sources/App/Features/Team/Models/TeamResponse.swift b/Sources/App/Features/Team/Models/TeamResponse.swift new file mode 100644 index 00000000..4f66e4dd --- /dev/null +++ b/Sources/App/Features/Team/Models/TeamResponse.swift @@ -0,0 +1,15 @@ +import Foundation +import Vapor + +struct TeamResponse: Content { + let teamMembers: [TeamMember] +} + +struct TeamMember: Content { + let name: String + let role: String? + let twitter: String? + let linkedin: String? + let slack: String? + let imageURL: String +} diff --git a/Sources/App/routes.swift b/Sources/App/routes.swift index 1c64a130..ac725294 100644 --- a/Sources/App/routes.swift +++ b/Sources/App/routes.swift @@ -57,6 +57,7 @@ func routes(_ app: Application) throws { let apiV2Routes = app.grouped("api", "v2") try apiV2Routes.grouped("schedule").register(collection: ScheduleAPIControllerV2()) + try apiV2Routes.grouped("team").register(collection: TeamAPIController()) // MARK: - Admin Routes let adminRoutes = app.grouped("admin").grouped(AdminMiddleware())