shellphone.app/app/phone-calls/components/phone-calls-list.tsx

25 lines
627 B
TypeScript
Raw Normal View History

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) {
return <div>empty state</div>;
2021-07-31 14:33:18 +00:00
}
return (
<ul className="divide-y">
{phoneCalls.map((phoneCall) => {
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 14:33:18 +00:00
})}
</ul>
);
2021-07-31 14:33:18 +00:00
}