feat(dashboard, js-sdk): shipping option type mngmt dashboard (#13208)

* chore(types, api): support shipping option type api endpoints

* core flows

* api

* typos

* compiler errors

* integration tests

* remove metadata

* changeset

* modify test

* upsert

* change remote query

* minor to patch

* description optional

* chore(dashboard, js-sdk): shipping option type management on admin dashboard

* description optional

* woops my bad

* my bad again

* create and edit

* prettier

* build code from label

* remove metadata route

* remove some translation text that is not used

* remove unsued files

* changeset

* adapt test

* fix test

* suggestion

---------

Co-authored-by: william bouchard <williambouchard@williams-MacBook-Pro.local>
This commit is contained in:
William Bouchard
2025-08-14 15:21:33 -04:00
committed by GitHub
parent 257e71f988
commit 4b3c43fe92
36 changed files with 1344 additions and 5 deletions

View File

@@ -0,0 +1,44 @@
import { HttpTypes } from "@medusajs/types"
import { createColumnHelper } from "@tanstack/react-table"
import { useMemo } from "react"
import { useTranslation } from "react-i18next"
import { DateCell } from "../../../components/table/table-cells/common/date-cell"
import { TextCell } from "../../../components/table/table-cells/common/text-cell"
const columnHelper = createColumnHelper<HttpTypes.AdminShippingOptionType>()
export const useShippingOptionTypeTableColumns = () => {
const { t } = useTranslation()
return useMemo(
() => [
columnHelper.accessor("label", {
header: () => t("fields.label"),
cell: ({ getValue }) => <TextCell text={getValue()} />,
}),
columnHelper.accessor("code", {
header: () => t("fields.code"),
cell: ({ getValue }) => <TextCell text={getValue()} />,
}),
columnHelper.accessor("description", {
header: () => t("fields.description"),
cell: ({ getValue }) => <TextCell text={getValue()} />,
}),
columnHelper.accessor("created_at", {
header: () => t("fields.createdAt"),
cell: ({ getValue }) => {
return <DateCell date={getValue()} />
},
}),
columnHelper.accessor("updated_at", {
header: () => t("fields.updatedAt"),
cell: ({ getValue }) => {
return <DateCell date={getValue()} />
},
}),
],
[t]
)
}

View File

@@ -0,0 +1,5 @@
import { useDateTableFilters } from "./use-date-table-filters"
export const useShippingOptionTypeTableFilters = () => {
return useDateTableFilters()
}

View File

@@ -0,0 +1,32 @@
import { HttpTypes } from "@medusajs/types"
import { useQueryParams } from "../../use-query-params"
type UseShippingOptionTypeTableQueryProps = {
prefix?: string
pageSize?: number
}
export const useShippingOptionTypeTableQuery = ({
prefix,
pageSize = 20,
}: UseShippingOptionTypeTableQueryProps) => {
const queryObject = useQueryParams(
["offset", "q", "order", "created_at", "updated_at"],
prefix
)
const { offset, q, order, created_at, updated_at } = queryObject
const searchParams: HttpTypes.AdminShippingOptionTypeListParams = {
limit: pageSize,
offset: offset ? Number(offset) : 0,
order,
created_at: created_at ? JSON.parse(created_at) : undefined,
updated_at: updated_at ? JSON.parse(updated_at) : undefined,
q,
}
return {
searchParams,
raw: queryObject,
}
}