drishti/src/MailboxList.tsx

40 lines
876 B
TypeScript
Raw Normal View History

import React from "react";
import Stack from "react-bootstrap/Stack";
import { Client, IAccount } from "./types";
type MailboxListProps = { account: IAccount | null; client: Client | null };
type MailboxListState = {};
class MailboxList extends React.Component<MailboxListProps, MailboxListState> {
componentDidMount() {
if (this.props.account == null) return;
if (this.props.client == null) return;
const args = {
accountId: this.props.account.id,
ids: [],
};
this.props.client
.mailbox_get(args)
.then(() => {
console.log("got mailboxen");
})
.catch(() => {
console.error("Failed to get mailboxes");
});
}
render() {
return this.props.account == null ? (
<Stack />
) : (
<Stack>
{this.props.account.mailboxes.map((m) => (
<li key={m.id}>{m.name}</li>
))}
</Stack>
);
}
}
export default MailboxList;