Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

revert company list

Jean-Baptiste Kaisera4d58ba98a05
diff --git a/src/components/atomic-crm/companies/CompanyList.tsx b/src/components/atomic-crm/companies/CompanyList.tsx
index 7e2a8664..fb0d1ce9 100644
--- a/src/components/atomic-crm/companies/CompanyList.tsx
+++ b/src/components/atomic-crm/companies/CompanyList.tsx
@@ -1,29 +1,18 @@
+import { useGetIdentity, useListContext } from "ra-core";
import { CreateButton } from "@/components/admin/create-button";
import { ExportButton } from "@/components/admin/export-button";
import { List } from "@/components/admin/list";
import { ListPagination } from "@/components/admin/list-pagination";
import { SortButton } from "@/components/admin/sort-button";
-import { InfiniteListBase, useGetIdentity, useListContext } from "ra-core";
-import { useIsMobile } from "@/hooks/use-mobile";
-import { MobileContent } from "../layout/MobileContent";
-import MobileHeader from "../layout/MobileHeader";
import { TopToolbar } from "../layout/TopToolbar";
-import { InfinitePagination } from "../misc/InfinitePagination";
import { CompanyEmpty } from "./CompanyEmpty";
import { CompanyListFilter } from "./CompanyListFilter";
import { ImageList } from "./GridList";
export const CompanyList = () => {
- const isMobile = useIsMobile();
- return isMobile ? <CompanyListMobile /> : <CompanyListDesktop />;
-};
-
-const CompanyListDesktop = () => {
const { identity } = useGetIdentity();
-
if (!identity) return null;
-
return (
<List
title={false}
@@ -32,24 +21,12 @@ const CompanyListDesktop = () => {
actions={<CompanyListActions />}
pagination={<ListPagination rowsPerPageOptions={[10, 25, 50, 100]} />}
>
- <DesktopCompanyListLayout />
+ <CompanyListLayout />
</List>
);
};
-const CompanyListMobile = () => {
- const { identity } = useGetIdentity();
-
- if (!identity) return null;
-
- return (
- <InfiniteListBase perPage={25} sort={{ field: "name", order: "ASC" }}>
- <MobileCompanyListLayout />
- </InfiniteListBase>
- );
-};
-
-const DesktopCompanyListLayout = () => {
+const CompanyListLayout = () => {
const { data, isPending, filterValues } = useListContext();
const hasFilters = filterValues && Object.keys(filterValues).length > 0;
@@ -66,30 +43,6 @@ const DesktopCompanyListLayout = () => {
);
};
-const MobileCompanyListLayout = () => {
- const { data, isPending, filterValues } = useListContext();
-
- const hasFilters = filterValues && Object.keys(filterValues).length > 0;
-
- if (isPending) return null;
-
- if (!data?.length && !hasFilters) return <CompanyEmpty />;
-
- return (
- <div>
- <MobileHeader>
- <CompanyListFilter />
- </MobileHeader>
- <MobileContent>
- <ImageList />
- <div className="flex justify-center">
- <InfinitePagination />
- </div>
- </MobileContent>
- </div>
- );
-};
-
const CompanyListActions = () => {
return (
<TopToolbar>
diff --git a/src/components/atomic-crm/companies/CompanyListFilter.tsx b/src/components/atomic-crm/companies/CompanyListFilter.tsx
index b3140bcf..f5275b00 100644
--- a/src/components/atomic-crm/companies/CompanyListFilter.tsx
+++ b/src/components/atomic-crm/companies/CompanyListFilter.tsx
@@ -1,9 +1,9 @@
-import { ToggleFilterButton } from "@/components/admin/toggle-filter-button";
import { Building, Truck, Users } from "lucide-react";
-import { useGetIdentity } from "ra-core";
+import { FilterLiveForm, useGetIdentity } from "ra-core";
+import { ToggleFilterButton } from "@/components/admin/toggle-filter-button";
+import { SearchInput } from "@/components/admin/search-input";
import { FilterCategory } from "../filters/FilterCategory";
-import { ResponsiveFilters } from "../misc/ResponsiveFilters";
import { useConfigurationContext } from "../root/ConfigurationContext";
import { sizes } from "./sizes";
@@ -15,13 +15,17 @@ export const CompanyListFilter = () => {
name: sector,
}));
return (
- <ResponsiveFilters>
+ <div className="w-52 min-w-52 flex flex-col gap-8">
+ <FilterLiveForm>
+ <SearchInput source="q" />
+ </FilterLiveForm>
+
<FilterCategory icon={<Building className="h-4 w-4" />} label="Size">
{sizes.map((size) => (
<ToggleFilterButton
- key={size.id}
className="w-full justify-between"
label={size.name}
+ key={size.name}
value={{ size: size.id }}
/>
))}
@@ -30,9 +34,9 @@ export const CompanyListFilter = () => {
<FilterCategory icon={<Truck className="h-4 w-4" />} label="Sector">
{sectors.map((sector) => (
<ToggleFilterButton
- key={sector.id}
className="w-full justify-between"
label={sector.name}
+ key={sector.name}
value={{ sector: sector.id }}
/>
))}
@@ -48,6 +52,6 @@ export const CompanyListFilter = () => {
value={{ sales_id: identity?.id }}
/>
</FilterCategory>
- </ResponsiveFilters>
+ </div>
);
};