diff --git a/.changeset/stale-eyes-float.md b/.changeset/stale-eyes-float.md new file mode 100644 index 0000000000000..2d6c828aff7d8 --- /dev/null +++ b/.changeset/stale-eyes-float.md @@ -0,0 +1,6 @@ +--- +"@medusajs/dashboard": patch +"@medusajs/types": patch +--- + +fix(dashboard,types): Fix TS errors diff --git a/packages/admin/dashboard/src/components/common/action-menu/action-menu.tsx b/packages/admin/dashboard/src/components/common/action-menu/action-menu.tsx index 2ef6ca956d889..cd918763c2591 100644 --- a/packages/admin/dashboard/src/components/common/action-menu/action-menu.tsx +++ b/packages/admin/dashboard/src/components/common/action-menu/action-menu.tsx @@ -1,7 +1,7 @@ import { DropdownMenu, IconButton, clx } from "@medusajs/ui" import { EllipsisHorizontal } from "@medusajs/icons" -import { ReactNode } from "react" +import { PropsWithChildren, ReactNode } from "react" import { Link } from "react-router-dom" import { ConditionalTooltip } from "../conditional-tooltip" @@ -28,18 +28,20 @@ export type ActionGroup = { actions: Action[] } -type ActionMenuProps = { +type ActionMenuProps = PropsWithChildren<{ groups: ActionGroup[] -} +}> + +export const ActionMenu = ({ groups, children }: ActionMenuProps) => { + const inner = children ?? ( + + + + ) -export const ActionMenu = ({ groups }: ActionMenuProps) => { return ( - - - - - + {inner} {groups.map((group, index) => { if (!group.actions.length) { diff --git a/packages/admin/dashboard/src/components/common/button-menu/button-menu.tsx b/packages/admin/dashboard/src/components/common/button-menu/button-menu.tsx deleted file mode 100644 index 54ba5a476ec9c..0000000000000 --- a/packages/admin/dashboard/src/components/common/button-menu/button-menu.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { DropdownMenu, clx } from "@medusajs/ui" - -import { PropsWithChildren, ReactNode } from "react" -import { Link } from "react-router-dom" - -type Action = { - icon: ReactNode - label: string - disabled?: boolean -} & ( - | { - to: string - onClick?: never - } - | { - onClick: () => void - to?: never - } -) - -type ActionGroup = { - actions: Action[] -} - -type ActionMenuProps = { - groups: ActionGroup[] -} - -export const ButtonMenu = ({ - groups, - children, -}: PropsWithChildren) => { - return ( - - {children} - - {groups.map((group, index) => { - if (!group.actions.length) { - return null - } - - const isLast = index === groups.length - 1 - - return ( - - {group.actions.map((action, index) => { - if (action.onClick) { - return ( - { - e.stopPropagation() - action.onClick() - }} - className={clx( - "[&_svg]:text-ui-fg-subtle flex items-center gap-x-2", - { - "[&_svg]:text-ui-fg-disabled": action.disabled, - } - )} - > - {action.icon} - {action.label} - - ) - } - - return ( -
- - e.stopPropagation()}> - {action.icon} - {action.label} - - -
- ) - })} - {!isLast && } -
- ) - })} -
-
- ) -} diff --git a/packages/admin/dashboard/src/components/common/button-menu/index.ts b/packages/admin/dashboard/src/components/common/button-menu/index.ts deleted file mode 100644 index a3a827d6173da..0000000000000 --- a/packages/admin/dashboard/src/components/common/button-menu/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./action-menu" diff --git a/packages/admin/dashboard/src/components/common/date/index.ts b/packages/admin/dashboard/src/components/common/date/index.ts deleted file mode 100644 index 98cb13cafc947..0000000000000 --- a/packages/admin/dashboard/src/components/common/date/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import format from "date-fns/format" - -export function formatDate(date: string | Date) { - const value = new Date(date) - value.setMinutes(value.getMinutes() - value.getTimezoneOffset()) - - const hour12 = Intl.DateTimeFormat().resolvedOptions().hour12 - const timestampFormat = hour12 ? "dd MMM yyyy hh:MM a" : "dd MMM yyyy HH:MM" - - return format(value, timestampFormat) -} diff --git a/packages/admin/dashboard/src/components/forms/address-form/address-form.tsx b/packages/admin/dashboard/src/components/forms/address-form/address-form.tsx index 5485882289143..2dd74890e9bd7 100644 --- a/packages/admin/dashboard/src/components/forms/address-form/address-form.tsx +++ b/packages/admin/dashboard/src/components/forms/address-form/address-form.tsx @@ -2,11 +2,11 @@ import { Heading, Input, Select, clx } from "@medusajs/ui" import { useTranslation } from "react-i18next" import { z } from "zod" +import { HttpTypes } from "@medusajs/types" import { Control } from "react-hook-form" import { AddressSchema } from "../../../lib/schemas" import { Form } from "../../common/form" import { CountrySelect } from "../../inputs/country-select" -import { HttpTypes } from "@medusajs/types" type AddressFieldValues = z.infer @@ -187,14 +187,24 @@ export const AddressForm = ({ - {countries.map((country) => ( - - {country.display_name} - - ))} + {countries.map((country) => { + /** + * If a country does not have an ISO 2 code, it is not + * a valid country and should not be selectable. + */ + if (!country.iso_2) { + return null + } + + return ( + + {country.display_name} + + ) + })} ) : ( diff --git a/packages/admin/dashboard/src/components/forms/metadata-form/metadata-form.tsx b/packages/admin/dashboard/src/components/forms/metadata-form/metadata-form.tsx index c59374f055a13..19bee56d37339 100644 --- a/packages/admin/dashboard/src/components/forms/metadata-form/metadata-form.tsx +++ b/packages/admin/dashboard/src/components/forms/metadata-form/metadata-form.tsx @@ -18,7 +18,7 @@ import { Trash, } from "@medusajs/icons" import { FetchError } from "@medusajs/js-sdk" -import { ComponentPropsWithoutRef, forwardRef, useRef } from "react" +import { ComponentPropsWithoutRef, forwardRef } from "react" import { ConditionalTooltip } from "../../common/conditional-tooltip" import { Form } from "../../common/form" import { InlineTip } from "../../common/inline-tip" @@ -78,7 +78,6 @@ const InnerForm = ({ const { t } = useTranslation() const { handleSuccess } = useRouteModal() - const deletedOriginalRows = useRef([]) const hasUneditableRows = getHasUneditableRows(metadata) const form = useForm>({ diff --git a/packages/admin/dashboard/src/components/table/table-cells/common/created-at-cell/created-at-cell.tsx b/packages/admin/dashboard/src/components/table/table-cells/common/created-at-cell/created-at-cell.tsx index 50b480961b5b4..3b8309055c4d6 100644 --- a/packages/admin/dashboard/src/components/table/table-cells/common/created-at-cell/created-at-cell.tsx +++ b/packages/admin/dashboard/src/components/table/table-cells/common/created-at-cell/created-at-cell.tsx @@ -1,6 +1,6 @@ import { Tooltip } from "@medusajs/ui" -import format from "date-fns/format" import { useTranslation } from "react-i18next" +import { useDate } from "../../../../../hooks/use-date" import { PlaceholderCell } from "../placeholder-cell" type DateCellProps = { @@ -8,28 +8,26 @@ type DateCellProps = { } export const CreatedAtCell = ({ date }: DateCellProps) => { + const { getFullDate } = useDate() + if (!date) { return } - const value = new Date(date) - value.setMinutes(value.getMinutes() - value.getTimezoneOffset()) - - const hour12 = Intl.DateTimeFormat().resolvedOptions().hour12 - const timestampFormat = hour12 ? "dd MMM yyyy hh:MM a" : "dd MMM yyyy HH:MM" - return (
{`${format( - value, - timestampFormat - )}`} + {`${getFullDate({ + date, + includeTime: true, + })}`} } > - {format(value, "dd MMM yyyy")} + + {getFullDate({ date, includeTime: true })} +
) diff --git a/packages/admin/dashboard/src/components/table/table-cells/order/customer-cell/customer-cell.tsx b/packages/admin/dashboard/src/components/table/table-cells/order/customer-cell/customer-cell.tsx index 050aa744b3369..39d5045ac3767 100644 --- a/packages/admin/dashboard/src/components/table/table-cells/order/customer-cell/customer-cell.tsx +++ b/packages/admin/dashboard/src/components/table/table-cells/order/customer-cell/customer-cell.tsx @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next" export const CustomerCell = ({ customer, }: { - customer: HttpTypes.AdminCustomer | null + customer?: HttpTypes.AdminCustomer | null }) => { if (!customer) { return - diff --git a/packages/admin/dashboard/src/components/table/table-cells/order/payment-status-cell/payment-status-cell.tsx b/packages/admin/dashboard/src/components/table/table-cells/order/payment-status-cell/payment-status-cell.tsx index 0aacd0ba09e33..01382e098a3e4 100644 --- a/packages/admin/dashboard/src/components/table/table-cells/order/payment-status-cell/payment-status-cell.tsx +++ b/packages/admin/dashboard/src/components/table/table-cells/order/payment-status-cell/payment-status-cell.tsx @@ -1,9 +1,10 @@ +import { HttpTypes } from "@medusajs/types" import { useTranslation } from "react-i18next" import { getOrderPaymentStatus } from "../../../../../lib/order-helpers" import { StatusCell } from "../../common/status-cell" type PaymentStatusCellProps = { - status: PaymentStatus + status: HttpTypes.AdminOrder["payment_status"] } export const PaymentStatusCell = ({ status }: PaymentStatusCellProps) => { diff --git a/packages/admin/dashboard/src/components/table/table-cells/order/sales-channel-cell/sales-channel-cell.tsx b/packages/admin/dashboard/src/components/table/table-cells/order/sales-channel-cell/sales-channel-cell.tsx index c451cb12b27b9..50a3e0f35575e 100644 --- a/packages/admin/dashboard/src/components/table/table-cells/order/sales-channel-cell/sales-channel-cell.tsx +++ b/packages/admin/dashboard/src/components/table/table-cells/order/sales-channel-cell/sales-channel-cell.tsx @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next" export const SalesChannelCell = ({ channel, }: { - channel: HttpTypes.AdminSalesChannel | null + channel?: HttpTypes.AdminSalesChannel | null }) => { if (!channel) { return - diff --git a/packages/admin/dashboard/src/components/table/table-cells/region/countries-cell/countries-cell.tsx b/packages/admin/dashboard/src/components/table/table-cells/region/countries-cell/countries-cell.tsx index 22727be4850a8..085f18de819a5 100644 --- a/packages/admin/dashboard/src/components/table/table-cells/region/countries-cell/countries-cell.tsx +++ b/packages/admin/dashboard/src/components/table/table-cells/region/countries-cell/countries-cell.tsx @@ -1,4 +1,4 @@ -import { RegionCountryDTO } from "@medusajs/types" +import { HttpTypes } from "@medusajs/types" import { useTranslation } from "react-i18next" import { countries as COUNTRIES } from "../../../../../lib/data/countries" @@ -6,24 +6,24 @@ import { ListSummary } from "../../../../common/list-summary" import { PlaceholderCell } from "../../common/placeholder-cell" type CountriesCellProps = { - countries?: RegionCountryDTO[] | null + countries?: HttpTypes.AdminRegionCountry[] | null } export const CountriesCell = ({ countries }: CountriesCellProps) => { - const { t } = useTranslation() - if (!countries || countries.length === 0) { return } + const list = countries + .map( + (country) => + COUNTRIES.find((c) => c.iso_2 === country.iso_2)?.display_name + ) + .filter(Boolean) as string[] + return (
- - COUNTRIES.find((c) => c.iso_2 === country.iso_2)!.display_name - )} - /> +
) } diff --git a/packages/admin/dashboard/src/extensions/dashboard-extension-provider/types.ts b/packages/admin/dashboard/src/extensions/dashboard-extension-provider/types.ts deleted file mode 100644 index bb4fc6a93baad..0000000000000 --- a/packages/admin/dashboard/src/extensions/dashboard-extension-provider/types.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { InjectionZone } from "@medusajs/admin-shared" -import { ComponentType } from "react" -import { LoaderFunction } from "react-router-dom" -import { CustomFieldConfiguration } from "../../extensions/custom-field-registry/types" - -export type RouteExtension = { - Component: ComponentType - loader?: LoaderFunction - path: string -} - -export type MenuItemExtension = { - label: string - path: string - icon?: ComponentType -} - -export type WidgetExtension = { - Component: ComponentType - zone: InjectionZone[] -} - -export type RoutingExtensionConfig = { - routes: RouteExtension[] - menuItems: MenuItemExtension[] -} - -export type DashboardExtensionConfig = { - customFields?: CustomFieldConfiguration - menuItems?: MenuItemExtension[] - widgets?: WidgetExtension[] -} diff --git a/packages/admin/dashboard/src/hooks/api/auth.tsx b/packages/admin/dashboard/src/hooks/api/auth.tsx index 6d053e87d0887..170bfc5b70a19 100644 --- a/packages/admin/dashboard/src/hooks/api/auth.tsx +++ b/packages/admin/dashboard/src/hooks/api/auth.tsx @@ -1,11 +1,14 @@ -import { UseMutationOptions, useMutation } from "@tanstack/react-query" import { FetchError } from "@medusajs/js-sdk" -import { sdk } from "../../lib/client" import { HttpTypes } from "@medusajs/types" +import { UseMutationOptions, useMutation } from "@tanstack/react-query" +import { sdk } from "../../lib/client" export const useSignInWithEmailPass = ( options?: UseMutationOptions< - string, + | string + | { + location: string + }, FetchError, HttpTypes.AdminSignUpWithEmailPassword > diff --git a/packages/admin/dashboard/src/hooks/api/claims.tsx b/packages/admin/dashboard/src/hooks/api/claims.tsx index a191f459d108a..4fb5bbebcc924 100644 --- a/packages/admin/dashboard/src/hooks/api/claims.tsx +++ b/packages/admin/dashboard/src/hooks/api/claims.tsx @@ -208,14 +208,13 @@ export const useAddClaimInboundItems = ( id: string, orderId: string, options?: UseMutationOptions< - HttpTypes.AdminClaimResponse, + HttpTypes.AdminClaimReturnPreviewResponse, FetchError, HttpTypes.AdminAddClaimInboundItems > ) => { return useMutation({ - mutationFn: (payload: HttpTypes.AdminAddClaimInboundItems) => - sdk.admin.claim.addInboundItems(id, payload), + mutationFn: (payload) => sdk.admin.claim.addInboundItems(id, payload), onSuccess: (data: any, variables: any, context: any) => { queryClient.invalidateQueries({ queryKey: ordersQueryKeys.details(), diff --git a/packages/admin/dashboard/src/hooks/api/collections.tsx b/packages/admin/dashboard/src/hooks/api/collections.tsx index 9a6fbded6d65a..49e8aee34836c 100644 --- a/packages/admin/dashboard/src/hooks/api/collections.tsx +++ b/packages/admin/dashboard/src/hooks/api/collections.tsx @@ -37,7 +37,7 @@ export const useCollection = ( } export const useCollections = ( - query?: FindParams & HttpTypes.AdminCollectionFilters, + query?: FindParams & HttpTypes.AdminCollectionListParams, options?: Omit< UseQueryOptions< PaginatedResponse<{ collections: HttpTypes.AdminCollection[] }>, @@ -60,7 +60,7 @@ export const useCollections = ( export const useUpdateCollection = ( id: string, options?: UseMutationOptions< - { collection: HttpTypes.AdminCollection }, + HttpTypes.AdminCollectionResponse, FetchError, HttpTypes.AdminUpdateCollection > @@ -82,7 +82,7 @@ export const useUpdateCollection = ( export const useUpdateCollectionProducts = ( id: string, options?: UseMutationOptions< - { collection: HttpTypes.AdminCollection }, + HttpTypes.AdminCollectionResponse, FetchError, HttpTypes.AdminUpdateCollectionProducts > @@ -110,7 +110,7 @@ export const useUpdateCollectionProducts = ( export const useCreateCollection = ( options?: UseMutationOptions< - { collection: HttpTypes.AdminCollection }, + HttpTypes.AdminCollectionResponse, FetchError, HttpTypes.AdminCreateCollection > diff --git a/packages/admin/dashboard/src/hooks/api/invites.tsx b/packages/admin/dashboard/src/hooks/api/invites.tsx index 17a5f4e135ed6..3edfd86eb72a8 100644 --- a/packages/admin/dashboard/src/hooks/api/invites.tsx +++ b/packages/admin/dashboard/src/hooks/api/invites.tsx @@ -1,8 +1,5 @@ -import { - AdminInviteResponse, - HttpTypes, - PaginatedResponse, -} from "@medusajs/types" +import { FetchError } from "@medusajs/js-sdk" +import { HttpTypes } from "@medusajs/types" import { QueryKey, UseMutationOptions, @@ -13,7 +10,6 @@ import { import { sdk } from "../../lib/client" import { queryClient } from "../../lib/query-client" import { queryKeysFactory } from "../../lib/query-key-factory" -import { FetchError } from "@medusajs/js-sdk" const INVITES_QUERY_KEY = "invites" as const const invitesQueryKeys = queryKeysFactory(INVITES_QUERY_KEY) @@ -22,9 +18,9 @@ export const useInvite = ( id: string, options?: Omit< UseQueryOptions< - { invite: HttpTypes.AdminInviteResponse }, + HttpTypes.AdminInviteResponse, FetchError, - { invite: HttpTypes.AdminInviteResponse }, + HttpTypes.AdminInviteResponse, QueryKey >, "queryFn" | "queryKey" @@ -43,9 +39,9 @@ export const useInvites = ( query?: Record, options?: Omit< UseQueryOptions< - PaginatedResponse<{ invites: HttpTypes.AdminInviteResponse[] }>, + HttpTypes.AdminInviteListResponse, FetchError, - PaginatedResponse<{ invites: HttpTypes.AdminInviteResponse[] }>, + HttpTypes.AdminInviteListResponse, QueryKey >, "queryFn" | "queryKey" @@ -62,7 +58,7 @@ export const useInvites = ( export const useCreateInvite = ( options?: UseMutationOptions< - { invite: AdminInviteResponse }, + HttpTypes.AdminInviteResponse, FetchError, HttpTypes.AdminCreateInvite > @@ -79,11 +75,7 @@ export const useCreateInvite = ( export const useResendInvite = ( id: string, - options?: UseMutationOptions< - { invite: AdminInviteResponse }, - FetchError, - void - > + options?: UseMutationOptions ) => { return useMutation({ mutationFn: () => sdk.admin.invite.resend(id), @@ -118,7 +110,7 @@ export const useDeleteInvite = ( export const useAcceptInvite = ( inviteToken: string, options?: UseMutationOptions< - { user: HttpTypes.AdminUserResponse }, + HttpTypes.AdminAcceptInviteResponse, FetchError, HttpTypes.AdminAcceptInvite & { auth_token: string } > diff --git a/packages/admin/dashboard/src/hooks/api/price-lists.tsx b/packages/admin/dashboard/src/hooks/api/price-lists.tsx index 7c3fd1d43d039..1a4e2ac4fc166 100644 --- a/packages/admin/dashboard/src/hooks/api/price-lists.tsx +++ b/packages/admin/dashboard/src/hooks/api/price-lists.tsx @@ -128,7 +128,7 @@ export const useBatchPriceListPrices = ( id: string, query?: HttpTypes.AdminPriceListParams, options?: UseMutationOptions< - HttpTypes.AdminPriceListResponse, + HttpTypes.AdminPriceListBatchResponse, FetchError, HttpTypes.AdminBatchPriceListPrice > diff --git a/packages/admin/dashboard/src/hooks/table/columns/use-order-table-columns.tsx b/packages/admin/dashboard/src/hooks/table/columns/use-order-table-columns.tsx index e28ced6cab6e4..f26abbc35b8f2 100644 --- a/packages/admin/dashboard/src/hooks/table/columns/use-order-table-columns.tsx +++ b/packages/admin/dashboard/src/hooks/table/columns/use-order-table-columns.tsx @@ -1,3 +1,4 @@ +import { HttpTypes } from "@medusajs/types" import { ColumnDef, ColumnDefBase, @@ -33,7 +34,6 @@ import { TotalCell, TotalHeader, } from "../../../components/table/table-cells/order/total-cell" -import { HttpTypes } from "@medusajs/types" // We have to use any here, as the type of Order is so complex that it lags the TS server const columnHelper = createColumnHelper() diff --git a/packages/admin/dashboard/src/index.ts b/packages/admin/dashboard/src/index.ts deleted file mode 100644 index 18000e720893e..0000000000000 --- a/packages/admin/dashboard/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./render" diff --git a/packages/admin/dashboard/src/routes/orders/order-create-edit/components/order-edit-create-form/order-edit-items-section.tsx b/packages/admin/dashboard/src/routes/orders/order-create-edit/components/order-edit-create-form/order-edit-items-section.tsx index 1f212308174bb..e2a253475d67c 100644 --- a/packages/admin/dashboard/src/routes/orders/order-create-edit/components/order-edit-create-form/order-edit-items-section.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-create-edit/components/order-edit-create-form/order-edit-items-section.tsx @@ -1,15 +1,15 @@ -import { useMemo, useState } from "react" import { AdminOrder, AdminOrderPreview } from "@medusajs/types" import { Button, Heading, Input, toast } from "@medusajs/ui" +import { useMemo, useState } from "react" import { useTranslation } from "react-i18next" import { RouteFocusModal, StackedFocusModal, useStackedModal, } from "../../../../../components/modals" +import { useAddOrderEditItems } from "../../../../../hooks/api/order-edits" import { AddOrderEditItemsTable } from "../add-order-edit-items-table" import { OrderEditItem } from "./order-edit-item" -import { useAddOrderEditItems } from "../../../../../hooks/api/order-edits" type ExchangeInboundSectionProps = { order: AdminOrder @@ -39,16 +39,19 @@ export const OrderEditItemsSection = ({ * CALLBACKS */ const onItemsSelected = async () => { - try { - await addItems({ + await addItems( + { items: addedVariants.map((i) => ({ variant_id: i, quantity: 1, })), - }) - } catch (e) { - toast.error(e.message) - } + }, + { + onError: (e) => { + toast.error(e.message) + }, + } + ) setIsOpen("inbound-items", false) } diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx index 06432bcd3dbd7..c48a14611fbc0 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/order-summary-section.tsx @@ -38,7 +38,6 @@ import { import { AdminReservation } from "@medusajs/types/src/http" import { AdminPaymentCollection } from "../../../../../../../../core/types/dist/http/payment/admin/entities" import { ActionMenu } from "../../../../../components/common/action-menu" -import { ButtonMenu } from "../../../../../components/common/button-menu/button-menu" import { Thumbnail } from "../../../../../components/common/thumbnail" import { useClaims } from "../../../../../hooks/api/claims" import { useExchanges } from "../../../../../hooks/api/exchanges" @@ -193,7 +192,7 @@ export const OrderSummarySection = ({ order }: OrderSummarySectionProps) => { {t("orders.returns.receive.action")} ) : ( - { @@ -225,7 +224,7 @@ export const OrderSummarySection = ({ order }: OrderSummarySectionProps) => { - + ))} {showAllocateButton && ( diff --git a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/return-info-popover.tsx b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/return-info-popover.tsx index c73b4107bbf0e..92dc670ceb69f 100644 --- a/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/return-info-popover.tsx +++ b/packages/admin/dashboard/src/routes/orders/order-detail/components/order-summary-section/return-info-popover.tsx @@ -3,7 +3,7 @@ import { AdminReturn } from "@medusajs/types" import { Badge, Popover, Text } from "@medusajs/ui" import { useState } from "react" import { useTranslation } from "react-i18next" -import { formatDate } from "../../../../../components/common/date" +import { useDate } from "../../../../../hooks/use-date" type ReturnInfoPopoverProps = { orderReturn: AdminReturn @@ -13,6 +13,8 @@ function ReturnInfoPopover({ orderReturn }: ReturnInfoPopoverProps) { const { t } = useTranslation() const [open, setOpen] = useState(false) + const { getFullDate } = useDate() + const handleMouseEnter = () => { setOpen(true) } @@ -44,7 +46,7 @@ function ReturnInfoPopover({ orderReturn }: ReturnInfoPopoverProps) { onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave} autoFocus={false} - className="focus-visible:outline-none align-sub" + className="align-sub focus-visible:outline-none" > @@ -52,7 +54,7 @@ function ReturnInfoPopover({ orderReturn }: ReturnInfoPopoverProps) {
@@ -64,7 +66,7 @@ function ReturnInfoPopover({ orderReturn }: ReturnInfoPopoverProps) { {t(`orders.returns.returnRequested`)} {" · "} - {formatDate(orderReturn.requested_at)} + {getFullDate({ date: orderReturn.requested_at, includeTime: true })} @@ -73,7 +75,10 @@ function ReturnInfoPopover({ orderReturn }: ReturnInfoPopoverProps) { {" · "} {orderReturn.received_at - ? formatDate(orderReturn.received_at) + ? getFullDate({ + date: orderReturn.received_at, + includeTime: true, + }) : "-"}
diff --git a/packages/admin/dashboard/src/routes/tax-regions/common/hooks.ts b/packages/admin/dashboard/src/routes/tax-regions/common/hooks.ts index 0f519a09041ce..1caaa514f8b36 100644 --- a/packages/admin/dashboard/src/routes/tax-regions/common/hooks.ts +++ b/packages/admin/dashboard/src/routes/tax-regions/common/hooks.ts @@ -32,20 +32,12 @@ export const useDeleteTaxRegionAction = ({ await mutateAsync(undefined, { onSuccess: () => { - toast.success(t("general.success"), { - description: t("taxRegions.delete.successToast"), - dismissable: true, - dismissLabel: t("actions.close"), - }) + toast.success(t("taxRegions.delete.successToast")) navigate(to, { replace: true }) }, onError: (e) => { - toast.error(t("general.error"), { - description: e.message, - dismissable: true, - dismissLabel: t("actions.close"), - }) + toast.error(e.message) }, }) } diff --git a/packages/admin/dashboard/src/routes/users/user-edit/components/edit-user-form/edit-user-form.tsx b/packages/admin/dashboard/src/routes/users/user-edit/components/edit-user-form/edit-user-form.tsx index 7ee591bc17bd1..d448fe6e29900 100644 --- a/packages/admin/dashboard/src/routes/users/user-edit/components/edit-user-form/edit-user-form.tsx +++ b/packages/admin/dashboard/src/routes/users/user-edit/components/edit-user-form/edit-user-form.tsx @@ -4,14 +4,14 @@ import { useForm } from "react-hook-form" import { useTranslation } from "react-i18next" import * as zod from "zod" -import { UserDTO } from "@medusajs/types" +import { HttpTypes } from "@medusajs/types" import { Form } from "../../../../../components/common/form" import { RouteDrawer, useRouteModal } from "../../../../../components/modals" import { KeyboundForm } from "../../../../../components/utilities/keybound-form" import { useUpdateUser } from "../../../../../hooks/api/users" type EditUserFormProps = { - user: UserDTO + user: HttpTypes.AdminUser } const EditUserFormSchema = zod.object({ diff --git a/packages/admin/dashboard/src/routes/users/user-invite/components/invite-user-form/invite-user-form.tsx b/packages/admin/dashboard/src/routes/users/user-invite/components/invite-user-form/invite-user-form.tsx index 61622ec318b8a..136d5b420f6b9 100644 --- a/packages/admin/dashboard/src/routes/users/user-invite/components/invite-user-form/invite-user-form.tsx +++ b/packages/admin/dashboard/src/routes/users/user-invite/components/invite-user-form/invite-user-form.tsx @@ -1,6 +1,6 @@ import { zodResolver } from "@hookform/resolvers/zod" import { ArrowPath, Link, Trash } from "@medusajs/icons" -import { InviteDTO } from "@medusajs/types" +import { HttpTypes } from "@medusajs/types" import { Alert, Button, @@ -70,7 +70,7 @@ export const InviteUserForm = () => { const columns = useColumns() const { table } = useDataTable({ - data: (invites ?? []) as InviteDTO[], + data: invites ?? [], columns, count, enablePagination: true, @@ -185,7 +185,7 @@ export const InviteUserForm = () => { ) } -const InviteActions = ({ invite }: { invite: InviteDTO }) => { +const InviteActions = ({ invite }: { invite: HttpTypes.AdminInvite }) => { const { mutateAsync: revokeAsync } = useDeleteInvite(invite.id) const { mutateAsync: resendAsync } = useResendInvite(invite.id) @@ -253,7 +253,7 @@ const InviteActions = ({ invite }: { invite: InviteDTO }) => { ) } -const columnHelper = createColumnHelper() +const columnHelper = createColumnHelper() const useColumns = () => { const { t } = useTranslation() diff --git a/packages/admin/dashboard/src/routes/users/user-metadata/user-metadata.tsx b/packages/admin/dashboard/src/routes/users/user-metadata/user-metadata.tsx index 6c64330f1ea13..e88f49e798898 100644 --- a/packages/admin/dashboard/src/routes/users/user-metadata/user-metadata.tsx +++ b/packages/admin/dashboard/src/routes/users/user-metadata/user-metadata.tsx @@ -7,8 +7,8 @@ import { useUpdateUser, useUser } from "../../../hooks/api" export const UserMetadata = () => { const { id } = useParams() - const { user, isPending, isError, error } = useUser(id) - const { mutateAsync, isPending: isMutating } = useUpdateUser(id) + const { user, isPending, isError, error } = useUser(id!) + const { mutateAsync, isPending: isMutating } = useUpdateUser(id!) if (isError) { throw error diff --git a/packages/core/types/src/http/invite/admin/entities.ts b/packages/core/types/src/http/invite/admin/entities.ts index 10dc03dfcc1e0..35cbba36b29a1 100644 --- a/packages/core/types/src/http/invite/admin/entities.ts +++ b/packages/core/types/src/http/invite/admin/entities.ts @@ -18,7 +18,7 @@ export interface AdminInvite { /** * The date the invite expires. */ - expires_at?: Date + expires_at: string /** * Key-value pairs of custom data. */ @@ -26,9 +26,9 @@ export interface AdminInvite { /** * The date that the invite was created. */ - created_at?: Date + created_at: string /** * The date that the invite was updated. */ - updated_at?: Date + updated_at: string }