feat(dashboard): Admin UI regions v2 (#6943)
This commit is contained in:
1 parent
df0751f122
commit
58c68f6715
72 files changed
+475
-1687
No files matched your search
@@ -4,6 +4,7 @@ import { authenticate } from "../../../utils/authenticate-middleware"
|
||||
import * as queryConfig from "./query-config"
|
||||
import {
|
||||
AdminGetPaymentsParams,
|
||||
AdminGetPaymentsPaymentProvidersParams,
|
||||
AdminPostPaymentsCapturesReq,
|
||||
AdminPostPaymentsRefundsReq,
|
||||
} from "./validators"
|
||||
@@ -24,6 +25,16 @@ export const adminPaymentRoutesMiddlewares: MiddlewareRoute[] = [
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
method: ["GET"],
|
||||
matcher: "/admin/payments/payment-providers",
|
||||
middlewares: [
|
||||
transformQuery(
|
||||
AdminGetPaymentsPaymentProvidersParams,
|
||||
queryConfig.listTransformPaymentProvidersQueryConfig
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
method: ["GET"],
|
||||
matcher: "/admin/payments/:id",
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
|
||||
import { IPaymentModuleService } from "@medusajs/types"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../types/routing"
|
||||
import { AdminGetPaymentsPaymentProvidersParams } from "../validators"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<AdminGetPaymentsPaymentProvidersParams>,
|
||||
res: MedusaResponse
|
||||
) => {
|
||||
const paymentModule = req.scope.resolve<IPaymentModuleService>(
|
||||
ModuleRegistrationName.PAYMENT
|
||||
)
|
||||
|
||||
const [payment_providers, count] =
|
||||
await paymentModule.listAndCountPaymentProviders(req.filterableFields, {
|
||||
skip: req.listConfig.skip,
|
||||
take: req.listConfig.take,
|
||||
})
|
||||
|
||||
res.status(200).json({
|
||||
count,
|
||||
payment_providers,
|
||||
offset: req.listConfig.skip,
|
||||
limit: req.listConfig.take,
|
||||
})
|
||||
}
|
||||
@@ -28,3 +28,12 @@ export const retrieveTransformQueryConfig = {
|
||||
allowedRelations: allowedAdminPaymentRelations,
|
||||
isList: false,
|
||||
}
|
||||
|
||||
export const defaultAdminPaymentPaymentProviderFields = ["id", "is_enabled"]
|
||||
|
||||
export const listTransformPaymentProvidersQueryConfig = {
|
||||
defaultFields: defaultAdminPaymentPaymentProviderFields,
|
||||
defaultRelations: [],
|
||||
allowedRelations: [],
|
||||
isList: true,
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Type } from "class-transformer"
|
||||
import { IsInt, IsOptional, ValidateNested } from "class-validator"
|
||||
import { IsBoolean, IsInt, IsOptional, ValidateNested } from "class-validator"
|
||||
import {
|
||||
DateComparisonOperator,
|
||||
FindParams,
|
||||
@@ -56,3 +56,24 @@ export class AdminPostPaymentsRefundsReq {
|
||||
@IsOptional()
|
||||
amount?: number
|
||||
}
|
||||
|
||||
export class AdminGetPaymentsPaymentProvidersParams extends extendedFindParamsMixin(
|
||||
{
|
||||
limit: 20,
|
||||
offset: 0,
|
||||
}
|
||||
) {
|
||||
/**
|
||||
* IDs to filter users by.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsType([String, [String]])
|
||||
id?: string | string[]
|
||||
|
||||
/**
|
||||
* Filter providers by `enabled` flag
|
||||
*/
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
is_enabled?: boolean
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { OperatorMap } from "@medusajs/types"
|
||||
import { Type } from "class-transformer"
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
IsObject,
|
||||
IsOptional,
|
||||
IsString,
|
||||
@@ -87,6 +88,10 @@ export class AdminPostRegionsReq {
|
||||
@IsOptional()
|
||||
countries?: string[]
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
automatic_taxes?: boolean
|
||||
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
metadata?: Record<string, unknown>
|
||||
@@ -110,6 +115,10 @@ export class AdminPostRegionsRegionReq {
|
||||
@IsOptional()
|
||||
countries?: string[]
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
automatic_taxes?: boolean
|
||||
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
metadata?: Record<string, unknown>
|
||||
|
||||
@@ -231,3 +231,4 @@ export * from "./add-payment-provider"
|
||||
export * from "./create-region"
|
||||
export * from "./list-regions"
|
||||
export * from "./update-region"
|
||||
export * from "./get-region"
|
||||
Reference in new issue
Block a user