feat(adshboard,types,medusa): enable adding notes/return reason to inbound claims (#8488)

* wip: setup UI

* wip: rendering modal, adding claim items, create checks

* fix: make form work after merge

* fix: continuation of claim edit

* chore: ability to add and remove items to claim inbound

* chore: minor fixes

* chore: add toast messages on actions

* feat(adshboard,types,medusa): enable adding notes/return reason to inbound items

* chore: fix types in a bunch of places

* chore: add conditional for actions

* Update packages/admin-next/dashboard/src/routes/orders/order-create-claim/components/claim-create-form/claim-create-form.tsx

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

---------

Co-authored-by: fPolic <mainacc.polic@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Riqwan Thamir
2024-08-07 19:32:07 +02:00
committed by GitHub
co-authored by Oli Juhl fPolic
parent c017be2a54
commit d50161fa32
13 changed files with 404 additions and 99 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ export class Order {
}
async retrievePreview(id: string, headers?: ClientHeaders) {
return await this.client.fetch<{ order: HttpTypes.AdminOrder }>(
return await this.client.fetch<HttpTypes.AdminOrderPreviewResponse>(
`/admin/orders/${id}/preview`,
{
headers,
@@ -17,9 +17,9 @@ interface AdminClaimAddItems {
interface AdminClaimUpdateItem {
quantity?: number
reason_id?: ClaimReason
reason_id?: string | null
description?: string
internal_note?: string
internal_note?: string | null
}
interface AdminClaimAddShippingMethod {
@@ -31,7 +31,7 @@ interface AdminClaimAddShippingMethod {
}
interface AdminClaimUpdateShippingMethod {
custom_price?: number
custom_price?: number | null
internal_note?: string
metadata?: Record<string, unknown> | null
}
@@ -1,5 +1,6 @@
import { GeoZoneType } from "../../../fulfillment"
import { AdminShippingOption } from "../../shipping-option"
import { AdminStockLocation } from "../../stock-locations"
export interface AdminGeoZone {
id: string
@@ -17,6 +18,7 @@ export interface AdminServiceZone {
id: string
name: string
fulfillment_set_id: string
fulfillment_set: AdminFulfillmentSet
geo_zones: AdminGeoZone[]
shipping_options: AdminShippingOption[]
created_at: string
@@ -28,6 +30,7 @@ export interface AdminFulfillmentSet {
id: string
name: string
type: string
location: AdminStockLocation
service_zones: AdminServiceZone[]
created_at: string
updated_at: string
@@ -2,6 +2,8 @@ import { AdminPaymentCollection } from "../payment/admin"
import {
BaseOrder,
BaseOrderAddress,
BaseOrderChange,
BaseOrderChangeAction,
BaseOrderFilters,
BaseOrderLineItem,
BaseOrderShippingMethod,
@@ -45,3 +47,19 @@ export interface AdminCreateOrderShipment {
export interface AdminCancelOrderFulfillment {
no_notification?: boolean
}
// Order Preview
export interface AdminOrderPreview
extends Omit<AdminOrder, "items" | "shipping_methods"> {
return_requested_total: number
order_change: BaseOrderChange
items: (BaseOrderLineItem & { actions?: BaseOrderChangeAction[] })[]
shipping_methods: (BaseOrderShippingMethod & {
actions?: BaseOrderChangeAction[]
})[]
}
export interface AdminOrderPreviewResponse {
order: AdminOrderPreview
}
+223 -1
View File
@@ -1,5 +1,6 @@
import { BaseFilterable, OperatorMap } from "../../dal"
import { BigNumberValue } from "../../totals"
import { BaseClaim } from "../claim/common"
import { BasePaymentCollection } from "../payment/common"
import { BaseProduct, BaseProductVariant } from "../product/common"
@@ -116,7 +117,7 @@ export interface BaseOrderLineItem {
title: string
subtitle: string | null
thumbnail: string | null
variant?: BaseProductVariant
variant?: BaseProductVariant | null
variant_id: string | null
product?: BaseProduct
product_id: string | null
@@ -305,3 +306,224 @@ export interface BaseOrderFilters extends BaseFilterable<BaseOrderFilters> {
id?: string[] | string | OperatorMap<string | string[]>
status?: string[] | string | OperatorMap<string | string[]>
}
export interface BaseOrderChange {
/**
* The ID of the order change
*/
id: string
/**
* The version of the order change
*/
version: number
/**
* The type of the order change
*/
change_type?: "return" | "exchange" | "claim" | "edit"
/**
* The ID of the associated order
*/
order_id: string
/**
* The ID of the associated return order
*/
return_id: string
/**
* The ID of the associated exchange order
*/
exchange_id: string
/**
* The ID of the associated claim order
*/
claim_id: string
/**
* The associated order
*
* @expandable
*/
order: BaseOrder
/**
* The associated return order
*
* @expandable
*/
return_order: any
/**
* The associated exchange order
*
* @expandable
*/
exchange: any
/**
* The associated claim order
*
* @expandable
*/
claim: BaseClaim
/**
* The actions of the order change
*
* @expandable
*/
actions: BaseOrderChangeAction[]
/**
* The status of the order change
*/
status: string
/**
* The requested by of the order change
*/
requested_by: string | null
/**
* When the order change was requested
*/
requested_at: Date | string | null
/**
* The confirmed by of the order change
*/
confirmed_by: string | null
/**
* When the order change was confirmed
*/
confirmed_at: Date | string | null
/**
* The declined by of the order change
*/
declined_by: string | null
/**
* The declined reason of the order change
*/
declined_reason: string | null
/**
* The metadata of the order change
*/
metadata: Record<string, unknown> | null
/**
* When the order change was declined
*/
declined_at: Date | string | null
/**
* The canceled by of the order change
*/
canceled_by: string | null
/**
* When the order change was canceled
*/
canceled_at: Date | string | null
/**
* When the order change was created
*/
created_at: Date | string
/**
* When the order change was updated
*/
updated_at: Date | string
}
/**
* The order change action details.
*/
export interface BaseOrderChangeAction {
/**
* The ID of the order change action
*/
id: string
/**
* The ID of the associated order change
*/
order_change_id: string | null
/**
* The associated order change
*
* @expandable
*/
order_change: BaseOrderChange | null
/**
* The ID of the associated order
*/
order_id: string | null
/**
* The ID of the associated return.
*/
return_id: string | null
/**
* The ID of the associated claim.
*/
claim_id: string | null
/**
* The ID of the associated exchange.
*/
exchange_id: string | null
/**
* The associated order
*
* @expandable
*/
order: BaseOrder | null
/**
* The reference of the order change action
*/
reference: string
/**
* The ID of the reference
*/
reference_id: string
/**
* The action of the order change action
*/
action: string
/**
* The details of the order change action
*/
details: Record<string, unknown> | null
/**
* The internal note of the order change action
*/
internal_note: string | null
/**
* When the order change action was created
*/
created_at: Date | string
/**
* When the order change action was updated
*/
updated_at: Date | string
}
+2 -2
View File
@@ -56,8 +56,8 @@ export interface AdminAddReturnItems {
export interface AdminUpdateReturnItems {
quantity?: number
internal_note?: string
reason_id?: string
internal_note?: string | null
reason_id?: string | null
}
export interface AdminAddReturnShipping {
@@ -86,7 +86,7 @@ export interface UpdateClaimItemWorkflowInput {
action_id: string
data: {
quantity?: BigNumberInput
reason_id?: ClaimReason
reason_id?: string | null
internal_note?: string | null
}
}