-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dashboard,icons,types,js-sdk): add providers to location UI #8328
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
691b8fe
feat(dashboard,icons,types,js-sdk): add providers to location UI
riqwan b1ed309
Merge branch 'develop' into feat/fulfillment-providers-ui
riqwan da49837
chore: address review comments
riqwan cbe1165
chore: scope results on create an dupdate shipping options
riqwan 3503e84
Merge branch 'develop' into feat/fulfillment-providers-ui
riqwan e5452d0
Merge branch 'develop' into feat/fulfillment-providers-ui
riqwan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 24 additions & 0 deletions
24
...s/admin-next/dashboard/src/hooks/table/columns/use-fulfillment-provider-table-columns.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,24 @@ | ||
import { HttpTypes } from "@medusajs/types" | ||
import { createColumnHelper } from "@tanstack/react-table" | ||
import { useMemo } from "react" | ||
import { useTranslation } from "react-i18next" | ||
import { | ||
TextCell, | ||
TextHeader, | ||
} from "../../../components/table/table-cells/common/text-cell" | ||
|
||
const columnHelper = createColumnHelper<HttpTypes.AdminFulfillmentProvider>() | ||
|
||
export const useFulfillmentProviderTableColumns = () => { | ||
const { t } = useTranslation() | ||
|
||
return useMemo( | ||
() => [ | ||
columnHelper.accessor("id", { | ||
header: () => <TextHeader text={"Provider"} />, | ||
cell: ({ getValue }) => <TextCell text={getValue()} />, | ||
}), | ||
], | ||
[t] | ||
) | ||
} |
31 changes: 31 additions & 0 deletions
31
...ages/admin-next/dashboard/src/hooks/table/query/use-fulfillment-providers-table-query.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,31 @@ | ||
import { HttpTypes } from "@medusajs/types" | ||
import { useQueryParams } from "../../use-query-params" | ||
|
||
type UseFulfillmentProviderTableQueryProps = { | ||
prefix?: string | ||
pageSize?: number | ||
} | ||
|
||
export const useFulfillmentProvidersTableQuery = ({ | ||
prefix, | ||
pageSize = 20, | ||
}: UseFulfillmentProviderTableQueryProps) => { | ||
const queryObject = useQueryParams( | ||
["offset", "q", "stock_location_id"], | ||
prefix | ||
) | ||
|
||
const { offset, q, stock_location_id } = queryObject | ||
|
||
const searchParams: HttpTypes.AdminFulfillmentProviderListParams = { | ||
limit: pageSize, | ||
offset: offset ? Number(offset) : 0, | ||
stock_location_id, | ||
q, | ||
} | ||
|
||
return { | ||
searchParams, | ||
raw: queryObject, | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
...utes/locations/location-detail/components/location-fulfillment-providers-section/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 * from "./location-fulfillment-providers-section" |
83 changes: 83 additions & 0 deletions
83
...ponents/location-fulfillment-providers-section/location-fulfillment-providers-section.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,83 @@ | ||
import { HandTruck, PencilSquare } from "@medusajs/icons" | ||
import { HttpTypes } from "@medusajs/types" | ||
import { Container, Heading, Text } from "@medusajs/ui" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import { ActionMenu } from "../../../../../components/common/action-menu" | ||
import { NoRecords } from "../../../../../components/common/empty-table-content" | ||
import { IconAvatar } from "../../../../../components/common/icon-avatar" | ||
import { ListSummary } from "../../../../../components/common/list-summary" | ||
import { useFulfillmentProviders } from "../../../../../hooks/api" | ||
|
||
type LocationsFulfillmentProvidersSectionProps = { | ||
location: HttpTypes.AdminStockLocation | ||
} | ||
|
||
function LocationsFulfillmentProvidersSection({ | ||
location, | ||
}: LocationsFulfillmentProvidersSectionProps) { | ||
const { t } = useTranslation() | ||
const { count } = useFulfillmentProviders({ | ||
limit: 1, | ||
fields: "id", | ||
}) | ||
|
||
return ( | ||
<Container className="flex flex-col px-6 py-4"> | ||
<div className="flex items-center justify-between"> | ||
<Heading level="h2"> | ||
{t("stockLocations.fulfillmentProviders.header")} | ||
</Heading> | ||
|
||
<ActionMenu | ||
groups={[ | ||
{ | ||
actions: [ | ||
{ | ||
label: t("actions.edit"), | ||
to: "fulfillment-providers", | ||
icon: <PencilSquare />, | ||
}, | ||
], | ||
}, | ||
]} | ||
/> | ||
</div> | ||
|
||
{location?.fulfillment_providers?.length ? ( | ||
<div className="flex flex-col gap-y-4 pt-4"> | ||
<div className="grid grid-cols-[28px_1fr] items-center gap-x-3"> | ||
<IconAvatar> | ||
<HandTruck className="text-ui-fg-subtle" /> | ||
</IconAvatar> | ||
|
||
<ListSummary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: should the "+1 more" be displayed inline without spacing in between and right alignment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a comment below that changes this whole thing. |
||
n={2} | ||
className="text-ui-fg-base" | ||
inline | ||
list={location?.fulfillment_providers?.map((fp) => fp.id) ?? []} | ||
/> | ||
</div> | ||
|
||
<Text className="text-ui-fg-subtle" size="small" leading="compact"> | ||
{t("stockLocations.fulfillmentProviders.connectedTo", { | ||
count: location?.fulfillment_providers?.length, | ||
total: count, | ||
})} | ||
</Text> | ||
</div> | ||
) : ( | ||
<NoRecords | ||
className="h-fit pb-2 pt-6 text-center" | ||
action={{ | ||
label: t("stockLocations.fulfillmentProviders.action"), | ||
to: "fulfillment-providers", | ||
}} | ||
message={t("stockLocations.fulfillmentProviders.noProviders")} | ||
/> | ||
)} | ||
</Container> | ||
) | ||
} | ||
|
||
export default LocationsFulfillmentProvidersSection |
2 changes: 1 addition & 1 deletion
2
packages/admin-next/dashboard/src/routes/locations/location-detail/const.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export const detailsFields = | ||
"name,*sales_channels,*address,fulfillment_sets.type,fulfillment_sets.name,*fulfillment_sets.service_zones.geo_zones,*fulfillment_sets.service_zones,*fulfillment_sets.service_zones.shipping_options,*fulfillment_sets.service_zones.shipping_options.rules,*fulfillment_sets.service_zones.shipping_options.shipping_profile" | ||
"name,*sales_channels,*address,fulfillment_sets.type,fulfillment_sets.name,*fulfillment_sets.service_zones.geo_zones,*fulfillment_sets.service_zones,*fulfillment_sets.service_zones.shipping_options,*fulfillment_sets.service_zones.shipping_options.rules,*fulfillment_sets.service_zones.shipping_options.shipping_profile,*fulfillment_providers" |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: think we can skip invalidating the lists key for this one