feat(dashboard): Setup parallel V2 routes (#6691)
**What** - Moves all current route definitions to `v1.tsx` - Creates a new `v2.tsx` file for future V2 routes. - Updates RouteProvider to serve V1 or V2 routes based on if `MEDUSA_V2` is set. **How to use it** When working on V2 domains you should set `MEDUSA_V2=true` in `/packages/admin-next/dashboard/.env`. We can't use the Feature Flag in the Medusa project since there are breaking changes in the `/admin/store` endpoint between the two versions, so it needs to be managed manually. **For people implementing V2 domains** To add a new route you should: - Add the route component in `/v2-routes` - Define which path will render it in `v2.tsx`. I would prefer that we don't try to implement a lot of conditional code that will make the codebase unnecessarily complex. So if I was to implement the V2 login page, I would copy/past the v1 login route into `v2-routes`, make the required changes, eg. replace `useAdminLogin` with `useAdminCustomPost(...)`, instead of trying to force the current V1 Login page to work with both APIs. There will hopefully be a lot of components/sections from each domain that is re-usable between versions. As an example if you are working on the Product details page for V2 you might want to reuse the `product-general-section.tsx` file, as it works without having to make any modifications. In that case I propose that we create a `modules/product` folder and move the component in there which we can them import into both the v1 and v2 version of the route.
This commit is contained in:
+2
-1
@@ -1,7 +1,8 @@
|
||||
/// <reference types="vite/client" />
|
||||
// / <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly MEDUSA_ADMIN_BACKEND_URL: string
|
||||
readonly MEDUSA_V2: boolean
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
|
||||
Reference in New Issue
Block a user