2021-07-31 15:57:43 +00:00
|
|
|
import { Direction } from "../../../db";
|
|
|
|
import usePhoneCalls from "../hooks/use-phone-calls";
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
export default function PhoneCallsList() {
|
2021-08-05 17:07:15 +00:00
|
|
|
const phoneCalls = usePhoneCalls()[0];
|
2021-07-31 14:33:18 +00:00
|
|
|
|
|
|
|
if (phoneCalls.length === 0) {
|
2021-07-31 15:57:43 +00:00
|
|
|
return <div>empty state</div>;
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ul className="divide-y">
|
|
|
|
{phoneCalls.map((phoneCall) => {
|
2021-07-31 15:57:43 +00:00
|
|
|
const recipient = Direction.Outbound ? phoneCall.to : phoneCall.from;
|
2021-07-31 14:33:18 +00:00
|
|
|
return (
|
2021-08-05 17:07:15 +00:00
|
|
|
<li key={phoneCall.id} className="flex flex-row justify-between py-2">
|
2021-07-31 14:33:18 +00:00
|
|
|
<div>{recipient}</div>
|
|
|
|
<div>{new Date(phoneCall.createdAt).toLocaleString("fr-FR")}</div>
|
|
|
|
</li>
|
2021-07-31 15:57:43 +00:00
|
|
|
);
|
2021-07-31 14:33:18 +00:00
|
|
|
})}
|
|
|
|
</ul>
|
2021-07-31 15:57:43 +00:00
|
|
|
);
|
2021-07-31 14:33:18 +00:00
|
|
|
}
|