From b43552c5eb6f1d7cfe9ba56cd639aea300f3957c Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Mon, 12 Sep 2022 14:47:57 +0200 Subject: [PATCH] remove stuff --- .env.example | 1 - src/components/UserModal/UserModal.tsx | 277 ------------------ src/components/UserModal/consts.ts | 64 ---- src/components/UserModal/index.ts | 1 - src/components/UserModal/types.ts | 6 - src/components/index.ts | 1 - src/index.tsx | 45 +-- src/modules/dashboard/AppIframe.tsx | 2 +- .../DashboardCard/DashboardCard.tsx | 50 ++-- src/modules/index.ts | 2 - src/modules/login/Login.tsx | 47 --- src/modules/login/LoginCallback.tsx | 58 ---- src/modules/login/index.ts | 1 - src/modules/users/Users.tsx | 186 ------------ .../MultipleUsersModal/MultipleUsersModal.tsx | 248 ---------------- .../components/MultipleUsersModal/index.ts | 1 - .../components/MultipleUsersModal/types.ts | 10 - src/modules/users/components/index.ts | 1 - src/modules/users/index.ts | 1 - src/redux/index.ts | 2 - src/redux/store.ts | 35 --- src/redux/types.ts | 11 - src/services/api/apiCall.ts | 42 --- src/services/api/config.ts | 3 - src/services/api/index.ts | 5 - src/services/api/redux/actions.ts | 186 ------------ src/services/api/redux/index.ts | 14 - src/services/api/redux/reducers.ts | 176 ----------- src/services/api/redux/traits.ts | 29 -- src/services/api/redux/types.ts | 29 -- src/services/api/types.ts | 29 -- src/services/auth/api.ts | 42 --- src/services/auth/hooks/index.ts | 1 - src/services/auth/hooks/use-auth.ts | 29 -- src/services/auth/index.ts | 3 - src/services/auth/redux/actions.ts | 32 -- src/services/auth/redux/index.ts | 4 - src/services/auth/redux/reducers.ts | 47 --- src/services/auth/redux/selectors.ts | 28 -- src/services/auth/redux/types.ts | 7 - src/services/auth/transformations.ts | 21 -- src/services/auth/types.ts | 6 - src/services/users/api.ts | 11 - src/services/users/hooks/index.ts | 1 - src/services/users/hooks/use-users.ts | 74 ----- src/services/users/index.ts | 7 - src/services/users/redux/actions.ts | 255 ---------------- src/services/users/redux/index.ts | 4 - src/services/users/redux/reducers.ts | 46 --- src/services/users/redux/selectors.ts | 6 - src/services/users/redux/types.ts | 26 -- src/services/users/transformations.ts | 93 ------ src/services/users/types.ts | 36 --- 53 files changed, 26 insertions(+), 2316 deletions(-) delete mode 100644 src/components/UserModal/UserModal.tsx delete mode 100644 src/components/UserModal/consts.ts delete mode 100644 src/components/UserModal/index.ts delete mode 100644 src/components/UserModal/types.ts delete mode 100644 src/modules/login/Login.tsx delete mode 100644 src/modules/login/LoginCallback.tsx delete mode 100644 src/modules/login/index.ts delete mode 100644 src/modules/users/Users.tsx delete mode 100644 src/modules/users/components/MultipleUsersModal/MultipleUsersModal.tsx delete mode 100644 src/modules/users/components/MultipleUsersModal/index.ts delete mode 100644 src/modules/users/components/MultipleUsersModal/types.ts delete mode 100644 src/modules/users/components/index.ts delete mode 100644 src/modules/users/index.ts delete mode 100644 src/redux/index.ts delete mode 100644 src/redux/store.ts delete mode 100644 src/redux/types.ts delete mode 100644 src/services/api/apiCall.ts delete mode 100644 src/services/api/config.ts delete mode 100644 src/services/api/index.ts delete mode 100644 src/services/api/redux/actions.ts delete mode 100644 src/services/api/redux/index.ts delete mode 100644 src/services/api/redux/reducers.ts delete mode 100644 src/services/api/redux/traits.ts delete mode 100644 src/services/api/redux/types.ts delete mode 100644 src/services/api/types.ts delete mode 100644 src/services/auth/api.ts delete mode 100644 src/services/auth/hooks/index.ts delete mode 100644 src/services/auth/hooks/use-auth.ts delete mode 100644 src/services/auth/index.ts delete mode 100644 src/services/auth/redux/actions.ts delete mode 100644 src/services/auth/redux/index.ts delete mode 100644 src/services/auth/redux/reducers.ts delete mode 100644 src/services/auth/redux/selectors.ts delete mode 100644 src/services/auth/redux/types.ts delete mode 100644 src/services/auth/transformations.ts delete mode 100644 src/services/auth/types.ts delete mode 100644 src/services/users/api.ts delete mode 100644 src/services/users/hooks/index.ts delete mode 100644 src/services/users/hooks/use-users.ts delete mode 100644 src/services/users/index.ts delete mode 100644 src/services/users/redux/actions.ts delete mode 100644 src/services/users/redux/index.ts delete mode 100644 src/services/users/redux/reducers.ts delete mode 100644 src/services/users/redux/selectors.ts delete mode 100644 src/services/users/redux/types.ts delete mode 100644 src/services/users/transformations.ts delete mode 100644 src/services/users/types.ts diff --git a/.env.example b/.env.example index f3afcc4..a263397 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1 @@ -REACT_APP_API_URL=http://stackspin_proxy:8081/api/v1 REACT_APP_HYDRA_PUBLIC_URL=https://sso.init.stackspin.net \ No newline at end of file diff --git a/src/components/UserModal/UserModal.tsx b/src/components/UserModal/UserModal.tsx deleted file mode 100644 index 404db4b..0000000 --- a/src/components/UserModal/UserModal.tsx +++ /dev/null @@ -1,277 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import _ from 'lodash'; -import { TrashIcon } from '@heroicons/react/outline'; -import { useFieldArray, useForm, useWatch } from 'react-hook-form'; -import { Banner, Modal, ConfirmationModal } from 'src/components'; -import { Input, Select } from 'src/components/Form'; -import { User, UserRole, useUsers } from 'src/services/users'; -import { useAuth } from 'src/services/auth'; -import { appAccessList, initialUserForm } from './consts'; -import { UserModalProps } from './types'; - -export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps) => { - const [deleteModal, setDeleteModal] = useState(false); - const [isAdminRoleSelected, setAdminRoleSelected] = useState(true); - const [isPersonalModal, setPersonalModal] = useState(false); - const { - user, - loadUser, - loadPersonalInfo, - editUserById, - editPersonalInfo, - createNewUser, - userModalLoading, - deleteUserById, - clearSelectedUser, - } = useUsers(); - const { currentUser, isAdmin } = useAuth(); - - const { control, reset, handleSubmit } = useForm({ - defaultValues: initialUserForm, - }); - - const { fields, update } = useFieldArray({ - control, - name: 'app_roles', - }); - - useEffect(() => { - if (userId) { - const currentUserId = currentUser?.id; - if (currentUserId === userId) { - setPersonalModal(true); - loadPersonalInfo(); - } else { - loadUser(userId); - } - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [userId, open]); - - useEffect(() => { - if (!_.isEmpty(user)) { - reset(user); - } - - return () => { - reset(initialUserForm); - }; - }, [user, reset, open]); - - const dashboardRole = useWatch({ - control, - name: 'app_roles.0.role', - }); - - useEffect(() => { - const isAdminDashboardRoleSelected = dashboardRole === UserRole.Admin; - setAdminRoleSelected(isAdminDashboardRoleSelected); - if (isAdminDashboardRoleSelected) { - fields.forEach((field, index) => update(index, { name: field.name, role: UserRole.Admin })); - } else { - fields.forEach((field, index) => update(index, { name: field.name, role: UserRole.User })); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [dashboardRole]); - - const handleSave = async () => { - try { - if (isPersonalModal) { - await handleSubmit((data) => editPersonalInfo(data))(); - } else if (userId) { - await handleSubmit((data) => editUserById(data))(); - } else { - await handleSubmit((data) => createNewUser(data))(); - } - } catch (e: any) { - // Continue - } - - onClose(); - clearSelectedUser(); - setUserId(null); - }; - - const handleKeyPress = (e: any) => { - if (e.key === 'Enter' || e.key === 'NumpadEnter') { - handleSave(); - } - }; - - const handleClose = () => { - onClose(); - clearSelectedUser(); - setUserId(null); - }; - - const deleteModalOpen = () => setDeleteModal(true); - const deleteModalClose = () => setDeleteModal(false); - - const handleDelete = () => { - if (userId) { - deleteUserById(userId); - } - - clearSelectedUser(); - setUserId(null); - handleClose(); - deleteModalClose(); - }; - - return ( - <> - -