-
+
{t("orders.returns.inboundShipping")}
+
{t("orders.returns.inboundShippingHint")}
@@ -595,23 +634,10 @@ export const ClaimCreateForm = ({
val && onShippingOptionChange(val)
}}
{...field}
- options={(shipping_options ?? [])
- .filter(
- (so) =>
- (locationId
- ? so.service_zone.fulfillment_set!
- .location.id === locationId
- : true) &&
- !!so.rules.find(
- (r) =>
- r.attribute === "is_return" &&
- r.value === "true"
- )
- )
- .map((so) => ({
- label: so.name,
- value: so.id,
- }))}
+ options={inboundShippingOptions.map((so) => ({
+ label: so.name,
+ value: so.id,
+ }))}
disabled={!locationId}
/>
diff --git a/packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-outbound-section.tsx b/packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-outbound-section.tsx
index da1da35c3cea1..052f47027def1 100644
--- a/packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-outbound-section.tsx
+++ b/packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-outbound-section.tsx
@@ -24,7 +24,6 @@ import {
useUpdateClaimOutboundItems,
} from "../../../../../hooks/api/claims"
import { useShippingOptions } from "../../../../../hooks/api/shipping-options"
-import { useStockLocations } from "../../../../../hooks/api/stock-locations"
import { sdk } from "../../../../../lib/client"
import { AddClaimOutboundItemsTable } from "../add-claim-outbound-items-table"
import { ClaimOutboundItem } from "./claim-outbound-item"
@@ -57,13 +56,9 @@ export const ClaimOutboundSection = ({
/**
* HOOKS
*/
- const { stock_locations = [] } = useStockLocations({ limit: 999 })
const { shipping_options = [] } = useShippingOptions({
limit: 999,
fields: "*prices,+service_zone.fulfillment_set.location.id",
- /**
- * TODO: this should accept filter for location_id
- */
})
const { mutateAsync: addOutboundShipping } = useAddClaimOutboundShipping(
@@ -154,17 +149,6 @@ export const ClaimOutboundSection = ({
})
}, [previewOutboundItems])
- useEffect(() => {
- // TODO: Pick the shipping methods from actions where return_id is null for outbound
- const method = preview.shipping_methods.find(
- (s) => !!s.actions?.find((a) => a.action === "SHIPPING_ADD")
- )
-
- if (method) {
- form.setValue("outbound_option_id", method.shipping_option_id)
- }
- }, [preview.shipping_methods])
-
const locationId = form.watch("location_id")
const showOutboundItemsPlaceholder = !outboundItems.length
@@ -201,17 +185,16 @@ export const ClaimOutboundSection = ({
setIsOpen("outbound-items", false)
}
- // TODO: implement outbound shipping
- const { mutateAsync: updateClaimRequest, isPending: isUpdating } = {} // useUpdateClaim(claim.id, order.id)
- const onLocationChange = async (selectedLocationId?: string | null) => {
- await updateClaimRequest({ location_id: selectedLocationId })
- }
-
const onShippingOptionChange = async (selectedOptionId: string) => {
- const promises = preview.shipping_methods
- .map((s) => s.actions?.find((a) => a.action === "SHIPPING_ADD")?.id)
+ const outboundShippingMethods = preview.shipping_methods.filter((s) => {
+ const action = s.actions?.find((a) => a.action === "SHIPPING_ADD")
+
+ return action && !!!action?.return?.id
+ })
+
+ const promises = outboundShippingMethods
.filter(Boolean)
- .map(deleteOutboundShipping)
+ .map((action) => deleteOutboundShipping(action.id))
await Promise.all(promises)
@@ -270,7 +253,7 @@ export const ClaimOutboundSection = ({
).variants
variants.forEach((variant) => {
- ret[variant.id] = variant.inventory[0]?.location_levels || []
+ ret[variant.id] = variant.inventory?.[0]?.location_levels || []
})
return ret
@@ -403,24 +386,11 @@ export const ClaimOutboundSection = ({
val && onShippingOptionChange(val)
}}
{...field}
- options={(shipping_options ?? [])
- .filter(
- (so) =>
- (locationId
- ? so.service_zone.fulfillment_set!.location
- .id === locationId
- : true) &&
- !!so.rules.find(
- (r) =>
- r.attribute === "is_return" &&
- r.value === "true"
- )
- )
- .map((so) => ({
- label: so.name,
- value: so.id,
- }))}
- disabled={!locationId}
+ options={shipping_options.map((so) => ({
+ label: so.name,
+ value: so.id,
+ }))}
+ disabled={!shipping_options.length}
/>
diff --git a/packages/core/types/src/http/return/admin.ts b/packages/core/types/src/http/return/admin.ts
index 7ea64f9fed672..c766025e6c8f5 100644
--- a/packages/core/types/src/http/return/admin.ts
+++ b/packages/core/types/src/http/return/admin.ts
@@ -17,6 +17,7 @@ export interface AdminReturn {
order_id: string
status?: string
exchange_id?: string
+ location_id?: string
claim_id?: string
order_version: number
display_id: number
@@ -79,7 +80,7 @@ export interface AdminConfirmReturnRequest {
}
export interface AdminUpdateReturnRequest {
- location_id?: string
+ location_id?: string | null
no_notification?: boolean
metadata?: Record | null
}
diff --git a/packages/core/types/src/http/shipping-option/admin/queries.ts b/packages/core/types/src/http/shipping-option/admin/queries.ts
index ccd74fc1e6741..10f0648ed39d0 100644
--- a/packages/core/types/src/http/shipping-option/admin/queries.ts
+++ b/packages/core/types/src/http/shipping-option/admin/queries.ts
@@ -5,6 +5,7 @@ export interface AdminShippingOptionListParams extends FindParams {
id?: string | string[]
q?: string
service_zone_id?: string
+ stock_location_id?: string | string[]
shipping_profile_id?: string
provider_id?: string
shipping_option_type_id?: string