Organize directories
This commit is contained in:
parent
8a91c9b89b
commit
4898382f78
433 changed files with 0 additions and 0 deletions
59
apps/metamigo-frontend/components/accounts/AccountEdit.tsx
Normal file
59
apps/metamigo-frontend/components/accounts/AccountEdit.tsx
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import { FC } from "react";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import {
|
||||
SimpleForm,
|
||||
TextInput,
|
||||
Edit,
|
||||
ReferenceInput,
|
||||
SelectInput,
|
||||
DateInput,
|
||||
Toolbar,
|
||||
DeleteButton,
|
||||
EditProps,
|
||||
} from "react-admin";
|
||||
import { useSession } from "next-auth/react";
|
||||
|
||||
const useStyles = makeStyles((_theme) => ({
|
||||
defaultToolbar: {
|
||||
flex: 1,
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
},
|
||||
}));
|
||||
|
||||
type AccountEditToolbarProps = {
|
||||
record?: any;
|
||||
};
|
||||
|
||||
const AccountEditToolbar: FC<AccountEditToolbarProps> = (props) => {
|
||||
const { data: session } = useSession();
|
||||
const classes = useStyles(props);
|
||||
return (
|
||||
<Toolbar className={classes.defaultToolbar} {...props}>
|
||||
<DeleteButton disabled={session?.user?.email === props.record?.userId} />
|
||||
</Toolbar>
|
||||
);
|
||||
};
|
||||
|
||||
const AccountTitle = ({ record }: { record?: any }) => {
|
||||
let title = "";
|
||||
if (record) title = record.name ? record.name : record.email;
|
||||
return <span>Account {title}</span>;
|
||||
};
|
||||
|
||||
export const AccountEdit = (props: EditProps) => (
|
||||
<Edit title={<AccountTitle />} {...props}>
|
||||
<SimpleForm toolbar={<AccountEditToolbar />}>
|
||||
<TextInput disabled source="id" />
|
||||
<ReferenceInput source="userId" reference="users">
|
||||
<SelectInput disabled optionText="email" />
|
||||
</ReferenceInput>
|
||||
<TextInput disabled source="providerType" />
|
||||
<TextInput disabled source="providerId" />
|
||||
<TextInput disabled source="providerAccountId" />
|
||||
<DateInput disabled source="createdAt" />
|
||||
<DateInput disabled source="updatedAt" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
export default AccountEdit;
|
||||
43
apps/metamigo-frontend/components/accounts/AccountList.tsx
Normal file
43
apps/metamigo-frontend/components/accounts/AccountList.tsx
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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;
|
||||
};
|
||||
|
||||
const DeleteNotSelfButton: FC<DeleteNotSelfButtonProps> = (props) => {
|
||||
const { data: session } = useSession();
|
||||
return (
|
||||
<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;
|
||||
10
apps/metamigo-frontend/components/accounts/index.ts
Normal file
10
apps/metamigo-frontend/components/accounts/index.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import AccountIcon from "@material-ui/icons/AccountTree";
|
||||
import AccountList from "./AccountList";
|
||||
import AccountEdit from "./AccountEdit";
|
||||
|
||||
// eslint-disable-next-line import/no-anonymous-default-export
|
||||
export default {
|
||||
list: AccountList,
|
||||
edit: AccountEdit,
|
||||
icon: AccountIcon,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue