Skip to content

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

Improve sales list UI

François Zaninottoa1f3732ae30f
diff --git a/src/sales/SalesList.tsx b/src/sales/SalesList.tsx
index df73644d..c1ab0909 100644
--- a/src/sales/SalesList.tsx
+++ b/src/sales/SalesList.tsx
@@ -1,6 +1,5 @@
-import Stack from '@mui/material/Stack';
+import { Chip, Stack } from '@mui/material';
import {
- BooleanField,
CreateButton,
DatagridConfigurable,
ExportButton,
@@ -9,20 +8,44 @@ import {
TextField,
TopToolbar,
usePermissions,
+ useRecordContext,
} from 'react-admin';
import { Navigate } from 'react-router';
-function SalesListActions() {
- return (
- <TopToolbar>
- <ExportButton />
- <CreateButton variant="contained" label="New user" />
- </TopToolbar>
- );
-}
+const SalesListActions = () => (
+ <TopToolbar>
+ <ExportButton />
+ <CreateButton variant="contained" label="New user" />
+ </TopToolbar>
+);
const filters = [<SearchInput source="q" alwaysOn />];
+const OptionsField = (_props: { label?: string | boolean }) => {
+ const record = useRecordContext();
+ if (!record) return null;
+ return (
+ <Stack direction="row" gap={1}>
+ {record.administrator && (
+ <Chip
+ label="Admin"
+ size="small"
+ variant="outlined"
+ color="primary"
+ />
+ )}
+ {record.disabled && (
+ <Chip
+ label="Disabled"
+ size="small"
+ variant="outlined"
+ color="warning"
+ />
+ )}
+ </Stack>
+ );
+};
+
export function SalesList() {
const { isPending, permissions } = usePermissions();
if (isPending) {
@@ -44,8 +67,7 @@ export function SalesList() {
<TextField source="first_name" />
<TextField source="last_name" />
<TextField source="email" />
- <BooleanField source="administrator" FalseIcon={null} />
- <BooleanField source="disabled" FalseIcon={null} />
+ <OptionsField label={false} />
</DatagridConfigurable>
</List>
</Stack>