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,11 +1,11 @@
import { omit, pickBy } from "lodash"
import { AdminGetCustomersParams } from "../../api/routes/admin/customers"
import { isDefined } from "medusa-core-utils"
import { AdminCustomersListRes } from "../../api"
import { AdminGetCustomersParams } from "../../api/routes/admin/customers"
import { Customer } from "../../models/customer"
import { CustomerService } from "../../services"
import { FindConfig } from "../../types/common"
import { validator } from "../../utils/validator"
import { Customer } from "../../models/customer"
import { isDefined } from "medusa-core-utils"
const listAndCount = async (
scope,
@@ -21,16 +21,29 @@ const listAndCount = async (
expandFields = validatedQueryParams.expand.split(",")
}
let orderBy: { [key: string]: "ASC" | "DESC" } | undefined = undefined
if (validatedQueryParams.order) {
const order = validatedQueryParams.order
const direction = order.startsWith("-") ? "DESC" : "ASC"
const field = order.replace(/^-/, "")
orderBy = {
[field]: direction,
}
}
const listConfig: FindConfig<Customer> = {
relations: expandFields,
skip: validatedQueryParams.offset,
take: validatedQueryParams.limit,
order: orderBy,
}
const filterableFields = omit(validatedQueryParams, [
"limit",
"offset",
"expand",
"fields",
"order",
])
const [customers, count] = await customerService.listAndCount(