chore(dashboard): Remove v1 code and medusa-react (#7420)
This commit is contained in:
committed by
GitHub
parent
9cbe0085d0
commit
e01472aae6
@@ -1,57 +0,0 @@
|
||||
import {
|
||||
AdminCampaignRes,
|
||||
AdminCampaignsListRes,
|
||||
AdminGetCampaignsCampaignParams,
|
||||
AdminGetCampaignsParams,
|
||||
AdminPostCampaignsCampaignReq,
|
||||
} from "@medusajs/medusa"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { queryKeysFactory, useAdminCustomQuery } from "medusa-react"
|
||||
import { medusa } from "../medusa"
|
||||
|
||||
const QUERY_KEY = "admin_campaigns"
|
||||
export const adminCampaignKeys = queryKeysFactory<
|
||||
typeof QUERY_KEY,
|
||||
AdminGetCampaignsParams
|
||||
>(QUERY_KEY)
|
||||
|
||||
export const adminCampaignQueryFns = {
|
||||
list: (query: AdminGetCampaignsParams) =>
|
||||
medusa.admin.custom.get(`/admin/campaigns`, query),
|
||||
detail: (id: string) => medusa.admin.custom.get(`/admin/campaigns/${id}`),
|
||||
}
|
||||
|
||||
export const useV2Campaigns = (
|
||||
query?: AdminGetCampaignsParams,
|
||||
options?: object
|
||||
) => {
|
||||
const { data, ...rest } = useAdminCustomQuery<
|
||||
AdminGetCampaignsParams,
|
||||
AdminCampaignsListRes
|
||||
>("/admin/campaigns", adminCampaignKeys.list(query), query, options)
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useV2Campaign = (
|
||||
id: string,
|
||||
query?: AdminGetCampaignsParams,
|
||||
options?: object
|
||||
) => {
|
||||
const { data, ...rest } = useAdminCustomQuery<
|
||||
AdminGetCampaignsCampaignParams,
|
||||
AdminCampaignRes
|
||||
>(`/admin/campaigns/${id}`, adminCampaignKeys.detail(id), query, options)
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useV2DeleteCampaign = (id: string) => {
|
||||
return useMutation(() => medusa.admin.custom.delete(`/admin/campaigns/${id}`))
|
||||
}
|
||||
|
||||
export const useV2PostCampaign = (id: string) => {
|
||||
return useMutation((args: AdminPostCampaignsCampaignReq) =>
|
||||
medusa.client.request("POST", `/admin/campaigns/${id}`, args)
|
||||
)
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import { CurrencyDTO } from "@medusajs/types"
|
||||
import { adminCurrenciesKeys, useAdminCustomQuery } from "medusa-react"
|
||||
import { V2ListRes } from "./types/common"
|
||||
|
||||
// TODO: Add types once we export V2 API types
|
||||
export const useV2Currencies = (query?: any, options?: any) => {
|
||||
const { data, ...rest } = useAdminCustomQuery(
|
||||
`/admin/currencies`,
|
||||
adminCurrenciesKeys.list(query),
|
||||
query,
|
||||
options
|
||||
)
|
||||
|
||||
const typedData: {
|
||||
currencies: CurrencyDTO[] | undefined
|
||||
} & V2ListRes = {
|
||||
currencies: data?.currencies,
|
||||
count: data?.count,
|
||||
offset: data?.offset,
|
||||
limit: data?.limit,
|
||||
}
|
||||
|
||||
return { ...typedData, ...rest }
|
||||
}
|
||||
|
||||
export const useV2Currency = (id: string, options?: any) => {
|
||||
const { data, ...rest } = useAdminCustomQuery(
|
||||
`/admin/currencies/${id}`,
|
||||
adminCurrenciesKeys.detail(id),
|
||||
undefined,
|
||||
options
|
||||
)
|
||||
|
||||
const currency: CurrencyDTO | undefined = data?.currency
|
||||
|
||||
return { currency, ...rest }
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from "./auth"
|
||||
export * from "./campaign"
|
||||
export * from "./currencies"
|
||||
@@ -1,13 +0,0 @@
|
||||
export type AcceptInviteInput = {
|
||||
payload: {
|
||||
first_name: string
|
||||
last_name: string
|
||||
}
|
||||
// Token for the created auth user
|
||||
token: string
|
||||
}
|
||||
|
||||
export type CreateAuthUserInput = {
|
||||
email: string
|
||||
password: string
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
export type V2ListRes = {
|
||||
count: number | undefined
|
||||
offset: number | undefined
|
||||
limit: number | undefined
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { CurrencyDTO, PaymentProviderDTO, StoreDTO } from "@medusajs/types"
|
||||
|
||||
export type Store = StoreDTO & {
|
||||
default_currency: CurrencyDTO | null
|
||||
currencies?: CurrencyDTO[]
|
||||
payment_providers?: PaymentProviderDTO[]
|
||||
}
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
AdminCustomerGroupResponse,
|
||||
} from "@medusajs/types"
|
||||
import { z } from "zod"
|
||||
import { CreateCustomerGroupSchema } from "../../v2-routes/customer-groups/customer-group-create/components/create-customer-group-form"
|
||||
import { EditCustomerGroupSchema } from "../../v2-routes/customer-groups/customer-group-edit/components/edit-customer-group-form"
|
||||
import { CreateCustomerGroupSchema } from "../../routes/customer-groups/customer-group-create/components/create-customer-group-form"
|
||||
import { EditCustomerGroupSchema } from "../../routes/customer-groups/customer-group-edit/components/edit-customer-group-form"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveCustomerGroup(id: string, query?: Record<string, any>) {
|
||||
|
||||
-6
@@ -1,4 +1,3 @@
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
import { QueryClient } from "@tanstack/react-query"
|
||||
|
||||
export const MEDUSA_BACKEND_URL = __BACKEND_URL__ ?? "http://localhost:9000"
|
||||
@@ -12,8 +11,3 @@ export const queryClient = new QueryClient({
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 1,
|
||||
})
|
||||
Reference in New Issue
Block a user