minor fixes to region domain and api (#7042)
This commit is contained in:
1 parent
f175cac4af
commit
276278cbe7
7 files changed
+25
-22
No files matched your search
@@ -13,6 +13,6 @@ export const formatProvider = (id: string) => {
|
|||||||
name
|
name
|
||||||
.split("-")
|
.split("-")
|
||||||
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
||||||
.join(" ") + (type ? ` (${type})` : "")
|
.join(" ") + (type ? ` (${type.toUpperCase()})` : "")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
+12
-7
@@ -16,24 +16,24 @@ import { useForm, useWatch } from "react-hook-form"
|
|||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
import * as zod from "zod"
|
import * as zod from "zod"
|
||||||
|
|
||||||
import { RegionCountryDTO, PaymentProviderDTO } from "@medusajs/types"
|
import { PaymentProviderDTO, RegionCountryDTO } from "@medusajs/types"
|
||||||
|
|
||||||
import { Combobox } from "../../../../../components/common/combobox"
|
import { Combobox } from "../../../../../components/common/combobox"
|
||||||
import { Form } from "../../../../../components/common/form"
|
import { Form } from "../../../../../components/common/form"
|
||||||
import { SplitView } from "../../../../../components/layout/split-view"
|
import { SplitView } from "../../../../../components/layout/split-view"
|
||||||
import {
|
import {
|
||||||
useRouteModal,
|
|
||||||
RouteFocusModal,
|
RouteFocusModal,
|
||||||
|
useRouteModal,
|
||||||
} from "../../../../../components/route-modal"
|
} from "../../../../../components/route-modal"
|
||||||
import { DataTable } from "../../../../../components/table/data-table"
|
import { DataTable } from "../../../../../components/table/data-table"
|
||||||
|
import { useCreateRegion } from "../../../../../hooks/api/regions"
|
||||||
import { useDataTable } from "../../../../../hooks/use-data-table"
|
import { useDataTable } from "../../../../../hooks/use-data-table"
|
||||||
import { countries as staticCountries } from "../../../../../lib/countries"
|
import { countries as staticCountries } from "../../../../../lib/countries"
|
||||||
|
import { CurrencyInfo } from "../../../../../lib/currencies"
|
||||||
import { formatProvider } from "../../../../../lib/format-provider"
|
import { formatProvider } from "../../../../../lib/format-provider"
|
||||||
import { useCountries } from "../../../common/hooks/use-countries"
|
import { useCountries } from "../../../common/hooks/use-countries"
|
||||||
import { useCountryTableColumns } from "../../../common/hooks/use-country-table-columns"
|
import { useCountryTableColumns } from "../../../common/hooks/use-country-table-columns"
|
||||||
import { useCountryTableQuery } from "../../../common/hooks/use-country-table-query"
|
import { useCountryTableQuery } from "../../../common/hooks/use-country-table-query"
|
||||||
import { CurrencyInfo } from "../../../../../lib/currencies"
|
|
||||||
import { useCreateRegion } from "../../../../../hooks/api/regions"
|
|
||||||
|
|
||||||
type CreateRegionFormProps = {
|
type CreateRegionFormProps = {
|
||||||
currencies: CurrencyInfo[]
|
currencies: CurrencyInfo[]
|
||||||
@@ -78,7 +78,7 @@ export const CreateRegionForm = ({
|
|||||||
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|
||||||
const { mutateAsync, isLoading } = useCreateRegion()
|
const { mutateAsync, isPending } = useCreateRegion()
|
||||||
|
|
||||||
const handleSubmit = form.handleSubmit(async (values) => {
|
const handleSubmit = form.handleSubmit(async (values) => {
|
||||||
await mutateAsync(
|
await mutateAsync(
|
||||||
@@ -195,7 +195,7 @@ export const CreateRegionForm = ({
|
|||||||
{t("actions.cancel")}
|
{t("actions.cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
</RouteFocusModal.Close>
|
</RouteFocusModal.Close>
|
||||||
<Button size="small" type="submit" isLoading={isLoading}>
|
<Button size="small" type="submit" isLoading={isPending}>
|
||||||
{t("actions.save")}
|
{t("actions.save")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -322,7 +322,12 @@ export const CreateRegionForm = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex items-center justify-end">
|
<div className="flex items-center justify-end">
|
||||||
<Button onClick={() => setOpen(true)} type="button">
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
size="small"
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
{t("regions.addCountries")}
|
{t("regions.addCountries")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Outlet, useLoaderData, useParams } from "react-router-dom"
|
import { Outlet, useLoaderData, useParams } from "react-router-dom"
|
||||||
|
|
||||||
|
import { JsonViewSection } from "../../../components/common/json-view-section"
|
||||||
|
import { useRegion } from "../../../hooks/api/regions"
|
||||||
import { RegionCountrySection } from "./components/region-country-section"
|
import { RegionCountrySection } from "./components/region-country-section"
|
||||||
import { RegionGeneralSection } from "./components/region-general-section"
|
import { RegionGeneralSection } from "./components/region-general-section"
|
||||||
import { regionLoader } from "./loader"
|
import { regionLoader } from "./loader"
|
||||||
import { useRegion } from "../../../hooks/api/regions"
|
|
||||||
|
|
||||||
export const RegionDetail = () => {
|
export const RegionDetail = () => {
|
||||||
const initialData = useLoaderData() as Awaited<
|
const initialData = useLoaderData() as Awaited<
|
||||||
@@ -13,7 +14,7 @@ export const RegionDetail = () => {
|
|||||||
const { id } = useParams()
|
const { id } = useParams()
|
||||||
const { region, isLoading, isError, error } = useRegion(
|
const { region, isLoading, isError, error } = useRegion(
|
||||||
id!,
|
id!,
|
||||||
{ fields: "*payment_providers" },
|
{ fields: "*payment_providers,*countries" },
|
||||||
{
|
{
|
||||||
initialData,
|
initialData,
|
||||||
}
|
}
|
||||||
@@ -32,6 +33,7 @@ export const RegionDetail = () => {
|
|||||||
<div className="flex flex-col gap-y-2">
|
<div className="flex flex-col gap-y-2">
|
||||||
<RegionGeneralSection region={region} />
|
<RegionGeneralSection region={region} />
|
||||||
<RegionCountrySection region={region} />
|
<RegionCountrySection region={region} />
|
||||||
|
<JsonViewSection data={region} />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import {
|
|
||||||
AuthenticatedMedusaRequest,
|
|
||||||
MedusaResponse,
|
|
||||||
} from "../../../../types/routing"
|
|
||||||
import {
|
import {
|
||||||
deleteRegionsWorkflow,
|
deleteRegionsWorkflow,
|
||||||
updateRegionsWorkflow,
|
updateRegionsWorkflow,
|
||||||
} from "@medusajs/core-flows"
|
} from "@medusajs/core-flows"
|
||||||
|
import {
|
||||||
|
AuthenticatedMedusaRequest,
|
||||||
|
MedusaResponse,
|
||||||
|
} from "../../../../types/routing"
|
||||||
|
|
||||||
import { UpdateRegionDTO } from "@medusajs/types"
|
import { UpdateRegionDTO } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
remoteQueryObjectFromString
|
remoteQueryObjectFromString,
|
||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import * as QueryConfig from "./query-config"
|
import * as QueryConfig from "./query-config"
|
||||||
|
|
||||||
|
import { transformBody, transformQuery } from "../../../api/middlewares"
|
||||||
import {
|
import {
|
||||||
AdminGetRegionsParams,
|
AdminGetRegionsParams,
|
||||||
AdminGetRegionsRegionParams,
|
AdminGetRegionsRegionParams,
|
||||||
AdminPostRegionsRegionReq,
|
AdminPostRegionsRegionReq,
|
||||||
AdminPostRegionsReq,
|
AdminPostRegionsReq,
|
||||||
} from "./validators"
|
} from "./validators"
|
||||||
import { transformBody, transformQuery } from "../../../api/middlewares"
|
|
||||||
|
|
||||||
import { MiddlewareRoute } from "../../../loaders/helpers/routing/types"
|
import { MiddlewareRoute } from "../../../loaders/helpers/routing/types"
|
||||||
import { authenticate } from "../../../utils/authenticate-middleware"
|
import { authenticate } from "../../../utils/authenticate-middleware"
|
||||||
|
|||||||
@@ -6,11 +6,7 @@ export const defaultAdminRegionFields = [
|
|||||||
"updated_at",
|
"updated_at",
|
||||||
"deleted_at",
|
"deleted_at",
|
||||||
"metadata",
|
"metadata",
|
||||||
"countries.id",
|
"*countries",
|
||||||
"countries.iso_2",
|
|
||||||
"countries.iso_3",
|
|
||||||
"countries.num_code",
|
|
||||||
"countries.name",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
export const retrieveTransformQueryConfig = {
|
export const retrieveTransformQueryConfig = {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
IsString,
|
IsString,
|
||||||
ValidateNested,
|
ValidateNested,
|
||||||
} from "class-validator"
|
} from "class-validator"
|
||||||
import { extendedFindParamsMixin, FindParams } from "../../../types/common"
|
import { FindParams, extendedFindParamsMixin } from "../../../types/common"
|
||||||
import { OperatorMapValidator } from "../../../types/validators/operator-map"
|
import { OperatorMapValidator } from "../../../types/validators/operator-map"
|
||||||
|
|
||||||
export class AdminGetRegionsRegionParams extends FindParams {}
|
export class AdminGetRegionsRegionParams extends FindParams {}
|
||||||
|
|||||||
Reference in new issue
Block a user