fix(dashboard,types): Fix TS errors (#10457)

**What**
- Fixes TS erros in dashboard project
- Updates incorrect HTTP Invite types
- Fixes incorrectly formatted dates in dashboard
This commit is contained in:
Kasper Fabricius Kristensen
2024-12-08 12:51:13 +01:00
committed by GitHub
parent 55f5ce4690
commit 864f53011b
28 changed files with 120 additions and 252 deletions

View File

@@ -1,6 +1,6 @@
import { Tooltip } from "@medusajs/ui"
import format from "date-fns/format"
import { useTranslation } from "react-i18next"
import { useDate } from "../../../../../hooks/use-date"
import { PlaceholderCell } from "../placeholder-cell"
type DateCellProps = {
@@ -8,28 +8,26 @@ type DateCellProps = {
}
export const CreatedAtCell = ({ date }: DateCellProps) => {
const { getFullDate } = useDate()
if (!date) {
return <PlaceholderCell />
}
const value = new Date(date)
value.setMinutes(value.getMinutes() - value.getTimezoneOffset())
const hour12 = Intl.DateTimeFormat().resolvedOptions().hour12
const timestampFormat = hour12 ? "dd MMM yyyy hh:MM a" : "dd MMM yyyy HH:MM"
return (
<div className="flex h-full w-full items-center overflow-hidden">
<Tooltip
className="z-10"
content={
<span className="text-pretty">{`${format(
value,
timestampFormat
)}`}</span>
<span className="text-pretty">{`${getFullDate({
date,
includeTime: true,
})}`}</span>
}
>
<span className="truncate">{format(value, "dd MMM yyyy")}</span>
<span className="truncate">
{getFullDate({ date, includeTime: true })}
</span>
</Tooltip>
</div>
)

View File

@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next"
export const CustomerCell = ({
customer,
}: {
customer: HttpTypes.AdminCustomer | null
customer?: HttpTypes.AdminCustomer | null
}) => {
if (!customer) {
return <span className="text-ui-fg-muted">-</span>

View File

@@ -1,9 +1,10 @@
import { HttpTypes } from "@medusajs/types"
import { useTranslation } from "react-i18next"
import { getOrderPaymentStatus } from "../../../../../lib/order-helpers"
import { StatusCell } from "../../common/status-cell"
type PaymentStatusCellProps = {
status: PaymentStatus
status: HttpTypes.AdminOrder["payment_status"]
}
export const PaymentStatusCell = ({ status }: PaymentStatusCellProps) => {

View File

@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next"
export const SalesChannelCell = ({
channel,
}: {
channel: HttpTypes.AdminSalesChannel | null
channel?: HttpTypes.AdminSalesChannel | null
}) => {
if (!channel) {
return <span className="text-ui-fg-muted">-</span>

View File

@@ -1,4 +1,4 @@
import { RegionCountryDTO } from "@medusajs/types"
import { HttpTypes } from "@medusajs/types"
import { useTranslation } from "react-i18next"
import { countries as COUNTRIES } from "../../../../../lib/data/countries"
@@ -6,24 +6,24 @@ import { ListSummary } from "../../../../common/list-summary"
import { PlaceholderCell } from "../../common/placeholder-cell"
type CountriesCellProps = {
countries?: RegionCountryDTO[] | null
countries?: HttpTypes.AdminRegionCountry[] | null
}
export const CountriesCell = ({ countries }: CountriesCellProps) => {
const { t } = useTranslation()
if (!countries || countries.length === 0) {
return <PlaceholderCell />
}
const list = countries
.map(
(country) =>
COUNTRIES.find((c) => c.iso_2 === country.iso_2)?.display_name
)
.filter(Boolean) as string[]
return (
<div className="flex size-full items-center overflow-hidden">
<ListSummary
list={countries.map(
(country) =>
COUNTRIES.find((c) => c.iso_2 === country.iso_2)!.display_name
)}
/>
<ListSummary list={list} />
</div>
)
}