feat(js-sdk,types,medusa): add list locales store method to JS SDK (#14314)
* feat(js-sdk,types,medusa): add list locales store method to JS SDK * add missing locale parameter
This commit is contained in:
1 parent
d813fc4ff9
commit
accb778039
8 files changed
+58
-1
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/js-sdk": patch
|
||||||
|
"@medusajs/types": patch
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(js-sdk,types,medusa): add list locales store method to JS SDK
|
||||||
@@ -1654,4 +1654,33 @@ export class Store {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tags locale
|
||||||
|
*/
|
||||||
|
public locale = {
|
||||||
|
/**
|
||||||
|
* This method retrieves the list of supported locales in the store. It sends a request to the
|
||||||
|
* [List Locales](https://docs.medusajs.com/api/store#locales_getlocales) API route.
|
||||||
|
*
|
||||||
|
* @param headers - Headers to pass in the request.
|
||||||
|
* @returns The list of supported locales.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* sdk.store.locale.list()
|
||||||
|
* .then(({ locales }) => {
|
||||||
|
* console.log(locales)
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
list: async (
|
||||||
|
headers?: ClientHeaders
|
||||||
|
) => {
|
||||||
|
return this.client.fetch<HttpTypes.StoreLocaleListResponse>(
|
||||||
|
`/store/locales`,
|
||||||
|
{
|
||||||
|
headers,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from "./admin"
|
export * from "./admin"
|
||||||
|
export * from "./store"
|
||||||
export * from "./common"
|
export * from "./common"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { BaseLocale } from "../common";
|
||||||
|
|
||||||
|
export interface StoreLocale extends Pick<BaseLocale, "code" | "name"> {}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./entities"
|
||||||
|
export * from "./responses"
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { StoreLocale } from "./entities";
|
||||||
|
|
||||||
|
export interface StoreLocaleListResponse {
|
||||||
|
locales: StoreLocale[]
|
||||||
|
}
|
||||||
@@ -11,6 +11,12 @@ export interface AdminUpdateOrder {
|
|||||||
* The order's billing address.
|
* The order's billing address.
|
||||||
*/
|
*/
|
||||||
billing_address?: OrderAddress
|
billing_address?: OrderAddress
|
||||||
|
/**
|
||||||
|
* The order's locale code. Items in the
|
||||||
|
* order will be translated to the given locale,
|
||||||
|
* if translations are available.
|
||||||
|
*/
|
||||||
|
locale?: string | null
|
||||||
/**
|
/**
|
||||||
* The order's metadata.
|
* The order's metadata.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||||
|
import { HttpTypes } from "@medusajs/framework/types"
|
||||||
|
|
||||||
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
|
export const GET = async (
|
||||||
|
req: MedusaRequest,
|
||||||
|
res: MedusaResponse<HttpTypes.StoreLocaleListResponse>
|
||||||
|
) => {
|
||||||
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
|
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
Reference in new issue
Block a user