Skip to content
This repository was archived by the owner on Oct 12, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions HackIllinois/ViewControllers/HIScanQRCodeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ extension HIScanQRCodeViewController: AVCaptureMetadataOutputObjectsDelegate {
self.present(alert, animated: true, completion: nil)
}

func getUserIdData(userID: String) {
func staffCheckIn(userID: String, status: String) {
guard let user = HIApplicationStateController.shared.user else { return }
HIAPI.RegistrationService.getAttendeeRegistrationUserID(userID: userID)
.onCompletion { result in
Expand All @@ -300,6 +300,7 @@ extension HIScanQRCodeViewController: AVCaptureMetadataOutputObjectsDelegate {
guard let first = apiAttendeeContainer.firstName else { return }
guard let last = apiAttendeeContainer.lastName else { return }
currentUserName = first + " " + last
self.handleStaffCheckInAlert(status: status)
}
} catch {
print("An error has occurred \(error)")
Expand All @@ -316,21 +317,20 @@ extension HIScanQRCodeViewController: AVCaptureMetadataOutputObjectsDelegate {
guard let user = HIApplicationStateController.shared.user else { return }
if user.roles.contains(.staff) {
if selectedEventID != "" {
if let qrInfo = decode(code) {
if let userId = qrInfo["userId"] {
currentUserID = userId as? String ?? ""
getUserIdData(userID: currentUserID)
}
}
if let range = code.range(of: "userToken=") {
let userToken = code[range.upperBound...]
respondingToQRCodeFound = false
HIAPI.EventService.staffCheckIn(userToken: String(userToken), eventId: selectedEventID)
.onCompletion { result in
do {
let (codeResult, _) = try result.get()
DispatchQueue.main.async {
self.handleStaffCheckInAlert(status: codeResult.status)
DispatchQueue.main.async { [self] in
if let qrInfo = self.decode(code) {
if let userId = qrInfo["userId"] {
currentUserID = userId as? String ?? ""
staffCheckIn(userID: currentUserID, status: codeResult.status)
}
}
}
} catch {
print(error, error.localizedDescription)
Expand Down