Explorar el Código

converted script to script setup in ProfileCardList

tags/0.0.1
diaseu hace 4 años
padre
commit
0cfcde0730
Se han modificado 1 ficheros con 77 adiciones y 57 borrados
  1. 77
    57
      frontend/src/components/ProfileCardList.vue

+ 77
- 57
frontend/src/components/ProfileCardList.vue Ver fichero

13
                 .card__content
13
                 .card__content
14
                     h3.p-1.mv-0.b-solid.rounded {{ profile.name }}
14
                     h3.p-1.mv-0.b-solid.rounded {{ profile.name }}
15
 
15
 
16
+        //- TODO: Make functional (using match queue endpoints)
17
+        //- queue.service.js
18
+        //- Call function that calls service that talks to endpoint
19
+        //- Will need GET http://localhost:3001/api/profile/1/queue  <- will look like array with profile ids [2, 3, 4, 6]
20
+        //- Need profile id (logged in profile) and target id (id on card)
21
+
16
         nav.swipe_icons.w-full.f-row.between
22
         nav.swipe_icons.w-full.f-row.between
17
-            h2 A
18
-            h2 H
19
-            h2 P
23
+            //- Accept
24
+            button.p-1(@click='accept') A
25
+            //- Hold
26
+            button.p-1(@click='hold') H
27
+            //- Pass
28
+            button.p-1(@click='pass') P
20
 </template>
29
 </template>
21
 
30
 
22
-<script>
23
-export default {
24
-    name: 'ProfileCardList',
25
-    props: {
26
-        profiles: {
27
-            type: [Object, Array],
28
-            default: () => [
29
-                {
30
-                    uid: '1',
31
-                    name: 'Fullname',
32
-                    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:*',
33
-                    metadata: { age: '21', rawMetadata: 'Some Text Here!' },
34
-                },
35
-            ],
36
-        },
37
-        uid: {
38
-            type: Number,
39
-            default: 9999,
40
-        },
41
-    },
42
-    data: () => ({
43
-        config: {
44
-            // allowedDirections: [VueSwing.Direction.LEFT, VueSwing.Direction.RIGHT],
45
-            minThrowOutDistance: 250,
46
-            maxThrowOutDistance: 300,
47
-        },
48
-        favorites: [],
49
-        requests: [],
50
-    }),
51
-    computed: {
52
-        currentCard() {
53
-            return this.profiles[this.profiles.length - 1]
54
-        },
55
-    },
56
-    created() {
57
-        this.getUser()
31
+<script setup>
32
+import { computed } from 'vue'
33
+
34
+// TODO: Please review this conversion from script to script setup
35
+// converted from the props section
36
+const props = defineProps({
37
+    profiles: {
38
+        type: [Object, Array],
39
+        default: () => [
40
+            {
41
+                uid: '1',
42
+                name: 'Fullname',
43
+                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:*',
44
+                metadata: { age: '21', rawMetadata: 'Some Text Here!' },
45
+            },
46
+        ],
58
     },
47
     },
59
-    methods: {
60
-        logOut() {},
61
-        reject() {
62
-            this.swipped(this.currentCard)
63
-        },
64
-        swipped(profile) {
65
-            const index = this.profiles.findIndex(u => u.uid == profile.uid)
66
-            this.profiles.splice(index, 1)
67
-            profile.id = Date.now() + (Math.random() * 100000).toFixed()
68
-            this.profiles.unshift({ ...profile })
69
-        },
70
-        getUser() {
71
-            return
72
-        },
73
-        onRequest() {
74
-            const data = { ...this.currentCard }
75
-            return
76
-        },
48
+    uid: {
49
+        type: Number,
50
+        default: 9999,
77
     },
51
     },
52
+})
53
+// from the computed section
54
+const currentCard = computed(() => this.profiles[this.profiles.length - 1]);
55
+// from the method section
56
+const logOut = () => {};
57
+const reject = () => {
58
+    this.swipped(this.currentCard)
59
+}
60
+const swipped = profile => {
61
+    const index = this.profiles.findIndex(u => u.uid == profile.uid)
62
+    this.profiles.splice(index, 1)
63
+    profile.id = Date.now() + (Math.random() * 100000).toFixed()
64
+    this.profiles.unshift({ ...profile })
65
+}
66
+const getUser = () => {
67
+}
68
+const onRequest = () => {
69
+    const data = { ...this.currentCard }
70
+}
71
+const accept = () => {
72
+    console.log('accepted')
73
+}
74
+const hold = () => {
75
+    console.log('held')
78
 }
76
 }
77
+const pass = () => {
78
+    console.log('passed')
79
+
80
+}
81
+
82
+// from the data() section
83
+const config = {
84
+    // allowedDirections: [VueSwing.Direction.LEFT, VueSwing.Direction.RIGHT],
85
+    minThrowOutDistance: 250,
86
+    maxThrowOutDistance: 300,
87
+}
88
+const favorites = []
89
+const requests = []
90
+
91
+    // // I dont know how to convert these to the script setup method
92
+// created() {
93
+//     this.getUser(),
94
+// },
95
+// End conversion from script to script setup
96
+
97
+
79
 </script>
98
 </script>
99
+
80
 <style lang="postcss">
100
 <style lang="postcss">
81
 .profile_card_list_container
101
 .profile_card_list_container
82
     display: flex
102
     display: flex

Loading…
Cancelar
Guardar