|
1
|
import { Tooltip } from "@medusajs/ui" |
|
2
|
import { useTranslation } from "react-i18next" |
|
3
|
import { PlaceholderCell } from "../placeholder-cell" |
|
4
|
import { useDate } from "../../../../../hooks/use-date" |
|
5
|
|
|
6
|
type DateCellProps = { |
|
7
|
date?: Date | string | null |
|
8
|
} |
|
9
|
|
|
10
|
export const DateCell = ({ date }: DateCellProps) => { |
|
11
|
const { getFullDate } = useDate() |
|
12
|
|
|
13
|
if (!date) { |
|
14
|
return <PlaceholderCell /> |
|
15
|
} |
|
16
|
|
|
17
|
return ( |
|
18
|
<div className="flex h-full w-full items-center overflow-hidden"> |
|
19
|
<Tooltip |
|
20
|
className="z-10" |
|
21
|
content={ |
|
22
|
<span className="text-pretty">{`${getFullDate({ |
|
23
|
date, |
|
24
|
includeTime: true, |
|
25
|
})}`}</span> |
|
26
|
} |
|
27
|
> |
|
28
|
<span className="truncate"> |
|
29
|
{getFullDate({ date, includeTime: false })} |
|
30
|
</span> |
|
31
|
</Tooltip> |
|
32
|
</div> |
|
33
|
) |
|
34
|
} |
|
35
|
|
|
36
|
export const DateHeader = () => { |
|
37
|
const { t } = useTranslation() |
|
38
|
|
|
39
|
return ( |
|
40
|
<div className="flex h-full w-full items-center"> |
|
41
|
<span className="truncate">{t("fields.date")}</span> |
|
42
|
</div> |
|
43
|
) |
|
44
|
} |