2020-03-12 14:29:21 +01:00
< template >
2020-02-18 08:57:00 +01:00
< div v-if ="loggedUser" >
2020-06-25 11:36:35 +02:00
< nav class = "breadcrumb" aria -label = " breadcrumbs " >
< ul >
< li >
< router -link : to = "{ name: RouteName.ACCOUNT_SETTINGS }" > { { $t ( "Account" ) } } < / r o u t e r - l i n k >
< / li >
< li class = "is-active" >
< router -link : to = "{ name: RouteName.NOTIFICATIONS }" > { {
$t ( "Email notifications" )
} } < / r o u t e r - l i n k >
< / li >
< / ul >
< / nav >
2020-06-08 12:28:19 +02:00
< section >
< div class = "setting-title" >
< h2 > { { $t ( "Participation notifications" ) } } < / h2 >
< / div >
< div class = "field" >
< strong > { {
2020-06-16 16:15:38 +02:00
$t (
"Mobilizon will send you an email when the events you are attending have important changes: date and time, address, confirmation or cancellation, etc."
)
2020-06-08 12:28:19 +02:00
} } < / strong >
2020-02-18 08:57:00 +01:00
< p >
2020-06-16 16:15:38 +02:00
{ { $t ( "Other notification options:" ) } }
2020-02-18 08:57:00 +01:00
< / p >
2020-06-08 12:28:19 +02:00
< / div >
< div class = "field" >
< b -checkbox v-model ="notificationOnDay" @input="updateSetting({ notificationOnDay })" >
< strong > { { $t ( "Notification on the day of the event" ) } } < / strong >
< p >
{ {
$t ( "We'll use your timezone settings to send a recap of the morning of the event." )
} }
< / p >
2020-06-16 16:15:38 +02:00
< div v-if ="loggedUser.settings && loggedUser.settings.timezone" >
< em > { {
$t ( "Your timezone is currently set to {timezone}." , {
timezone : loggedUser . settings . timezone ,
} )
} } < / em >
< router -link class = "change-timezone" : to = "{ name: RouteName.PREFERENCES }" > { {
$t ( "Change timezone" )
} } < / r o u t e r - l i n k >
< / div >
2020-06-08 12:28:19 +02:00
< span v-else > {{ $ t ( " You can pick your timezone into your preferences. " ) }} < / span >
< / b - c h e c k b o x >
< / div >
< div class = "field" >
< b -checkbox v-model ="notificationEachWeek" @input="updateSetting({ notificationEachWeek })" >
< strong > { { $t ( "Recap every week" ) } } < / strong >
< p >
{ { $t ( "You'll get a weekly recap every Monday for upcoming events, if you have any." ) } }
< / p >
< / b - c h e c k b o x >
< / div >
< div class = "field" >
< b -checkbox
v - model = "notificationBeforeEvent"
@ input = "updateSetting({ notificationBeforeEvent })"
>
< strong > { { $t ( "Notification before the event" ) } } < / strong >
< p >
{ {
$t (
"We'll send you an email one hour before the event begins, to be sure you won't forget about it."
)
} }
< / p >
< / b - c h e c k b o x >
< / div >
< / section >
< section >
< div class = "setting-title" >
< h2 > { { $t ( "Organizer notifications" ) } } < / h2 >
< / div >
2020-06-16 16:15:38 +02:00
< div class = "field is-primary" >
2020-06-08 12:28:19 +02:00
< strong > { { $t ( "Notifications for manually approved participations to an event" ) } } < / strong >
< b -select
v - model = "notificationPendingParticipation"
@ input = "updateSetting({ notificationPendingParticipation })"
>
< option
v - for = "(value, key) in notificationPendingParticipationValues"
: value = "key"
: key = "key"
> { { value } } < / o p t i o n
>
< / b - s e l e c t >
< / div >
< / section >
2020-02-18 08:57:00 +01:00
< / div >
2020-03-12 14:29:21 +01:00
< / template >
< script lang = "ts" >
2020-02-18 08:57:00 +01:00
import { Component , Vue , Watch } from "vue-property-decorator" ;
import { USER _SETTINGS , SET _USER _SETTINGS } from "../../graphql/user" ;
2020-06-27 19:12:45 +02:00
import { IUser , INotificationPendingParticipationEnum } from "../../types/current-user.model" ;
2020-06-16 16:15:38 +02:00
import RouteName from "../../router/name" ;
2020-03-12 14:29:21 +01:00
2020-02-18 08:57:00 +01:00
@ Component ( {
apollo : {
loggedUser : USER _SETTINGS ,
} ,
} )
2020-03-12 14:29:21 +01:00
export default class Notifications extends Vue {
2020-06-27 19:12:45 +02:00
loggedUser ! : IUser ;
2020-02-18 08:57:00 +01:00
notificationOnDay = true ;
notificationEachWeek = false ;
notificationBeforeEvent = false ;
2020-03-12 14:29:21 +01:00
2020-06-08 12:28:19 +02:00
notificationPendingParticipation = INotificationPendingParticipationEnum . NONE ;
notificationPendingParticipationValues : object = { } ;
2020-06-16 16:15:38 +02:00
RouteName = RouteName ;
2020-06-08 12:28:19 +02:00
mounted ( ) {
this . notificationPendingParticipationValues = {
2020-06-16 16:15:38 +02:00
[ INotificationPendingParticipationEnum . NONE ] : this . $t ( "Do not receive any mail" ) ,
[ INotificationPendingParticipationEnum . DIRECT ] : this . $t ( "Receive one email per request" ) ,
[ INotificationPendingParticipationEnum . ONE _HOUR ] : this . $t ( "Hourly email summary" ) ,
[ INotificationPendingParticipationEnum . ONE _DAY ] : this . $t ( "Daily email summary" ) ,
2020-06-08 12:28:19 +02:00
} ;
}
2020-06-11 10:58:23 +02:00
@ Watch ( "loggedUser" )
setSettings ( ) {
if ( this . loggedUser && this . loggedUser . settings ) {
this . notificationOnDay = this . loggedUser . settings . notificationOnDay ;
this . notificationEachWeek = this . loggedUser . settings . notificationEachWeek ;
this . notificationBeforeEvent = this . loggedUser . settings . notificationBeforeEvent ;
this . notificationPendingParticipation = this . loggedUser . settings . notificationPendingParticipation ;
}
}
2020-02-18 08:57:00 +01:00
async updateSetting ( variables : object ) {
await this . $apollo . mutate < { setUserSettings : string } > ( {
mutation : SET _USER _SETTINGS ,
variables ,
} ) ;
}
2020-03-12 14:29:21 +01:00
}
2020-02-18 08:57:00 +01:00
< / script >
2020-06-16 16:15:38 +02:00
< style lang = "scss" scoped >
@ import "../../variables.scss" ;
. field {
& : not ( : last - child ) {
margin - bottom : 1.5 rem ;
}
a . change - timezone {
2020-06-17 15:54:24 +02:00
color : $primary ;
2020-06-16 16:15:38 +02:00
text - decoration : underline ;
text - decoration - color : # fea72b ;
text - decoration - thickness : 2 px ;
margin - left : 5 px ;
}
}
< / style >