-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(dashboard): admin locations v2 (#6868)
* initial create * add list for stock locations * add changeset * redo changes for stock locatino module' * add changeset * naming * prep for pr * move integration tests * fix pr feedback * add changeset * update changeset * init * undo versioning updates * rm whitespace * move common files to modules * Update packages/admin-next/dashboard/src/v2-routes/locations/location-edit/location-edit.tsx Co-authored-by: Adrien de Peretti <[email protected]> * rm logs * fields instead of expands --------- Co-authored-by: Riqwan Thamir <[email protected]> Co-authored-by: Adrien de Peretti <[email protected]>
- Loading branch information
1 parent
6c6e530
commit fd3fc13
Showing
25 changed files
with
176 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/admin-next/dashboard/src/routes/locations/location-create/location-create.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
packages/admin-next/dashboard/src/routes/locations/location-detail/location-detail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/admin-next/dashboard/src/routes/locations/location-edit/location-edit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/admin-next/dashboard/src/routes/locations/location-list/location-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/admin-next/dashboard/src/v2-routes/locations/location-add-sales-channels/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { LocationAddSalesChannels as Component } from "./location-add-sales-channels" |
8 changes: 8 additions & 0 deletions
8
...board/src/v2-routes/locations/location-add-sales-channels/location-add-sales-channels.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useAdminAddLocationToSalesChannel } from "medusa-react" | ||
import { RouteFocusModal } from "../../../components/route-modal" | ||
|
||
export const LocationAddSalesChannels = () => { | ||
const { mutateAsync } = useAdminAddLocationToSalesChannel() // TODO: We need a batch mutation instead of this to avoid multiple requests | ||
|
||
return <RouteFocusModal></RouteFocusModal> | ||
} |
1 change: 1 addition & 0 deletions
1
packages/admin-next/dashboard/src/v2-routes/locations/location-create/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { LocationCreate as Component } from "./location-create" |
10 changes: 10 additions & 0 deletions
10
packages/admin-next/dashboard/src/v2-routes/locations/location-create/location-create.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { CreateLocationForm } from "../../../modules/locations/location-create/components/create-location-form" | ||
import { RouteFocusModal } from "../../../components/route-modal" | ||
|
||
export const LocationCreate = () => { | ||
return ( | ||
<RouteFocusModal> | ||
<CreateLocationForm /> | ||
</RouteFocusModal> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/admin-next/dashboard/src/v2-routes/locations/location-detail/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { LocationDetail as Component } from "./location-detail" |
39 changes: 39 additions & 0 deletions
39
packages/admin-next/dashboard/src/v2-routes/locations/location-detail/location-detail.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Outlet, json, useParams } from "react-router-dom" | ||
|
||
import { JsonViewSection } from "../../../components/common/json-view-section" | ||
import { LocationGeneralSection } from "../../../modules/locations/location-detail/components/location-general-section" | ||
import { LocationSalesChannelSection } from "../../../modules/locations/location-detail/components/location-sales-channel-section" | ||
import { useAdminStockLocations } from "medusa-react" | ||
|
||
export const LocationDetail = () => { | ||
const { id } = useParams() | ||
const { stock_locations, isLoading, isError, error } = useAdminStockLocations( | ||
{ | ||
id, | ||
fields: "*address,*sales_channels", | ||
} | ||
) | ||
|
||
if (isLoading) { | ||
return <div>Loading...</div> | ||
} | ||
|
||
if (isError) { | ||
throw error | ||
} | ||
|
||
const stock_location = stock_locations?.[0] | ||
|
||
if (!stock_location) { | ||
throw json({ message: "Not found" }, 404) | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col gap-y-2"> | ||
<LocationGeneralSection location={stock_location} /> | ||
<LocationSalesChannelSection location={stock_location} /> | ||
<JsonViewSection data={stock_location} /> | ||
<Outlet /> | ||
</div> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/admin-next/dashboard/src/v2-routes/locations/location-edit/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { LocationEdit as Component } from "./location-edit" |
36 changes: 36 additions & 0 deletions
36
packages/admin-next/dashboard/src/v2-routes/locations/location-edit/location-edit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { EditLocationForm } from "../../../modules/locations/location-edit/components/edit-location-form/edit-location-form" | ||
import { Heading } from "@medusajs/ui" | ||
import { RouteDrawer } from "../../../components/route-modal" | ||
import { useAdminStockLocations } from "medusa-react" | ||
import { useParams } from "react-router-dom" | ||
import { useTranslation } from "react-i18next" | ||
|
||
export const LocationEdit = () => { | ||
const { id } = useParams() | ||
|
||
const { stock_locations, isLoading, isError, error } = useAdminStockLocations( | ||
{ | ||
id, | ||
expand: "address", | ||
} | ||
) | ||
|
||
const { t } = useTranslation() | ||
|
||
if (isError) { | ||
throw error | ||
} | ||
|
||
const stock_location = stock_locations?.[0] | ||
|
||
return ( | ||
<RouteDrawer> | ||
<RouteDrawer.Header> | ||
<Heading className="capitalize">{t("locations.editLocation")}</Heading> | ||
</RouteDrawer.Header> | ||
{!isLoading && !!stock_location && ( | ||
<EditLocationForm location={stock_location} /> | ||
)} | ||
</RouteDrawer> | ||
) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/admin-next/dashboard/src/v2-routes/locations/location-list/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { LocationList as Component } from "./location-list" |
11 changes: 11 additions & 0 deletions
11
packages/admin-next/dashboard/src/v2-routes/locations/location-list/location-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { LocationsListTable } from "../../../modules/locations/location-list/components/locations-list-table" | ||
import { Outlet } from "react-router-dom" | ||
|
||
export const LocationList = () => { | ||
return ( | ||
<div className="flex flex-col gap-y-2"> | ||
<LocationsListTable /> | ||
<Outlet /> | ||
</div> | ||
) | ||
} |