feat(dashboard,medusa,ui): Manual gift cards + cleanup (#6380)

**Dashboard**
- Adds different views for managing manual/custom gift cards (not associated with a product gift card).
- Cleans up several table implementations to use new DataTable component.
- Minor cleanup of translation file.

**Medusa**
- Adds missing query params for list endpoints in the following admin domains: /customers, /customer-groups, /collections, and /gift-cards.

**UI**
- Adds new sizes for Badge component.

**Note for review**
Since this PR contains updates to the translation keys, it touches a lot of files. For the review the parts that are relevant are: the /gift-cards domain of admin, the table overview of collections, customers, and customer groups. And the changes to the list endpoints in the core.
This commit is contained in:
Kasper Fabricius Kristensen
2024-02-12 14:47:37 +01:00
committed by GitHub
parent bc2a63782b
commit d37ff8024d
138 changed files with 3230 additions and 1399 deletions

View File

@@ -1,9 +1,9 @@
import { IsNumber, IsOptional, IsString, ValidateNested } from "class-validator"
import { Request, Response } from "express"
import { DateComparisonOperator } from "../../../../types/common"
import ProductCollectionService from "../../../../services/product-collection"
import { Type } from "class-transformer"
import ProductCollectionService from "../../../../services/product-collection"
import { DateComparisonOperator } from "../../../../types/common"
/**
* @oas [get] /admin/collections
@@ -17,6 +17,7 @@ import { Type } from "class-transformer"
* - (query) title {string} Filter collections by their title.
* - (query) handle {string} Filter collections by their handle.
* - (query) q {string} a term to search collections by their title or handle.
* - (query) order {string} A field to sort-order the retrieved collections by.
* - (query) discount_condition_id {string} Filter collections by a discount condition ID associated with them.
* - in: query
* name: created_at
@@ -248,6 +249,13 @@ export class AdminGetCollectionsParams extends AdminGetCollectionsPaginationPara
@IsOptional()
q?: 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 `-`.
*/
@IsString()
@IsOptional()
order?: string
/**
* Filter product collections by their associated discount condition's ID.
*/

View File

@@ -1,9 +1,9 @@
import { IsNumber, IsOptional, IsString } from "class-validator"
import { Request, Response } from "express"
import { Type } from "class-transformer"
import { CustomerGroupService } from "../../../../services"
import { FilterableCustomerGroupProps } from "../../../../types/customer-groups"
import { Type } from "class-transformer"
/**
* @oas [get] /admin/customer-groups
@@ -100,6 +100,7 @@ import { Type } from "class-transformer"
* format: date
* - (query) limit=10 {integer} The number of customer groups to return.
* - (query) expand {string} Comma-separated relations that should be expanded in the returned customer groups.
* - (query) fields {string} Comma-separated fields that should be included in the returned customer groups.
* x-codegen:
* method: list
* queryParams: AdminGetCustomerGroupsParams
@@ -231,4 +232,11 @@ export class AdminGetCustomerGroupsParams extends FilterableCustomerGroupProps {
@IsString()
@IsOptional()
expand?: string
/**
* {@inheritDoc FindPaginationParams.fields}
*/
@IsString()
@IsOptional()
fields?: string
}

View File

@@ -1,8 +1,9 @@
import { IsNumber, IsOptional, IsString } from "class-validator"
import { AdminListCustomerSelector } from "../../../../types/customers"
import { Type } from "class-transformer"
import { Request, Response } from "express"
import customerController from "../../../../controllers/customers"
import { AdminListCustomerSelector } from "../../../../types/customers"
/**
* @oas [get] /admin/customers
@@ -13,8 +14,11 @@ import customerController from "../../../../controllers/customers"
* parameters:
* - (query) limit=50 {integer} The number of customers to return.
* - (query) offset=0 {integer} The number of customers to skip when retrieving the customers.
* - (query) expand {string} Comma-separated relations that should be expanded in the returned customer.
* - (query) expand {string} Comma-separated relations that should be expanded in the returned customers.
* - (query) fields {string} Comma-separated fields that should be included in the returned customers.
* - (query) q {string} term to search customers' email, first_name, and last_name fields.
* - (query) has_account {boolean} Filter customers by whether they have an account.
* - (query) order {string} A field to sort-order the retrieved customers by.
* - in: query
* name: groups
* style: form
@@ -24,6 +28,50 @@ import customerController from "../../../../controllers/customers"
* type: array
* items:
* type: string
* - in: query
* name: created_at
* description: Filter by a creation date range.
* schema:
* type: object
* properties:
* lt:
* type: string
* description: filter by dates less than this date
* format: date
* gt:
* type: string
* description: filter by dates greater than this date
* format: date
* lte:
* type: string
* description: filter by dates less than or equal to this date
* format: date
* gte:
* type: string
* description: filter by dates greater than or equal to this date
* format: date
* - in: query
* name: updated_at
* description: Filter by an update date range.
* schema:
* type: object
* properties:
* lt:
* type: string
* description: filter by dates less than this date
* format: date
* gt:
* type: string
* description: filter by dates greater than this date
* format: date
* lte:
* type: string
* description: filter by dates less than or equal to this date
* format: date
* gte:
* type: string
* description: filter by dates greater than or equal to this date
* format: date
* x-codegen:
* method: list
* queryParams: AdminGetCustomersParams
@@ -96,7 +144,7 @@ import customerController from "../../../../controllers/customers"
* "500":
* $ref: "#/components/responses/500_error"
*/
export default async (req, res) => {
export default async (req: Request, res: Response) => {
const result = await customerController.listAndCount(
req.scope,
req.query,
@@ -135,4 +183,11 @@ export class AdminGetCustomersParams extends AdminListCustomerSelector {
@IsString()
@IsOptional()
expand?: string
/**
* {@inheritDoc FindParams.fields}
*/
@IsString()
@IsOptional()
fields?: string
}

View File

@@ -1,10 +1,10 @@
import { IsInt, IsOptional, IsString } from "class-validator"
import { GiftCardService } from "../../../../services"
import { Type } from "class-transformer"
import { pickBy } from "lodash"
import { validator } from "../../../../utils/validator"
import { isDefined } from "medusa-core-utils"
import { GiftCardService } from "../../../../services"
import { validator } from "../../../../utils/validator"
/**
* @oas [get] /admin/gift-cards
@@ -16,6 +16,7 @@ import { isDefined } from "medusa-core-utils"
* - (query) offset=0 {number} The number of gift cards to skip when retrieving the gift cards.
* - (query) limit=50 {number} Limit the number of gift cards returned.
* - (query) q {string} a term to search gift cards' code or display ID
* - (query) order {string} A gift card field to sort-order the retrieved gift cards by.
* x-codegen:
* method: list
* queryParams: AdminGetGiftCardsParams
@@ -135,4 +136,11 @@ export class AdminGetGiftCardsParams {
@IsOptional()
@IsString()
q?: 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 `-`.
*/
@IsOptional()
@IsString()
order?: string
}