feat(dashboard): manage discounts conditions (#6620)
**What** - forms for managing discount conditions --- https://github.com/medusajs/medusa/assets/16856471/bb0b3fe8-fa60-479b-bc42-6db9d422bcdf Co-authored-by: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com>
This commit is contained in:
co-authored by
Kasper Fabricius Kristensen
parent
9288f53327
commit
a1b4aff127
+34
@@ -0,0 +1,34 @@
|
||||
import { CustomerGroup } from "@medusajs/medusa"
|
||||
import { createColumnHelper } from "@tanstack/react-table"
|
||||
import { useMemo } from "react"
|
||||
import { Text } from "@medusajs/ui"
|
||||
|
||||
import { NameHeader } from "../../../components/table/table-cells/common/name-cell"
|
||||
import {
|
||||
CreatedAtHeader,
|
||||
CreatedAtCell,
|
||||
} from "../../../components/table/table-cells/common/created-at-cell"
|
||||
|
||||
const columnHelper = createColumnHelper<CustomerGroup>()
|
||||
|
||||
export const useCustomerGroupTableColumns = () => {
|
||||
return useMemo(
|
||||
() => [
|
||||
columnHelper.display({
|
||||
id: "name",
|
||||
header: () => <NameHeader />,
|
||||
cell: ({
|
||||
row: {
|
||||
original: { name },
|
||||
},
|
||||
}) => <Text size="small">{name}</Text>,
|
||||
}),
|
||||
|
||||
columnHelper.accessor("created_at", {
|
||||
header: () => <CreatedAtHeader />,
|
||||
cell: ({ getValue }) => <CreatedAtCell date={getValue()} />,
|
||||
}),
|
||||
],
|
||||
[]
|
||||
)
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import { AdminGetCustomerGroupsParams } from "@medusajs/medusa"
|
||||
|
||||
import { useQueryParams } from "../../use-query-params"
|
||||
|
||||
type UseCustomerGroupTableQueryProps = {
|
||||
prefix?: string
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export const useCustomerGroupTableQuery = ({
|
||||
prefix,
|
||||
pageSize = 20,
|
||||
}: UseCustomerGroupTableQueryProps) => {
|
||||
const queryObject = useQueryParams(
|
||||
["offset", "q", "has_account", "order", "created_at", "updated_at"],
|
||||
prefix
|
||||
)
|
||||
|
||||
const { offset, created_at, updated_at, q, order } = queryObject
|
||||
|
||||
const searchParams: AdminGetCustomerGroupsParams = {
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user