chore: Remove @medusajs/medusa usage + local types from dashboard (#8883)

Closes CC-403
This commit is contained in:
Oli Juhl
2024-08-30 17:37:44 +02:00
committed by GitHub
parent 3da01035f3
commit 4350fe5368
62 changed files with 296 additions and 618 deletions

View File

@@ -1,4 +1,3 @@
import { Country } from "@medusajs/medusa"
import { Heading, Input, Select, clx } from "@medusajs/ui"
import { useTranslation } from "react-i18next"
import { z } from "zod"
@@ -7,12 +6,13 @@ import { Control } from "react-hook-form"
import { AddressSchema } from "../../../lib/schemas"
import { Form } from "../../common/form"
import { CountrySelect } from "../../inputs/country-select"
import { HttpTypes } from "@medusajs/types"
type AddressFieldValues = z.infer<typeof AddressSchema>
type AddressFormProps = {
control: Control<AddressFieldValues>
countries?: Country[]
countries?: HttpTypes.AdminRegionCountry[]
layout: "grid" | "stack"
}

View File

@@ -1,4 +1,3 @@
import { Customer, DraftOrder, Order } from "@medusajs/medusa"
import { Select, Text, clx } from "@medusajs/ui"
import { useInfiniteQuery } from "@tanstack/react-query"
import { format } from "date-fns"
@@ -19,6 +18,7 @@ import { TransferOwnershipSchema } from "../../../lib/schemas"
import { Form } from "../../common/form"
import { Skeleton } from "../../common/skeleton"
import { Combobox } from "../../inputs/combobox"
import { HttpTypes } from "@medusajs/types"
type TransferOwnerShipFieldValues = z.infer<typeof TransferOwnershipSchema>
@@ -26,14 +26,16 @@ type TransferOwnerShipFormProps = {
/**
* The Order or DraftOrder to transfer ownership of.
*/
order: Order | DraftOrder
order: HttpTypes.AdminOrder
/**
* React Hook Form control object.
*/
control: Control<TransferOwnerShipFieldValues>
}
const isOrder = (order: Order | DraftOrder): order is Order => {
const isOrder = (
order: HttpTypes.AdminOrder
): order is HttpTypes.AdminOrder => {
return "customer" in order
}
@@ -90,7 +92,7 @@ export const TransferOwnerShipForm = ({
},
})
const createLabel = (customer?: Customer) => {
const createLabel = (customer?: HttpTypes.AdminCustomer) => {
if (!customer) {
return ""
}
@@ -187,7 +189,7 @@ export const TransferOwnerShipForm = ({
)
}
const OrderDetailsTable = ({ order }: { order: Order }) => {
const OrderDetailsTable = ({ order }: { order: HttpTypes.AdminOrder }) => {
const { t } = useTranslation()
const { label: fulfillmentLabel } = getOrderFulfillmentStatus(
@@ -208,7 +210,8 @@ const OrderDetailsTable = ({ order }: { order: Order }) => {
)
}
const DraftOrderDetailsTable = ({ draft }: { draft: DraftOrder }) => {
// TODO: Create type for Draft Order when we have it
const DraftOrderDetailsTable = ({ draft }: { draft: HttpTypes.AdminOrder }) => {
const { t } = useTranslation()
return (
@@ -219,10 +222,12 @@ const DraftOrderDetailsTable = ({ draft }: { draft: DraftOrder }) => {
label={t("fields.status")}
value={t(`draftOrders.status.${draft.status}`)}
/>
<TotalRow
{/* TODO: This will likely change. We don't use carts for draft orders any longer. */}
{/* <TotalRow
total={draft.cart.total || 0}
currencyCode={draft.cart.region.currency_code}
/>
/> */}
</Table>
)
}