2023-06-28 12:55:24 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2023-02-13 12:41:30 +00:00
|
|
|
import { FC } from "react";
|
|
|
|
|
import {
|
|
|
|
|
List,
|
|
|
|
|
Datagrid,
|
|
|
|
|
DateField,
|
|
|
|
|
TextField,
|
|
|
|
|
ReferenceField,
|
|
|
|
|
DeleteButton,
|
|
|
|
|
ListProps,
|
|
|
|
|
} from "react-admin";
|
|
|
|
|
import { useSession } from "next-auth/react";
|
|
|
|
|
|
|
|
|
|
type DeleteNotSelfButtonProps = {
|
|
|
|
|
record?: any;
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-14 17:40:24 +00:00
|
|
|
const DeleteNotSelfButton: FC<DeleteNotSelfButtonProps> = (props: any) => {
|
2023-02-13 12:41:30 +00:00
|
|
|
const { data: session } = useSession();
|
|
|
|
|
return (
|
2023-03-14 17:40:24 +00:00
|
|
|
// @ts-ignore
|
2023-02-13 12:41:30 +00:00
|
|
|
<DeleteButton
|
|
|
|
|
disabled={session?.user?.email === props.record.userId}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const AccountList = (props: ListProps) => (
|
|
|
|
|
<List {...props} exporter={false}>
|
|
|
|
|
<Datagrid rowClick="edit">
|
|
|
|
|
<ReferenceField source="userId" reference="users">
|
|
|
|
|
<TextField source="email" />
|
|
|
|
|
</ReferenceField>
|
|
|
|
|
<TextField source="providerType" />
|
|
|
|
|
<TextField source="providerId" />
|
|
|
|
|
<TextField source="providerAccountId" />
|
|
|
|
|
<DateField source="createdAt" />
|
|
|
|
|
<DateField source="updatedAt" />
|
|
|
|
|
<DeleteNotSelfButton />
|
|
|
|
|
</Datagrid>
|
|
|
|
|
</List>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export default AccountList;
|