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

List component in Ant-d resources not supported #6673

Open
Villva-vinoth opened this issue Feb 11, 2025 · 0 comments
Open

List component in Ant-d resources not supported #6673

Villva-vinoth opened this issue Feb 11, 2025 · 0 comments

Comments

@Villva-vinoth
Copy link

import {
useTranslate,
getDefaultFilter,
} from "@refinedev/core";
import {
CreateButton,
EditButton,
FilterDropdown,
List,
useTable,
} from "@refinedev/antd";
import { EyeOutlined, SearchOutlined } from "@ant-design/icons";
import { Table, Typography, theme, InputNumber, Input } from "antd";
import InputMask from "react-input-mask";
import type { ICourier } from "../../interfaces";
import {
PaginationTotal,
CourierStatus,
} from "../../components";
import type { PropsWithChildren } from "react";

export const CourierList = ({ children }: PropsWithChildren) => {

const t = useTranslate();
const { token } = theme.useToken();

const { tableProps, filters } = useTable({});

return (
<>
<List
breadcrumb={false}
headerButtons={(props) => [
<CreateButton
{...props.createButtonProps}
key="create"
size="large"
>
{t("couriers.actions.add")}
,
]}
>
<Table
{...tableProps}
rowKey="id"
scroll={{ x: true }}
pagination={{
...tableProps.pagination,
showTotal: (total) => (

),
}}
>
<Table.Column
title={
<Typography.Text
style={{
whiteSpace: "nowrap",
}}
>
ID #
</Typography.Text>
}
dataIndex="id"
key="id"
width={80}
render={(value) => (
<Typography.Text
style={{
whiteSpace: "nowrap",
}}
>
#{value}
</Typography.Text>
)}
filterIcon={(filtered) => (
<SearchOutlined
style={{
color: filtered ? token.colorPrimary : undefined,
}}
/>
)}
defaultFilteredValue={getDefaultFilter("id", filters, "eq")}
filterDropdown={(props) => (
<FilterDropdown {...props}>
<InputNumber
addonBefore="#"
style={{ width: "100%" }}
placeholder={t("products.filter.id.placeholder")}
/>

)}
/>

      <Table.Column<ICourier>
        key="name"
        dataIndex="name"
        title={t("couriers.fields.name.label")}
        filterIcon={(filtered) => (
          <SearchOutlined
            style={{
              color: filtered ? token.colorPrimary : undefined,
            }}
          />
        )}
        defaultFilteredValue={getDefaultFilter("name", filters, "contains")}
        filterDropdown={(props) => (
          <FilterDropdown {...props}>
            <Input placeholder={t("couriers.filter.name.placeholder")} />
          </FilterDropdown>
        )}
      />
     
      <Table.Column
        dataIndex="gsm"
        key="gsm"
        title={t("couriers.fields.gsm.label")}
        filterIcon={(filtered) => (
          <SearchOutlined
            style={{
              color: filtered ? token.colorPrimary : undefined,
            }}
          />
        )}
        defaultFilteredValue={getDefaultFilter("gsm", filters, "eq")}
        filterDropdown={(props) => (
          <FilterDropdown {...props}>
            <InputMask mask="(999) 999 99 99">
              {/* 
                          // eslint-disable-next-line @typescript-eslint/ban-ts-comment
                          // @ts-ignore */}
              {(props: InputProps) => <Input {...props} />}
            </InputMask>
          </FilterDropdown>
        )}
        render={(value) => (
          <Typography.Text
            style={{
              whiteSpace: "nowrap",
            }}
          >
            {value}
          </Typography.Text>
        )}
      />
      
      
      <Table.Column<ICourier>
        dataIndex="status"
        key="status"
        title={t("couriers.fields.status.label")}
        render={(_, record) => {
          return <CourierStatus value={record.status} />;
        }}
      />
      <Table.Column
        title={t("table.actions")}
        key="actions"
        fixed="right"
        align="center"
        render={(_, record: ICourier) => {
          return (
            <EditButton
              icon={<EyeOutlined />}
              hideText
              recordItemId={record.id}
            />
          );
        }}
      />
    </Table>
  </List>
  {children}
</>

);
};

Inside this List from ant-d
if i dont give resource it will take resource from routes
if i specify resource it does not work

when in the couriers list module
i given the resource ="stores" as a list props

it defaultly take routes - resources ,

but alternatively i passed useTable props
resource="stores"

it worked !

but any how inside the list component its not supported...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant