From 119d6c2673557902c492279b9f614dbe90ad0557 Mon Sep 17 00:00:00 2001 From: Ajeyakrishna <98796547+Ajeyakrishna-k@users.noreply.github.com> Date: Tue, 17 Oct 2023 08:28:05 +0530 Subject: [PATCH 1/3] CHORE : refactored date call --- src/components/issues/TaskRequestForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/issues/TaskRequestForm.tsx b/src/components/issues/TaskRequestForm.tsx index 4e585ddc6..55bfd3f81 100644 --- a/src/components/issues/TaskRequestForm.tsx +++ b/src/components/issues/TaskRequestForm.tsx @@ -23,7 +23,7 @@ date.setDate(date.getDate() + 7); const sevenDaysFromToday = date.toISOString().split('T')[0]; const initialState = { - endsOn: date.getTime(), + endsOn: Date.now(), startedOn: Date.now(), description: ' ', }; From 3626b7edf88eab6f8a3a3a60e3a166683d278e28 Mon Sep 17 00:00:00 2001 From: kotesh_Mudila Date: Tue, 17 Oct 2023 12:57:32 +0530 Subject: [PATCH 2/3] REFACTOR: replace idle members(users) api with existing idle-users api (#946) * REFACTOR: replace idle members(users) api with existing idle-users api * REFACTOR: renamed variables according to the response * CHORES: indentation * REFACTOR: removed non-useful variable declaration --------- Co-authored-by: Vinit khandal <111434418+vinit717@users.noreply.github.com> --- __mocks__/handlers/idle-users.handler.js | 70 +++++++++++++++++++ __mocks__/handlers/members.handler.js | 67 ------------------ ...bersApi.test.tsx => idleUsersApi.test.tsx} | 16 ++--- src/app/services/api.ts | 2 +- src/app/services/idleUsersApi.ts | 20 ++++++ src/app/services/membersApi.ts | 22 ------ src/constants/url.ts | 2 +- src/pages/availability-panel/index.tsx | 4 +- src/types/AvailabilityPanel.d.ts | 30 ++++++++ 9 files changed, 132 insertions(+), 101 deletions(-) create mode 100644 __mocks__/handlers/idle-users.handler.js delete mode 100644 __mocks__/handlers/members.handler.js rename __tests__/Unit/hooks/{membersApi.test.tsx => idleUsersApi.test.tsx} (83%) create mode 100644 src/app/services/idleUsersApi.ts delete mode 100644 src/app/services/membersApi.ts create mode 100644 src/types/AvailabilityPanel.d.ts diff --git a/__mocks__/handlers/idle-users.handler.js b/__mocks__/handlers/idle-users.handler.js new file mode 100644 index 000000000..2d17b8934 --- /dev/null +++ b/__mocks__/handlers/idle-users.handler.js @@ -0,0 +1,70 @@ +import { rest } from 'msw'; +const URL = process.env.NEXT_PUBLIC_BASE_URL; + +const idleUsersHandler = [ + rest.get(`${URL}/users/search?state=IDLE`, (_, res, ctx) => { + return res( + ctx.status(200), + ctx.json({ + message: 'Users found successfully!', + users: [ + { + id: '26gZFJaXRfd8ghb3p0at', + discordId: '759647978121068544', + last_name: 'reddy', + first_name: 'chandra', + updated_at: 1695404825067, + username: 'chandra', + picture: { + url: 'https://res.cloudinary.com/realdevsquad/image/upload/v1689296550/profile/It0BbP0M2Wh8vdWUmMJB/a4j7tbh4g5ccbfepss88.jpg', + }, + roles: { + archived: false, + in_discord: true, + member: false, + }, + }, + { + id: '2iaxlIok0itcIhD0zlsT', + discordId: '824562502310035487', + last_name: 'joy', + first_name: 'khushi', + roles: { + archived: false, + }, + updated_at: 1695404825078, + username: 'khushi', + }, + { + id: '3KeWfLRLN98L0QGv0hdL', + discordId: '619787720713175040', + roles: { + archived: false, + }, + last_name: 'b', + first_name: 'pronoy', + updated_at: 1695404825079, + username: 'pronoy', + }, + ], + count: 3, + }) + ); + }), +]; + +export const failedIdleUsersHandler = rest.get( + `${URL}/users/search?state=IDLE`, + (_, res, ctx) => { + return res( + ctx.status(500), + ctx.json({ + statusCode: 500, + error: 'Internal Server Error', + message: 'An internal server error occurred', + }) + ); + } +); + +export default idleUsersHandler; diff --git a/__mocks__/handlers/members.handler.js b/__mocks__/handlers/members.handler.js deleted file mode 100644 index 9dcd406ad..000000000 --- a/__mocks__/handlers/members.handler.js +++ /dev/null @@ -1,67 +0,0 @@ -import { rest } from 'msw'; -const URL = process.env.NEXT_PUBLIC_BASE_URL; - -const membersHandlers = [ - rest.get(`${URL}/members/idle`, (_, res, ctx) => { - return res( - ctx.status(200), - ctx.json({ - message: 'Idle members returned successfully!', - idleMemberUserNames: [ - 'rohan-rajgupta', - 'sumit', - 'swaraj', - 'rohit', - 'tanya', - 'akshay', - 'shubham', - 'devashish', - 'lakshay', - 'rucha', - 'swebert', - 'nikhil', - 'ishika', - 'rajakvk', - 'moses', - 'prem', - 'bhavesh', - 'ankush', - 'prakash', - 'deipayan', - 'mehul', - 'ashwini', - 'amanA', - 'sagar', - 'shankar', - 'aman-saxena', - 'harshith', - 'pranav', - 'ankur', - 'pujarini', - 'sanyogita', - 'pavan', - 'ankita', - 'shashwat', - 'vividh', - 'rahil', - ], - }) - ); - }), -]; - -export const failedIdleMembersHandler = rest.get( - `${URL}/members/idle`, - (_, res, ctx) => { - return res( - ctx.status(500), - ctx.json({ - statusCode: 500, - error: 'Internal Server Error', - message: 'An internal server error occurred', - }) - ); - } -); - -export default membersHandlers; diff --git a/__tests__/Unit/hooks/membersApi.test.tsx b/__tests__/Unit/hooks/idleUsersApi.test.tsx similarity index 83% rename from __tests__/Unit/hooks/membersApi.test.tsx rename to __tests__/Unit/hooks/idleUsersApi.test.tsx index e8a50320d..f588f8402 100644 --- a/__tests__/Unit/hooks/membersApi.test.tsx +++ b/__tests__/Unit/hooks/idleUsersApi.test.tsx @@ -1,13 +1,13 @@ import { setupServer } from 'msw/node'; import handlers, { - failedIdleMembersHandler, -} from '../../../__mocks__/handlers/members.handler.js'; + failedIdleUsersHandler, +} from '../../../__mocks__/handlers/idle-users.handler.js'; import { PropsWithChildren } from 'react'; import { act, renderHook } from '@testing-library/react-hooks'; import { Provider } from 'react-redux'; import { store } from '@/app/store'; -import { useGetIdleMembersQuery } from '@/app/services/membersApi'; +import { useGetIdleUsersQuery } from '@/app/services/idleUsersApi'; const server = setupServer(...handlers); @@ -23,10 +23,10 @@ function Wrapper({ return {children}; } -describe('useGetIdleMembersQuery', () => { - test('returns idle members', async () => { +describe('useGetIdleUsersQuery', () => { + test('returns idle users', async () => { const { result, waitForNextUpdate } = renderHook( - () => useGetIdleMembersQuery(), + () => useGetIdleUsersQuery(), { wrapper: Wrapper, } @@ -46,9 +46,9 @@ describe('useGetIdleMembersQuery', () => { }); test('checks for error response', async () => { - server.use(failedIdleMembersHandler); + server.use(failedIdleUsersHandler); const { result, waitForNextUpdate } = renderHook( - () => useGetIdleMembersQuery(), + () => useGetIdleUsersQuery(), { wrapper: Wrapper, } diff --git a/src/app/services/api.ts b/src/app/services/api.ts index 5105d0d66..661812310 100644 --- a/src/app/services/api.ts +++ b/src/app/services/api.ts @@ -23,7 +23,7 @@ export const api = createApi({ 'Tags', 'Levels', 'Challenges', - 'Idle_Members', + 'Idle_Users', 'Progress_Details', 'User_Standup', 'TASK_REQUEST', diff --git a/src/app/services/idleUsersApi.ts b/src/app/services/idleUsersApi.ts new file mode 100644 index 000000000..4feb61f26 --- /dev/null +++ b/src/app/services/idleUsersApi.ts @@ -0,0 +1,20 @@ +import { USERS_IDLE } from '@/constants/url'; +import { api } from './api'; +import { UserResponseData } from '@/types/AvailabilityPanel'; +type IdleUsersResponse = { users: UserResponseData[] }; + +export const idleUsersApi = api.injectEndpoints({ + endpoints: (build) => ({ + getIdleUsers: build.query({ + query: () => USERS_IDLE, + providesTags: ['Idle_Users'], + transformResponse: (response: IdleUsersResponse) => { + const IdleUsers = response.users.map((user) => user.username); + IdleUsers.sort(); + return IdleUsers; + }, + }), + }), +}); + +export const { useGetIdleUsersQuery } = idleUsersApi; diff --git a/src/app/services/membersApi.ts b/src/app/services/membersApi.ts deleted file mode 100644 index 594c2610d..000000000 --- a/src/app/services/membersApi.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MEMBERS_IDLE } from '@/constants/url'; -import { api } from './api'; - -type IdleMembersResponse = { idleMemberUserNames: string[] }; -export const membersApi = api.injectEndpoints({ - endpoints: (build) => ({ - getIdleMembers: build.query({ - query: () => MEMBERS_IDLE, - providesTags: ['Idle_Members'], - transformResponse: (response: IdleMembersResponse) => { - const filterMembers = response.idleMemberUserNames.filter( - (username: string) => username - ); - const sortedIdleMembers = filterMembers.sort(); - - return sortedIdleMembers; - }, - }), - }), -}); - -export const { useGetIdleMembersQuery } = membersApi; diff --git a/src/constants/url.ts b/src/constants/url.ts index 88fb2ed15..bdcc1a16f 100644 --- a/src/constants/url.ts +++ b/src/constants/url.ts @@ -11,7 +11,7 @@ export const LOGIN_URL = `https://github.com/login/oauth/authorize?client_id=23c export const MEMBERS_URL = 'https://members.realdevsquad.com'; export const CHALLENGES_URL = `${BASE_URL}/challenges`; export const USER_SELF = `${BASE_URL}/users/self`; -export const MEMBERS_IDLE = `${BASE_URL}/members/idle`; +export const USERS_IDLE = `${BASE_URL}/users/search?state=IDLE`; export const DEFAULT_AVATAR = '/Avatar.png'; export const RDS_LOGO = '/RDSLogo.png'; export const GITHUB_LOGO = '/github-white.png'; diff --git a/src/pages/availability-panel/index.tsx b/src/pages/availability-panel/index.tsx index 580f94583..037fcb257 100644 --- a/src/pages/availability-panel/index.tsx +++ b/src/pages/availability-panel/index.tsx @@ -9,7 +9,7 @@ import updateTasksStatus from '@/helperFunctions/updateTasksStatus'; import { AVAILABLE } from '@/constants/task-status'; import { FEATURE } from '@/constants/task-type'; import { BASE_URL } from '@/constants/url'; -import { useGetIdleMembersQuery } from '@/app/services/membersApi'; +import { useGetIdleUsersQuery } from '@/app/services/idleUsersApi'; const AvailabilityPanel: FC = () => { const [unAssignedTasks, setUnAssignedTasks] = useState([]); @@ -21,7 +21,7 @@ const AvailabilityPanel: FC = () => { isError: isIdleMembersError, isLoading: isIdleMemberLoading, refetch: refreshMemberList, - } = useGetIdleMembersQuery(); + } = useGetIdleUsersQuery(); useEffect(() => { const fetchTasks = async () => { diff --git a/src/types/AvailabilityPanel.d.ts b/src/types/AvailabilityPanel.d.ts new file mode 100644 index 000000000..0abeb8a04 --- /dev/null +++ b/src/types/AvailabilityPanel.d.ts @@ -0,0 +1,30 @@ +export interface UserResponseData { + id: string; + incompleteUserDetails: boolean; + website: string; + discordJoinedAt: string; + discordId: string; + roles: { + archived: boolean; + in_discord: boolean; + member: boolean; + }; + last_name: string; + linkedin_id: string; + yoe: number; + picture: { + publicId: string; + url: string; + }; + github_created_at: number; + github_display_name: string; + github_id: string; + company: string; + designation: string; + twitter_id: string; + first_name: string; + status: string; + username: string; + updated_at: number; + created_at: number; +} From 51e8c7376fa60504dc1222d28ade66511137d3cb Mon Sep 17 00:00:00 2001 From: Vinit khandal <111434418+vinit717@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:45:15 +0530 Subject: [PATCH 3/3] remove feature flag from task-dependency and it's test (#952) --- .../Components/Tasks/TaskDependency.test.tsx | 6 ++-- src/components/taskDetails/index.tsx | 32 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/__tests__/Unit/Components/Tasks/TaskDependency.test.tsx b/__tests__/Unit/Components/Tasks/TaskDependency.test.tsx index d63e7228d..a1a300776 100644 --- a/__tests__/Unit/Components/Tasks/TaskDependency.test.tsx +++ b/__tests__/Unit/Components/Tasks/TaskDependency.test.tsx @@ -43,8 +43,7 @@ describe('TaskDependency', () => { isEditing={true} setEditedTaskDetails={setEditedTaskDetails} /> - , - { query: { dev: 'true' } } + ); const checkboxes = container.querySelectorAll('input[type="checkbox"]'); const firstCheckbox = checkboxes[0] as HTMLInputElement; @@ -68,8 +67,7 @@ describe('TaskDependency', () => { isEditing={true} setEditedTaskDetails={setEditedTaskDetails} /> - , - { query: { dev: 'true' } } + ); const loadingText = await waitFor(() => getByText('Loading...')); expect(loadingText).toBeInTheDocument(); diff --git a/src/components/taskDetails/index.tsx b/src/components/taskDetails/index.tsx index 5fa61b001..f795aeb7a 100755 --- a/src/components/taskDetails/index.tsx +++ b/src/components/taskDetails/index.tsx @@ -264,24 +264,20 @@ const TaskDetails: FC = ({ taskID }) => { - {isDevModeEnabled && ( - <> - - - - - )} + <> + + + +