fix(admin-next,types): fix some http type names (#8836)
This commit is contained in:
1 parent
8fbfb1445d
commit
61e7b2eb24
16 files changed
+45
-45
No files matched your search
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
import { createColumnHelper } from "@tanstack/react-table"
|
import { createColumnHelper } from "@tanstack/react-table"
|
||||||
|
|
||||||
import { CampaignResponse } from "@medusajs/types"
|
import { AdminCampaign } from "@medusajs/types"
|
||||||
import { useMemo } from "react"
|
import { useMemo } from "react"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
import { DateCell } from "../../../components/table/table-cells/common/date-cell"
|
import { DateCell } from "../../../components/table/table-cells/common/date-cell"
|
||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
NameHeader,
|
NameHeader,
|
||||||
} from "../../../components/table/table-cells/sales-channel/name-cell"
|
} from "../../../components/table/table-cells/sales-channel/name-cell"
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<CampaignResponse>()
|
const columnHelper = createColumnHelper<AdminCampaign>()
|
||||||
|
|
||||||
export const useCampaignTableColumns = () => {
|
export const useCampaignTableColumns = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod"
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
import { CampaignResponse, PromotionDTO } from "@medusajs/types"
|
import { AdminCampaign, PromotionDTO } from "@medusajs/types"
|
||||||
import { Button, Checkbox, Hint, Tooltip, toast } from "@medusajs/ui"
|
import { Button, Checkbox, Hint, Tooltip, toast } from "@medusajs/ui"
|
||||||
import { keepPreviousData } from "@tanstack/react-query"
|
import { keepPreviousData } from "@tanstack/react-query"
|
||||||
import {
|
import {
|
||||||
@@ -21,7 +21,7 @@ import { usePromotionTableQuery } from "../../../../hooks/table/query-v2/use-pro
|
|||||||
import { useDataTable } from "../../../../hooks/use-data-table"
|
import { useDataTable } from "../../../../hooks/use-data-table"
|
||||||
|
|
||||||
type AddCampaignPromotionsFormProps = {
|
type AddCampaignPromotionsFormProps = {
|
||||||
campaign: CampaignResponse
|
campaign: AdminCampaign
|
||||||
}
|
}
|
||||||
|
|
||||||
const AddCampaignPromotionsSchema = zod.object({
|
const AddCampaignPromotionsSchema = zod.object({
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod"
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
import { CampaignResponse } from "@medusajs/types"
|
import { AdminCampaign } from "@medusajs/types"
|
||||||
import { Button, CurrencyInput, Input, toast } from "@medusajs/ui"
|
import { Button, CurrencyInput, Input, toast } from "@medusajs/ui"
|
||||||
import { useForm } from "react-hook-form"
|
import { useForm } from "react-hook-form"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
@@ -10,7 +10,7 @@ import { useUpdateCampaign } from "../../../../../hooks/api/campaigns"
|
|||||||
import { getCurrencySymbol } from "../../../../../lib/data/currencies"
|
import { getCurrencySymbol } from "../../../../../lib/data/currencies"
|
||||||
|
|
||||||
type EditCampaignBudgetFormProps = {
|
type EditCampaignBudgetFormProps = {
|
||||||
campaign: CampaignResponse
|
campaign: AdminCampaign
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditCampaignSchema = zod.object({
|
const EditCampaignSchema = zod.object({
|
||||||
|
|||||||
+5
-5
@@ -1,11 +1,11 @@
|
|||||||
import { ChartPie, PencilSquare } from "@medusajs/icons"
|
import { ChartPie, PencilSquare } from "@medusajs/icons"
|
||||||
import { CampaignResponse } from "@medusajs/types"
|
import { AdminCampaign } from "@medusajs/types"
|
||||||
import { Container, Heading, Text } from "@medusajs/ui"
|
import { Container, Heading, Text } from "@medusajs/ui"
|
||||||
import { Trans, useTranslation } from "react-i18next"
|
import { Trans, useTranslation } from "react-i18next"
|
||||||
import { ActionMenu } from "../../../../../components/common/action-menu"
|
import { ActionMenu } from "../../../../../components/common/action-menu"
|
||||||
|
|
||||||
type CampaignBudgetProps = {
|
type CampaignBudgetProps = {
|
||||||
campaign: CampaignResponse
|
campaign: AdminCampaign
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CampaignBudget = ({ campaign }: CampaignBudgetProps) => {
|
export const CampaignBudget = ({ campaign }: CampaignBudgetProps) => {
|
||||||
@@ -15,14 +15,14 @@ export const CampaignBudget = ({ campaign }: CampaignBudgetProps) => {
|
|||||||
<Container className="flex flex-col gap-y-4 px-6 py-4">
|
<Container className="flex flex-col gap-y-4 px-6 py-4">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="flex-grow">
|
<div className="flex-grow">
|
||||||
<div className="float-left bg-ui-bg-base shadow-borders-base flex size-7 items-center justify-center rounded-md">
|
<div className="bg-ui-bg-base shadow-borders-base float-left flex size-7 items-center justify-center rounded-md">
|
||||||
<div className="bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]">
|
<div className="bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]">
|
||||||
<ChartPie className="text-ui-fg-subtle" />
|
<ChartPie className="text-ui-fg-subtle" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Heading
|
<Heading
|
||||||
className="ml-10 mt-[1.5px] font-normal text-ui-fg-subtle"
|
className="text-ui-fg-subtle ml-10 mt-[1.5px] font-normal"
|
||||||
level="h3"
|
level="h3"
|
||||||
>
|
>
|
||||||
{t("campaigns.fields.budget_limit")}
|
{t("campaigns.fields.budget_limit")}
|
||||||
@@ -46,7 +46,7 @@ export const CampaignBudget = ({ campaign }: CampaignBudgetProps) => {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Text
|
<Text
|
||||||
className="text-ui-fg-subtle border-l-4 border-ui-border-strong pl-3"
|
className="text-ui-fg-subtle border-ui-border-strong border-l-4 pl-3"
|
||||||
size="small"
|
size="small"
|
||||||
leading="compact"
|
leading="compact"
|
||||||
>
|
>
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
import { PencilSquare, Trash } from "@medusajs/icons"
|
import { PencilSquare, Trash } from "@medusajs/icons"
|
||||||
import { CampaignResponse, PromotionReponse } from "@medusajs/types"
|
import { AdminCampaign, AdminPromotion } from "@medusajs/types"
|
||||||
import { Button, Checkbox, Container, Heading, usePrompt } from "@medusajs/ui"
|
import { Button, Checkbox, Container, Heading, usePrompt } from "@medusajs/ui"
|
||||||
import { RowSelectionState, createColumnHelper } from "@tanstack/react-table"
|
import { RowSelectionState, createColumnHelper } from "@tanstack/react-table"
|
||||||
import { useMemo, useState } from "react"
|
import { useMemo, useState } from "react"
|
||||||
@@ -16,7 +16,7 @@ import { usePromotionTableQuery } from "../../../../../hooks/table/query-v2/use-
|
|||||||
import { useDataTable } from "../../../../../hooks/use-data-table"
|
import { useDataTable } from "../../../../../hooks/use-data-table"
|
||||||
|
|
||||||
type CampaignPromotionSectionProps = {
|
type CampaignPromotionSectionProps = {
|
||||||
campaign: CampaignResponse
|
campaign: AdminCampaign
|
||||||
}
|
}
|
||||||
|
|
||||||
const PAGE_SIZE = 10
|
const PAGE_SIZE = 10
|
||||||
@@ -127,7 +127,7 @@ const PromotionActions = ({
|
|||||||
promotion,
|
promotion,
|
||||||
campaignId,
|
campaignId,
|
||||||
}: {
|
}: {
|
||||||
promotion: PromotionReponse
|
promotion: AdminPromotion
|
||||||
campaignId: string
|
campaignId: string
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -182,7 +182,7 @@ const PromotionActions = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<PromotionReponse>()
|
const columnHelper = createColumnHelper<AdminPromotion>()
|
||||||
|
|
||||||
const useColumns = () => {
|
const useColumns = () => {
|
||||||
const columns = usePromotionTableColumns()
|
const columns = usePromotionTableColumns()
|
||||||
|
|||||||
+5
-5
@@ -1,10 +1,10 @@
|
|||||||
import { CurrencyDollar } from "@medusajs/icons"
|
import { CurrencyDollar } from "@medusajs/icons"
|
||||||
import { CampaignResponse } from "@medusajs/types"
|
import { AdminCampaign } from "@medusajs/types"
|
||||||
import { Container, Heading, Text } from "@medusajs/ui"
|
import { Container, Heading, Text } from "@medusajs/ui"
|
||||||
import { Trans, useTranslation } from "react-i18next"
|
import { Trans, useTranslation } from "react-i18next"
|
||||||
|
|
||||||
type CampaignSpendProps = {
|
type CampaignSpendProps = {
|
||||||
campaign: CampaignResponse
|
campaign: AdminCampaign
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CampaignSpend = ({ campaign }: CampaignSpendProps) => {
|
export const CampaignSpend = ({ campaign }: CampaignSpendProps) => {
|
||||||
@@ -12,14 +12,14 @@ export const CampaignSpend = ({ campaign }: CampaignSpendProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="flex flex-col gap-y-4 px-6 py-4">
|
<Container className="flex flex-col gap-y-4 px-6 py-4">
|
||||||
<div className="grid grid-cols-[28px_1fr] items-center gap-x-3 mb-2">
|
<div className="mb-2 grid grid-cols-[28px_1fr] items-center gap-x-3">
|
||||||
<div className="bg-ui-bg-base shadow-borders-base flex size-7 items-center justify-center rounded-md">
|
<div className="bg-ui-bg-base shadow-borders-base flex size-7 items-center justify-center rounded-md">
|
||||||
<div className="bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]">
|
<div className="bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]">
|
||||||
<CurrencyDollar className="text-ui-fg-subtle" />
|
<CurrencyDollar className="text-ui-fg-subtle" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Heading level="h3" className="font-normal text-ui-fg-subtle">
|
<Heading level="h3" className="text-ui-fg-subtle font-normal">
|
||||||
{campaign.budget?.type === "spend"
|
{campaign.budget?.type === "spend"
|
||||||
? t("campaigns.fields.total_spend")
|
? t("campaigns.fields.total_spend")
|
||||||
: t("campaigns.fields.total_used")}
|
: t("campaigns.fields.total_used")}
|
||||||
@@ -28,7 +28,7 @@ export const CampaignSpend = ({ campaign }: CampaignSpendProps) => {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Text
|
<Text
|
||||||
className="text-ui-fg-subtle border-l-4 border-ui-border-strong pl-3"
|
className="text-ui-fg-subtle border-ui-border-strong border-l-4 pl-3"
|
||||||
size="small"
|
size="small"
|
||||||
leading="compact"
|
leading="compact"
|
||||||
>
|
>
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod"
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
import { CampaignResponse } from "@medusajs/types"
|
import { AdminCampaign } from "@medusajs/types"
|
||||||
import { Button, DatePicker, Input, toast } from "@medusajs/ui"
|
import { Button, DatePicker, Input, toast } from "@medusajs/ui"
|
||||||
import { useForm } from "react-hook-form"
|
import { useForm } from "react-hook-form"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
@@ -9,7 +9,7 @@ import { RouteDrawer, useRouteModal } from "../../../../../components/modals"
|
|||||||
import { useUpdateCampaign } from "../../../../../hooks/api/campaigns"
|
import { useUpdateCampaign } from "../../../../../hooks/api/campaigns"
|
||||||
|
|
||||||
type EditCampaignFormProps = {
|
type EditCampaignFormProps = {
|
||||||
campaign: CampaignResponse
|
campaign: AdminCampaign
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditCampaignSchema = zod.object({
|
const EditCampaignSchema = zod.object({
|
||||||
|
|||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
import { PencilSquare, Trash } from "@medusajs/icons"
|
import { PencilSquare, Trash } from "@medusajs/icons"
|
||||||
import { CampaignResponse } from "@medusajs/types"
|
import { AdminCampaign } from "@medusajs/types"
|
||||||
import { Button, Container, Heading, toast, usePrompt } from "@medusajs/ui"
|
import { Button, Container, Heading, toast, usePrompt } from "@medusajs/ui"
|
||||||
import { keepPreviousData } from "@tanstack/react-query"
|
import { keepPreviousData } from "@tanstack/react-query"
|
||||||
import { createColumnHelper } from "@tanstack/react-table"
|
import { createColumnHelper } from "@tanstack/react-table"
|
||||||
@@ -74,7 +74,7 @@ export const CampaignListTable = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const CampaignActions = ({ campaign }: { campaign: CampaignResponse }) => {
|
const CampaignActions = ({ campaign }: { campaign: AdminCampaign }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const prompt = usePrompt()
|
const prompt = usePrompt()
|
||||||
const { mutateAsync } = useDeleteCampaign(campaign.id)
|
const { mutateAsync } = useDeleteCampaign(campaign.id)
|
||||||
@@ -131,7 +131,7 @@ const CampaignActions = ({ campaign }: { campaign: CampaignResponse }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<CampaignResponse>()
|
const columnHelper = createColumnHelper<AdminCampaign>()
|
||||||
|
|
||||||
const useColumns = () => {
|
const useColumns = () => {
|
||||||
const base = useCampaignTableColumns()
|
const base = useCampaignTableColumns()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CampaignResponse } from "@medusajs/types"
|
import { AdminCampaign } from "@medusajs/types"
|
||||||
import { isAfter, isBefore } from "date-fns"
|
import { isAfter, isBefore } from "date-fns"
|
||||||
|
|
||||||
export function campaignStatus(campaign: CampaignResponse) {
|
export function campaignStatus(campaign: AdminCampaign) {
|
||||||
if (campaign.ends_at) {
|
if (campaign.ends_at) {
|
||||||
if (isBefore(new Date(campaign.ends_at), new Date())) {
|
if (isBefore(new Date(campaign.ends_at), new Date())) {
|
||||||
return "expired"
|
return "expired"
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,5 @@
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod"
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
import { CampaignResponse, PromotionDTO } from "@medusajs/types"
|
import { AdminCampaign, AdminPromotion } from "@medusajs/types"
|
||||||
import { Button, RadioGroup, Select, Text } from "@medusajs/ui"
|
import { Button, RadioGroup, Select, Text } from "@medusajs/ui"
|
||||||
import { useEffect } from "react"
|
import { useEffect } from "react"
|
||||||
import { useForm, useWatch } from "react-hook-form"
|
import { useForm, useWatch } from "react-hook-form"
|
||||||
@@ -12,8 +12,8 @@ import { CreateCampaignFormFields } from "../../../../campaigns/common/component
|
|||||||
import { CampaignDetails } from "./campaign-details"
|
import { CampaignDetails } from "./campaign-details"
|
||||||
|
|
||||||
type EditPromotionFormProps = {
|
type EditPromotionFormProps = {
|
||||||
promotion: PromotionDTO
|
promotion: AdminPromotion
|
||||||
campaigns: CampaignResponse[]
|
campaigns: AdminCampaign[]
|
||||||
}
|
}
|
||||||
|
|
||||||
const EditPromotionSchema = zod.object({
|
const EditPromotionSchema = zod.object({
|
||||||
@@ -27,7 +27,7 @@ export const AddCampaignPromotionFields = ({
|
|||||||
withNewCampaign = true,
|
withNewCampaign = true,
|
||||||
}: {
|
}: {
|
||||||
form: any
|
form: any
|
||||||
campaigns: CampaignResponse[]
|
campaigns: AdminCampaign[]
|
||||||
withNewCampaign?: boolean
|
withNewCampaign?: boolean
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
import { CampaignResponse } from "@medusajs/types"
|
import { AdminCampaign } from "@medusajs/types"
|
||||||
import { Heading, Text } from "@medusajs/ui"
|
import { Heading, Text } from "@medusajs/ui"
|
||||||
import { Fragment } from "react"
|
import { Fragment } from "react"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
|
|
||||||
type CampaignDetailsProps = {
|
type CampaignDetailsProps = {
|
||||||
campaign?: CampaignResponse
|
campaign?: AdminCampaign
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CampaignDetails = ({ campaign }: CampaignDetailsProps) => {
|
export const CampaignDetails = ({ campaign }: CampaignDetailsProps) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ApiKeyType } from "../../../api-key"
|
import { ApiKeyType } from "../../../api-key"
|
||||||
import { PaginatedResponse } from "../../common"
|
import { PaginatedResponse } from "../../common"
|
||||||
|
|
||||||
interface ApiKeyResponse {
|
interface AdminApiKey {
|
||||||
id: string
|
id: string
|
||||||
token: string
|
token: string
|
||||||
redacted: string
|
redacted: string
|
||||||
@@ -15,9 +15,9 @@ interface ApiKeyResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminApiKeyResponse {
|
export interface AdminApiKeyResponse {
|
||||||
api_key: ApiKeyResponse
|
api_key: AdminApiKey
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AdminApiKeyListResponse = PaginatedResponse<{
|
export type AdminApiKeyListResponse = PaginatedResponse<{
|
||||||
api_keys: ApiKeyResponse[]
|
api_keys: AdminApiKey[]
|
||||||
}>
|
}>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { CampaignBudgetTypeValues } from "../../../promotion"
|
import { CampaignBudgetTypeValues } from "../../../promotion"
|
||||||
import { PaginatedResponse } from "../../common"
|
import { PaginatedResponse } from "../../common"
|
||||||
|
|
||||||
export interface CampaignResponse {
|
export interface AdminCampaign {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string
|
||||||
@@ -19,9 +19,9 @@ export interface CampaignResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type AdminCampaignListResponse = PaginatedResponse<{
|
export type AdminCampaignListResponse = PaginatedResponse<{
|
||||||
campaigns: CampaignResponse[]
|
campaigns: AdminCampaign[]
|
||||||
}>
|
}>
|
||||||
|
|
||||||
export interface AdminCampaignResponse {
|
export interface AdminCampaignResponse {
|
||||||
campaign: CampaignResponse
|
campaign: AdminCampaign
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
PromotionRuleOperatorValues,
|
PromotionRuleOperatorValues,
|
||||||
PromotionTypeValues
|
PromotionTypeValues
|
||||||
} from "../../promotion"
|
} from "../../promotion"
|
||||||
import { CampaignResponse } from "../campaign"
|
import { AdminCampaign } from "../campaign"
|
||||||
|
|
||||||
export interface BasePromotionRule {
|
export interface BasePromotionRule {
|
||||||
id: string
|
id: string
|
||||||
@@ -38,7 +38,7 @@ export interface BasePromotion {
|
|||||||
application_method?: BaseApplicationMethod
|
application_method?: BaseApplicationMethod
|
||||||
rules?: BasePromotionRule[]
|
rules?: BasePromotionRule[]
|
||||||
campaign_id?: string
|
campaign_id?: string
|
||||||
campaign?: CampaignResponse
|
campaign?: AdminCampaign
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BasePromotionRuleValue {
|
export interface BasePromotionRuleValue {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export interface ReservationResponse {
|
export interface AdminReservation {
|
||||||
id: string
|
id: string
|
||||||
line_item_id: string | null
|
line_item_id: string | null
|
||||||
location_id: string
|
location_id: string
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { PaginatedResponse } from "../../common"
|
import { PaginatedResponse } from "../../common"
|
||||||
import { ReservationResponse } from "./entities"
|
import { AdminReservation } from "./entities"
|
||||||
|
|
||||||
export interface AdminReservationResponse {
|
export interface AdminReservationResponse {
|
||||||
reservation: ReservationResponse
|
reservation: AdminReservation
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AdminReservationListResponse = PaginatedResponse<{
|
export type AdminReservationListResponse = PaginatedResponse<{
|
||||||
reservations: ReservationResponse[]
|
reservations: AdminReservation[]
|
||||||
}>
|
}>
|
||||||
Reference in new issue
Block a user