Skip to content

Commit

Permalink
add VIPs
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed May 2, 2024
1 parent 1d3f90c commit a91f9b4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/Zureg/Hackathon/ZuriHac2024/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ csvHeader = Csv.header
[ "UUID"
, "State"
, "Scanned"
, "VIP"
, "Name"
, "Email"
, "Region"
Expand Down
7 changes: 7 additions & 0 deletions lib/Zureg/Main/Web.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ app hackathon =
Database.writeEvents db uuid [MarkSpam :: Event a]
respond . redirect $ "ticket?uuid=" <> E.uuidToText uuid

["vip"] | Wai.requestMethod req == Http.methodPost ->
scannerAuthorized req $ do
uuid <- getUuidParam req
_ <- Database.getRegistrant db uuid :: IO (Registrant a)
Database.writeEvents db uuid [MarkVip :: Event a]
respond . redirect $ "ticket?uuid=" <> E.uuidToText uuid

["cancel"] -> do
reqBody <- TL.decodeUtf8 <$> Wai.strictRequestBody req
(view, mbCancel) <- runForm req reqBody "cancel" $
Expand Down
12 changes: 11 additions & 1 deletion lib/Zureg/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ data Event a
| Uncancel UncancelInfo
| JoinChat JoinChatInfo
| MarkSpam
| MarkVip
deriving (Eq, Show)

--------------------------------------------------------------------------------
Expand All @@ -82,11 +83,19 @@ data Registrant a = Registrant
, rAdditionalInfo :: Maybe a
, rState :: Maybe RegisterState
, rScanned :: Bool
, rVip :: Bool
} deriving (Eq, Show)

registrantProjection :: E.UUID -> E.Projection (Registrant a) (Event a)
registrantProjection uuid = E.Projection
{ E.projectionSeed = Registrant uuid Nothing Nothing Nothing False
{ E.projectionSeed = Registrant
{ rUuid = uuid
, rInfo = Nothing
, rAdditionalInfo = Nothing
, rState = Nothing
, rScanned = False
, rVip = False
}
, E.projectionEventHandler = \registrant event -> case event of
Cancel | Just Spam /= rState registrant ->
registrant {rState = Just Cancelled}
Expand All @@ -101,6 +110,7 @@ registrantProjection uuid = E.Projection
Uncancel _ | Just Cancelled <- rState registrant ->
registrant {rState = Just Registered}
MarkSpam -> registrant {rState = Just Spam}
MarkVip -> registrant {rVip = True}
_ -> registrant
}

Expand Down
1 change: 1 addition & 0 deletions lib/Zureg/Model/Csv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ instance ToNamedRecord a => ToNamedRecord (Registrant a) where
Just ai -> toNamedRecord ai
Nothing -> HM.empty
, namedRecord [ "Scanned" .= rScanned ]
, namedRecord [ "VIP" .= rVip ]
]

instance ToNamedRecord RegisterState where
Expand Down
2 changes: 2 additions & 0 deletions lib/Zureg/Views.hs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ scan hackathon registrant@Registrant {..} = H.ul $ do
H.li $ H.strong $
let (html, ok) = registerState rState in (if ok then id else red) html

when rVip $ H.li $ "" <> H.strong "VIP"

H.li $ case (registrantRegisteredAt registrant, registrantToBadge registrant) of
(_, Nothing) -> red "No Badge"
(_, Just badge) ->
Expand Down

0 comments on commit a91f9b4

Please sign in to comment.