feat(): Add more translatable core entity (#14311)
* feat(): Add product type and collection translation support * Create sharp-poets-give.md * feat(): Add product type and collection translation support * feat(): Add product type and collection translation support * options * options * shipping options/type * return reason * fix * leave out shipping and return reason * leave out shipping and return reason * leave out shipping and return reason
This commit is contained in:
1 parent
ba6ed8d9dd
commit
e94e1a4676
18 files changed
+143
-70
No files matched your search
@@ -4,6 +4,7 @@ import {
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { refetchCollection } from "../helpers"
|
||||
import { applyTranslations } from "@medusajs/framework/utils"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
|
||||
@@ -15,5 +16,11 @@ export const GET = async (
|
||||
req.queryConfig.fields
|
||||
)
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: [collection],
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
res.status(200).json({ collection })
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
import {
|
||||
applyTranslations,
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/framework/utils"
|
||||
@@ -26,6 +27,12 @@ export const GET = async (
|
||||
|
||||
const { rows: collections, metadata } = await remoteQuery(query)
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: collections,
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
res.json({
|
||||
collections,
|
||||
count: metadata.count,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { StoreProductCategoryResponse } from "@medusajs/framework/types"
|
||||
import { MedusaError } from "@medusajs/framework/utils"
|
||||
import { applyTranslations, MedusaError } from "@medusajs/framework/utils"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
@@ -24,5 +24,12 @@ export const GET = async (
|
||||
`Product category with id: ${req.params.id} was not found`
|
||||
)
|
||||
}
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: [category],
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
res.json({ product_category: category })
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
import {
|
||||
StoreProductCategoryListParams,
|
||||
StoreProductCategoryListResponse,
|
||||
} from "@medusajs/framework/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import {
|
||||
StoreProductCategoryListParams,
|
||||
StoreProductCategoryListResponse,
|
||||
} from "@medusajs/framework/types"
|
||||
import {
|
||||
applyTranslations,
|
||||
ContainerRegistrationKeys,
|
||||
} from "@medusajs/framework/utils"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<StoreProductCategoryListParams>,
|
||||
@@ -21,6 +24,12 @@ export const GET = async (
|
||||
pagination: req.queryConfig.pagination,
|
||||
})
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: product_categories,
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
res.json({
|
||||
product_categories,
|
||||
count: metadata!.count,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { StoreProductTagResponse } from "@medusajs/framework/types"
|
||||
import {
|
||||
applyTranslations,
|
||||
ContainerRegistrationKeys,
|
||||
MedusaError,
|
||||
} from "@medusajs/framework/utils"
|
||||
@@ -30,5 +31,14 @@ export const GET = async (
|
||||
`Product tag with id: ${req.params.id} was not found`
|
||||
)
|
||||
}
|
||||
res.json({ product_tag: data[0] })
|
||||
|
||||
const productTag = data[0]
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: [productTag],
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
res.json({ product_tag: productTag })
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import {
|
||||
applyTranslations,
|
||||
ContainerRegistrationKeys,
|
||||
} from "@medusajs/framework/utils"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
@@ -18,6 +21,12 @@ export const GET = async (
|
||||
fields: req.queryConfig.fields,
|
||||
})
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: product_tags,
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
res.json({
|
||||
product_tags,
|
||||
count: metadata?.count ?? 0,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { StoreProductTypeResponse } from "@medusajs/framework/types"
|
||||
import {
|
||||
applyTranslations,
|
||||
ContainerRegistrationKeys,
|
||||
MedusaError,
|
||||
} from "@medusajs/framework/utils"
|
||||
@@ -30,5 +31,14 @@ export const GET = async (
|
||||
`Product type with id: ${req.params.id} was not found`
|
||||
)
|
||||
}
|
||||
res.json({ product_type: data[0] })
|
||||
|
||||
const productType = data[0]
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: [productType],
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
res.json({ product_type: productType })
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import {
|
||||
applyTranslations,
|
||||
ContainerRegistrationKeys,
|
||||
} from "@medusajs/framework/utils"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
@@ -18,6 +21,12 @@ export const GET = async (
|
||||
fields: req.queryConfig.fields,
|
||||
})
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: product_types,
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
res.json({
|
||||
product_types,
|
||||
count: metadata?.count ?? 0,
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
import { HttpTypes, QueryContextType } from "@medusajs/framework/types"
|
||||
import {
|
||||
applyTranslations,
|
||||
ContainerRegistrationKeys,
|
||||
MedusaError,
|
||||
QueryContext,
|
||||
@@ -60,6 +61,12 @@ export const GET = async (
|
||||
)
|
||||
}
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: [variant],
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
if (withInventoryQuantity) {
|
||||
await wrapVariantsWithInventoryQuantityForSalesChannel(req, [variant])
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
import { HttpTypes, QueryContextType } from "@medusajs/framework/types"
|
||||
import {
|
||||
applyTranslations,
|
||||
ContainerRegistrationKeys,
|
||||
QueryContext,
|
||||
} from "@medusajs/framework/utils"
|
||||
@@ -54,6 +55,12 @@ export const GET = async (
|
||||
}
|
||||
)
|
||||
|
||||
await applyTranslations({
|
||||
localeCode: req.locale,
|
||||
objects: variants,
|
||||
container: req.scope,
|
||||
})
|
||||
|
||||
if (withInventoryQuantity) {
|
||||
await wrapVariantsWithInventoryQuantityForSalesChannel(req, variants)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
import { StoreReturnReasonParamsType } from "../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest<StoreReturnReasonParamsType>,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest<HttpTypes.FindParams>,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
import { calculateShippingOptionsPricesWorkflow } from "@medusajs/core-flows"
|
||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
|
||||
export const POST = async (
|
||||
|
||||
@@ -10,10 +10,10 @@ export const GET = async (
|
||||
|
||||
const workflow = listShippingOptionsForCartWorkflow(req.scope)
|
||||
const { result: shipping_options } = await workflow.run({
|
||||
input: {
|
||||
cart_id,
|
||||
input: {
|
||||
cart_id,
|
||||
is_return: !!is_return,
|
||||
fields: req.queryConfig.fields
|
||||
fields: req.queryConfig.fields,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user