-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard,icons,types,js-sdk): add providers to location UI (#8328)
- Loading branch information
Showing
22 changed files
with
609 additions
and
96 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
25 changes: 25 additions & 0 deletions
25
...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,25 @@ | ||
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" | ||
import { formatProvider } from "../../../lib/format-provider" | ||
|
||
const columnHelper = createColumnHelper<HttpTypes.AdminFulfillmentProvider>() | ||
|
||
export const useFulfillmentProviderTableColumns = () => { | ||
const { t } = useTranslation() | ||
|
||
return useMemo( | ||
() => [ | ||
columnHelper.accessor("id", { | ||
header: () => <TextHeader text={"Provider"} />, | ||
cell: ({ getValue }) => <TextCell text={formatProvider(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" |
79 changes: 79 additions & 0 deletions
79
...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,79 @@ | ||
import { HandTruck, PencilSquare } from "@medusajs/icons" | ||
import { HttpTypes } from "@medusajs/types" | ||
import { Container, Heading } 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 { useFulfillmentProviders } from "../../../../../hooks/api" | ||
import { formatProvider } from "../../../../../lib/format-provider" | ||
|
||
type LocationsFulfillmentProvidersSectionProps = { | ||
location: HttpTypes.AdminStockLocation | ||
} | ||
|
||
function LocationsFulfillmentProvidersSection({ | ||
location, | ||
}: LocationsFulfillmentProvidersSectionProps) { | ||
const { t } = useTranslation() | ||
const { fulfillment_providers } = useFulfillmentProviders({ | ||
stock_location_id: location.id, | ||
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> | ||
|
||
{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 gap-y-3"> | ||
{fulfillment_providers?.map((fulfillmentProvider) => { | ||
return ( | ||
<> | ||
<IconAvatar> | ||
<HandTruck className="text-ui-fg-subtle" /> | ||
</IconAvatar> | ||
|
||
<div className="txt-compact-small"> | ||
{formatProvider(fulfillmentProvider.id)} | ||
</div> | ||
</> | ||
) | ||
})} | ||
</div> | ||
</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.