feat(admin-ui, medusa, medusa-react, medusa-js): Price List UI revamp (#5233)

* progress on cleanup

* rm forceMount

* close modal on succesful submit

* fix: invalidate price list query on useAdminCreatePriceListPrices

* sync translation keys

* add last translations

* sync translation keys

* improve tabbing between cells

* add comment

* fix: remove double variant, set collision boundary on column dropdown

* add widgets

* update lock file

* decrease details info size, and add missing status update function

* sync translation keys

* add snapshots and remove min/max

* add missing filter menu for customer groups table

* add translation keys for filter menu

* rm unused code

* Create tall-apricots-run.md

* Update tall-apricots-run.md

* fix: discard invalid paste values

* add translation keys

* bump snapshots + minor fixes

* rm console.log

* bump snapshots

* bump ui packages, and add missing tax inclusive display in New form

* update lock file

* fix filter menu

* update snapshot

* update ui package and fix sub menu position

---------

Co-authored-by: Sebastian Rindom <skrindom@gmail.com>
Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Kasper Fabricius Kristensen
2023-10-06 08:22:25 -07:00
committed by GitHub
co-authored by Sebastian Rindom Oli Juhl
parent 4ca70a0d0c
commit 0f34e0f381
86 changed files with 9910 additions and 2667 deletions
@@ -0,0 +1,110 @@
import { ArrayNotEmpty, IsString } from "class-validator"
import { Request, Response } from "express"
import { EntityManager } from "typeorm"
import PriceListService from "../../../../services/price-list"
import { validator } from "../../../../utils/validator"
/**
* @oas [delete] /admin/price-lists/{id}/products/prices/batch
* operationId: "DeletePriceListsPriceListProductsPricesBatch"
* summary: "Delete several Product's Prices"
* description: "Delete all the prices associated with the product IDs in a price list."
* x-authenticated: true
* parameters:
* - (path) id=* {string} The ID of the Price List
* x-codegen:
* method: deleteProductPrices
* x-codeSamples:
* - lang: JavaScript
* label: JS Client
* source: |
* import Medusa from "@medusajs/medusa-js"
* const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
* // must be previously logged in or use api token
* medusa.admin.priceLists.deleteProductPrices(priceListId, {
* product_ids: [
* product_id
* ]
* })
* .then(({ ids, object, deleted }) => {
* console.log(ids.length);
* });
* - lang: Shell
* label: cURL
* source: |
* curl -X DELETE '{backend_url}/admin/price-lists/{id}/products/prices/batch' \
* -H 'Authorization: Bearer {api_token}'
* -H 'Content-Type: application/json' \
* --data-raw '{
* "product_ids": [
* "prod_1",
* "prod_2"
* ]
* }'
* security:
* - api_token: []
* - cookie_auth: []
* tags:
* - Price Lists
* responses:
* 200:
* description: OK
* content:
* application/json:
* schema:
* $ref: "#/components/schemas/AdminPriceListDeleteProductPricesRes"
* "400":
* $ref: "#/components/responses/400_error"
* "401":
* $ref: "#/components/responses/unauthorized"
* "404":
* $ref: "#/components/responses/not_found_error"
* "409":
* $ref: "#/components/responses/invalid_state_error"
* "422":
* $ref: "#/components/responses/invalid_request_error"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req: Request, res: Response) => {
const { id } = req.params
const validated = await validator(
AdminDeletePriceListsPriceListProductsPricesBatchReq,
req.body
)
const priceListService: PriceListService =
req.scope.resolve("priceListService")
const manager: EntityManager = req.scope.resolve("manager")
const [deletedPriceIds] = await manager.transaction(
async (transactionManager) => {
return await priceListService
.withTransaction(transactionManager)
.deleteProductPrices(id, validated.product_ids)
}
)
return res.json({
ids: deletedPriceIds,
object: "money-amount",
deleted: true,
})
}
/**
* @schema AdminDeletePriceListsPriceListProductsPricesBatchReq
* type: object
* properties:
* product_ids:
* description: The product IDs of the products to delete the associated prices.
* type: array
* items:
* type: string
*/
export class AdminDeletePriceListsPriceListProductsPricesBatchReq {
@ArrayNotEmpty()
@IsString({ each: true })
product_ids: string[]
}
@@ -1,22 +1,22 @@
import "reflect-metadata"
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
import { PriceList, Product } from "../../../.."
import {
defaultAdminProductFields,
defaultAdminProductRelations,
} from "../products"
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
import middlewares, {
transformBody,
transformQuery,
} from "../../../middlewares"
import {
defaultAdminProductFields,
defaultAdminProductRelations,
} from "../products"
import { AdminGetPriceListPaginationParams } from "./list-price-lists"
import { AdminGetPriceListsPriceListProductsParams } from "./list-price-list-products"
import { AdminPostPriceListsPriceListReq } from "./create-price-list"
import { FlagRouter } from "@medusajs/utils"
import { Router } from "express"
import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/tax-inclusive-pricing"
import { AdminPostPriceListsPriceListReq } from "./create-price-list"
import { AdminGetPriceListsPriceListProductsParams } from "./list-price-list-products"
import { AdminGetPriceListPaginationParams } from "./list-price-lists"
const route = Router()
@@ -52,6 +52,12 @@ export default (app, featureFlagRouter: FlagRouter) => {
"/:id/products/:product_id/prices",
middlewares.wrap(require("./delete-product-prices").default)
)
route.delete(
"/:id/products/prices/batch",
middlewares.wrap(require("./delete-products-prices-batch").default)
)
route.delete(
"/:id/variants/:variant_id/prices",
middlewares.wrap(require("./delete-variant-prices").default)
@@ -287,6 +293,7 @@ export * from "./add-prices-batch"
export * from "./create-price-list"
export * from "./delete-price-list"
export * from "./delete-prices-batch"
export * from "./delete-products-prices-batch"
export * from "./get-price-list"
export * from "./list-price-list-products"
export * from "./list-price-lists"