feat(dashboard): Draft orders create (#6680)

**What**
- Adds Create draft order form
- Updates draft order details page to also display "custom" items.

**Note**
- Currently, the form is missing a way to input a discount code. Need to rethink this a bit, as the we can't implement the design in Figma.
- The current design is missing a way to select from a customers existing shipping addresses, we should add that to keep the features we have today.
- This PR uses `useInfiniteQuery` which does not work on our staging (due to duplicate dependencies as a result of building straight from the monorepo), so you will need to test locally.
This commit is contained in:
Kasper Fabricius Kristensen
2024-03-25 17:18:24 +00:00
committed by GitHub
parent 20132d7cea
commit 26531c5a38
54 changed files with 3414 additions and 536 deletions
@@ -9,7 +9,10 @@ import { Request, Response } from "express"
import { Transform, Type } from "class-transformer"
import { ProductVariantService } from "../../../../services"
import { DateComparisonOperator } from "../../../../types/common"
import {
DateComparisonOperator,
NumericalComparisonOperator,
} from "../../../../types/common"
import { IsType } from "../../../../utils"
import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean"
@@ -32,6 +35,28 @@ import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean"
* - (query) manage_inventory {boolean} Filter product variants by whether their inventory is managed or not.
* - (query) allow_backorder {boolean} Filter product variants by whether they are allowed to be backordered or not.
* - in: query
* name: inventory_quantity
* description: Filter by available inventory quantity
* schema:
* oneOf:
* - type: number
* description: a specific number to filter by.
* - type: object
* description: filter using less and greater than comparisons.
* properties:
* lt:
* type: number
* description: filter by inventory quantity less than this number
* gt:
* type: number
* description: filter by inventory quantity greater than this number
* lte:
* type: number
* description: filter by inventory quantity less than or equal to this number
* gte:
* type: number
* description: filter by inventory quantity greater than or equal to this number
* - in: query
* name: created_at
* description: Filter by a creation date range.
* schema:
@@ -189,6 +214,13 @@ export class AdminGetProductsVariantsParams {
@IsOptional()
order?: string
/**
* Number filters to apply on product variants' `inventory_quantity` field.
*/
@IsOptional()
@IsType([Number, NumericalComparisonOperator])
inventory_quantity?: number | NumericalComparisonOperator
/**
* Filter product variants by whether their inventory is managed or not.
*/
@@ -1,3 +1,4 @@
import { IsBoolean, IsInt, IsOptional, IsString } from "class-validator"
import {
CartService,
PricingService,
@@ -5,16 +6,16 @@ import {
RegionService,
SalesChannelService,
} from "../../../../services"
import { IsInt, IsOptional, IsString } from "class-validator"
import { AdminPriceSelectionParams } from "../../../../types/price-selection"
import { IInventoryService } from "@medusajs/types"
import { IsType } from "../../../../utils/validators/is-type"
import { NumericalComparisonOperator } from "../../../../types/common"
import { PricedVariant } from "../../../../types/pricing"
import ProductVariantService from "../../../../services/product-variant"
import { Type } from "class-transformer"
import { Transform, Type } from "class-transformer"
import { omit } from "lodash"
import ProductVariantService from "../../../../services/product-variant"
import { NumericalComparisonOperator } from "../../../../types/common"
import { AdminPriceSelectionParams } from "../../../../types/price-selection"
import { PricedVariant } from "../../../../types/pricing"
import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean"
import { IsType } from "../../../../utils/validators/is-type"
/**
* @oas [get] /admin/variants
@@ -40,6 +41,9 @@ import { omit } from "lodash"
* - (query) fields {string} "Comma-separated fields that should be included in the returned product variants."
* - (query) offset=0 {number} The number of product variants to skip when retrieving the product variants.
* - (query) limit=100 {number} Limit the number of product variants returned.
* - (query) order {string} The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
* - (query) manage_inventory {boolean} Filter product variants by whether their inventory is managed or not.
* - (query) allow_backorder {boolean} Filter product variants by whether they are allowed to be backordered or not.
* - in: query
* name: cart_id
* style: form
@@ -320,4 +324,27 @@ export class AdminGetVariantsParams extends AdminPriceSelectionParams {
@IsOptional()
@IsType([Number, NumericalComparisonOperator])
inventory_quantity?: number | NumericalComparisonOperator
/**
* The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
*/
@IsString()
@IsOptional()
order?: string
/**
* Filter product variants by whether their inventory is managed or not.
*/
@IsBoolean()
@IsOptional()
@Transform(({ value }) => optionalBooleanMapper.get(value.toLowerCase()))
manage_inventory?: boolean
/**
* Filter product variants by whether they are allowed to be backordered or not.
*/
@IsBoolean()
@IsOptional()
@Transform(({ value }) => optionalBooleanMapper.get(value.toLowerCase()))
allow_backorder?: boolean
}