From 4b96a7fa152f13adf93801d342ac222d879dc64a Mon Sep 17 00:00:00 2001 From: Peter Harrison <16875803+palisadoes@users.noreply.github.com> Date: Fri, 15 Dec 2023 04:45:34 -0800 Subject: [PATCH 1/2] Update .eslintrc.json --- .eslintrc.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 43780cfca1..dfb93ff263 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -30,8 +30,8 @@ "plugins": ["react", "@typescript-eslint", "jest"], "rules": { "react/destructuring-assignment": ["off"], - "@typescript-eslint/no-explicit-any": ["error"], - "@typescript-eslint/explicit-module-boundary-types": ["error"], + "@typescript-eslint/no-explicit-any": ["off"], + "@typescript-eslint/explicit-module-boundary-types": ["off"], "react/no-multi-comp": [ "error", { From d9e7acb3030d718f8b1f37c5b9609c1f708f23bf Mon Sep 17 00:00:00 2001 From: Mintu Gogoi <127925465+Min2who@users.noreply.github.com> Date: Fri, 15 Dec 2023 18:16:36 +0530 Subject: [PATCH 2/2] Single search modal instead of two search modal (#1166) * Single search modal * fixes failing test * updated the test that were failing * small commit * fixes test --- public/locales/en.json | 3 +- .../OrganizationPeople.test.tsx | 64 ++++++------------- .../OrganizationPeople/OrganizationPeople.tsx | 56 ++++++---------- 3 files changed, 40 insertions(+), 83 deletions(-) diff --git a/public/locales/en.json b/public/locales/en.json index 3e238baefe..668c0fae94 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -202,8 +202,7 @@ "users": "Users", "searchName": "Enter Name", "searchevent": "Enter Event", - "searchFirstName": "Enter First Name", - "searchLastName": "Enter Last Name" + "searchFullName": "Enter Full Name" }, "userListCard": { "joined": "Joined", diff --git a/src/screens/OrganizationPeople/OrganizationPeople.test.tsx b/src/screens/OrganizationPeople/OrganizationPeople.test.tsx index 605c01f785..ac2beecae7 100644 --- a/src/screens/OrganizationPeople/OrganizationPeople.test.tsx +++ b/src/screens/OrganizationPeople/OrganizationPeople.test.tsx @@ -461,10 +461,9 @@ console.error = jest.fn(); describe('Organization People Page', () => { const searchData = { - firstName: 'Aditya', - lastNameMember: 'Memberguy', - lastNameAdmin: 'Adminguy', - lastNameUser: 'Userguytwo', + fullNameMember: 'Aditya Memberguy', + fullNameAdmin: 'Aditya Adminguy', + fullNameUser: 'Aditya Userguytwo', location: 'Delhi, India', event: 'Event', }; @@ -716,12 +715,12 @@ describe('Organization People Page', () => { expect(findtext).toBeInTheDocument(); userEvent.type( - screen.getByPlaceholderText(/Enter First Name/i), - searchData.firstName + screen.getByPlaceholderText(/Enter Full Name/i), + searchData.fullNameMember ); await wait(); - expect(screen.getByPlaceholderText(/Enter First Name/i)).toHaveValue( - searchData.firstName + expect(screen.getByPlaceholderText(/Enter Full Name/i)).toHaveValue( + searchData.fullNameMember ); await wait(); @@ -755,29 +754,16 @@ describe('Organization People Page', () => { expect(screen.getByLabelText(/Members/i)).toBeChecked(); await wait(); - const firstNameInput = screen.getByPlaceholderText(/Enter First Name/i); - const lastNameInput = screen.getByPlaceholderText(/Enter Last Name/i); + const fullNameInput = screen.getByPlaceholderText(/Enter Full Name/i); // Only First Name - userEvent.type(firstNameInput, searchData.firstName); + userEvent.type(fullNameInput, searchData.fullNameMember); await wait(); let findtext = screen.getByText(/Aditya Memberguy/i); await wait(); expect(findtext).toBeInTheDocument(); - // First & Last Name - userEvent.type(lastNameInput, searchData.lastNameMember); - await wait(); - - findtext = screen.getByText(/Aditya Memberguy/i); - await wait(); - expect(findtext).toBeInTheDocument(); - - // Only Last Name - userEvent.type(firstNameInput, ''); - await wait(); - findtext = screen.getByText(/Aditya Memberguy/i); await wait(); expect(findtext).toBeInTheDocument(); @@ -819,12 +805,12 @@ describe('Organization People Page', () => { expect(findtext).toBeInTheDocument(); userEvent.type( - screen.getByPlaceholderText(/Enter First Name/i), - searchData.firstName + screen.getByPlaceholderText(/Enter Full Name/i), + searchData.fullNameAdmin ); await wait(); - expect(screen.getByPlaceholderText(/Enter First Name/i)).toHaveValue( - searchData.firstName + expect(screen.getByPlaceholderText(/Enter Full Name/i)).toHaveValue( + searchData.fullNameAdmin ); await wait(); @@ -860,33 +846,19 @@ describe('Organization People Page', () => { expect(screen.getByLabelText(/Admins/i)).toBeChecked(); await wait(); - const firstNameInput = screen.getByPlaceholderText(/Enter First Name/i); - const lastNameInput = screen.getByPlaceholderText(/Enter Last Name/i); + const fullNameInput = screen.getByPlaceholderText(/Enter Full Name/i); // Only First Name - userEvent.type(firstNameInput, searchData.firstName); + userEvent.type(fullNameInput, searchData.fullNameAdmin); await wait(); let findtext = screen.getByText(/Aditya Adminguy/i); await wait(); expect(findtext).toBeInTheDocument(); - // First & Last Name - userEvent.type(lastNameInput, searchData.lastNameAdmin); - await wait(); - - findtext = screen.getByText(/Aditya Adminguy/i); - await wait(); - expect(findtext).toBeInTheDocument(); - - // Only Last Name - userEvent.type(firstNameInput, ''); - await wait(); - findtext = screen.getByText(/Aditya Adminguy/i); await wait(); expect(findtext).toBeInTheDocument(); - await wait(); expect(window.location).toBeAt('/orgpeople/id=orgid'); }); @@ -972,10 +944,10 @@ describe('Organization People Page', () => { expect(screen.getByLabelText(/Users/i)).toBeChecked(); await wait(); - const firstNameInput = screen.getByPlaceholderText(/Enter First Name/i); + const fullNameInput = screen.getByPlaceholderText(/Enter Full Name/i); - // Only First Name - userEvent.type(firstNameInput, searchData.firstName); + // Only Full Name + userEvent.type(fullNameInput, searchData.fullNameUser); await wait(); const orgUsers = dataQueryForUsers?.filter( diff --git a/src/screens/OrganizationPeople/OrganizationPeople.tsx b/src/screens/OrganizationPeople/OrganizationPeople.tsx index 8a15d4cb55..2314d116bf 100644 --- a/src/screens/OrganizationPeople/OrganizationPeople.tsx +++ b/src/screens/OrganizationPeople/OrganizationPeople.tsx @@ -47,6 +47,8 @@ function organizationPeople(): JSX.Element { lastName_contains: '', }); + const [fullName, setFullName] = useState(''); + const { data: memberData, loading: memberLoading, @@ -112,22 +114,31 @@ function organizationPeople(): JSX.Element { } /* istanbul ignore next */ - const handleFirstNameSearchChange = (filterData: any): void => { + const handleFullNameSearchChange = (fullName: string): void => { /* istanbul ignore next */ + const [firstName, lastName] = fullName.split(' '); + + const newFilterData = { + firstName_contains: firstName ?? '', + lastName_contains: lastName ?? '', + }; + + setFilterData(newFilterData); + if (state === 0) { memberRefetch({ - ...filterData, + ...newFilterData, orgId: currentUrl, }); } else if (state === 1) { adminRefetch({ - ...filterData, + ...newFilterData, orgId: currentUrl, admin_for: currentUrl, }); } else { usersRefetch({ - ...filterData, + ...newFilterData, }); } }; @@ -148,8 +159,8 @@ function organizationPeople(): JSX.Element { setPage(0); }; - const debouncedHandleFirstNameSearchChange = debounce( - handleFirstNameSearchChange + const debouncedHandleFullNameSearchChange = debounce( + handleFullNameSearchChange ); return ( @@ -160,42 +171,17 @@ function organizationPeople(): JSX.Element {