Add text message log to report display

This commit is contained in:
Eli Ribble 2026-04-28 05:15:01 +00:00
parent 4ce91d77d4
commit 82b313f62f
No known key found for this signature in database
3 changed files with 51 additions and 18 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/Gleipnir-Technology/bob/dialect/psql"
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
"github.com/Gleipnir-Technology/nidus-sync/db"
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
"github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
"github.com/rs/zerolog/log"
@ -157,12 +158,16 @@ func logEntriesFromTexts(ctx context.Context, report_ids []int32) (map[int32][]*
} else {
user_id_ptr = &user_id
}
type_ := "message-text-outgoing"
if row.Origin == enums.CommsTextoriginCustomer {
type_ = "message-text-incoming"
}
logs = append(logs, &types.LogEntry{
Created: row.Created,
ID: row.ID,
Message: row.Content,
ReportID: report_id,
Type: "text-message",
Type: type_,
UserID: user_id_ptr,
})
results[report_id] = logs

View file

@ -112,20 +112,7 @@
:key="index"
class="border-start border-2 ps-2 mb-2"
>
<div v-if="entry.type === 'created'">
<div class="text-muted">Initial Report</div>
<small class="text-muted">{{
formatDate(entry.created)
}}</small>
</div>
<div v-else-if="entry.type === 'message-text'">
<div class="text-muted">Text Message</div>
<div>{{ entry.message }}</div>
<small class="text-muted">{{
formatDate(entry.created)
}}</small>
</div>
<div v-else>{{ entry.type }}</div>
<ListCardActivityLog :entry="entry" />
</div>
<div
v-if="
@ -148,6 +135,7 @@
<script setup lang="ts">
import { ref } from "vue";
import { Communication, User } from "@/type/api";
import ListCardActivityLog from "@/components/ListCardActivityLog.vue";
interface Emits {
(e: "markSignal"): void;
(e: "markInvalid"): void;
@ -173,9 +161,6 @@ function applyMessageTemplate(template: string) {
messageText.value = templates[template as keyof typeof templates];
}
}
function formatDate(date: Date) {
return date.toLocaleString();
}
function handleTemplateChange(event: Event) {
const target = event.target as HTMLSelectElement;
applyMessageTemplate(target.value);

View file

@ -0,0 +1,43 @@
<template>
<div>
<div class="text-muted">
<i class="bi" :class="typeToIcon()" />{{ typeToTitle() }}
</div>
<div>{{ entry.message }}</div>
<small class="text-muted">{{ formatDate(entry.created) }}</small>
</div>
</template>
<script setup lang="ts">
import { LogEntry } from "@/type/api";
interface Props {
entry: LogEntry;
}
const props = defineProps<Props>();
function formatDate(date: Date) {
return date.toLocaleString();
}
function typeToIcon(): string {
if (props.entry.type == "message-text-incoming") {
return "bi-box-arrow-in-left";
} else if (props.entry.type == "message-text-outgoing") {
return "bi-box-arrow-out-right";
} else if (props.entry.type == "created") {
return "bi-stars";
} else {
return "bi-question";
}
}
function typeToTitle(): string {
if (props.entry.type == "message-text-incoming") {
return "Incoming Text";
} else if (props.entry.type == "message-text-outgoing") {
return "Outgoing Text";
} else if (props.entry.type == "created") {
return "Report Created";
} else {
return props.entry.type;
}
}
</script>