feat(dashboard): order edit UI (#8700)

**What**
- order edit create flow
- active order edit panel

**Note**
- basic implementation of the flow, edge cases from the design such as fulfilled quantities validation will be added in a followup
This commit is contained in:
Frane Polić
2024-08-23 06:42:06 +00:00
committed by GitHub
parent 02c6574e01
commit 49353f8c3c
29 changed files with 1470 additions and 16 deletions
+3
View File
@@ -33,6 +33,7 @@ import { TaxRate } from "./tax-rate"
import { TaxRegion } from "./tax-region"
import { Upload } from "./upload"
import { User } from "./user"
import { OrderEdit } from "./order-edit"
export class Admin {
public invite: Invite
@@ -56,6 +57,7 @@ export class Admin {
public inventoryItem: InventoryItem
public notification: Notification
public order: Order
public orderEdit: OrderEdit
public return: Return
public claim: Claim
public exchange: Exchange
@@ -92,6 +94,7 @@ export class Admin {
this.inventoryItem = new InventoryItem(client)
this.notification = new Notification(client)
this.order = new Order(client)
this.orderEdit = new OrderEdit(client)
this.return = new Return(client)
this.claim = new Claim(client)
this.taxRate = new TaxRate(client)
@@ -0,0 +1,140 @@
import { HttpTypes } from "@medusajs/types"
import { Client } from "../client"
import { ClientHeaders } from "../types"
export class OrderEdit {
private client: Client
constructor(client: Client) {
this.client = client
}
async initiateRequest(
body: HttpTypes.AdminInitiateOrderEditRequest,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderEditPreviewResponse>(
`/admin/order-edits`,
{
method: "POST",
headers,
body,
query,
}
)
}
async request(
id: string,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderEditPreviewResponse>(
`/admin/order-edits/${id}/request`,
{
method: "POST",
headers,
query,
}
)
}
async confirm(
id: string,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderEditPreviewResponse>(
`/admin/order-edits/${id}/confirm`,
{
method: "POST",
headers,
query,
}
)
}
async cancelRequest(
id: string,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderEditDeleteResponse>(
`/admin/order-edits/${id}`,
{
method: "DELETE",
headers,
query,
}
)
}
async addItems(
id: string,
body: HttpTypes.AdminAddOrderEditItems,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderEditPreviewResponse>(
`/admin/order-edits/${id}/items`,
{
method: "POST",
headers,
body,
query,
}
)
}
async updateOriginalItem(
id: string,
itemId: string,
body: HttpTypes.AdminUpdateOrderEditItem,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderEditPreviewResponse>(
`/admin/order-edits/${id}/items/item/${itemId}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async updateAddedItem(
id: string,
actionId: string,
body: HttpTypes.AdminUpdateOrderEditItem,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderEditPreviewResponse>(
`/admin/order-edits/${id}/items/${actionId}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async removeAddedItem(
id: string,
actionId: string,
query?: HttpTypes.SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderEditPreviewResponse>(
`/admin/order-edits/${id}/items/${actionId}`,
{
method: "DELETE",
headers,
query,
}
)
}
}
+5 -1
View File
@@ -23,7 +23,11 @@ export class Order {
)
}
async retrievePreview(id: string, headers?: ClientHeaders) {
async retrievePreview(
id: string,
query?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderPreviewResponse>(
`/admin/orders/${id}/preview`,
{