-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add dialog to setup notifications
- Loading branch information
Showing
8 changed files
with
168 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.notificationDialog { | ||
& fieldset { | ||
grid-template-columns: 1fr auto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
type classesType = {notificationDialog: string} | ||
|
||
@module("./NotificationDialog.module.css") external classes: classesType = "default" | ||
|
||
@react.component | ||
let make = ( | ||
~currentUserNotificationSubscription, | ||
~currentUserUid, | ||
~onDismiss, | ||
~onUpdateSubscription, | ||
~place, | ||
) => { | ||
let sendTestNotification = NotificationHooks.useDispatchTestNotification(~currentUserUid, ~place) | ||
<Dialog className={classes.notificationDialog} visible={true}> | ||
<header> | ||
<h3> {React.string(`Nastavení notifikací`)} </h3> | ||
<p> {React.string(`Přihlaš se k odběru důležitých zpráv.`)} </p> | ||
</header> | ||
<form> | ||
<fieldset className={`reset ${Styles.fieldset.grid}`}> | ||
<InputWrapper | ||
inputName="free_table" | ||
inputSlot={<InputToggle | ||
checked={BitwiseUtils.bitAnd( | ||
currentUserNotificationSubscription, | ||
(NotificationEvents.FreeTable :> int), | ||
) !== 0} | ||
onChange={event => { | ||
let target = event->ReactEvent.Form.target | ||
let checked = target["checked"] | ||
onUpdateSubscription( | ||
checked | ||
? BitwiseUtils.bitOr( | ||
currentUserNotificationSubscription, | ||
(NotificationEvents.FreeTable :> int), | ||
) | ||
: BitwiseUtils.bitAnd( | ||
currentUserNotificationSubscription, | ||
BitwiseUtils.bitNot((NotificationEvents.FreeTable :> int)), | ||
), | ||
) | ||
}} | ||
/>} | ||
labelSlot={React.string("První pivo")} | ||
/> | ||
<InputWrapper | ||
inputName="fresh_keg" | ||
inputSlot={<InputToggle | ||
checked={BitwiseUtils.bitAnd( | ||
currentUserNotificationSubscription, | ||
(NotificationEvents.FreshKeg :> int), | ||
) !== 0} | ||
onChange={event => { | ||
let target = event->ReactEvent.Form.target | ||
let checked = target["checked"] | ||
onUpdateSubscription( | ||
checked | ||
? BitwiseUtils.bitOr( | ||
currentUserNotificationSubscription, | ||
(NotificationEvents.FreshKeg :> int), | ||
) | ||
: BitwiseUtils.bitAnd( | ||
currentUserNotificationSubscription, | ||
BitwiseUtils.bitNot((NotificationEvents.FreshKeg :> int)), | ||
), | ||
) | ||
}} | ||
/>} | ||
labelSlot={React.string("Čerstvý sud")} | ||
/> | ||
</fieldset> | ||
</form> | ||
{%raw(`import.meta.env.PROD`) | ||
? React.null | ||
: <button className={Styles.button.base} type_="button" onClick={_ => sendTestNotification()}> | ||
{React.string("Send test notification")} | ||
</button>} | ||
<footer> | ||
<button className={Styles.button.base} type_="button" onClick={_ => onDismiss()}> | ||
{React.string("Zavřít")} | ||
</button> | ||
</footer> | ||
</Dialog> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
let bitAnd = (a: int, b: int): int => %raw(`a & b`) | ||
|
||
let bitOr = (a: int, b: int): int => %raw(`a | b`) | ||
|
||
let bitNot = (a: int): int => %raw(`~a`) |