sur Intl.NumberFormat to format currency in billing history

This commit is contained in:
m5r 2021-10-03 18:18:34 +02:00
parent dd9d15d042
commit 22e2b21b14

View File

@ -46,33 +46,35 @@ export default function BillingHistory() {
</tr> </tr>
</thead> </thead>
<tbody className="bg-white divide-y divide-gray-200"> <tbody className="bg-white divide-y divide-gray-200">
{typeof payments !== "undefined" {payments.map((payment) => (
? payments.map((payment) => ( <tr key={payment.id}>
<tr key={payment.id}> <td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"> <time>{new Date(payment.payout_date).toDateString()}</time>
<time>{new Date(payment.payout_date).toDateString()}</time> </td>
</td> <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> {Intl.NumberFormat(undefined, {
{payment.amount} {payment.currency} style: "currency",
</td> currency: payment.currency,
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> currencyDisplay: "narrowSymbol",
{payment.is_paid === 1 ? "Paid" : "Upcoming"} }).format(payment.amount)}
</td> </td>
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{typeof payment.receipt_url !== "undefined" ? ( {payment.is_paid === 1 ? "Paid" : "Upcoming"}
<a </td>
href={payment.receipt_url} <td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
target="_blank" {typeof payment.receipt_url !== "undefined" ? (
rel="noopener noreferrer" <a
className="text-primary-600 hover:text-primary-900" href={payment.receipt_url}
> target="_blank"
View receipt rel="noopener noreferrer"
</a> className="text-primary-600 hover:text-primary-900"
) : null} >
</td> View receipt
</tr> </a>
)) ) : null}
: null} </td>
</tr>
))}
</tbody> </tbody>
</table> </table>
</div> </div>