fix(admin-ui): Wraps invite route correctly with analytics (#5118)
This commit is contained in:
1 parent
a52d5ed786
commit
299b98c401
3 files changed
+129
-126
No files matched your search
@@ -6,6 +6,8 @@ import {
|
|||||||
RouterProvider,
|
RouterProvider,
|
||||||
} from "react-router-dom"
|
} from "react-router-dom"
|
||||||
import Spinner from "./components/atoms/spinner"
|
import Spinner from "./components/atoms/spinner"
|
||||||
|
import { AnalyticsProvider } from "./providers/analytics-provider"
|
||||||
|
import { WRITE_KEY } from "./constants/analytics"
|
||||||
|
|
||||||
const NotFound = lazy(() => import("./pages/404"))
|
const NotFound = lazy(() => import("./pages/404"))
|
||||||
const Dashboard = lazy(() => import("./pages/a"))
|
const Dashboard = lazy(() => import("./pages/a"))
|
||||||
@@ -18,8 +20,22 @@ const router = createBrowserRouter(
|
|||||||
createRoutesFromElements(
|
createRoutesFromElements(
|
||||||
<>
|
<>
|
||||||
<Route path="/" element={<IndexPage />} />
|
<Route path="/" element={<IndexPage />} />
|
||||||
<Route path="a/*" element={<Dashboard />} />
|
<Route
|
||||||
<Route path="invite" element={<InvitePage />} />
|
path="a/*"
|
||||||
|
element={
|
||||||
|
<AnalyticsProvider writeKey={WRITE_KEY}>
|
||||||
|
<Dashboard />
|
||||||
|
</AnalyticsProvider>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="invite"
|
||||||
|
element={
|
||||||
|
<AnalyticsProvider writeKey={WRITE_KEY}>
|
||||||
|
<InvitePage />
|
||||||
|
</AnalyticsProvider>
|
||||||
|
}
|
||||||
|
/>
|
||||||
<Route path="login" element={<LoginPage />} />
|
<Route path="login" element={<LoginPage />} />
|
||||||
<Route path="reset-password" element={<ResetPasswordPage />} />
|
<Route path="reset-password" element={<ResetPasswordPage />} />
|
||||||
<Route path="*" element={<NotFound />} />
|
<Route path="*" element={<NotFound />} />
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import RouteErrorElement from "../components/extensions/route-container/route-er
|
|||||||
import PrivateRoute from "../components/private-route"
|
import PrivateRoute from "../components/private-route"
|
||||||
import SEO from "../components/seo"
|
import SEO from "../components/seo"
|
||||||
import Layout from "../components/templates/layout"
|
import Layout from "../components/templates/layout"
|
||||||
import { WRITE_KEY } from "../constants/analytics"
|
|
||||||
import Collections from "../domain/collections"
|
import Collections from "../domain/collections"
|
||||||
import Customers from "../domain/customers"
|
import Customers from "../domain/customers"
|
||||||
import Discounts from "../domain/discounts"
|
import Discounts from "../domain/discounts"
|
||||||
@@ -22,7 +21,6 @@ import ProductsRoute from "../domain/products"
|
|||||||
import PublishableApiKeys from "../domain/publishable-api-keys"
|
import PublishableApiKeys from "../domain/publishable-api-keys"
|
||||||
import SalesChannels from "../domain/sales-channels"
|
import SalesChannels from "../domain/sales-channels"
|
||||||
import Settings from "../domain/settings"
|
import Settings from "../domain/settings"
|
||||||
import { AnalyticsProvider } from "../providers/analytics-provider"
|
|
||||||
import { useRoutes } from "../providers/route-provider"
|
import { useRoutes } from "../providers/route-provider"
|
||||||
import { isRoute } from "../utils/extensions"
|
import { isRoute } from "../utils/extensions"
|
||||||
|
|
||||||
@@ -44,49 +42,44 @@ const DashboardRoutes = () => {
|
|||||||
const injectedRoutes = getTopLevelRoutes() || []
|
const injectedRoutes = getTopLevelRoutes() || []
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnalyticsProvider writeKey={WRITE_KEY}>
|
<DndProvider backend={HTML5Backend}>
|
||||||
<DndProvider backend={HTML5Backend}>
|
<Layout>
|
||||||
<Layout>
|
<SEO title="Medusa" />
|
||||||
<SEO title="Medusa" />
|
<Routes>
|
||||||
<Routes>
|
<Route path="oauth/:app_name" element={<Oauth />} />
|
||||||
<Route path="oauth/:app_name" element={<Oauth />} />
|
<Route path="products/*" element={<ProductsRoute />} />
|
||||||
<Route path="products/*" element={<ProductsRoute />} />
|
<Route path="product-categories/*" element={<ProductCategories />} />
|
||||||
<Route
|
<Route path="collections/*" element={<Collections />} />
|
||||||
path="product-categories/*"
|
<Route path="gift-cards/*" element={<GiftCards />} />
|
||||||
element={<ProductCategories />}
|
<Route path="orders/*" element={<Orders />} />
|
||||||
/>
|
<Route path="draft-orders/*" element={<DraftOrders />} />
|
||||||
<Route path="collections/*" element={<Collections />} />
|
<Route path="discounts/*" element={<Discounts />} />
|
||||||
<Route path="gift-cards/*" element={<GiftCards />} />
|
<Route path="customers/*" element={<Customers />} />
|
||||||
<Route path="orders/*" element={<Orders />} />
|
<Route path="pricing/*" element={<Pricing />} />
|
||||||
<Route path="draft-orders/*" element={<DraftOrders />} />
|
<Route path="settings/*" element={<Settings />} />
|
||||||
<Route path="discounts/*" element={<Discounts />} />
|
<Route path="sales-channels/*" element={<SalesChannels />} />
|
||||||
<Route path="customers/*" element={<Customers />} />
|
<Route
|
||||||
<Route path="pricing/*" element={<Pricing />} />
|
path="publishable-api-keys/*"
|
||||||
<Route path="settings/*" element={<Settings />} />
|
element={<PublishableApiKeys />}
|
||||||
<Route path="sales-channels/*" element={<SalesChannels />} />
|
/>
|
||||||
<Route
|
<Route path="inventory/*" element={<Inventory />} />
|
||||||
path="publishable-api-keys/*"
|
{injectedRoutes.map((route, index) => {
|
||||||
element={<PublishableApiKeys />}
|
return (
|
||||||
/>
|
<Route
|
||||||
<Route path="inventory/*" element={<Inventory />} />
|
key={index}
|
||||||
{injectedRoutes.map((route, index) => {
|
path={`/${route.path}/*`}
|
||||||
return (
|
errorElement={
|
||||||
<Route
|
<RouteErrorElement
|
||||||
key={index}
|
origin={isRoute(route) ? route.origin : ""}
|
||||||
path={`/${route.path}/*`}
|
/>
|
||||||
errorElement={
|
}
|
||||||
<RouteErrorElement
|
element={<RouteContainer route={route} />}
|
||||||
origin={isRoute(route) ? route.origin : ""}
|
/>
|
||||||
/>
|
)
|
||||||
}
|
})}
|
||||||
element={<RouteContainer route={route} />}
|
</Routes>
|
||||||
/>
|
</Layout>
|
||||||
)
|
</DndProvider>
|
||||||
})}
|
|
||||||
</Routes>
|
|
||||||
</Layout>
|
|
||||||
</DndProvider>
|
|
||||||
</AnalyticsProvider>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,15 +13,11 @@ import useNotification from "../hooks/use-notification"
|
|||||||
import { getErrorMessage } from "../utils/error-messages"
|
import { getErrorMessage } from "../utils/error-messages"
|
||||||
import FormValidator from "../utils/form-validator"
|
import FormValidator from "../utils/form-validator"
|
||||||
import { useAdminCreateAnalyticsConfig } from "../services/analytics"
|
import { useAdminCreateAnalyticsConfig } from "../services/analytics"
|
||||||
import {
|
import { useAnalytics } from "../providers/analytics-provider"
|
||||||
AnalyticsProvider,
|
|
||||||
useAnalytics,
|
|
||||||
} from "../providers/analytics-provider"
|
|
||||||
import AnalyticsConfigForm, {
|
import AnalyticsConfigForm, {
|
||||||
AnalyticsConfigFormType,
|
AnalyticsConfigFormType,
|
||||||
} from "../components/organisms/analytics-config-form"
|
} from "../components/organisms/analytics-config-form"
|
||||||
import { nestedForm } from "../utils/nested-form"
|
import { nestedForm } from "../utils/nested-form"
|
||||||
import { WRITE_KEY } from "../constants/analytics"
|
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
password: string
|
password: string
|
||||||
@@ -155,90 +151,88 @@ const InvitePage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AnalyticsProvider writeKey={WRITE_KEY}>
|
<PublicLayout>
|
||||||
<PublicLayout>
|
<SEO title="Create Account" />
|
||||||
<SEO title="Create Account" />
|
{signUp ? (
|
||||||
{signUp ? (
|
<form onSubmit={handleAcceptInvite}>
|
||||||
<form onSubmit={handleAcceptInvite}>
|
<div className="flex w-[300px] flex-col items-center">
|
||||||
<div className="flex w-[300px] flex-col items-center">
|
<h1 className="inter-xlarge-semibold mb-large text-[20px]">
|
||||||
<h1 className="inter-xlarge-semibold mb-large text-[20px]">
|
Create your Medusa account
|
||||||
Create your Medusa account
|
</h1>
|
||||||
</h1>
|
<div className="gap-y-small flex flex-col">
|
||||||
<div className="gap-y-small flex flex-col">
|
<div>
|
||||||
<div>
|
<SigninInput readOnly placeholder={token.user_email} />
|
||||||
<SigninInput readOnly placeholder={token.user_email} />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<SigninInput
|
|
||||||
placeholder="Password"
|
|
||||||
type={"password"}
|
|
||||||
{...register("password", {
|
|
||||||
required: FormValidator.required("Password"),
|
|
||||||
})}
|
|
||||||
autoComplete="new-password"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<SigninInput
|
|
||||||
placeholder="Confirm password"
|
|
||||||
type={"password"}
|
|
||||||
{...register("repeat_password", {
|
|
||||||
required: "You must confirm your password",
|
|
||||||
})}
|
|
||||||
autoComplete="new-password"
|
|
||||||
/>
|
|
||||||
<InputError errors={errors} name="repeat_password" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="gap-y-small my-8 flex w-[300px] flex-col">
|
<div>
|
||||||
<AnalyticsConfigForm
|
<SigninInput
|
||||||
form={nestedForm(form, "analytics")}
|
placeholder="Password"
|
||||||
compact={true}
|
type={"password"}
|
||||||
|
{...register("password", {
|
||||||
|
required: FormValidator.required("Password"),
|
||||||
|
})}
|
||||||
|
autoComplete="new-password"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<div>
|
||||||
variant="secondary"
|
<SigninInput
|
||||||
size="medium"
|
placeholder="Confirm password"
|
||||||
className="mt-large w-[300px]"
|
type={"password"}
|
||||||
loading={isLoading}
|
{...register("repeat_password", {
|
||||||
>
|
required: "You must confirm your password",
|
||||||
Create account
|
})}
|
||||||
</Button>
|
autoComplete="new-password"
|
||||||
<p className="inter-small-regular text-grey-50 mt-xlarge">
|
/>
|
||||||
Already signed up? <a href="/login">Log in</a>
|
<InputError errors={errors} name="repeat_password" />
|
||||||
</p>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="gap-y-small my-8 flex w-[300px] flex-col">
|
||||||
|
<AnalyticsConfigForm
|
||||||
|
form={nestedForm(form, "analytics")}
|
||||||
|
compact={true}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
) : (
|
|
||||||
<div className="flex flex-col items-center text-center">
|
|
||||||
<h1 className="inter-xlarge-semibold text-[20px]">
|
|
||||||
{first_run
|
|
||||||
? `Let's get you started!`
|
|
||||||
: `You have been invited to join the team`}
|
|
||||||
</h1>
|
|
||||||
{first_run ? (
|
|
||||||
<p className="inter-base-regular text-grey-50 mt-xsmall">
|
|
||||||
Create an admin account to access your <br /> Medusa dashboard.
|
|
||||||
</p>
|
|
||||||
) : (
|
|
||||||
<p className="inter-base-regular text-grey-50 mt-xsmall">
|
|
||||||
You can now join the team. Sign up below and get started
|
|
||||||
<br />
|
|
||||||
with your Medusa account right away.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="medium"
|
size="medium"
|
||||||
className="mt-xlarge w-[300px]"
|
className="mt-large w-[300px]"
|
||||||
onClick={() => setSignUp(true)}
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
Sign up
|
Create account
|
||||||
</Button>
|
</Button>
|
||||||
|
<p className="inter-small-regular text-grey-50 mt-xlarge">
|
||||||
|
Already signed up? <a href="/login">Log in</a>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
</form>
|
||||||
</PublicLayout>
|
) : (
|
||||||
</AnalyticsProvider>
|
<div className="flex flex-col items-center text-center">
|
||||||
|
<h1 className="inter-xlarge-semibold text-[20px]">
|
||||||
|
{first_run
|
||||||
|
? `Let's get you started!`
|
||||||
|
: `You have been invited to join the team`}
|
||||||
|
</h1>
|
||||||
|
{first_run ? (
|
||||||
|
<p className="inter-base-regular text-grey-50 mt-xsmall">
|
||||||
|
Create an admin account to access your <br /> Medusa dashboard.
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<p className="inter-base-regular text-grey-50 mt-xsmall">
|
||||||
|
You can now join the team. Sign up below and get started
|
||||||
|
<br />
|
||||||
|
with your Medusa account right away.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
size="medium"
|
||||||
|
className="mt-xlarge w-[300px]"
|
||||||
|
onClick={() => setSignUp(true)}
|
||||||
|
>
|
||||||
|
Sign up
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</PublicLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user