()
| 6 | import { getCurrencySymbol, getDateString } from "@/utils"; |
| 7 | |
| 8 | const PaymentHistoryTable = () => { |
| 9 | const [list, setList] = useState<Payment[]>([]); |
| 10 | const { data: session } = useSession(); |
| 11 | |
| 12 | useEffect(() => { |
| 13 | const refreshPaymentList = async (userId: string) => { |
| 14 | let list: Payment[] = []; |
| 15 | try { |
| 16 | const { data } = await axios.get("/api/payment", { |
| 17 | headers: { Authorization: `Bearer ${userId}` }, |
| 18 | }); |
| 19 | list = data; |
| 20 | } catch (error) { |
| 21 | // do nth |
| 22 | } |
| 23 | setList(list); |
| 24 | }; |
| 25 | |
| 26 | if (session?.user.id) { |
| 27 | refreshPaymentList(session.user.id); |
| 28 | } |
| 29 | }, [session]); |
| 30 | |
| 31 | if (list.length === 0) { |
| 32 | return <></>; |
| 33 | } |
| 34 | |
| 35 | return ( |
| 36 | <div className="px-4 sm:px-6 lg:px-8"> |
| 37 | <div className="mt-8 flow-root"> |
| 38 | <div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> |
| 39 | <div className="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8"> |
| 40 | <table className="min-w-full divide-y divide-gray-300"> |
| 41 | <thead> |
| 42 | <tr> |
| 43 | <th scope="col" className="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-0"> |
| 44 | {t("common.date")} |
| 45 | </th> |
| 46 | <th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"> |
| 47 | {t("common.description")} |
| 48 | </th> |
| 49 | <th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"> |
| 50 | {t("common.amount")} |
| 51 | </th> |
| 52 | <th scope="col" className="relative py-3.5 pl-3 pr-4 sm:pr-0"></th> |
| 53 | </tr> |
| 54 | </thead> |
| 55 | <tbody className="divide-y divide-gray-200"> |
| 56 | {list.map((payment) => ( |
| 57 | <tr key={payment.id}> |
| 58 | <td className="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-0"> |
| 59 | {getDateString(payment.createdAt)} |
| 60 | </td> |
| 61 | <td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{payment.description}</td> |
| 62 | <td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> |
| 63 | {getCurrencySymbol(payment.currency.toLocaleUpperCase())} |
| 64 | {payment.amount / 100} |
| 65 | </td> |
nothing calls this directly
no test coverage detected