Ver código fonte

broken vue/vite

tags/0.0.1
diaseu 4 anos atrás
pai
commit
cd25ff0b4b

+ 1
- 2
backend/lib/routes/membership/join.js Ver arquivo

@@ -63,7 +63,6 @@ module.exports = {
63 63
                 // TODO: LIMIT the amount of groupings by checking type
64 64
                 // !: You should only be able to match with the target_id ONCE
65 65
                 // !: You should only be associated with a single company too
66
-                console.log('---')
67 66
 
68 67
                 /** User membership service method to create membership */
69 68
                 const memberships = await membershipService.joinGrouping(
@@ -72,7 +71,7 @@ module.exports = {
72 71
                     groupingToWrite,
73 72
                     role,
74 73
                 )
75
-                console.log(memberships)
74
+
76 75
                 return h
77 76
                     .response({
78 77
                         ok: true,

+ 1
- 1
backend/lib/routes/profile/patch-queue.js Ver arquivo

@@ -50,7 +50,7 @@ module.exports = {
50 50
             const { include_profile, reinsert } = request.query
51 51
             const { profileService, matchQueueService } =
52 52
                 request.server.services()
53
-            console.log('reinsert', reinsert)
53
+            // console.log('reinsert', reinsert)
54 54
             const updatedQueue = await matchQueueService.markAsDeleted(
55 55
                 profile_id,
56 56
                 target_id,

+ 1
- 9
backend/lib/routes/profile/queue.js Ver arquivo

@@ -52,21 +52,13 @@ module.exports = {
52 52
 
53 53
             const queue = await matchQueueService.getQueue(profile_id)
54 54
             const queueIds = queue.map(entry => entry.target_id)
55
-            console.log('queueIds', queueIds)
55
+            // console.log('queueIds', queueIds)
56 56
             const res =  {
57 57
                 ok:true,
58 58
                 handler: pluginConfig.handlerType,
59 59
                 data: queueIds
60 60
             }
61 61
 
62
-            // HELP: I think there's an issue here
63
-            // queueIds spits out the queue profiles in the correct order
64
-            // ~However~ when it goes through getProfilesFor
65
-            // it comes back in literal database order regardless of is_deleted status
66
-            console.log(
67
-                'include_profile results',
68
-                await profileService.getProfilesFor(queueIds),
69
-            )
70 62
             if(include_profile) {
71 63
                 res.data = await profileService.getProfilesFor(queueIds)
72 64
             }

+ 1
- 1
backend/lib/routes/profile/score.js Ver arquivo

@@ -43,7 +43,7 @@ module.exports = {
43 43
         tags: ['api'],
44 44
         /** Protect this route with authentication? */
45 45
         auth: false,
46
-
46
+        cors: true,
47 47
         handler: async function (request, h) {
48 48
             const { profileService, matchQueueService } =
49 49
                 request.server.services()

+ 0
- 2
backend/lib/routes/user/current.js Ver arquivo

@@ -30,8 +30,6 @@ module.exports = {
30 30
         tags: ['api'],
31 31
         auth: 'default_jwt',
32 32
         handler: async function (request, h) {
33
-            // console.log('current')
34
-            // console.log(request)
35 33
             try {
36 34
                 const auth = {
37 35
                     credentials: request.auth.credentials,

+ 0
- 1
backend/lib/routes/user/list-profiles.js Ver arquivo

@@ -69,7 +69,6 @@ module.exports = {
69 69
                 userId,
70 70
                 type,
71 71
             )
72
-            console.log('get profiles - const profiles / in list-profiles.js', profiles)
73 72
             try {
74 73
                 return {
75 74
                     ok: true,

+ 0
- 2
backend/lib/services/match.js Ver arquivo

@@ -51,7 +51,6 @@ class Person {
51 51
         }
52 52
 
53 53
         this.swapWith = p => {
54
-            console.log('%s & %s swap partners', this.name, p.name)
55 54
             const thisFiance = this.fiance
56 55
             const pFiance = p.fiance
57 56
             this.engageTo(pFiance)
@@ -80,7 +79,6 @@ module.exports = class MatchService extends Schmervice.Service {
80 79
         for (let d = 0; d < diff; d++) {
81 80
             smallerList.push({ profile_id: `${d}-dummy`, queue: [] })
82 81
         }
83
-        console.log('---')
84 82
         let allPeople = [...seekers, ...posters]
85 83
         const queuesById = allPeople.reduce((queuesById, profile) => {
86 84
             queuesById[profile.profile_id] = profile.queue

+ 1
- 1
backend/lib/services/matchqueue.js Ver arquivo

@@ -13,7 +13,7 @@ module.exports = class MatchQueueService extends Schmervice.Service {
13 13
         const { MatchQueue } = this.server.models()
14 14
         return await MatchQueue.query()
15 15
             .where('profile_id', profileId)
16
-            .andWhere('is_deleted', false)
16
+            .where('is_deleted', 0)
17 17
     }
18 18
     /**
19 19
      * Returns queues by profile id by user type

+ 14
- 6
backend/lib/services/profile.js Ver arquivo

@@ -43,7 +43,6 @@ const scoreAll = (profileList, userProfile) => {
43 43
  * Grab the zip code string
44 44
  */
45 45
 const getZipCodeFromProfile = profile => {
46
-    console.log('profile getZipCode', profile)
47 46
     // There should only be one zip code entry per profile
48 47
     let zipRes = profile.responses.filter(
49 48
         // Whatever the zipcode questions is
@@ -116,15 +115,24 @@ module.exports = class ProfileService extends Schmervice.Service {
116 115
 
117 116
     async getProfilesFor(profileIdArray, type) {
118 117
         const { Profile } = this.server.models()
119
-
118
+        // profilesEntries is profiles in database row order 
120 119
         const profilesEntries = await Profile.query()
121 120
             .whereIn('profile_id', profileIdArray)
122 121
             .withGraphFetched('responses')
123 122
             .withGraphFetched('user')
124 123
 
125
-        return profilesEntries.map(profile => {
126
-            return new CompleteProfile(profile, type)
127
-        })
124
+        // taking the info from profilesEntries
125
+        // to repack into completeProfiles
126
+        // in same order as profileIdArray
127
+        const completeProfiles = []
128
+        profileIdArray.forEach(pid => {
129
+            profilesEntries.forEach(entry => {
130
+                if (entry.profile_id == pid) {
131
+                    completeProfiles.push(new CompleteProfile(entry, type))
132
+                }
133
+            })
134
+        })  
135
+        return completeProfiles
128 136
     }
129 137
 
130 138
     /**
@@ -299,7 +307,7 @@ module.exports = class ProfileService extends Schmervice.Service {
299 307
             parseInt(zipCode),
300 308
         )
301 309
         if (!zipInfo) {
302
-            console.log('zip:', zipCode)
310
+            console.error('zip:', zipCode)
303 311
         }
304 312
 
305 313
         return {

+ 1449
- 1533
frontend/package-lock.json
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 16
- 16
frontend/package.json Ver arquivo

@@ -9,27 +9,27 @@
9 9
         "format": "prettier .  --write"
10 10
     },
11 11
     "dependencies": {
12
-        "joi": "^17.4.0",
13
-        "vue": "^3.0.5",
14
-        "vue-router": "^4.0.12"
12
+        "joi": "^17.6.0",
13
+        "vue": "^3.2.31",
14
+        "vue-router": "^4.0.14"
15 15
     },
16 16
     "devDependencies": {
17
-        "@prettier/plugin-pug": "^1.17.3",
18
-        "@vitejs/plugin-vue": "^1.2.2",
19
-        "@vue/compiler-sfc": "^3.0.5",
20
-        "autoprefixer": "^10.2.5",
21
-        "eslint": "^8.3.0",
22
-        "eslint-config-prettier": "^8.3.0",
23
-        "eslint-plugin-vue": "^8.1.1",
24
-        "naive-ui": "^2.20.3",
25
-        "postcss": "^8.2.13",
26
-        "postcss-calc": "^8.0.0",
27
-        "postcss-import": "^14.0.1",
17
+        "@prettier/plugin-pug": "^1.19.2",
18
+        "@vitejs/plugin-vue": "^2.2.4",
19
+        "@vue/compiler-sfc": "^3.2.31",
20
+        "autoprefixer": "^10.4.2",
21
+        "eslint": "^8.11.0",
22
+        "eslint-config-prettier": "^8.5.0",
23
+        "eslint-plugin-vue": "^8.5.0",
24
+        "naive-ui": "^2.26.4",
25
+        "postcss": "^8.4.8",
26
+        "postcss-calc": "^8.2.4",
27
+        "postcss-import": "^14.0.2",
28 28
         "precss": "^4.0.0",
29 29
         "pug": "^3.0.2",
30 30
         "pug-plain-loader": "^1.1.0",
31
-        "sugarss": "^3.0.3",
32
-        "vite": "^2.2.3",
31
+        "sugarss": "^4.0.1",
32
+        "vite": "^2.8.6",
33 33
         "vite-fs": "^0.0.2",
34 34
         "watch": "^1.0.2"
35 35
     }

+ 23
- 14
frontend/src/components/ProfileCardList.vue Ver arquivo

@@ -3,15 +3,16 @@ section.profile_card_list.w-full
3 3
     .profile_card_list_container.w-full
4 4
         .swipe(
5 5
             :config='config'
6
-            :key='profile.uid'
6
+            :key='profile.pid'
7 7
             @throwout='swipped(profile)'
8
-            v-for='profile in profiles'
8
+            v-for='(profile, i) in profiles'
9
+            :style='{"z-index": 1000-i}'
9 10
         )
10 11
             .card.b-solid.rounded.p-0.bg-cover(
11 12
                 :style='{ "background-image": `url(${profile.avatar})` }'
12 13
             )
13 14
                 .card__content
14
-                    h3.p-1.mv-0.b-solid.rounded {{ profile.name }}
15
+                    h3.p-1.mv-0.b-solid.rounded {{ profile.pid  }} {{ profile.name }}
15 16
                 nav.swipe_icons.w-full.f-row.between
16 17
                     //- Accept
17 18
                     button.p-1(@click='accept') Accept
@@ -22,9 +23,10 @@ section.profile_card_list.w-full
22 23
 </template>
23 24
 
24 25
 <script setup>
25
-import { computed, defineProps } from 'vue'
26
-import { updateQueueByProfileId } from '../services/queue.service'
26
+import { computed, defineProps, defineEmits } from 'vue'
27
+import { updateQueueByProfileId, fetchMembershipsByProfileId, postMembershipByProfileId } from '../services'
27 28
 
29
+const emit = defineEmits(['reloadQueue'])
28 30
 // TODO: Please review this conversion from script to script setup
29 31
 // converted from the props section
30 32
 const props = defineProps({
@@ -32,14 +34,14 @@ const props = defineProps({
32 34
         type: [Object, Array],
33 35
         default: () => [
34 36
             {
35
-                uid: '1',
37
+                pid: '1',
36 38
                 name: 'Full Name',
37 39
                 avatar: 'https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/newborn-baby-boy-sleeping-peacefully-wearing-knit-royalty-free-image-1589459736.jpg?crop=0.669xw:1.00xh;0.228xw,0&resize=640:*',
38 40
                 metadata: { age: '21', rawMetadata: 'Some Text Here!' },
39 41
             },
40 42
         ],
41 43
     },
42
-    uid: {
44
+    pid: {
43 45
         type: Number,
44 46
         default: 9999,
45 47
     },
@@ -54,7 +56,7 @@ const reject = () => {
54 56
 
55 57
 
56 58
 const swipped = profile => {
57
-    const index = props.profiles.findIndex(u => u.uid == profile.uid)
59
+    const index = props.profiles.findIndex(u => u.pid == profile.pid)
58 60
     // TODO: bug, fix this
59 61
     props.profiles.splice(index, 1)
60 62
     profile.id = Date.now() + (Math.random() * 100000).toFixed()
@@ -67,17 +69,23 @@ const onRequest = () => {
67 69
     const data = { ...currentCard }
68 70
 }
69 71
 // AHP Button behavior
70
-const accept = () => {
72
+
73
+const accept = async () => {
71 74
     console.log('accepted aka do NOT reinsert')
72 75
     // need to pass these arguments (profileId, targetId, status)
73 76
     // the url structure is
74 77
     // const charmander = await db.get(`/profile/{profile_id}/queue/{target_id}/delete?include_profile=true&reinsert=false`)
75 78
     // http://localhost:3001/api/profile/38/queue/9/delete?include_profile=true&reinsert=true
76
-    const profileId = props.uid
77
-    const targetId = props.profiles[0].uid
79
+    const profileId = props.pid
80
+    const targetId = props.profiles[0].pid
78 81
     updateQueueByProfileId(profileId, targetId, false)
79 82
     // TODO: next step is grouping/membership
80
-    postMembershipByProfileId({ profileId, targetId })
83
+    const checkMembership = await fetchMembershipsByProfileId(profileId)
84
+    if (!checkMembership.length) {
85
+        console.log('Make membership')
86
+        postMembershipByProfileId({ profileId, targetId })
87
+    }
88
+    emit('reloadQueue')
81 89
 }
82 90
 const hold = () => {
83 91
     console.log('held? do we need this?')
@@ -85,9 +93,10 @@ const hold = () => {
85 93
 const pass = () => {
86 94
     console.log('passed aka do reinsert')
87 95
     // const charmander = await db.get(`/profile/{profile_id}/queue/{target_id}/delete?include_profile=true&reinsert=true`)
88
-    const profileId = props.uid
89
-    const targetId = props.profiles[0].uid
96
+    const profileId = props.pid
97
+    const targetId = props.profiles[0].pid
90 98
     updateQueueByProfileId(profileId, targetId, true)
99
+    emit('reloadQueue')
91 100
 }
92 101
 
93 102
 // from the data() section

+ 2
- 12
frontend/src/components/form.vue Ver arquivo

@@ -58,7 +58,6 @@ import Joi from 'joi'
58 58
 import { validatorMapping, makeKebob } from '@/utils'
59 59
 import { defineProps, reactive, ref } from 'vue'
60 60
 import { saveSurveyByProfileID, scoreSurveyByProfileId } from '../services/survey.service'
61
-import { fetchMembershipsByProfileId, postMembershipByProfileId } from '../services/grouping.service'
62 61
 
63 62
 const slidevalue = ref('0')
64 63
 
@@ -108,7 +107,7 @@ const isValid = step => {
108 107
 /**
109 108
  * Save or take the-nNext step in the form
110 109
  */
111
-const next = e => {
110
+const next = async e => {
112 111
     const validity = isValid(state.step - 1)
113 112
     if (validity.error) return console.error(validity.error)
114 113
     if (state.step === props.form.length) {
@@ -129,20 +128,11 @@ const next = e => {
129 128
         // Bc we don't want to pass the 1st question to backend & we want profileId
130 129
         // Necessary atm bc we manually added question in Survey class (entity)
131 130
         const profileId = idWithResponseVal.shift().val
132
-        const targetId = 0
133
-        const maxDistance = 10
131
+        const maxDistance = 100
134 132
         saveSurveyByProfileID(idWithResponseVal, profileId)
135 133
         alert('Responses submitted!')
136 134
         resetAnswers()
137 135
         scoreSurveyByProfileId(profileId, maxDistance)
138
-
139
-        const checkMembership = fetchMembershipsByProfileId(profileId)
140
-        console.log(checkMembership)
141
-        if (!checkMembership) {
142
-            console.log('Make membership')
143
-            // postMembershipByProfileId({ profileId, targetId })
144
-        }
145
-
146 136
         state.step = 1
147 137
     } else if (state.step < props.form.length) {
148 138
         state.step++

+ 1
- 1
frontend/src/services/queue.service.js Ver arquivo

@@ -17,7 +17,7 @@ const updateQueueByProfileId = async (profileId, targetId, reinsert) => {
17 17
     // targetId - the id of the profile viewed by the profileId
18 18
     // reinsert - if profileId accepted targetId, FALSE reinsert so no reinsert; if profileId passed targetId, TRUE reinsert so reinsert at end
19 19
     //
20
-    const updateQueue = db.patch(
20
+    const updateQueue = await db.patch(
21 21
         `/profile/${profileId}/queue/${targetId}/delete?include_profile=true&reinsert=${reinsert}`,
22 22
         // HELP: responseScheme says the structure should be array of either:
23 23
         // 1) NUMBER

+ 1
- 1
frontend/src/services/survey.service.js Ver arquivo

@@ -71,7 +71,7 @@ const updateSurveyByProfileId = async (surveyResponses, profileId) => {
71 71
 }
72 72
 
73 73
 const scoreSurveyByProfileId = async (profileId, maxDistance) => {
74
-    const scoreSurvey = db.get(`/profile/${profileId}/score?max_distance=${maxDistance}`)
74
+    const scoreSurvey = await db.get(`/profile/${profileId}/score?max_distance=${maxDistance}`)
75 75
     return scoreSurvey
76 76
 }
77 77
 

+ 22
- 14
frontend/src/views/home.vue Ver arquivo

@@ -1,9 +1,12 @@
1 1
 <template lang="pug">
2 2
 sidebar
3 3
 main.f-col.start.w-full
4
-    article#home
4
+    article#home(v-if='!loading')
5 5
         h1(v-if='user') {{ user.user_name }}
6
-        profile-card-list(:profiles='swipables' :uid='mypid')
6
+        profile-card-list(:profiles='swipables' :pid='parseInt(mypid)' @reloadQueue='getQueue')
7
+        input(v-model='mypid')
8
+        button(@click='getQueue') Submit
9
+    p(v-else) Loading...
7 10
     main-nav
8 11
 </template>
9 12
 
@@ -12,7 +15,6 @@ import sidebar from '../components/Sidebar.vue'
12 15
 import mainNav from '../components/MainNav.vue'
13 16
 import profileCardList from '../components/ProfileCardList.vue'
14 17
 import { fetchQueueByProfileId } from '../services'
15
-import { fetchMembershipsByProfileId, postMembershipByProfileId } from '../services/grouping.service'
16 18
 
17 19
 import batch_10 from '../../../backend/db/generated/_batch_10.js.ref'
18 20
 import batch_20 from '../../../backend/db/generated/_batch_20.js.ref'
@@ -25,32 +27,34 @@ export default {
25 27
         swipables: [],
26 28
         user: null,
27 29
         mypid: null,
30
+        loading: true
28 31
     }),
29 32
     async created() {
30 33
         // this.mypid = auth.currentUser?.mypid || "99999";
31
-        this.mypid = 38
34
+        this.mypid = 45
32 35
         // Uncomment below to use for batch file data
33 36
         // this.processProfilesFromBatch(this.parseBatch([batch_10, batch_20, batch_30]))
34
-
35
-        // Uncomment below to use API
36
-        const queueList = await fetchQueueByProfileId(this.mypid)
37
-        console.log('queueList', queueList)
38
-        this.processQueue(queueList)
39
-        const profileId = 38
40
-        const checkMembership = fetchMembershipsByProfileId(profileId)
41
-        console.log('checkMembership', checkMembership)
37
+        this.getQueue()
42 38
     },
43 39
     methods: {
40
+        async getQueue() {
41
+            this.loading = true
42
+            const queueList = await fetchQueueByProfileId(this.mypid)
43
+            this.processQueue(queueList)
44
+            this.loading = false
45
+        },
44 46
         processQueue(queueList) {
45 47
             const formattedList = []
46 48
             queueList.forEach(profile => {
47 49
                 const formatted = {
48
-                        uid: profile.profile_id,
50
+                        pid: profile.profile_id,
49 51
                         name: profile.user_name,
50 52
                         avatar: profile.user_media,
51 53
                     }
52 54
                 formattedList.push(formatted)
53 55
             })
56
+            console.log('formattedList', formattedList)
57
+            // formattedList.reverse()
54 58
             this.swipables = formattedList
55 59
         },
56 60
         // For Batch Data Parsing & Processing
@@ -75,7 +79,7 @@ export default {
75 79
             parsed.profiles.forEach(p => {
76 80
                 // console.log(parsed)
77 81
                 const user = findUser(p)
78
-                p.uid = p.profile_id
82
+                p.pid = p.profile_id
79 83
                 p.name = user.user_name
80 84
                 p.email = user.user_email
81 85
                 p.avatar = p.user_media[0]
@@ -103,4 +107,8 @@ main
103 107
         height: 100%
104 108
         width: 100%
105 109
         flex-direction: column
110
+
111
+    input, button
112
+        position: relative
113
+        z-index: 1000
106 114
 </style>

Carregando…
Cancelar
Salvar