Skip to content

Commit

Permalink
Use 'queryParamsPrefix' in demo grids
Browse files Browse the repository at this point in the history
  • Loading branch information
andrearutrecht committed Nov 13, 2024
1 parent cf3989d commit ca292a7
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const ManufacturersGrid: GridConfig<GQLManufacturer> = {
type: "grid",
gqlType: "Manufacturer",
fragmentName: "ManufacturersGridFuture", // configurable as it must be unique across project
queryParamsPrefix: "manufacturers",
columns: [
{ type: "text", name: "id", headerName: "ID" },
{ type: "text", name: "name", headerName: "Name" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const ProductVariantsGrid: GridConfig<GQLProductVariant> = {
type: "grid",
gqlType: "ProductVariant",
fragmentName: "ProductVariantsGridFuture", // configurable as it must be unique across project
queryParamsPrefix: "product-variants",
columns: [
{ type: "text", name: "name", headerName: "Name" },
{ type: "date", name: "createdAt", headerName: "Created at" },
Expand Down
1 change: 1 addition & 0 deletions demo/admin/src/products/future/ProductsGrid.cometGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const ProductsGrid: GridConfig<GQLProduct> = {
toolbarActionProp: true,
rowActionProp: true,
excelExport: true,
queryParamsPrefix: "products",
initialSort: [
{ field: "inStock", sort: "desc" },
{ field: "price", sort: "asc" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ function ManufacturersGridToolbar() {
export function ManufacturersGrid(): React.ReactElement {
const client = useApolloClient();
const intl = useIntl();
const dataGridProps = { ...useDataGridRemote(), ...usePersistentColumnState("ManufacturersGrid") };
const dataGridProps = {
...useDataGridRemote({
queryParamsPrefix: "manufacturers",
}),
...usePersistentColumnState("ManufacturersGrid"),
};

const columns: GridColDef<GQLManufacturersGridFutureFragment>[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ type Props = {
export function ProductVariantsGrid({ product }: Props): React.ReactElement {
const client = useApolloClient();
const intl = useIntl();
const dataGridProps = { ...useDataGridRemote(), ...usePersistentColumnState("ProductVariantsGrid") };
const dataGridProps = {
...useDataGridRemote({
queryParamsPrefix: "product-variants",
}),
...usePersistentColumnState("ProductVariantsGrid"),
};

const columns: GridColDef<GQLProductVariantsGridFutureFragment>[] = [
{ field: "name", headerName: intl.formatMessage({ id: "productVariant.name", defaultMessage: "Name" }), flex: 1, minWidth: 150 },
Expand Down
1 change: 1 addition & 0 deletions demo/admin/src/products/future/generated/ProductsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export function ProductsGrid({ filter, toolbarAction, rowAction, actionsColumnWi
{ field: "inStock", sort: "desc" },
{ field: "price", sort: "asc" },
],
queryParamsPrefix: "products",
}),
...usePersistentColumnState("ProductsGrid"),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export function generateGrid(
.join(",\n")} ], `
: ""
}
${config.queryParamsPrefix ? `, queryParamsPrefix: "${config.queryParamsPrefix}",` : ""}
${config.queryParamsPrefix ? `queryParamsPrefix: "${config.queryParamsPrefix}",` : ""}
}`
: "";

Expand Down

0 comments on commit ca292a7

Please sign in to comment.