Sfoglia il codice sorgente

:bug: fixing bad schema import

tags/0.0.1^2
J 3 anni fa
parent
commit
b431fd5ec7

+ 3
- 2
backend/lib/schemas/profiles.js Vedi File

3
 const Joi = require('joi')
3
 const Joi = require('joi')
4
 const surveyResponseSchema = require('./responses')
4
 const surveyResponseSchema = require('./responses')
5
 const userSchema = require('./user')
5
 const userSchema = require('./user')
6
+const tagSchema = require('./tags')
6
 
7
 
7
 const singleProfile = Joi.object({
8
 const singleProfile = Joi.object({
8
     profile_id: Joi.number(),
9
     profile_id: Joi.number(),
11
     user_email: Joi.string(),
12
     user_email: Joi.string(),
12
     responses: surveyResponseSchema.list,
13
     responses: surveyResponseSchema.list,
13
     reveal: Joi.array().items(),
14
     reveal: Joi.array().items(),
14
-    tags: Joi.array().items(),
15
+    tags: tagSchema.list,
15
     user_type: Joi.any(),
16
     user_type: Joi.any(),
16
     user: userSchema.single,
17
     user: userSchema.single,
17
     profile_description: Joi.string().allow(null, ''),
18
     profile_description: Joi.string().allow(null, ''),
22
 
23
 
23
 module.exports = {
24
 module.exports = {
24
     single: singleProfile,
25
     single: singleProfile,
25
-    list: Joi.array().items(singleProfile).label('profile_list')
26
+    list: Joi.array().items(singleProfile).label('profile_list'),
26
 }
27
 }

+ 24
- 0
backend/lib/schemas/tags.js Vedi File

1
+'use strict'
2
+
3
+const Joi = require('joi')
4
+
5
+const singleTag = Joi.object({
6
+    tag_id: Joi.number(),
7
+    tag_category: Joi.string(),
8
+    tag_description: Joi.string(),
9
+    is_active: Joi.number().required(),
10
+}).label('tag_single')
11
+
12
+const singleTagAssociation = Joi.object({
13
+    tag_association_id: Joi.number(),
14
+    profile_id: Joi.number().required(),
15
+    membership_id: Joi.number(),
16
+    tag_id: Joi.number().required(),
17
+    is_deleted: Joi.boolean().required(),
18
+}).label('tag_association_single')
19
+
20
+module.exports = {
21
+    association: singleTagAssociation,
22
+    single: singleTag,
23
+    list: Joi.array().items(singleTag).label('tag_list'),
24
+}

+ 0
- 1
frontend/src/components/MainNav.vue Vedi File

1
 <template lang="pug">
1
 <template lang="pug">
2
 nav#main-header
2
 nav#main-header
3
-    button(@click="$emit('show-sidebar')") toggle sidebar
4
     router-link(:to="`/matches`") matches
3
     router-link(:to="`/matches`") matches
5
     router-link(to='/') home
4
     router-link(to='/') home
6
     router-link(:to="`/survey`") survey
5
     router-link(:to="`/survey`") survey

+ 6
- 0
frontend/src/router/index.js Vedi File

2
 
2
 
3
 import HomeView from '../views/HomeView.vue'
3
 import HomeView from '../views/HomeView.vue'
4
 import ProfileView from '../views/ProfileView.vue'
4
 import ProfileView from '../views/ProfileView.vue'
5
+import ChatView from '../views/ChatView.vue'
5
 import MatchesView from '../views/MatchesView.vue'
6
 import MatchesView from '../views/MatchesView.vue'
6
 import LoginView from '../views/LoginView.vue'
7
 import LoginView from '../views/LoginView.vue'
7
 import SurveyView from '../views/SurveyView.vue'
8
 import SurveyView from '../views/SurveyView.vue'
30
         component: ProfileView,
31
         component: ProfileView,
31
         meta: { requiresAuth: true, requiresCompleteProfile: true },
32
         meta: { requiresAuth: true, requiresCompleteProfile: true },
32
     },
33
     },
34
+    {
35
+        path: '/chat/:tid',
36
+        component: ChatView,
37
+        meta: { requiresAuth: true, requiresCompleteProfile: true },
38
+    },
33
     {
39
     {
34
         path: `/survey`,
40
         path: `/survey`,
35
         component: SurveyView,
41
         component: SurveyView,

+ 42
- 0
frontend/src/views/ChatView.vue Vedi File

1
+<template lang="pug">
2
+main.view--chat.f-col.start.w-full
3
+    header 
4
+        h2 Chat Page
5
+ 
6
+    article(v-if="!loading")
7
+        h3 {{ profile.id }} 
8
+            span chatting with: {{ target.profile_id }}
9
+        p subscriptions: {{ profile.chatter.subscriptions }}
10
+    p(v-else) Loading...
11
+
12
+    MainNav(@show-sidebar="$emit('show-sidebar')")
13
+</template>
14
+
15
+<script>
16
+import { fetchProfileByProfileId, currentProfile } from '../services'
17
+
18
+export default {
19
+    name: 'ProfileView',
20
+    data: () => ({
21
+        loading: true,
22
+        target: {},
23
+        profile: currentProfile,
24
+    }),
25
+    created() {
26
+        this.getProfile()
27
+    },
28
+    methods: {
29
+        async getProfile() {
30
+            this.loading = true
31
+            try {
32
+                this.target = await fetchProfileByProfileId(
33
+                    this.$route.params.tid,
34
+                )
35
+            } catch (err) {
36
+                console.error(err)
37
+            }
38
+            this.loading = false
39
+        },
40
+    },
41
+}
42
+</script>

Loading…
Annulla
Salva