chore(order): aggregate statuses (#7497)
This commit is contained in:
committed by
GitHub
parent
8e66e10995
commit
bbca54efa7
+18
-15
@@ -1,27 +1,27 @@
|
||||
import React, { useEffect, useState } from "react"
|
||||
import * as zod from "zod"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import * as zod from "zod"
|
||||
|
||||
import { useForm, useWatch } from "react-hook-form"
|
||||
import { AdminOrder } from "@medusajs/types"
|
||||
import { Alert, Button, Select, toast } from "@medusajs/ui"
|
||||
import { OrderDTO } from "@medusajs/types"
|
||||
import { useForm, useWatch } from "react-hook-form"
|
||||
|
||||
import { Form } from "../../../../../components/common/form"
|
||||
import {
|
||||
RouteFocusModal,
|
||||
useRouteModal,
|
||||
} from "../../../../../components/route-modal"
|
||||
import { CreateFulfillmentSchema } from "./constants"
|
||||
import { Form } from "../../../../../components/common/form"
|
||||
import { OrderCreateFulfillmentItem } from "./order-create-fulfillment-item"
|
||||
import { getFulfillableQuantity } from "../../../../../lib/order-item"
|
||||
import { useCreateFulfillment } from "../../../../../hooks/api/fulfillment"
|
||||
import { useStockLocations } from "../../../../../hooks/api/stock-locations"
|
||||
import { useFulfillmentProviders } from "../../../../../hooks/api/fulfillment-providers"
|
||||
import { useStockLocations } from "../../../../../hooks/api/stock-locations"
|
||||
import { cleanNonValues, pick } from "../../../../../lib/common"
|
||||
import { getFulfillableQuantity } from "../../../../../lib/order-item"
|
||||
import { CreateFulfillmentSchema } from "./constants"
|
||||
import { OrderCreateFulfillmentItem } from "./order-create-fulfillment-item"
|
||||
|
||||
type OrderCreateFulfillmentFormProps = {
|
||||
order: OrderDTO
|
||||
order: AdminOrder
|
||||
}
|
||||
|
||||
export function OrderCreateFulfillmentForm({
|
||||
@@ -43,10 +43,13 @@ export function OrderCreateFulfillmentForm({
|
||||
|
||||
const form = useForm<zod.infer<typeof CreateFulfillmentSchema>>({
|
||||
defaultValues: {
|
||||
quantity: fulfillableItems.reduce((acc, item) => {
|
||||
acc[item.id] = getFulfillableQuantity(item)
|
||||
return acc
|
||||
}, {} as Record<string, number>),
|
||||
quantity: fulfillableItems.reduce(
|
||||
(acc, item) => {
|
||||
acc[item.id] = getFulfillableQuantity(item)
|
||||
return acc
|
||||
},
|
||||
{} as Record<string, number>
|
||||
),
|
||||
// send_notification: !order.no_notification,
|
||||
},
|
||||
resolver: zodResolver(CreateFulfillmentSchema),
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
import { AdminOrder } from "@medusajs/types"
|
||||
import { Container, Heading } from "@medusajs/ui"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { OrderNoteForm } from "./order-note-form"
|
||||
import { OrderTimeline } from "./order-timeline"
|
||||
import { OrderDTO } from "@medusajs/types"
|
||||
|
||||
type OrderActivityProps = {
|
||||
order: OrderDTO
|
||||
order: AdminOrder
|
||||
}
|
||||
|
||||
export const OrderActivitySection = ({ order }: OrderActivityProps) => {
|
||||
|
||||
+2
-2
@@ -5,12 +5,12 @@ import { useRef } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { z } from "zod"
|
||||
|
||||
import { AdminOrder } from "@medusajs/types"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Form } from "../../../../../components/common/form"
|
||||
import { OrderDTO } from "@medusajs/types"
|
||||
|
||||
type OrderNoteFormProps = {
|
||||
order: OrderDTO
|
||||
order: AdminOrder
|
||||
}
|
||||
|
||||
const OrderNoteSchema = z.object({
|
||||
|
||||
+2
-3
@@ -6,14 +6,13 @@ import { PropsWithChildren, ReactNode, useMemo, useState } from "react"
|
||||
import { Link } from "react-router-dom"
|
||||
|
||||
import { XMarkMini } from "@medusajs/icons"
|
||||
import { AdminOrder } from "@medusajs/types"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Skeleton } from "../../../../../components/common/skeleton"
|
||||
import { useDate } from "../../../../../hooks/use-date"
|
||||
import { getStylizedAmount } from "../../../../../lib/money-amount-helpers"
|
||||
import { OrderDTO } from "@medusajs/types"
|
||||
|
||||
type OrderTimelineProps = {
|
||||
order: OrderDTO
|
||||
order: AdminOrder
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-8
@@ -1,7 +1,7 @@
|
||||
import { Buildings, XCircle } from "@medusajs/icons"
|
||||
import {
|
||||
AdminOrder,
|
||||
FulfillmentDTO,
|
||||
OrderDTO,
|
||||
OrderLineItemDTO,
|
||||
ProductVariantDTO,
|
||||
} from "@medusajs/types"
|
||||
@@ -27,7 +27,7 @@ import { formatProvider } from "../../../../../lib/format-provider"
|
||||
import { getLocaleAmount } from "../../../../../lib/money-amount-helpers"
|
||||
|
||||
type OrderFulfillmentSectionProps = {
|
||||
order: OrderDTO & { fulfillments: FulfillmentDTO[] }
|
||||
order: AdminOrder
|
||||
}
|
||||
|
||||
export const OrderFulfillmentSection = ({
|
||||
@@ -103,11 +103,7 @@ const UnfulfilledItem = ({
|
||||
)
|
||||
}
|
||||
|
||||
const UnfulfilledItemBreakdown = ({
|
||||
order,
|
||||
}: {
|
||||
order: OrderDTO & { fulfillments: FulfillmentDTO[] }
|
||||
}) => {
|
||||
const UnfulfilledItemBreakdown = ({ order }: { order: AdminOrder }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
// Create an array of order items that haven't been fulfilled or at least not fully fulfilled
|
||||
@@ -161,7 +157,7 @@ const Fulfillment = ({
|
||||
index,
|
||||
}: {
|
||||
fulfillment: FulfillmentDTO
|
||||
order: OrderDTO
|
||||
order: AdminOrder
|
||||
index: number
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
+10
-7
@@ -1,5 +1,8 @@
|
||||
import { Buildings, PencilSquare, ArrowUturnLeft } from "@medusajs/icons"
|
||||
import { OrderDTO, OrderLineItemDTO, ReservationItemDTO } from "@medusajs/types"
|
||||
import {
|
||||
AdminOrder,
|
||||
OrderLineItemDTO,
|
||||
ReservationItemDTO,
|
||||
} from "@medusajs/types"
|
||||
import { Container, Copy, Heading, StatusBadge, Text } from "@medusajs/ui"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
@@ -11,7 +14,7 @@ import {
|
||||
} from "../../../../../lib/money-amount-helpers"
|
||||
|
||||
type OrderSummarySectionProps = {
|
||||
order: OrderDTO
|
||||
order: AdminOrder
|
||||
}
|
||||
|
||||
export const OrderSummarySection = ({ order }: OrderSummarySectionProps) => {
|
||||
@@ -25,7 +28,7 @@ export const OrderSummarySection = ({ order }: OrderSummarySectionProps) => {
|
||||
)
|
||||
}
|
||||
|
||||
const Header = ({ order }: { order: OrderDTO }) => {
|
||||
const Header = ({ order }: { order: AdminOrder }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
@@ -129,7 +132,7 @@ const Item = ({
|
||||
)
|
||||
}
|
||||
|
||||
const ItemBreakdown = ({ order }: { order: OrderDTO }) => {
|
||||
const ItemBreakdown = ({ order }: { order: AdminOrder }) => {
|
||||
// const { reservations, isError, error } = useAdminReservations({
|
||||
// line_item_id: order.items.map((i) => i.id),
|
||||
// })
|
||||
@@ -184,7 +187,7 @@ const Cost = ({
|
||||
</div>
|
||||
)
|
||||
|
||||
const CostBreakdown = ({ order }: { order: OrderDTO }) => {
|
||||
const CostBreakdown = ({ order }: { order: AdminOrder }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
@@ -230,7 +233,7 @@ const CostBreakdown = ({ order }: { order: OrderDTO }) => {
|
||||
)
|
||||
}
|
||||
|
||||
const Total = ({ order }: { order: OrderDTO }) => {
|
||||
const Total = ({ order }: { order: AdminOrder }) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user