Skip to content

Commit 39c436e

Browse files
committed
registration: checkbox agree to emails
1 parent ab27691 commit 39c436e

File tree

10 files changed

+128
-21
lines changed

10 files changed

+128
-21
lines changed

components/TField.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
v-bind="$attrs"
3030
:item="item"
3131
:value.sync="computedValue"
32+
:label="label"
33+
:name="name"
3234
:class="{ 'border-red-500': error }"
3335
v-on="$attrs.listeners"
34-
@input="(val) => $emit('input', set(val))"
36+
@input="onInput"
3537
/>
3638
</slot>
3739
<div v-if="error" class="field-error text-red-500 text-sm mt-2">
@@ -59,7 +61,7 @@ export default {
5961
inheritAttrs: false,
6062
props: {
6163
value: {
62-
type: [String, Object, Array, Number, Date],
64+
type: [String, Object, Array, Number, Date, Boolean],
6365
default: '',
6466
},
6567
item: {
@@ -70,6 +72,10 @@ export default {
7072
type: String,
7173
default: '',
7274
},
75+
name: {
76+
type: String,
77+
default: '',
78+
},
7379
description: {
7480
type: String,
7581
default: '',
@@ -154,11 +160,16 @@ export default {
154160
},
155161
},
156162
mounted() {
157-
this.elementId = camelize(this.label)
163+
this.elementId = this.name || camelize(this.label)
158164
159165
if (!this.value && this.default) {
160166
this.$emit('input', this.default)
161167
}
162168
},
169+
methods: {
170+
onInput(val) {
171+
this.$emit('input', this.set(val))
172+
},
173+
},
163174
}
164175
</script>

components/TInput/TCheckbox.vue

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<template>
2+
<label>
3+
<vt-checkbox v-model="input" v-bind="$attrs" v-on="$listeners" />
4+
<span class="text-sm mx-2 text-gray-700">{{ label }}</span>
5+
</label>
6+
</template>
7+
8+
<script>
9+
import { sanitize } from '~/utils'
10+
11+
export default {
12+
name: 'TInput',
13+
props: {
14+
value: {
15+
type: [String, Number, Object, Date, Boolean],
16+
default: '',
17+
},
18+
defaultValue: {
19+
type: String,
20+
default: '',
21+
},
22+
item: {
23+
type: Object,
24+
default: () => ({}),
25+
},
26+
label: {
27+
type: String,
28+
default: '',
29+
},
30+
},
31+
computed: {
32+
input: {
33+
get() {
34+
return this.value
35+
},
36+
set(val) {
37+
this.$emit('input', val)
38+
},
39+
},
40+
},
41+
}
42+
</script>

locales/de.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ account:
366366
name: Vollständiger Name
367367
phone: Telefon
368368
zone: Timezone
369+
emailConsent: Ich stimme zu, wesentliche E-Mails von WeDance zu erhalten, einschließlich Veranstaltungsaktualisierungen und Benachrichtigungen. Ich kann mich jederzeit von nicht wesentlichen E-Mails abmelden.
369370
newsletter:
370371
label: What kind of updated would you like to receive weekly?
371372
options:

locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ account:
423423
name: Full Name
424424
phone: Phone
425425
zone: Timezone
426+
emailConsent: I agree to receive emails from WeDance. I can unsubscribe from non-essential emails at any time.
427+
emailConsentError: Please agree to receive emails to proceed.
426428
newsletter:
427429
label: What kind of updated would you like to receive weekly?
428430
options:

pages/demo/check.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div>
3+
<div class="p-4">
4+
<TField component="TCheckbox" :value.sync="data" @input="onInput" />
5+
<pre>{{ data }}</pre>
6+
</div>
7+
</div>
8+
</template>
9+
10+
<script>
11+
export default {
12+
data: () => ({
13+
data: '',
14+
}),
15+
methods: {
16+
onInput(val) {
17+
this.data = val
18+
},
19+
},
20+
}
21+
</script>

plugins/vue-tailwind.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@ import {
44
TRichSelect,
55
TRadioGroup,
66
TCheckboxGroup,
7+
TCheckbox,
78
TInput,
89
TPagination,
910
} from 'vue-tailwind/dist/components'
1011

1112
const settings = {
13+
VtCheckbox: {
14+
component: TCheckbox,
15+
props: {
16+
classes: {
17+
label: '',
18+
input:
19+
'h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600',
20+
inputWrapper: '',
21+
wrapper: '',
22+
},
23+
},
24+
},
1225
TPagination: {
1326
component: TPagination,
1427
props: {

services/firebase/src/index.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { getFacebookEvent } from './lib/facebook_import'
2222
import { syncCalendar } from './lib/ical_import'
2323
import { getSchemaEvent } from './lib/schema_import'
2424
import { isFacebookEvent } from './lib/linguist'
25+
import { uniq } from 'lodash'
2526

2627
require('dotenv').config()
2728

@@ -610,12 +611,10 @@ export const commentNotification = functions.firestore
610611
.get()
611612
).data()
612613

613-
if (!post.watch) {
614-
return
615-
}
616-
617-
const watchList = post.watch.list
618-
const watchUsernames = Object.keys(watchList)
614+
const watchUsernames = uniq([
615+
...Object.keys(post?.watch?.list),
616+
post?.star.usernames,
617+
])
619618

620619
const recipients: RecipientList = {}
621620

@@ -626,32 +625,36 @@ export const commentNotification = functions.firestore
626625
continue
627626
}
628627

629-
if (comment.createdBy === account.id) {
630-
continue
631-
}
632-
633628
recipients[account.id] = {
634629
name: username,
635630
email: account.email,
636631
}
637632
}
638633

639-
const content = `
640-
**${comment.username} replied:**
634+
let content = ''
635+
636+
if (post.type === 'event') {
637+
content = `
638+
**${comment.username} wrote:**
641639
642640
${comment.body}
643641
644-
**on post ${post.title || ''}**
642+
[View event](https://wedance.vip/events/${post.id}#comments)
643+
`
644+
} else {
645+
content = `
646+
**${comment.username} wrote:**
645647
646-
${post.description}
648+
${comment.body}
647649
648-
[View comment](https://wedance.vip/posts/${post.id}#comment-${commentId})
650+
[View post](https://wedance.vip/posts/${post.id}#comment-${commentId})
649651
`
652+
}
650653

651654
const email = {
652655
from: 'WeDance <[email protected]>',
653656
recipients,
654-
subject: 'New comment on post you are watching',
657+
subject: post.name || post.title || 'New comment',
655658
content,
656659
type: 'commentNotification',
657660
id: commentId,

use/accounts.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ export const useAccounts = () => {
4343
component: 'TRichSelect',
4444
options: moment.tz.names(),
4545
},
46+
{
47+
name: 'emailConsent',
48+
label: t('account.emailConsent'),
49+
component: 'TCheckbox',
50+
register: true,
51+
hideLabel: true,
52+
validate(value) {
53+
return value
54+
},
55+
validationError: t('account.emailConsentError'),
56+
},
4657
]
4758

4859
return {

use/auth.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,10 @@ export const useAuth = () => {
476476
ls('username', username)
477477
ls('place', place)
478478
ls('gender', gender)
479-
await firebase.auth().createUserWithEmailAndPassword(email, password)
479+
const firebaseUser = await firebase
480+
.auth()
481+
.createUserWithEmailAndPassword(email, password)
482+
firebaseUser.sendEmailVerification()
480483
} catch (e) {
481484
state.error = e
482485
}

use/profiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ export const useProfiles = () => {
623623
const profileDetailFields = profileFields.filter((f) => !f.poster)
624624

625625
const registerFields = [
626-
...accountFields.filter((f) => f.register),
627626
...profileFields.filter((f) => f.register),
627+
...accountFields.filter((f) => f.register),
628628
]
629629

630630
const profileFilters = [

0 commit comments

Comments
 (0)