ソースを参照

:recycle: bundling profile prefs, email, and images in CompleteProfile objects | added prefs and email and images back to frontend

tags/0.0.1
J 4年前
コミット
c186e775f8

+ 4
- 0
backend/db/data-generator/config.json ファイルの表示

@@ -31,5 +31,9 @@
31 31
     ],
32 32
     "resKeys": [1, 2, 3, 4, 5, 6],
33 33
     "zipcodeKey": 7,
34
+    "mediaKey": 8,
35
+    "langKey": 9,
36
+    "blurbKey": 12,
37
+    "prefKeys": [7, 10, 11, 13, 14, 15, 16],
34 38
     "maxDistanceKey": 16
35 39
 }

+ 1
- 0
backend/lib/schemas/profiles.js ファイルの表示

@@ -8,6 +8,7 @@ const singleProfile = Joi.object({
8 8
     profile_id: Joi.number(),
9 9
     user_id: Joi.number(),
10 10
     user_name: Joi.string(),
11
+    user_email: Joi.string(),
11 12
     responses: surveyResponseSchema.list,
12 13
     tags: Joi.array().items(),
13 14
     user_type: Joi.any(),

+ 9
- 6
backend/lib/services/profile.js ファイルの表示

@@ -95,6 +95,7 @@ class CompleteProfile {
95 95
         this.user_id = profile.user_id // int user_id
96 96
         this.profile_id = profile.profile_id // int profile_id
97 97
         this.user_name = profile.user.user_name // string user_name
98
+        this.user_email = profile.user.user_email
98 99
         this.responses = []
99 100
         this.tags = profile.tags // [] of all tags
100 101
         this.user_type = type
@@ -108,15 +109,17 @@ class CompleteProfile {
108 109
             // [] of all "profile" responses
109 110
             this.responses = profile.responses
110 111
             // image, language, duration, presence, blurb, urgency, role, pronouns, distance
111
-            const prefs = ['presence', 'duration', 'zipcode']
112
-            prefs.forEach(pref => {
112
+            const prefs = ['zipcode', 'duration', 'presence', 'urgency', 'role', 'pronouns', 'distance']
113
+            const prefsKeys = config.prefKeys
114
+            prefs.forEach((pref, i) => {
113 115
                 this.profile_prefs[pref] = this.responses.filter(
114
-                    r => r.response_key_prompt === pref
116
+                    r => r.response_key_id === prefsKeys[i]
115 117
                 )[0]
116 118
             })
117
-            this.profile_description = this.responses.filter(r=> r.response_key_prompt === 'blurb')[0]
118
-            this.profile_media = this.responses.filter(r => r.response_key_prompt === 'image')
119
-            this.profile_languages = this.responses.filter(r => r.response_key_prompt === 'language')
119
+            // TODO: filter these correctly
120
+            this.profile_description = this.responses.filter(r => r.response_key_id === config.blurbKey).map(r => r.val)[0]
121
+            this.profile_media = this.responses.filter(r => r.response_key_id === config.mediaKey).map(r => r.val)
122
+            this.profile_languages = this.responses.filter(r => r.response_key_id === config.langKey).map(r => r.val)
120 123
         }
121 124
     }
122 125
 }

+ 17
- 1
frontend/src/views/ProfileView.vue ファイルの表示

@@ -4,7 +4,23 @@ main.view--profile.f-col.start.w-full
4 4
         h2 Profile Page
5 5
  
6 6
     article(v-if="!loading")
7
-        h3 {{ profile }}
7
+        h3 name: {{ profile.user_name }}
8
+            span(v-if="profile.user_email") | email: {{ profile.user_email }}
9
+        h5(v-if="profile.profile_prefs.pronouns") My pronouns are {{ profile.profile_prefs.pronouns.val }}
10
+        
11
+        p I am looking for a 
12
+            span {{ profile.profile_prefs.presence.val }} 
13
+            span {{ profile.profile_prefs.role.val }} 
14
+            span role 
15
+            span no further than {{ profile.profile_prefs.distance.val }} miles away 
16
+            span from {{ profile.profile_prefs.zipcode.val }}
17
+
18
+        p About: {{ profile.profile_description}}
19
+        p I am {{ profile.profile_prefs.urgency.val.split("_").join(" ") }}.
20
+
21
+        p tags: {{ profile.tags }}
22
+        p images: {{ profile.profile_media }}
23
+        p responses: {{ profile.responses.length }}
8 24
         button(@click="$router.go(-1)") back
9 25
 
10 26
     p(v-else) Loading...

読み込み中…
キャンセル
保存