From 9f934b5ab8c2209c6760e4388a6e0592e9dd41c2 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 27 Feb 2022 11:04:57 -0500 Subject: [PATCH] Break table rows into own component --- .../components/admin/users/UserTableRow.tsx | 80 +++++++++++++++ .../admin/users/UsersContainerV2.tsx | 97 +++---------------- 2 files changed, 94 insertions(+), 83 deletions(-) create mode 100644 resources/scripts/components/admin/users/UserTableRow.tsx diff --git a/resources/scripts/components/admin/users/UserTableRow.tsx b/resources/scripts/components/admin/users/UserTableRow.tsx new file mode 100644 index 000000000..62d036a5c --- /dev/null +++ b/resources/scripts/components/admin/users/UserTableRow.tsx @@ -0,0 +1,80 @@ +import { Checkbox } from '@/components/elements/inputs'; +import { Dropdown } from '@/components/elements/dropdown'; +import { BanIcon, DotsVerticalIcon, LockOpenIcon, PencilIcon, SupportIcon, TrashIcon } from '@heroicons/react/solid'; +import React, { useState } from 'react'; +import { User } from '@/api/admin/user'; +import { Dialog } from '@/components/elements/dialog'; +import { Button } from '@/components/elements/button/index'; + +interface Props { + user: User; +} + +const UserTableRow = ({ user }: Props) => { + const [ visible, setVisible ] = useState(false); + + return ( + <> + setVisible(false)}> + + This account will be permanently deleted. + + setVisible(false)} + > + Cancel + + Delete + + + + +
+ +
+ + +
+
+ {'User +
+
+

+ {user.email} +

+

+ {user.uuid} +

+
+
+ + + {user.isUsingTwoFactor && + + 2-FA Enabled + + } + + + + + + + }>Edit + }>Reset Password + } disabled={!user.isUsingTwoFactor}> + Disable 2-FA + + }>Suspend + + } onClick={() => setVisible(true)} danger>Delete + Account + + + + + + ); +}; + +export default UserTableRow; diff --git a/resources/scripts/components/admin/users/UsersContainerV2.tsx b/resources/scripts/components/admin/users/UsersContainerV2.tsx index 96f57feca..f037fc9df 100644 --- a/resources/scripts/components/admin/users/UsersContainerV2.tsx +++ b/resources/scripts/components/admin/users/UsersContainerV2.tsx @@ -2,19 +2,10 @@ import React, { useEffect, useState } from 'react'; import http from '@/api/http'; import { User } from '@/api/admin/user'; import { AdminTransformers } from '@/api/admin/transformers'; -import { Dropdown } from '@/components/elements/dropdown'; -import { - BanIcon, - DotsVerticalIcon, - LockOpenIcon, - PencilIcon, - PlusIcon, - SupportIcon, - TrashIcon, -} from '@heroicons/react/solid'; +import { LockOpenIcon, PlusIcon, SupportIcon, TrashIcon } from '@heroicons/react/solid'; import { Button } from '@/components/elements/button/index'; -import { Dialog } from '@/components/elements/dialog'; import { Checkbox, InputField } from '@/components/elements/inputs'; +import UserTableRow from '@/components/admin/users/UserTableRow'; const UsersContainerV2 = () => { const [ users, setUsers ] = useState([]); @@ -22,8 +13,6 @@ const UsersContainerV2 = () => { document.title = 'Admin | Users'; }, []); - const [ visible, setVisible ] = useState(false); - useEffect(() => { http.get('/api/application/users') .then(({ data }) => { @@ -39,37 +28,30 @@ const UsersContainerV2 = () => { Add User - setVisible(false)}> - - This account will be permanently deleted. - - setVisible(false)} - > - Cancel - - Delete - -
- +
- +
- +
- + - + - +
@@ -83,58 +65,7 @@ const UsersContainerV2 = () => { - {users.map(user => ( - - -
- -
- - -
-
- {'User -
-
-

- {user.email} -

-

- {user.uuid} -

-
-
- - - {user.isUsingTwoFactor && - - 2-FA Enabled - - } - - - - - - - }>Edit - }>Reset Password - } disabled={!user.isUsingTwoFactor}> - Disable 2-FA - - }>Suspend - - } onClick={() => setVisible(true)} danger>Delete - Account - - - - - ))} + {users.map(user => )}