import { DeesElement, property, html, customElement, type TemplateResult, css, state, cssManager } from '@design.estate/dees-element';
import * as appstate from '../appstate.js';
import * as shared from './shared/index.js';
declare global {
interface HTMLElementTagNameMap {
'ops-view-emails': OpsViewEmails;
}
}
interface IEmail {
id: string;
from: string;
to: string[];
cc?: string[];
bcc?: string[];
subject: string;
body: string;
html?: string;
attachments?: Array<{
filename: string;
size: number;
contentType: string;
}>;
date: number;
read: boolean;
folder: 'inbox' | 'sent' | 'draft' | 'trash';
flags?: string[];
messageId?: string;
inReplyTo?: string;
}
@customElement('ops-view-emails')
export class OpsViewEmails extends DeesElement {
@state()
private selectedFolder: 'inbox' | 'sent' | 'draft' | 'trash' = 'inbox';
@state()
private emails: IEmail[] = [];
@state()
private selectedEmail: IEmail | null = null;
@state()
private showCompose = false;
@state()
private isLoading = false;
@state()
private searchTerm = '';
constructor() {
super();
this.loadEmails();
}
public static styles = [
cssManager.defaultStyles,
shared.viewHostCss,
css`
:host {
display: block;
height: 100%;
}
.emailContainer {
display: grid;
grid-template-columns: 280px 1fr;
gap: 16px;
height: 100%;
min-height: 600px;
}
.sidebar {
display: flex;
flex-direction: column;
gap: 16px;
}
.mainContent {
display: flex;
flex-direction: column;
gap: 16px;
overflow: hidden;
}
.emailToolbar {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.searchBox {
flex: 1;
min-width: 200px;
max-width: 400px;
}
.emailList {
flex: 1;
overflow: hidden;
}
.emailPreview {
flex: 1;
display: flex;
flex-direction: column;
background: white;
border: 1px solid #e9ecef;
border-radius: 8px;
overflow: hidden;
}
.emailHeader {
padding: 24px;
border-bottom: 1px solid #e9ecef;
}
.emailSubject {
font-size: 24px;
font-weight: 600;
margin-bottom: 16px;
color: #333;
}
.emailMeta {
display: flex;
flex-direction: column;
gap: 8px;
font-size: 14px;
color: #666;
}
.emailMetaRow {
display: flex;
gap: 8px;
}
.emailMetaLabel {
font-weight: 600;
min-width: 60px;
}
.emailBody {
flex: 1;
padding: 24px;
overflow-y: auto;
font-size: 15px;
line-height: 1.6;
}
.emailActions {
display: flex;
gap: 8px;
padding: 16px 24px;
border-top: 1px solid #e9ecef;
background: #fafafa;
}
.emptyState {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
color: #999;
}
.emptyIcon {
font-size: 64px;
margin-bottom: 16px;
opacity: 0.3;
}
.emptyText {
font-size: 18px;
}
`,
];
public render() {
return html`