This commit is contained in:
parent
e8f899d098
commit
7eb0ad1221
4 changed files with 30 additions and 27 deletions
|
|
@ -22,7 +22,7 @@ func Contact(r *router) *contactR {
|
||||||
|
|
||||||
type contact struct {
|
type contact struct {
|
||||||
types.Contact
|
types.Contact
|
||||||
Messages []types.Message
|
Messages []types.Message `json:"messages"`
|
||||||
URI string
|
URI string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,7 @@
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
<div
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
class="card-header d-flex justify-content-between align-items-center"
|
|
||||||
>
|
|
||||||
<span>
|
<span>
|
||||||
<i class="bi bi-chat-dots"></i>
|
<i class="bi bi-chat-dots"></i>
|
||||||
Message History
|
Message History
|
||||||
|
|
@ -87,17 +85,13 @@
|
||||||
:key="idx"
|
:key="idx"
|
||||||
class="message-item"
|
class="message-item"
|
||||||
:class="
|
:class="
|
||||||
isOwn(msg)
|
isOwn(msg) ? 'message-item-outgoing' : 'message-item-incoming'
|
||||||
? 'message-item-outgoing'
|
|
||||||
: 'message-item-incoming'
|
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="message-bubble"
|
class="message-bubble"
|
||||||
:class="
|
:class="
|
||||||
isOwn(msg)
|
isOwn(msg) ? 'message-bubble-outgoing' : 'message-bubble-incoming'
|
||||||
? 'message-bubble-outgoing'
|
|
||||||
: 'message-bubble-incoming'
|
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<div class="message-content">
|
<div class="message-content">
|
||||||
|
|
@ -106,20 +100,12 @@
|
||||||
<div class="message-meta">
|
<div class="message-meta">
|
||||||
<TimeRelative :time="msg.created" />
|
<TimeRelative :time="msg.created" />
|
||||||
<span
|
<span
|
||||||
v-if="
|
v-if="ownIdentifier && msg.source && msg.destination"
|
||||||
ownIdentifier &&
|
|
||||||
msg.source &&
|
|
||||||
msg.destination
|
|
||||||
"
|
|
||||||
class="message-phone"
|
class="message-phone"
|
||||||
>
|
>
|
||||||
·
|
·
|
||||||
{{ isOwn(msg) ? 'to' : 'from' }}
|
{{ isOwn(msg) ? "to" : "from" }}
|
||||||
{{
|
{{ isOwn(msg) ? msg.destination : msg.source }}
|
||||||
isOwn(msg)
|
|
||||||
? msg.destination
|
|
||||||
: msg.source
|
|
||||||
}}
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -145,7 +131,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||||
|
|
||||||
const sortedMessages = computed(() => {
|
const sortedMessages = computed(() => {
|
||||||
return [...props.messages].sort(
|
return [...props.messages].sort(
|
||||||
(a, b) => a.created.getTime() - b.created.getTime(),
|
(a: Message, b: Message) => a.created.getTime() - b.created.getTime(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<p>No phone numbers</p>
|
<p>No phone numbers</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="contact.messages.length > 0">
|
||||||
|
<CardMessageHistory
|
||||||
|
:messages="contact.messages"
|
||||||
|
ownIdentifier="+16235525879"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -34,6 +40,7 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Contact } from "@/type/api";
|
import { Contact } from "@/type/api";
|
||||||
|
import CardMessageHistory from "@/components/CardMessageHistory.vue";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
contact?: Contact;
|
contact?: Contact;
|
||||||
|
|
|
||||||
|
|
@ -78,28 +78,38 @@ export class Bounds {
|
||||||
}
|
}
|
||||||
export interface ContactOptions {
|
export interface ContactOptions {
|
||||||
emails?: string[];
|
emails?: string[];
|
||||||
|
messages?: Message[];
|
||||||
name?: string;
|
name?: string;
|
||||||
phones?: Phone[];
|
phones?: Phone[];
|
||||||
uri?: string;
|
uri?: string;
|
||||||
}
|
}
|
||||||
export class Contact {
|
export class Contact {
|
||||||
emails: string[];
|
emails: string[];
|
||||||
|
messages: Message[];
|
||||||
name: string;
|
name: string;
|
||||||
phones: Phone[];
|
phones: Phone[];
|
||||||
uri: string;
|
uri: string;
|
||||||
constructor(options?: ContactOptions) {
|
constructor(options?: ContactOptions) {
|
||||||
this.emails = options?.emails ?? [];
|
this.emails = options?.emails ?? [];
|
||||||
|
this.messages = options?.messages ?? [];
|
||||||
this.name = options?.name ?? "";
|
this.name = options?.name ?? "";
|
||||||
this.phones = options?.phones ?? [];
|
this.phones = options?.phones ?? [];
|
||||||
this.uri = options?.uri ?? "";
|
this.uri = options?.uri ?? "";
|
||||||
}
|
}
|
||||||
static fromJSON(json: ContactDTO): Contact {
|
static fromJSON(json: ContactDTO): Contact {
|
||||||
return new Contact(json);
|
return new Contact({
|
||||||
|
emails: json.emails,
|
||||||
|
messages: json.messages.map((m: MessageDTO) => Message.fromJSON(m)),
|
||||||
|
name: json.name,
|
||||||
|
phones: json.phones,
|
||||||
|
uri: json.uri,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export interface ContactDTO {
|
export interface ContactDTO {
|
||||||
name: string;
|
|
||||||
emails: string[];
|
emails: string[];
|
||||||
|
messages: MessageDTO[];
|
||||||
|
name: string;
|
||||||
phones: Phone[];
|
phones: Phone[];
|
||||||
uri: string;
|
uri: string;
|
||||||
}
|
}
|
||||||
|
|
@ -715,9 +725,9 @@ export interface Site {
|
||||||
leads: Lead[];
|
leads: Lead[];
|
||||||
notes: string;
|
notes: string;
|
||||||
organization_id: number;
|
organization_id: number;
|
||||||
owner?: Contact;
|
owner?: ContactSimple;
|
||||||
parcel: Parcel;
|
parcel: Parcel;
|
||||||
resident?: Contact;
|
resident?: ContactSimple;
|
||||||
resident_owned: boolean;
|
resident_owned: boolean;
|
||||||
tags: Map<string, string>;
|
tags: Map<string, string>;
|
||||||
version: number;
|
version: number;
|
||||||
|
|
@ -725,7 +735,7 @@ export interface Site {
|
||||||
export interface ReviewTaskPool {
|
export interface ReviewTaskPool {
|
||||||
condition: string;
|
condition: string;
|
||||||
location: Location;
|
location: Location;
|
||||||
owner: Contact;
|
owner: ContactSimple;
|
||||||
site: Site;
|
site: Site;
|
||||||
}
|
}
|
||||||
export interface ReviewTask {
|
export interface ReviewTask {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue