Skip to content

Commit

Permalink
add dietary restrictions to alert message
Browse files Browse the repository at this point in the history
  • Loading branch information
s0phialiu committed Feb 18, 2024
1 parent ae6699a commit 26ec61b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 1 addition & 2 deletions HIAPI/Models/Staff.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public struct Staff: Codable {
public let isPrivate: Bool
public let displayOnStaffCheckIn: Bool


}

public struct UserAttendanceContainer: Codable, APIReturnable {
Expand All @@ -66,7 +65,7 @@ public struct UserAttendanceContainer: Codable, APIReturnable {
}
public let success: Bool
public let error: String?
public let dietaryRestrictions: [String]
public let dietaryRestrictions: [String]?
}

public struct StaffAttendanceContainer: Codable, APIReturnable {
Expand Down
2 changes: 1 addition & 1 deletion HackIllinois/ViewControllers/HIQRScannerSelection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ extension HIQRScannerSelection {
closeButton.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 8).isActive = true
closeButton.constrain(width: 60, height: 60)
closeButton.imageView?.contentMode = .scaleToFill
let label = HILabel(style: (UIDevice.current.userInterfaceIdiom == .pad) ? .viewTitleBrown : .viewTitle)
let label = HILabel(style: (UIDevice.current.userInterfaceIdiom == .pad) ? .viewTitleBrown : .viewTitleBrown)
label.text = "SCANNER"
view.addSubview(label)
label.centerYAnchor.constraint(equalTo: closeButton.centerYAnchor).isActive = true
Expand Down
15 changes: 14 additions & 1 deletion HackIllinois/ViewControllers/HIScanQRCodeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ extension HIScanQRCodeViewController: AVCaptureMetadataOutputObjectsDelegate {
switch status {
case "Success":
alertTitle = "Success!"
alertMessage = "Name: \(currentUserName)\n Diet: \(dietaryString)"
alertMessage = "Dietary Restrictions: \(dietaryString)"
//alertMessage = "Name: \(currentUserName)\n Diet: \(dietaryString)"
case "InvalidEventId":
alertTitle = "Error!"
alertMessage = "Invalid Event ID"
Expand Down Expand Up @@ -397,6 +398,18 @@ extension HIScanQRCodeViewController: AVCaptureMetadataOutputObjectsDelegate {
let (codeResult, _) = try result.get()
DispatchQueue.main.async { [self] in
print(codeResult.dietaryRestrictions)
// Parse dietary string
dietaryString = ""
if let dietaryRestrictions = codeResult.dietaryRestrictions, !dietaryRestrictions.isEmpty {
for (index, diet) in dietaryRestrictions.enumerated() {
dietaryString += diet
if index < dietaryRestrictions.count - 1 {
dietaryString += ", "
}
}
} else {
dietaryString = "None"
}
self.handleStaffCheckInAlert(status: "Success")
}
} catch {
Expand Down

0 comments on commit 26ec61b

Please sign in to comment.