Skip to content

Commit a27515c

Browse files
committed
Fix UI
1 parent 48d1012 commit a27515c

13 files changed

Lines changed: 319 additions & 43 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ jobs:
5252

5353
- name: Build 🏗️
5454
run: yarn generate
55+
env:
56+
BASE_URL: https://api.httpsms.com
5557

5658
- name: Deploy 🚀
5759
uses: FirebaseExtended/action-hosting-deploy@v0
5860
with:
59-
repoToken: '${{ secrets.GITHUB_TOKEN }}'
61+
repoToken: "${{ secrets.GITHUB_TOKEN }}"
6062
channelId: live
61-
entryPoint: './web'
62-
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_HTTPSMS_86C51 }}'
63+
entryPoint: "./web"
64+
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_HTTPSMS_86C51 }}"
6365
projectId: httpsms-86c51

api/pkg/di/container.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"os"
77
"time"
88

9+
"github.com/gofiber/fiber/v2/middleware/cors"
10+
911
"github.com/NdoleStudio/http-sms-manager/pkg/entities"
1012
"github.com/NdoleStudio/http-sms-manager/pkg/listeners"
1113
"github.com/NdoleStudio/http-sms-manager/pkg/repositories"
@@ -65,6 +67,9 @@ func (container *Container) App() (app *fiber.App) {
6567
app.Use(fiberLogger.New())
6668
}
6769

70+
// Default config
71+
app.Use(cors.New())
72+
6873
container.app = app
6974
return app
7075
}

api/pkg/handlers/message_thread_handler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ func (h *MessageThreadHandler) Index(c *fiber.Ctx) error {
6262

6363
ctxLogger := h.tracer.CtxLogger(h.logger, span)
6464

65+
ctxLogger.Info(c.OriginalURL())
66+
6567
var request requests.MessageThreadIndex
6668
if err := c.QueryParser(&request); err != nil {
6769
msg := fmt.Sprintf("cannot marshall params [%s] into %T", c.OriginalURL(), request)

api/pkg/requests/message_index_request.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
// MessageIndex is the payload fetching entities.Message sent between 2 numbers
1313
type MessageIndex struct {
1414
Skip string `json:"skip" query:"skip"`
15-
Contact string `json:"contact" query:"to"`
16-
Owner string `json:"owner" query:"from"`
15+
Contact string `json:"contact" query:"contact"`
16+
Owner string `json:"owner" query:"owner"`
1717
Query string `json:"query" query:"query"`
1818
Limit string `json:"limit" query:"limit"`
1919
}

api/pkg/validators/message_handler_validator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ func (validator MessageHandlerValidator) ValidateMessageIndex(_ context.Context,
130130
"numeric",
131131
"min:0",
132132
},
133-
"from": []string{
133+
"contact": []string{
134134
"required",
135135
"min:1",
136136
},
137137
"query": []string{
138138
"max:100",
139139
},
140-
"to": []string{
140+
"owner": []string{
141141
"required",
142142
phoneNumberRule,
143143
},

api/pkg/validators/message_thread_handler_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (validator *MessageThreadHandlerValidator) ValidateMessageThreadIndex(_ con
5353
},
5454
Messages: map[string][]string{
5555
"owner": {
56-
"regex:The 'owner' field must be a valid E.164 phone number: https://en.wikipedia.org/wiki/E.164",
56+
"regex:The owner field must be a valid E.164 phone number: https://en.wikipedia.org/wiki/E.164",
5757
},
5858
},
5959
})

web/components/MessageThread.vue

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
<template>
22
<v-list two-line class="px-0 py-0" subheader>
3-
<v-list-item-group v-model="selected">
3+
<v-list-item-group>
44
<template v-for="thread in threads">
5-
<v-list-item :key="thread.id" class="py-1">
5+
<v-list-item
6+
:key="thread.id"
7+
:to="'/threads/' + thread.id"
8+
class="py-1"
9+
>
610
<v-list-item-avatar :color="thread.color">
711
<v-icon dark> mdi-account </v-icon>
812
</v-list-item-avatar>
913
<v-list-item-content>
1014
<v-list-item-title>
11-
{{ thread.phoneNumber }}
15+
{{ thread.contact }}
1216
</v-list-item-title>
1317
<v-list-item-subtitle>
14-
{{ thread.message }}
18+
{{ thread.last_message_content }}
1519
</v-list-item-subtitle>
1620
</v-list-item-content>
1721
<v-list-item-action>
1822
<v-list-item-action-text>
19-
{{ thread.date }}
23+
{{ threadDate(thread.order_timestamp) }}
2024
</v-list-item-action-text>
2125
</v-list-item-action>
2226
</v-list-item>
@@ -28,36 +32,17 @@
2832
<script lang="ts">
2933
import { Vue, Component } from 'vue-property-decorator'
3034
31-
type ThreadItem = {
32-
id: string
33-
phoneNumber: string
34-
message: string
35-
date: string
36-
color: string
37-
}
38-
3935
@Component
4036
export default class MessageThread extends Vue {
41-
selected: string = '1'
42-
get threads(): Array<ThreadItem> {
43-
return [
44-
{
45-
id: '1',
46-
phoneNumber: '+1 800 5550 100',
47-
message:
48-
'I was calling about the apartment? Is it still available and can I see it today?',
49-
date: 'Fri',
50-
color: 'indigo',
51-
},
52-
{
53-
id: '2',
54-
phoneNumber: '+1 800 5550 500',
55-
message:
56-
'I was calling about the apartment? Is it still available and can I see it today?',
57-
date: '20 May',
58-
color: 'teal',
59-
},
60-
]
37+
get threads(): Array<MessageThread> {
38+
return this.$store.getters.getThreads
39+
}
40+
41+
threadDate(date: string): string {
42+
return new Date(date).toLocaleString(undefined, {
43+
month: 'short',
44+
day: 'numeric',
45+
})
6146
}
6247
}
6348
</script>

web/layouts/default.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
</template>
1313
</v-navigation-drawer>
1414
<v-main>
15-
<v-container fluid :fill-height="$vuetify.breakpoint.lgAndUp">
15+
<v-container
16+
fluid
17+
class="pa-0"
18+
:fill-height="$vuetify.breakpoint.lgAndUp"
19+
>
1620
<Nuxt />
1721
</v-container>
1822
</v-main>
@@ -23,11 +27,24 @@
2327
import { Vue, Component } from 'vue-property-decorator'
2428
2529
@Component
26-
export default class DefaultLayout extends Vue {}
30+
export default class DefaultLayout extends Vue {
31+
mounted() {
32+
this.$store.dispatch('loadThreads')
33+
}
34+
}
2735
</script>
2836

2937
<style lang="scss">
3038
html {
3139
overflow-y: auto;
3240
}
41+
42+
.v-application {
43+
.w-full {
44+
width: 100%;
45+
}
46+
.h-full {
47+
height: 100%;
48+
}
49+
}
3350
</style>

web/models/message-thread.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export interface MessageThread {
2+
color: string
3+
contact: string
4+
created_at: string
5+
id: string
6+
last_message_content: string
7+
last_message_id: string
8+
order_timestamp: string
9+
owner: string
10+
updated_at: string
11+
}

web/models/message.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export interface Message {
2+
contact: string
3+
content: string
4+
created_at: string
5+
failure_reason: string
6+
id: string
7+
last_attempted_at: string | null
8+
order_timestamp: string
9+
owner: string
10+
received_at: string | null
11+
request_received_at: string | null
12+
send_time: number | null
13+
sent_at: string
14+
status: string
15+
type: string
16+
updated_at: string
17+
}

0 commit comments

Comments
 (0)