Skip to content
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

refactor(admin-ui): Use generics in ReactDataTableComponentProps #2500

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ React components will receive the value of the current column as the `rowItem` p
import { ReactDataTableComponentProps } from '@vendure/admin-ui/react';
import React from 'react';

export function SlugLink({ rowItem }: ReactDataTableComponentProps) {
const slug: string = rowItem.slug;
export function SlugLink({ rowItem }: ReactDataTableComponentProps<{ slug: string }>) {
const slug = rowItem.slug;
return (
<a href={`https://example.com/category/${slug}`} target="_blank">
{slug}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ e.g. the `Product` object if used in the `product-list` table.
import { ReactDataTableComponentProps } from '@vendure/admin-ui/react';
import React from 'react';

export function SlugWithLink({ rowItem }: ReactDataTableComponentProps) {
export function SlugWithLink({ rowItem }: ReactDataTableComponentProps<{ slug: string }>) {
return (
<a href={`https://example.com/products/${rowItem.slug}`} target="_blank">
{rowItem.slug}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export interface ReactDataTableComponentConfig {
* @description
* The props that will be passed to the React component registered via {@link registerReactDataTableComponent}.
*/
export interface ReactDataTableComponentProps {
rowItem: any;
export interface ReactDataTableComponentProps<T = any> {
rowItem: T;
[prop: string]: any;
}

Expand All @@ -60,7 +60,7 @@ export interface ReactDataTableComponentProps {
* import { ReactDataTableComponentProps } from '\@vendure/admin-ui/react';
* import React from 'react';
*
* export function SlugWithLink({ rowItem }: ReactDataTableComponentProps) {
* export function SlugWithLink({ rowItem }: ReactDataTableComponentProps<{ slug: string }>) {
* return (
* <a href={`https://example.com/products/${rowItem.slug}`} target="_blank">
* {rowItem.slug}
Expand All @@ -79,7 +79,7 @@ export interface ReactDataTableComponentProps {
* tableId: 'product-list',
* columnId: 'slug',
* props: {
* foo: 'bar',
* foo: 'bar',
* },
* }),
* ];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ReactDataTableComponentProps } from '@vendure/admin-ui/react';
import React from 'react';

export function SlugWithLink({ rowItem }: ReactDataTableComponentProps) {
const slug: string = rowItem.slug;
export function SlugWithLink({ rowItem }: ReactDataTableComponentProps<{ slug: string }>) {
const slug = rowItem.slug;
return (
<a href={`https://example.com/category/${slug}`} target="_blank">
{slug}
Expand Down
Loading