|
1 | 1 | <template> |
2 | | - <h1>test</h1> |
| 2 | + <!-- eslint-disable max-len --> |
| 3 | + <div class="mx-4 sm:mx-16 lg:mx-32"> |
| 4 | + <NavBar v-bind:currentRoute="'Matches'"></NavBar> |
| 5 | + <section class="mx-auto"> |
| 6 | + <div> |
| 7 | + <div class="mt-8"> |
| 8 | + <div v-if="matches.length"> |
| 9 | + <h1 class="text-xl text-gray-matcha text-center">New matches</h1> |
| 10 | + <div></div> |
| 11 | + </div> |
| 12 | + <div v-else class="flex items-center"> |
| 13 | + <div> |
| 14 | + <img src="../../assets/link.png" class="w-8 opacity-75"> |
| 15 | + </div> |
| 16 | + <div class="ml-4"> |
| 17 | + <h1 class="text-xl text-gray-matcha font-bold">No new matches</h1> |
| 18 | + <h1 class="text-sm text-gray-500">If someone likes you back, that user will appear here</h1> |
| 19 | + </div> |
| 20 | + </div> |
| 21 | + </div> |
| 22 | + <div class="mt-8"> |
| 23 | + <div v-if="messages.length"> |
| 24 | + <h1 class="text-xl text-gray-matcha text-center">Messages</h1> |
| 25 | + <div></div> |
| 26 | + </div> |
| 27 | + <div v-else class="flex items-center"> |
| 28 | + <div> |
| 29 | + <img src="../../assets/chat.png" class="w-8 opacity-75"> |
| 30 | + </div> |
| 31 | + <div class="ml-4"> |
| 32 | + <h1 class="text-xl text-gray-matcha font-bold">No messages</h1> |
| 33 | + <h1 class="text-sm text-gray-500">Conversations with your matches will appear here</h1> |
| 34 | + </div> |
| 35 | + </div> |
| 36 | + </div> |
| 37 | + </div> |
| 38 | + </section> |
| 39 | + </div> |
3 | 40 | </template> |
4 | 41 |
|
5 | 42 | <script> |
| 43 | +/* eslint-disable max-len */ |
| 44 | +/* eslint-disable no-await-in-loop */ |
| 45 | +
|
| 46 | +import NavBar from '@/components/shared/NavBar.vue'; |
| 47 | +
|
| 48 | +export default { |
| 49 | + name: 'Matches', |
| 50 | + components: { |
| 51 | + NavBar, |
| 52 | + }, |
| 53 | + data: () => ({ |
| 54 | + matches: [], |
| 55 | + messages: [], |
| 56 | + }), |
| 57 | + methods: { |
| 58 | + async fetchMatches() { |
| 59 | + const matchesRequest = await this.$http.get('/matches'); |
| 60 | + const { matches } = matchesRequest.data; |
| 61 | + for (let i = 0; i < matches.length; i += 1) { |
| 62 | + const userRequest = await this.$http.get(`/users/${matches[i].user_1}`); |
| 63 | + this.matches.push(userRequest.data); |
| 64 | + } |
| 65 | + }, |
| 66 | + async fetchMessages() { |
| 67 | + const messagesRequest = await this.$http.get('/conversations'); |
| 68 | + const messages = messagesRequest.data; |
| 69 | + for (let i = 0; i <= messages.length; i += 1) { |
| 70 | + const userChattingWith = await this.$http.get(`/users/${messages[i].with_user}`); |
| 71 | + messages[i].user = userChattingWith.data; |
| 72 | + } |
| 73 | + this.messages = messages; |
| 74 | + }, |
| 75 | + }, |
| 76 | + async beforeMount() { |
| 77 | + await this.fetchMatches(); |
| 78 | + await this.fetchMessages(); |
| 79 | + }, |
| 80 | +}; |
6 | 81 | </script> |
0 commit comments