9
9
< span class ="opacity-100 "> Notificações</ span >
10
10
</ a >
11
11
</ div >
12
- < div class ="flex flex-col ">
13
- {% for notification in notifications %}
14
- < div class ="flex flex-row h-fit w-full p-4 pt-3 pl-3 border-solid border-b-2 hover:bg-gray-100 dark:hover:bg-gray-700 border-gray-100 dark:border-gray-700 " >
15
- < div class ="flex mr-2 ">
16
- {% if notification.created_by.twikkerprofile.avatar %}
17
- < img class ="rounded-full h-12 w-12 " src ="{{ notification.created_by.twikkerprofile.avatar.url }} ">
18
- {% endif %}
19
- </ div >
20
- < div >
21
- {% if notification.notification_type == 'message' %}
22
- < a href ="{% url 'notifications' %}?goto=conversation¬ification={{ notification.id }} ">
23
- < strong > {{ notification.created_by.username }}</ strong > sent you a message
24
- < small > {{ notification.created_at|naturaltime }}</ small >
25
- </ a >
26
- {% elif notification.notification_type == 'follower' %}
27
- < a href ="{% url 'notifications' %}?goto=twikkerprofile¬ification={{ notification.id }} ">
28
- < strong > {{ notification.created_by.username }}</ strong > started following you
29
- < small > {{ notification.created_at|naturaltime }}</ small >
30
- </ a >
31
- {% elif notification.notification_type == 'like' %}
32
- < a href ="{% url 'notifications' %}?goto=twikkerprofile¬ification={{ notification.id }} ">
33
- < strong > {{ notification.created_by.username }}</ strong > liked a tweek you made
34
- < small > {{ notification.created_at|naturaltime }}</ small >
35
- </ a >
36
- {% elif notification.notification_type == 'mention' %}
37
- < a href ="{% url 'notifications' %}?goto=twikkerprofile¬ification={{ notification.id }} ">
38
- < strong > {{ notification.created_by.username }}</ strong > mentioned you in a tweek
39
- < small > {{ notification.created_at|naturaltime }}</ small >
40
- </ a >
41
- {% endif %}
42
- </ div >
12
+ < div id ="notificationapp " class ="flex flex-col ">
13
+ < div v-for ="notification in notifications " class ="flex flex-row h-fit w-full p-4 pt-3 pl-3 border-solid border-b-2 hover:bg-gray-100 dark:hover:bg-gray-700 border-gray-100 dark:border-gray-700 " >
14
+ < div >
15
+ < a v-if ="notification.notification_type == 'message' " >
16
+ < strong > [[ notification.created_by ]]</ strong > sent you a message
17
+ < small > [[ notification.created_at ]]</ small >
18
+ </ a >
19
+ < a v-if ="notification.notification_type == 'follower' " >
20
+ < strong > [[ notification.created_by ]]</ strong > started following you
21
+ < small > [[ notification.created_at ]]</ small >
22
+ </ a >
23
+ < a v-if ="notification.notification_type == 'like' " >
24
+ < strong > [[ notification.created_by ]]</ strong > liked a tweek you made
25
+ < small > [[ notification.created_at ]]</ small >
26
+ </ a >
27
+ < a v-if ="notification.notification_type == 'dislike' ">
28
+ < strong > [[ notification.created_by ]]</ strong > liked a tweek you made
29
+ < small > [[ notification.created_at ]]</ small >
30
+ </ a >
31
+ < a v-if ="notification.notification_type == 'mention' ">
32
+ < strong > [[ notification.created_by ]]</ strong > mentioned you in a tweek
33
+ < small > [[ notification.created_at ]]</ small >
34
+ </ a >
43
35
</ div >
44
- {% endfor %}
36
+ </ div >
45
37
</ div >
46
38
</ div >
39
+ {% endblock %}
40
+
41
+ {% block script %}
42
+ < script >
43
+ const { createApp} = Vue
44
+ const notificationapp = createApp ( {
45
+ delimiters : [ '[[' , ']]' ] ,
46
+ data ( ) {
47
+ return {
48
+ notifications : [ ] ,
49
+ }
50
+ } ,
51
+ mounted ( ) {
52
+ this . getNotifications ( ) ;
53
+ } ,
54
+ methods : {
55
+ getNotifications ( ) {
56
+ fetch ( '/api/notifications/' + { { request. user . id } } )
57
+ . then ( response => response . json ( ) )
58
+ . then ( data => {
59
+ this . notifications = data
60
+ } )
61
+ } ,
62
+ }
63
+ } ) . mount ( "#notificationapp" )
64
+ </ script >
47
65
{% endblock %}
0 commit comments