feat(admin-sdk,admin-bundler,admin-shared,medusa): Restructure admin packages (#8988)
**What** - Renames /admin-next -> /admin - Renames @medusajs/admin-sdk -> @medusajs/admin-bundler - Creates a new package called @medusajs/admin-sdk that will hold all tooling relevant to creating admin extensions. This is currently `defineRouteConfig` and `defineWidgetConfig`, but will eventually also export methods for adding custom fields, register translation, etc. - cc: @shahednasser we should update the examples in the docs so these functions are imported from `@medusajs/admin-sdk`. People will also need to install the package in their project, as it's no longer a transient dependency. - cc: @olivermrbl we might want to publish a changelog when this is merged, as it is a breaking change, and will require people to import the `defineXConfig` from the new package instead of `@medusajs/admin-shared`. - Updates CODEOWNERS so /admin packages does not require a review from the UI team.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { ExclamationCircle } from "@medusajs/icons"
|
||||
import { Text } from "@medusajs/ui"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Navigate, useLocation, useRouteError } from "react-router-dom"
|
||||
|
||||
import { isFetchError } from "../../../lib/is-fetch-error"
|
||||
|
||||
export const ErrorBoundary = () => {
|
||||
const error = useRouteError()
|
||||
const location = useLocation()
|
||||
const { t } = useTranslation()
|
||||
|
||||
let code: number | null = null
|
||||
|
||||
if (isFetchError(error)) {
|
||||
if (error.status === 401) {
|
||||
return <Navigate to="/login" state={{ from: location }} replace />
|
||||
}
|
||||
|
||||
code = error.status ?? null
|
||||
}
|
||||
|
||||
let title: string
|
||||
let message: string
|
||||
|
||||
switch (code) {
|
||||
case 400:
|
||||
title = t("errorBoundary.badRequestTitle")
|
||||
message = t("errorBoundary.badRequestMessage")
|
||||
break
|
||||
case 404:
|
||||
title = t("errorBoundary.notFoundTitle")
|
||||
message = t("errorBoundary.notFoundMessage")
|
||||
break
|
||||
case 500:
|
||||
title = t("errorBoundary.internalServerErrorTitle")
|
||||
message = t("errorBoundary.internalServerErrorMessage")
|
||||
break
|
||||
default:
|
||||
title = t("errorBoundary.defaultTitle")
|
||||
message = t("errorBoundary.defaultMessage")
|
||||
break
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex size-full min-h-[calc(100vh-57px-24px)] items-center justify-center">
|
||||
<div className="flex flex-col gap-y-6">
|
||||
<div className="text-ui-fg-subtle flex flex-col items-center gap-y-3">
|
||||
<ExclamationCircle />
|
||||
<div className="flex flex-col items-center justify-center gap-y-1">
|
||||
<Text size="small" leading="compact" weight="plus">
|
||||
{title}
|
||||
</Text>
|
||||
<Text
|
||||
size="small"
|
||||
className="text-ui-fg-muted text-balance text-center"
|
||||
>
|
||||
{message}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { ErrorBoundary } from "./error-boundary"
|
||||
Reference in New Issue
Block a user