feat(dashboard,types,sdk,medusa,ui): ProductCategory domain (#7675)

**What**
- Add missing features to ProductCategory domain in admin
- Add types
- Add SDK

**UI**
- Moves the TooltipProvider from the component to an export. Users should now wrap their entire application in a TooltipProvider. This change was made to take advantage of the built-in features of Radix Tooltip, and allows us to skip the delayDuration when moving the cursor from one tooltip to another within 500ms.
- Fixes the layout of the Hint component, as the create form revealed that it was off.
- Fixes an issue where focus styles were missing from the dropdown menu.

**Note**
- ~~We currently don't have an endpoint for deleting categories, so I have disabled the button in the admin. See CORE--2286~~ PR has been opened to add delete endpoint, so I have re-enabled the delete button.
- The update category workflow seems to be broken, it's possible for the `mpath` of a category to reach an invalid state, that breaks `include_descendants_tree` from working. See CORE-2287.
- The ProductCategory model is incorrect. All fields are optional and it's not possible to set the description to null, which means the only way of unsetting it is to set it to `""`. See CORE-2276.
- The design for the Organize drag-n-drop form is not final. Ludvig will create a final design, and we can then update the form.
- Currently, all things related to Metadata is left out, as we need to update the flow for metadata according to the latest designs.

RESOLVES CORE-1960, CORE-2230
*except for the above mentioned issues.
This commit is contained in:
Kasper Fabricius Kristensen
2024-06-12 13:15:12 +02:00
committed by GitHub
parent 73ca358606
commit 2f76fbc6ed
71 changed files with 2208 additions and 187 deletions

View File

@@ -5,6 +5,7 @@ import { FulfillmentSet } from "./fulfillment-set"
import { Invite } from "./invite"
import { Order } from "./order"
import { Product } from "./product"
import { ProductCategory } from "./product-category"
import { ProductCollection } from "./product-collection"
import { Region } from "./region"
import { SalesChannel } from "./sales-channel"
@@ -20,6 +21,7 @@ export class Admin {
public invite: Invite
public customer: Customer
public productCollection: ProductCollection
public productCategory: ProductCategory
public product: Product
public upload: Upload
public region: Region
@@ -38,6 +40,7 @@ export class Admin {
this.invite = new Invite(client)
this.customer = new Customer(client)
this.productCollection = new ProductCollection(client)
this.productCategory = new ProductCategory(client)
this.product = new Product(client)
this.upload = new Upload(client)
this.region = new Region(client)

View File

@@ -0,0 +1,97 @@
import { HttpTypes } from "@medusajs/types"
import { Client } from "../client"
import { ClientHeaders } from "../types"
export class ProductCategory {
private client: Client
constructor(client: Client) {
this.client = client
}
async create(
body: HttpTypes.AdminCreateProductCategory,
query?: HttpTypes.AdminProductCategoryParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminProductCategoryResponse>(
`/admin/product-categories`,
{
method: "POST",
headers,
body,
query,
}
)
}
async update(
id: string,
body: HttpTypes.AdminUpdateProductCategory,
query?: HttpTypes.AdminProductCategoryParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminProductCategoryResponse>(
`/admin/product-categories/${id}`,
{
method: "POST",
headers,
body,
query,
}
)
}
async list(
query?: HttpTypes.AdminProductCategoryListParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminProductCategoryListResponse>(
`/admin/product-categories`,
{
headers,
query: query,
}
)
}
async retrieve(
id: string,
query?: HttpTypes.AdminProductCategoryParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminProductCategoryResponse>(
`/admin/product-categories/${id}`,
{
query,
headers,
}
)
}
async delete(id: string, headers?: ClientHeaders) {
return this.client.fetch<HttpTypes.AdminProductCategoryDeleteResponse>(
`/admin/product-categories/${id}`,
{
method: "DELETE",
headers,
}
)
}
async updateProducts(
id: string,
body: HttpTypes.AdminUpdateProductCategoryProducts,
query?: HttpTypes.AdminProductCategoryParams,
headers?: ClientHeaders
) {
return this.client.fetch<HttpTypes.AdminProductCategoryResponse>(
`/admin/product-categories/${id}/products`,
{
method: "POST",
headers,
body,
query,
}
)
}
}