42 lines
887 B
TypeScript
42 lines
887 B
TypeScript
|
import React from "react";
|
||
|
import Stack from "react-bootstrap/Stack";
|
||
|
|
||
|
import Client from "./client/Client";
|
||
|
import { IAccount, IMailbox } from "./client/types";
|
||
|
|
||
|
type EmailListProps = {
|
||
|
account: IAccount | null;
|
||
|
client: Client | null;
|
||
|
mailbox: IMailbox | null;
|
||
|
};
|
||
|
|
||
|
type EmailListState = {};
|
||
|
|
||
|
class EmailList extends React.Component<EmailListProps, EmailListState> {
|
||
|
componentDidUpdate() {
|
||
|
if (this.props.account == null) return;
|
||
|
if (this.props.client == null) return;
|
||
|
if (this.props.mailbox == null) return;
|
||
|
this.props.client.emailList(
|
||
|
this.props.account.id,
|
||
|
this.props.mailbox.id,
|
||
|
[],
|
||
|
);
|
||
|
}
|
||
|
|
||
|
render() {
|
||
|
return !(this.props.account && this.props.mailbox) ? (
|
||
|
<Stack />
|
||
|
) : (
|
||
|
<Stack>
|
||
|
{this.props.mailbox.emails.map((m) => (
|
||
|
<div className="p-2" key={m.id}>
|
||
|
{m.subject}
|
||
|
</div>
|
||
|
))}
|
||
|
</Stack>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
export default EmailList;
|