Skip to content

Commit

Permalink
fixed which staff events show up in staff button view controller
Browse files Browse the repository at this point in the history
  • Loading branch information
s0phialiu committed Feb 15, 2024
1 parent 745e010 commit 61a655a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions HIAPI/Models/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public struct Event: Codable {
case points
case isAsync
case mapImageUrl
case displayOnStaffCheckIn
}

public let id: String
Expand All @@ -95,6 +96,7 @@ public struct Event: Codable {
public let points: Int
public let isAsync: Bool
public let mapImageUrl: String?
public let displayOnStaffCheckIn: Bool?
}

public struct Location: Codable {
Expand Down
4 changes: 2 additions & 2 deletions HIAPI/Services/EventService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public class EventService: BaseService {
return APIRequest<Attendance>(service: self, endpoint: "staff/attendance/", body: body, headers: headers, method: .POST)
}

public static func getStaffCheckInEvents(authToken: String) -> APIRequest<StaffEventContainer> {
public static func getStaffCheckInEvents(authToken: String) -> APIRequest<EventContainer> {
var header = HTTPHeaders()
header["Authorization"] = authToken
return APIRequest<StaffEventContainer>(service: self, endpoint: "event/staff/", headers: header, method: .GET)
return APIRequest<EventContainer>(service: self, endpoint: "event/", headers: header, method: .GET)
}

public static func create(event: Event) -> APIRequest<EventContainer> {
Expand Down
8 changes: 4 additions & 4 deletions HackIllinois/ViewControllers/HIStaffButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
import HIAPI

struct HIStaffButtonView: View {
@State var events = [HIAPI.StaffEvent]()
@State var events = [HIAPI.Event]()
@State var highlightedID = ""
@ObservedObject var observable: HIStaffButtonViewObservable

Expand Down Expand Up @@ -51,13 +51,13 @@ struct HIStaffButtonView: View {
}

func getStaffEvents() {
HIAPI.EventService.getStaffCheckInEvents(authToken: HIApplicationStateController.shared.user?.token ?? "")
guard let user = HIApplicationStateController.shared.user else { return }
HIAPI.EventService.getStaffCheckInEvents(authToken: user.token)
.onCompletion { result in
do {
let (containedEvents, _) = try result.get()
DispatchQueue.main.async {
self.events = containedEvents.events
print(self.events)
self.events = containedEvents.events.filter { $0.displayOnStaffCheckIn == true }
}
} catch {
print("An error has occurred \(error)")
Expand Down

0 comments on commit 61a655a

Please sign in to comment.