🚸 Format datetimes
This commit is contained in:
1 parent
1bd8fddf73
commit
e240eda1cb
1 file changed
+5
-2
@@ -1,9 +1,12 @@
|
|||||||
import { useQuery } from "@apollo/client";
|
import { useQuery } from "@apollo/client";
|
||||||
|
import { parseISO, format } from "date-fns";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { Order, OrderLine, OrderListDocument, Transaction, TransactionListDocument } from "../../types";
|
import { Order, OrderLine, OrderListDocument, Transaction, TransactionListDocument } from "../../types";
|
||||||
import styles from "./Log.module.css";
|
import styles from "./Log.module.css";
|
||||||
|
|
||||||
|
const formatTime = (isoDateTime: string): string => format(parseISO(isoDateTime), "yyyy-MM-dd HH:mm");
|
||||||
|
|
||||||
export const Log = () => {
|
export const Log = () => {
|
||||||
const { data: ordersData, loading: ordersLoading } = useQuery(OrderListDocument);
|
const { data: ordersData, loading: ordersLoading } = useQuery(OrderListDocument);
|
||||||
const { data: transactionsData, loading: transactionsLoading } = useQuery(TransactionListDocument);
|
const { data: transactionsData, loading: transactionsLoading } = useQuery(TransactionListDocument);
|
||||||
@@ -30,7 +33,7 @@ export const Log = () => {
|
|||||||
<tbody>
|
<tbody>
|
||||||
{orders.map((order: Order) => (
|
{orders.map((order: Order) => (
|
||||||
<tr key={order.id}>
|
<tr key={order.id}>
|
||||||
<td>{order.created}</td>
|
<td>{formatTime(order.created)}</td>
|
||||||
<td>{order.isExternal ? "Ekstern" : `${order.customer?.firstName} ${order.customer?.lastName}`}</td>
|
<td>{order.isExternal ? "Ekstern" : `${order.customer?.firstName} ${order.customer?.lastName}`}</td>
|
||||||
<td>
|
<td>
|
||||||
{(order.orderlines ?? []).map((line: OrderLine) => (
|
{(order.orderlines ?? []).map((line: OrderLine) => (
|
||||||
@@ -58,7 +61,7 @@ export const Log = () => {
|
|||||||
<tbody>
|
<tbody>
|
||||||
{transactions.map((trans: Transaction) => (
|
{transactions.map((trans: Transaction) => (
|
||||||
<tr key={trans.id}>
|
<tr key={trans.id}>
|
||||||
<td>{trans.created}</td>
|
<td>{formatTime(trans.created)}</td>
|
||||||
<td>
|
<td>
|
||||||
{trans.user.firstName} {trans.user.lastName}
|
{trans.user.firstName} {trans.user.lastName}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in new issue
Block a user