From a31a19aa0dab8b6d9fb1cdc36d6879299ecca432 Mon Sep 17 00:00:00 2001 From: Samarth Bhadane Date: Sat, 11 Jan 2025 08:31:58 -0800 Subject: [PATCH 1/2] Fixed Linting Issues --- .eslintignore | 1 - .prettierignore | 1 - .../PasswordInputModal.jsx | 2 +- src/reducers/actionItemsReducer.js | 3 + src/reducers/allProjectsReducer.js | 69 ++++---- src/reducers/allTasksReducer.js | 116 +++++++------ src/reducers/allTeamsReducer.js | 140 +++++++++------- src/reducers/allTimeEntriesReducer.js | 3 + .../allUserProfilesBasicInfoReducer.js | 63 +++---- src/reducers/allUserProfilesReducer.js | 51 +++--- src/reducers/allUsersTimeEntriesReducer.js | 3 + src/reducers/authReducer.js | 22 ++- src/reducers/badgeReducer.js | 3 + src/reducers/blueSquareEmailBcc.js | 20 +-- .../bmdashboard/consumablesReducer.js | 20 +-- src/reducers/bmdashboard/equipmentReducer.js | 17 +- .../bmdashboard/inventoryTypeReducer.js | 130 ++++++++------- .../bmdashboard/inventoryUnitReducer.js | 37 +++-- src/reducers/bmdashboard/lessonsReducer.js | 116 ++++++------- src/reducers/bmdashboard/materialsReducer.js | 157 +++++++++--------- .../bmdashboard/projectByIdReducer.js | 13 +- src/reducers/bmdashboard/projectReducer.js | 13 +- src/reducers/bmdashboard/reusablesReducer.js | 157 +++++++++--------- src/reducers/dashboardReducer.js | 10 +- src/reducers/errorsReducer.js | 3 + src/reducers/followUpReducer.js | 5 +- src/reducers/handleSuccessReducer.js | 3 + src/reducers/index.js | 48 +++--- src/reducers/informationReducer.js | 14 +- src/reducers/leaderboardDataReducer.js | 1 + src/reducers/managingTeamsReducer.js | 4 +- src/reducers/monthlyDashboardDataReducer.js | 3 + src/reducers/mouseoverTextReducer.js | 24 ++- src/reducers/notificationReducer.js | 85 ++++++---- src/reducers/ownerMessageReducer.js | 13 +- src/reducers/popupEditorReducer.js | 16 +- src/reducers/projectByIdReducer.js | 3 + src/reducers/projectMembershipReducer.js | 65 +++++--- src/reducers/projectReportReducer.js | 14 +- src/reducers/rolePresetReducer.js | 45 +++-- src/reducers/roleReducer.js | 43 +++-- src/reducers/teamByIdReducer.js | 5 +- src/reducers/teamMembershipReducer.js | 3 + src/reducers/teamsTeamMembersReducer.js | 1 + src/reducers/themeReducer.js | 3 + .../timeEntriesForSpecifiedPeriodReducer.js | 3 + src/reducers/timeEntriesReducer.js | 3 + src/reducers/timeOffRequestReducer.js | 26 ++- src/reducers/totalOrgSummaryReducer.js | 5 +- src/reducers/userProfileByIdReducer.js | 2 + src/reducers/userProjectMembersReducer.js | 5 +- src/reducers/userProjectsByUserNameReducer.js | 32 ++-- src/reducers/userProjectsReducer.js | 5 +- src/reducers/userTeamMembersReducer.js | 5 +- src/reducers/warningsReducer.js | 5 +- src/reducers/wbsReducer.js | 19 ++- src/reducers/weeklyDashboardDataReducer.js | 5 +- .../weeklySummariesAIPromptReducer.js | 13 +- src/reducers/weeklySummariesReducer.js | 5 +- src/reducers/weeklySummariesReportReducer.js | 11 +- .../weeklySummaryRecipientsReducer.js | 34 ++-- 61 files changed, 1007 insertions(+), 739 deletions(-) diff --git a/.eslintignore b/.eslintignore index 1ecdc0e014..5a81ba7ef1 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,7 +7,6 @@ src/App.css src/config.json src/index.js -src/reducers/** src/styles.js src/__tests__/** diff --git a/.prettierignore b/.prettierignore index 03e1f8649b..05937e6cff 100644 --- a/.prettierignore +++ b/.prettierignore @@ -6,7 +6,6 @@ src/config.json src/index.js src/languages/** -src/reducers/** src/registerServiceWorker.js src/routes.js src/setupTests.js diff --git a/src/components/WeeklySummariesReport/PasswordInputModal.jsx b/src/components/WeeklySummariesReport/PasswordInputModal.jsx index a49f013b9f..c5d2845649 100644 --- a/src/components/WeeklySummariesReport/PasswordInputModal.jsx +++ b/src/components/WeeklySummariesReport/PasswordInputModal.jsx @@ -22,7 +22,7 @@ import { authorizeWeeklySummaries, authorizeWeeklySummariesReportError, } from '../../actions/weeklySummariesReportRecepients'; -import { weeklySummaryRecipientsReducer } from '../../reducers/weeklySummaryRecipientsReducer'; +import weeklySummaryRecipientsReducer from '../../reducers/weeklySummaryRecipientsReducer'; export default function PasswordInputModal({ onClose, diff --git a/src/reducers/actionItemsReducer.js b/src/reducers/actionItemsReducer.js index a9a467ad45..86b242c92d 100644 --- a/src/reducers/actionItemsReducer.js +++ b/src/reducers/actionItemsReducer.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line default-param-last export const actionItemsReducer = (actionItems = null, action) => { if (action.type === 'GET_ACTION_ITEMS') { return action.payload; @@ -5,3 +6,5 @@ export const actionItemsReducer = (actionItems = null, action) => { return actionItems; }; + +export default actionItemsReducer; diff --git a/src/reducers/allProjectsReducer.js b/src/reducers/allProjectsReducer.js index 1872b2c3ec..00512e91c4 100644 --- a/src/reducers/allProjectsReducer.js +++ b/src/reducers/allProjectsReducer.js @@ -1,4 +1,4 @@ -import * as types from "../constants/projects"; +import * as types from '../constants/projects'; const allProjectsInital = { fetching: false, @@ -8,61 +8,74 @@ const allProjectsInital = { error: null, }; +// eslint-disable-next-line default-param-last export const allProjectsReducer = (allProjects = allProjectsInital, action) => { - const updateState = (updatedProperties) => { - return { - ...allProjects, - ...updatedProperties, - }; - }; + const updateState = updatedProperties => ({ + ...allProjects, + ...updatedProperties, + }); + const { status, error = null } = action; - let index, projects; + switch (action.type) { - case types.FETCH_PROJECTS_START: + case types.FETCH_PROJECTS_START: { return updateState({ fetching: true }); - case types.FETCH_PROJECTS_ERROR: + } + + case types.FETCH_PROJECTS_ERROR: { return updateState({ fetching: false, status, error }); - case types.FETCH_PROJECTS_SUCCESS: + } + + case types.FETCH_PROJECTS_SUCCESS: { return updateState({ fetching: false, fetched: true, projects: action.projects, status, }); - case types.ADD_NEW_PROJECT: + } + + case types.ADD_NEW_PROJECT: { if (status !== 201) return updateState({ status, error }); const { newProject } = action; return updateState({ projects: [...allProjects.projects, newProject], status, }); - case types.UPDATE_PROJECT: + } + + case types.UPDATE_PROJECT: { if (status !== 200) return updateState({ status, error }); const { updatedProject } = action; - index = allProjects.projects.findIndex(project => project._id === updatedProject._id); + const index = allProjects.projects.findIndex(project => project._id === updatedProject._id); + if (index !== -1) { - projects = [ + const updatedProjects = [ ...allProjects.projects.slice(0, index), updatedProject, ...allProjects.projects.slice(index + 1), ]; - return updateState({ projects, status }); - } - else { - return updateState({ status:404, error: "Project not found." }); + return updateState({ projects: updatedProjects, status }); } - case types.DELETE_PROJECT: + + return updateState({ status: 404, error: 'Project not found.' }); + } + + case types.DELETE_PROJECT: { if (status !== 200) return updateState({ status, error }); const { projectId } = action; - index = allProjects.projects.findIndex(project => project._id === projectId); - projects = Object.assign([ - ...allProjects.projects.slice(0, index), - ...allProjects.projects.slice(index + 1), - ]); - return updateState({ projects, status }); - case types.CLEAR_ERROR: + const updatedProjects = allProjects.projects.filter(project => project._id !== projectId); + return updateState({ projects: updatedProjects, status }); + } + + case types.CLEAR_ERROR: { return updateState({ status: 200, error: null }); - default: + } + + default: { return allProjects; + } } }; + +export default allProjectsReducer; diff --git a/src/reducers/allTasksReducer.js b/src/reducers/allTasksReducer.js index da1a6e7451..c48b1bab72 100644 --- a/src/reducers/allTasksReducer.js +++ b/src/reducers/allTasksReducer.js @@ -1,6 +1,5 @@ -import { createOrUpdateTaskNotificationHTTP } from 'actions/taskNotification'; import { fetchTeamMembersTaskSuccess } from 'components/TeamMemberTasks/actions'; -import * as types from "../constants/task"; +import * as types from '../constants/task'; const allTasksInital = { fetching: false, @@ -15,7 +14,7 @@ const filterAndSort = (tasks, level) => { return tasks.sort((a, b) => { const aArr = a.num.split('.'); const bArr = b.num.split('.'); - for (let i = 0; i < level; i++) { + for (let i = 0; i < level; i += 1) { if (+aArr[i] !== +bArr[i]) return +aArr[i] - +bArr[i]; } return 0; @@ -46,26 +45,34 @@ const sortByNum = tasks => { return filterAndSort(appendTasks, 4); }; +// eslint-disable-next-line default-param-last export const taskReducer = (allTasks = allTasksInital, action) => { - let newTaskItems; switch (action.type) { - case types.FETCH_TASKS_START: + case types.FETCH_TASKS_START: { return { ...allTasks, fetched: false, fetching: true, error: 'none' }; - case types.FETCH_TASKS_ERROR: + } + + case types.FETCH_TASKS_ERROR: { return { ...allTasks, fetched: true, fetching: false, error: action.err }; - case types.RECEIVE_TASKS: - allTasks.fetchedData[action.level] = action.taskItems; - newTaskItems = allTasks.fetchedData.flat(); + } + + case types.RECEIVE_TASKS: { + const updatedFetchedData = [...allTasks.fetchedData]; + updatedFetchedData[action.level] = action.taskItems; + + const newTaskItems = updatedFetchedData.flat(); return { ...allTasks, - fetchedData: [...allTasks.fetchedData], + fetchedData: updatedFetchedData, taskItems: sortByNum(newTaskItems), fetched: true, fetching: false, error: 'none', }; - case types.ADD_NEW_TASK: - newTaskItems = [action.newTask, ...allTasks.taskItems]; + } + + case types.ADD_NEW_TASK: { + const newTaskItems = [action.newTask, ...allTasks.taskItems]; return { ...allTasks, taskItems: sortByNum(newTaskItems), @@ -73,31 +80,36 @@ export const taskReducer = (allTasks = allTasksInital, action) => { fetching: false, error: 'none', }; - case types.DELETE_TASK: - const delIndexStart = allTasks.taskItems.findIndex(task => task._id === action.taskId); - let delIndexEnd = delIndexStart; - allTasks.taskItems.forEach((task, index) => { - if (task.parentId3 === action.taskId) { - delIndexEnd = index; - } - if (task.parentId2 === action.taskId) { - delIndexEnd = index; - } - if (task.parentId1 === action.taskId) { - delIndexEnd = index; + } + + case types.DELETE_TASK: { + const startIndex = allTasks.taskItems.findIndex(task => task._id === action.taskId); + const endIndex = allTasks.taskItems.reduce((lastIndex, task, index) => { + if ( + task.parentId1 === action.taskId || + task.parentId2 === action.taskId || + task.parentId3 === action.taskId + ) { + return index; } - }); + return lastIndex; + }, startIndex); + + const updatedTasks = [ + ...allTasks.taskItems.slice(0, startIndex), + ...allTasks.taskItems.slice(endIndex + 1), + ]; + return { ...allTasks, - taskItems: [ - ...allTasks.taskItems.slice(0, delIndexStart), - ...allTasks.taskItems.slice(delIndexEnd + 1), - ], + taskItems: updatedTasks, fetched: true, fetching: false, error: 'none', }; - case types.EMPTY_TASK_ITEMS: + } + + case types.EMPTY_TASK_ITEMS: { return { ...allTasks, taskItems: [], @@ -106,31 +118,39 @@ export const taskReducer = (allTasks = allTasksInital, action) => { fetching: false, error: 'none', }; - case types.UPDATE_TASK: - const updIndexStart = allTasks.taskItems.findIndex(task => task._id === action.taskId); - const updIndexEnd = updIndexStart; - let updatedTask = allTasks.taskItems.filter(task => task._id === action.taskId)[0]; - updatedTask = { ...updatedTask, ...action.updatedTask }; + } + + case types.UPDATE_TASK: { + const updatedTasks = allTasks.taskItems.map(task => + task._id === action.taskId ? { ...task, ...action.updatedTask } : task, + ); + return { ...allTasks, - taskItems: [ - ...allTasks.taskItems.slice(0, updIndexStart), - updatedTask, - ...allTasks.taskItems.slice(updIndexEnd + 1), - ], + taskItems: updatedTasks, fetched: true, fetching: false, error: 'none', }; - case types.COPY_TASK: - const copiedTask = allTasks.taskItems.find(item => item._id === action.taskId); + } + + case types.COPY_TASK: { + const copiedTask = allTasks.taskItems.find(task => task._id === action.taskId); return { ...allTasks, copiedTask }; - case types.ADD_NEW_TASK_ERROR: - const error = action.err; - return { ...allTasks, error }; - case fetchTeamMembersTaskSuccess.type: - return { ...allTasks, ...action.tasks }; // change that when there will be backend - default: + } + + case types.ADD_NEW_TASK_ERROR: { + return { ...allTasks, error: action.err }; + } + + case fetchTeamMembersTaskSuccess.type: { + return { ...allTasks, ...action.tasks }; // Placeholder for backend integration + } + + default: { return allTasks; + } } }; + +export default taskReducer; diff --git a/src/reducers/allTeamsReducer.js b/src/reducers/allTeamsReducer.js index 491af18d32..eb9b4e212c 100644 --- a/src/reducers/allTeamsReducer.js +++ b/src/reducers/allTeamsReducer.js @@ -1,3 +1,4 @@ +/* eslint-disable default-param-last */ import * as types from '../constants/allTeamsConstants'; const userTeamsInitial = { @@ -15,102 +16,123 @@ export const updateObject = (oldObject, updatedProperties) => ({ export const allUserTeamsReducer = (allTeams = userTeamsInitial, action) => { switch (action.type) { - case types.FETCH_USER_TEAMS_START: + case types.FETCH_USER_TEAMS_START: { return { ...allTeams, fetching: true, status: '200' }; + } - case types.FETCH_USER_TEAMS_ERROR: + case types.FETCH_USER_TEAMS_ERROR: { return { ...allTeams, fetching: false, status: '404' }; + } - case types.RECEIVE_ALL_USER_TEAMS: - return updateObject(allTeams, { + case types.RECEIVE_ALL_USER_TEAMS: { + return { + ...allTeams, allTeams: action.payload, fetching: false, fetched: true, status: '200', - }); + }; + } - case types.ADD_NEW_TEAM: - return updateObject(allTeams, { - allTeams: Object.assign([...allTeams.allTeams, action.payload]), + case types.ADD_NEW_TEAM: { + return { + ...allTeams, + allTeams: [...allTeams.allTeams, action.payload], fetching: false, fetched: true, status: '200', - }); + }; + } - case types.USER_TEAMS_UPDATE: + case types.USER_TEAMS_UPDATE: { const index = allTeams.allTeams.findIndex(team => team._id === action.team._id); - return updateObject(allTeams, { - allTeams: Object.assign([ - ...allTeams.allTeams.slice(0, index), - action.team, - ...allTeams.allTeams.slice(index + 1), - ]), + const updatedTeams = [ + ...allTeams.allTeams.slice(0, index), + action.team, + ...allTeams.allTeams.slice(index + 1), + ]; + return { + ...allTeams, + allTeams: updatedTeams, fetching: false, fetched: true, status: '200', - }); + }; + } - case types.TEAMS_DELETE: - return updateObject(allTeams, { - allTeams: Object.assign(allTeams.allTeams.filter(item => item._id !== action.team)), + case types.TEAMS_DELETE: { + const updatedTeams = allTeams.allTeams.filter(item => item._id !== action.team); + return { + ...allTeams, + allTeams: updatedTeams, fetching: false, fetched: true, status: '200', - }); + }; + } - case types.UPDATE_TEAM: - const teams = Object.assign([...allTeams.allTeams]); - const updatedTeam = teams.find(team => team._id === action.teamId); - updatedTeam.isActive = action.isActive; - updatedTeam.teamName = action.teamName; - updatedTeam.teamCode = action.teamCode; - return updateObject(allTeams, { - allTeams: teams, + case types.UPDATE_TEAM: { + const updatedTeams = allTeams.allTeams.map(team => + team._id === action.teamId + ? { + ...team, + isActive: action.isActive, + teamName: action.teamName, + teamCode: action.teamCode, + } + : team, + ); + return { + ...allTeams, + allTeams: updatedTeams, fetching: false, fetched: true, status: '200', - }); - case types.UPDATE_TEAM_MEMBER_VISIBILITY: + }; + } + + case types.UPDATE_TEAM_MEMBER_VISIBILITY: { const { teamId, userId, visibility } = action; const updatedTeams = allTeams.allTeams.map(team => { if (team._id === teamId) { - const updatedMembers = team.members.map(member => { - if (member.userId === userId) { - member.visible = visibility; - } - return member; - }); - + const updatedMembers = team.members.map(member => + member.userId === userId ? { ...member, visible: visibility } : member, + ); return { ...team, members: updatedMembers }; } return team; }); - return updateObject(allTeams, { + return { + ...allTeams, allTeams: updatedTeams, fetching: false, fetched: true, status: '200', - }); - - case types.FETCH_ALL_TEAM_CODE_SUCCESS: - const payload = action.payload; - return { - ...allTeams, - allTeamCode: payload, - fetching: false, - fetched: true, - status: '200', - }; - - case types.FETCH_ALL_TEAM_CODE_FAILURE: - return { - ...allTeams, - fetching: false, - fetched: false, - status: '500', - }; + }; + } + + case types.FETCH_ALL_TEAM_CODE_SUCCESS: { + const { payload } = action; + return { + ...allTeams, + allTeamCode: payload, + fetching: false, + fetched: true, + status: '200', + }; + } + + case types.FETCH_ALL_TEAM_CODE_FAILURE: { + return { + ...allTeams, + fetching: false, + fetched: false, + status: '500', + }; + } - default: + default: { return allTeams; + } } }; diff --git a/src/reducers/allTimeEntriesReducer.js b/src/reducers/allTimeEntriesReducer.js index f765eae40a..c7f8dde90e 100644 --- a/src/reducers/allTimeEntriesReducer.js +++ b/src/reducers/allTimeEntriesReducer.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line default-param-last export const allTimeEntriesReducer = (allTimeEntries = null, action) => { if (action.type === 'GET_ALL_TIME_ENTRIES') { return action.payload; @@ -5,3 +6,5 @@ export const allTimeEntriesReducer = (allTimeEntries = null, action) => { return allTimeEntries; }; + +export default allTimeEntriesReducer; diff --git a/src/reducers/allUserProfilesBasicInfoReducer.js b/src/reducers/allUserProfilesBasicInfoReducer.js index 4f23ebe1d4..eae138f1bc 100644 --- a/src/reducers/allUserProfilesBasicInfoReducer.js +++ b/src/reducers/allUserProfilesBasicInfoReducer.js @@ -1,38 +1,39 @@ import * as types from '../constants/userManagement'; const userProfilesBasicInfoInitial = { - fetching: false, - fetched: false, - userProfilesBasicInfo: [], - status: 404, - }; + fetching: false, + fetched: false, + userProfilesBasicInfo: [], + status: 404, +}; - export const updateObject = (oldObject, updatedProperties) => { - return { - ...oldObject, - ...updatedProperties, - }; +export const updateObject = (oldObject, updatedProperties) => { + return { + ...oldObject, + ...updatedProperties, }; +}; - export const allUserProfilesBasicInfoReducer = (userProfilesBasicInfo = userProfilesBasicInfoInitial, action) => { - switch (action.type) { - case types.FETCH_USER_PROFILE_BASIC_INFO: - return { ...userProfilesBasicInfo, fetching: true, status: '200' }; - - case types.FETCH_USER_PROFILE_BASIC_INFO_ERROR: - return { ...userProfilesBasicInfo, fetching: false, status: '404' }; - - case types.RECEIVE_USER_PROFILE_BASIC_INFO: - return updateObject(userProfilesBasicInfo, { - userProfilesBasicInfo: action.payload, - fetching: false, - fetched: true, - status: '200', - }); - default: - return userProfilesBasicInfo; - } - }; - +export const allUserProfilesBasicInfoReducer = ( + // eslint-disable-next-line default-param-last + userProfilesBasicInfo = userProfilesBasicInfoInitial, + action, +) => { + switch (action.type) { + case types.FETCH_USER_PROFILE_BASIC_INFO: + return { ...userProfilesBasicInfo, fetching: true, status: '200' }; - \ No newline at end of file + case types.FETCH_USER_PROFILE_BASIC_INFO_ERROR: + return { ...userProfilesBasicInfo, fetching: false, status: '404' }; + + case types.RECEIVE_USER_PROFILE_BASIC_INFO: + return updateObject(userProfilesBasicInfo, { + userProfilesBasicInfo: action.payload, + fetching: false, + fetched: true, + status: '200', + }); + default: + return userProfilesBasicInfo; + } +}; diff --git a/src/reducers/allUserProfilesReducer.js b/src/reducers/allUserProfilesReducer.js index d580980158..c50b5ebdf2 100644 --- a/src/reducers/allUserProfilesReducer.js +++ b/src/reducers/allUserProfilesReducer.js @@ -1,15 +1,24 @@ -import { update } from 'lodash'; +/* eslint-disable no-case-declarations */ +/* eslint-disable default-param-last */ import * as types from '../constants/userManagement'; const userProfilesInitial = { fetching: false, fetched: false, userProfiles: [], - editable: { 'first': 1, 'last': 1, 'role': 1, 'email': 1, 'weeklycommittedHours': 1 ,'startDate':1,'endDate':1}, + editable: { + first: 1, + last: 1, + role: 1, + email: 1, + weeklycommittedHours: 1, + startDate: 1, + endDate: 1, + }, pagestats: { pageSize: 10, selectedPage: 1 }, status: 100, - updating:false, - newUserData:[] + updating: false, + newUserData: [], }; export const updateObject = (oldObject, updatedProperties) => { @@ -19,6 +28,7 @@ export const updateObject = (oldObject, updatedProperties) => { }; }; +// eslint-disable-next-line default-param-last export const allUserProfilesReducer = (userProfiles = userProfilesInitial, action) => { switch (action.type) { case types.FETCH_USER_PROFILES_START: @@ -49,7 +59,9 @@ export const allUserProfilesReducer = (userProfiles = userProfilesInitial, actio }); case types.USER_PROFILE_DELETE: - const deletedIndex = userProfiles.userProfiles.findIndex(user => user._id === action.user._id); + const deletedIndex = userProfiles.userProfiles.findIndex( + user => user._id === action.user._id, + ); return updateObject(userProfiles, { userProfiles: Object.assign([ ...userProfiles.userProfiles.slice(0, deletedIndex), @@ -64,25 +76,24 @@ export const allUserProfilesReducer = (userProfiles = userProfilesInitial, actio } }; - export const enableUserInfoEditReducer = (userProfile = userProfilesInitial, action) => { switch (action.type) { - case "ENABLE_USER_PROFILE_EDIT": - return updateObject(userProfile, {...userProfile, "editable": action.payload }) - case "DISABLE_USER_PROFILE_EDIT": - return updateObject(userProfile, { "editable": action.payload }) - case "START_USER_INFO_UPDATE": - return ({...userProfile, - newUserData: userProfile.newUserData.concat(action.payload)}) - default: return userProfile + case 'ENABLE_USER_PROFILE_EDIT': + return updateObject(userProfile, { ...userProfile, editable: action.payload }); + case 'DISABLE_USER_PROFILE_EDIT': + return updateObject(userProfile, { editable: action.payload }); + case 'START_USER_INFO_UPDATE': + return { ...userProfile, newUserData: userProfile.newUserData.concat(action.payload) }; + default: + return userProfile; } -} +}; export const changeUserPageStatusReducer = (userProfile = userProfilesInitial, action) => { switch (action.type) { - case "CHANGE_USER_PROFILE_PAGE": - - return updateObject(userProfile.pagestats, action.payload) - default: return userProfile + case 'CHANGE_USER_PROFILE_PAGE': + return updateObject(userProfile.pagestats, action.payload); + default: + return userProfile; } -} \ No newline at end of file +}; diff --git a/src/reducers/allUsersTimeEntriesReducer.js b/src/reducers/allUsersTimeEntriesReducer.js index 334b9b2087..b0de45687e 100644 --- a/src/reducers/allUsersTimeEntriesReducer.js +++ b/src/reducers/allUsersTimeEntriesReducer.js @@ -6,6 +6,7 @@ const initialState = { error: null, }; +// eslint-disable-next-line default-param-last export const allUsersTimeEntriesReducer = (state = initialState, action) => { switch (action.type) { case actions.FETCH_ALL_USERS_TIME_ENTRIES_BEGIN: @@ -33,3 +34,5 @@ export const allUsersTimeEntriesReducer = (state = initialState, action) => { return state; } }; + +export default allUsersTimeEntriesReducer; diff --git a/src/reducers/authReducer.js b/src/reducers/authReducer.js index 5a6e6f7f39..34d83bdec9 100644 --- a/src/reducers/authReducer.js +++ b/src/reducers/authReducer.js @@ -8,24 +8,26 @@ const initialState = { profilePic: '', }; +// eslint-disable-next-line default-param-last export const authReducer = (auth = initialState, action) => { if (action.type === SET_CURRENT_USER) { if (!action.payload) { return initialState; - } if (action.payload.new) { + } + if (action.payload.new) { return { ...auth, isAuthenticated: false, user: action.payload, }; - } - return { - ...auth, - isAuthenticated: !isEmpty(action.payload), - user: action.payload, - }; - - } if (action.type === SET_HEADER_DATA) { + } + return { + ...auth, + isAuthenticated: !isEmpty(action.payload), + user: action.payload, + }; + } + if (action.type === SET_HEADER_DATA) { return { ...auth, firstName: action.payload.firstName, @@ -35,3 +37,5 @@ export const authReducer = (auth = initialState, action) => { return auth; }; + +export default authReducer; diff --git a/src/reducers/badgeReducer.js b/src/reducers/badgeReducer.js index 17e8ac29c9..0d01c27bff 100644 --- a/src/reducers/badgeReducer.js +++ b/src/reducers/badgeReducer.js @@ -27,6 +27,7 @@ const badgeInitial = { activeTab: '1', }; +// eslint-disable-next-line default-param-last export const badgeReducer = (state = badgeInitial, action) => { switch (action.type) { case GET_ALL_BADGE_DATA: @@ -72,3 +73,5 @@ export const badgeReducer = (state = badgeInitial, action) => { return state; } }; + +export default badgeReducer; diff --git a/src/reducers/blueSquareEmailBcc.js b/src/reducers/blueSquareEmailBcc.js index 2c40227803..08785c4902 100644 --- a/src/reducers/blueSquareEmailBcc.js +++ b/src/reducers/blueSquareEmailBcc.js @@ -5,6 +5,7 @@ const initialState = { error: null, }; +// eslint-disable-next-line default-param-last export const BlueSquareEmailAssignment = (state = initialState, action) => { switch (action.type) { case types.GET_BLUE_SQUARE_EMAIL_ASSIGNMENTS: @@ -12,10 +13,7 @@ export const BlueSquareEmailAssignment = (state = initialState, action) => { case types.SET_BLUE_SQUARE_EMAIL_ASSIGNMENT: return { ...state, - emailAssignment: [ - ...state.emailAssignment, - action.payload - ], + emailAssignment: [...state.emailAssignment, action.payload], error: null, }; case types.DELETE_BLUE_SQUARE_EMAIL_ASSIGNMENT: @@ -24,12 +22,14 @@ export const BlueSquareEmailAssignment = (state = initialState, action) => { emailAssignment: state.emailAssignment.filter(ele => ele._id !== action.payload), error: null, }; - case types.BLUE_SQUARE_EMAIL_ASSIGNMENT_ERROR: - return { - ...state, - error: action.payload, - }; + case types.BLUE_SQUARE_EMAIL_ASSIGNMENT_ERROR: + return { + ...state, + error: action.payload, + }; default: return state; } -}; \ No newline at end of file +}; + +export default BlueSquareEmailAssignment; diff --git a/src/reducers/bmdashboard/consumablesReducer.js b/src/reducers/bmdashboard/consumablesReducer.js index bd7a09b1f7..bbd581222e 100644 --- a/src/reducers/bmdashboard/consumablesReducer.js +++ b/src/reducers/bmdashboard/consumablesReducer.js @@ -3,21 +3,21 @@ import { POST_UPDATE_CONSUMABLE_START, POST_UPDATE_CONSUMABLE_END, POST_UPDATE_CONSUMABLE_ERROR, -} from '../../constants/bmdashboard/consumableConstants'; +} from '../../constants/bmdashboard/consumableConstants'; const defaultState = { consumableslist: [], updateConsumables: { loading: false, result: null, - error: undefined + error: undefined, }, updateConsumablesBulk: { loading: false, result: null, - error: undefined - } -} + error: undefined, + }, +}; // eslint-disable-next-line import/prefer-default-export, default-param-last export const consumablesReducer = (consumables = defaultState, action) => { @@ -32,10 +32,10 @@ export const consumablesReducer = (consumables = defaultState, action) => { }; } case POST_UPDATE_CONSUMABLE_START: { - const obj = { loading: true }; - // eslint-disable-next-line no-param-reassign - consumables.updateConsumables = obj; - return { ...consumables }; + const obj = { loading: true }; + // eslint-disable-next-line no-param-reassign + consumables.updateConsumables = obj; + return { ...consumables }; } case POST_UPDATE_CONSUMABLE_END: { const obj = { @@ -61,4 +61,4 @@ export const consumablesReducer = (consumables = defaultState, action) => { default: return consumables; } -}; \ No newline at end of file +}; diff --git a/src/reducers/bmdashboard/equipmentReducer.js b/src/reducers/bmdashboard/equipmentReducer.js index 265e795cb7..d6eebde1d7 100644 --- a/src/reducers/bmdashboard/equipmentReducer.js +++ b/src/reducers/bmdashboard/equipmentReducer.js @@ -1,23 +1,26 @@ -import { GET_EQUIPMENT_BY_ID, SET_EQUIPMENTS } from "constants/bmdashboard/equipmentConstants"; +import { GET_EQUIPMENT_BY_ID, SET_EQUIPMENTS } from 'constants/bmdashboard/equipmentConstants'; const defaultState = { equipmentslist: [], - singleEquipment: {} -} + singleEquipment: {}, +}; +// eslint-disable-next-line default-param-last export const equipmentReducer = (state = defaultState, action) => { switch (action.type) { case GET_EQUIPMENT_BY_ID: return { ...state, - singleEquipment: action.payload + singleEquipment: action.payload, }; case SET_EQUIPMENTS: return { ...state, - equipmentslist: action.payload + equipmentslist: action.payload, }; default: - return state; + return state; } -}; \ No newline at end of file +}; + +export default equipmentReducer; diff --git a/src/reducers/bmdashboard/inventoryTypeReducer.js b/src/reducers/bmdashboard/inventoryTypeReducer.js index 09eaab258c..4f14f1c412 100644 --- a/src/reducers/bmdashboard/inventoryTypeReducer.js +++ b/src/reducers/bmdashboard/inventoryTypeReducer.js @@ -1,4 +1,4 @@ - +/* eslint-disable no-param-reassign */ import GET_MATERIAL_TYPES, { GET_REUSABLE_TYPES, GET_EQUIPMENT_TYPES, @@ -15,30 +15,36 @@ import GET_MATERIAL_TYPES, { GET_TOOL_TYPES, GET_CONSUMABLE_TYPES, } from '../../constants/bmdashboard/inventoryTypeConstants'; -import { POST_TOOLS_LOG, POST_ERROR_TOOLS_LOG, RESET_POST_TOOLS_LOG } from '../../constants/bmdashboard/toolsConstants' - +import { + POST_TOOLS_LOG, + POST_ERROR_TOOLS_LOG, + RESET_POST_TOOLS_LOG, +} from '../../constants/bmdashboard/toolsConstants'; const defaultState = { list: [], invTypeList: { - "All": null, "Materials": null, "Consumables": null, "Equipments": null, - "Reusables": null, "Tools:": null + All: null, + Materials: null, + Consumables: null, + Equipments: null, + Reusables: null, + 'Tools:': null, }, postedResult: { result: null, error: null, - success: null - } -} + success: null, + }, +}; -// eslint-disable-next-line import/prefer-default-export +// eslint-disable-next-line default-param-last export const bmInvTypeReducer = (state = defaultState, action) => { - switch (action.type) { case GET_MATERIAL_TYPES: state.list = action.payload; return { - ...state + ...state, }; case POST_BUILDING_CONSUMABLE_INVENTORY_TYPE: return { @@ -52,22 +58,22 @@ export const bmInvTypeReducer = (state = defaultState, action) => { case GET_REUSABLE_TYPES: state.list = action.payload; return { - ...state + ...state, }; case GET_EQUIPMENT_TYPES: state.list = action.payload; return { - ...state + ...state, }; case GET_TOOL_TYPES: state.list = action.payload; return { - ...state + ...state, }; case GET_CONSUMABLE_TYPES: state.list = action.payload; return { - ...state + ...state, }; case POST_BUILDING_MATERIAL_INVENTORY_TYPE: return { @@ -75,8 +81,8 @@ export const bmInvTypeReducer = (state = defaultState, action) => { postedResult: { result: action.payload, success: true, - error: false - } + error: false, + }, }; case POST_ERROR_BUILDING_MATERIAL_INVENTORY_TYPE: return { @@ -84,8 +90,8 @@ export const bmInvTypeReducer = (state = defaultState, action) => { postedResult: { result: action.payload, success: false, - error: true - } + error: true, + }, }; case RESET_POST_BUILDING_MATERIAL_INVENTORY_TYPE: return { @@ -93,27 +99,27 @@ export const bmInvTypeReducer = (state = defaultState, action) => { postedResult: { result: null, success: null, - error: null - } - }; - case POST_ERROR_BUILDING_CONSUMABLE_INVENTORY_TYPE: - return { - ...state, - postedResult: { - result: action.payload, - success: false, - error: true, - }, - }; - case RESET_POST_BUILDING_CONSUMABLE_INVENTORY_TYPE: - return { - ...state, - postedResult: { - result: null, - success: null, - error: null, - }, - }; + error: null, + }, + }; + case POST_ERROR_BUILDING_CONSUMABLE_INVENTORY_TYPE: + return { + ...state, + postedResult: { + result: action.payload, + success: false, + error: true, + }, + }; + case RESET_POST_BUILDING_CONSUMABLE_INVENTORY_TYPE: + return { + ...state, + postedResult: { + result: null, + success: null, + error: null, + }, + }; case POST_BUILDING_TOOL_INVENTORY_TYPE: return { ...state, @@ -124,28 +130,28 @@ export const bmInvTypeReducer = (state = defaultState, action) => { }, }; case POST_ERROR_BUILDING_TOOL_INVENTORY_TYPE: - return { - ...state, - postedResult: { - result: action.payload, - success: false, - error: true, - }, - }; - case RESET_POST_BUILDING_TOOL_INVENTORY_TYPE: - return { - ...state, - postedResult: { - result: null, - success: null, - error: null, - }, - }; + return { + ...state, + postedResult: { + result: action.payload, + success: false, + error: true, + }, + }; + case RESET_POST_BUILDING_TOOL_INVENTORY_TYPE: + return { + ...state, + postedResult: { + result: null, + success: null, + error: null, + }, + }; case GET_INV_BY_TYPE: { - state.invTypeList[action.payload.type] = [...action.payload.data] - return { ...state } + state.invTypeList[action.payload.type] = [...action.payload.data]; + return { ...state }; } - // + // case POST_TOOLS_LOG: return { // eslint-disable-next-line no-undef @@ -180,4 +186,6 @@ export const bmInvTypeReducer = (state = defaultState, action) => { return state; } } -}; \ No newline at end of file +}; + +export default bmInvTypeReducer; diff --git a/src/reducers/bmdashboard/inventoryUnitReducer.js b/src/reducers/bmdashboard/inventoryUnitReducer.js index 5e9431aa3b..fd05185cac 100644 --- a/src/reducers/bmdashboard/inventoryUnitReducer.js +++ b/src/reducers/bmdashboard/inventoryUnitReducer.js @@ -1,31 +1,33 @@ +/* eslint-disable no-param-reassign */ import { FETCH_BUILDING_MATERIAL_INVENTORY_UNITS, - POST_BUILDING_MATERIAL_INVENTORY_UNIT, RESET_POST_BUILDING_MATERIAL_INVENTORY_UNIT -} from "constants/bmdashboard/inventoryTypeConstants"; + POST_BUILDING_MATERIAL_INVENTORY_UNIT, + RESET_POST_BUILDING_MATERIAL_INVENTORY_UNIT, +} from 'constants/bmdashboard/inventoryTypeConstants'; const defaultState = { list: [], postedResult: { result: null, error: null, - success: null - } -} + success: null, + }, +}; +// eslint-disable-next-line default-param-last export const bmInvUnitReducer = (state = defaultState, action) => { - switch (action.type) { case FETCH_BUILDING_MATERIAL_INVENTORY_UNITS: state.list = action.payload; - return { ...state } + return { ...state }; case POST_BUILDING_MATERIAL_INVENTORY_UNIT: return { ...state, postedResult: { result: action.payload, success: true, - error: false - } + error: false, + }, }; case RESET_POST_BUILDING_MATERIAL_INVENTORY_UNIT: return { @@ -33,12 +35,13 @@ export const bmInvUnitReducer = (state = defaultState, action) => { postedResult: { result: null, success: null, - error: null - } - } - default: - { - return state; - } + error: null, + }, + }; + default: { + return state; + } } -} \ No newline at end of file +}; + +export default bmInvUnitReducer; diff --git a/src/reducers/bmdashboard/lessonsReducer.js b/src/reducers/bmdashboard/lessonsReducer.js index 25a77eb7f6..f1201e9738 100644 --- a/src/reducers/bmdashboard/lessonsReducer.js +++ b/src/reducers/bmdashboard/lessonsReducer.js @@ -1,83 +1,73 @@ -import { GET_BM_LESSONS, UPDATE_LESSON, DELETE_LESSON, BM_LESSON_LIKES, SET_LESSON } from '../../constants/bmdashboard/lessonConstants' +import { + GET_BM_LESSONS, + UPDATE_LESSON, + DELETE_LESSON, + BM_LESSON_LIKES, + SET_LESSON, +} from '../../constants/bmdashboard/lessonConstants'; const initialState = { lessons: [], }; +// eslint-disable-next-line default-param-last export const lessonsReducer = (state = initialState, action) => { switch (action.type) { - case GET_BM_LESSONS: + case GET_BM_LESSONS: { return { lessons: action.payload, }; - + } - case UPDATE_LESSON: - const index = state.lessons.findIndex(lesson => lesson._id === action.lessonId); - - if (index !== -1) { - const updatedLesson = { - ...state.lessons[index], - content: action.content, - }; - - return { - ...state, - lessons: [ - ...state.lessons.slice(0, index), - updatedLesson, - ...state.lessons.slice(index + 1), - ], - }; - } - - // Return the current state if the lesson with the given ID is not found - return state; - + case UPDATE_LESSON: { + const { lessonId, content } = action; + const updatedLessons = state.lessons.map(lesson => + lesson._id === lessonId ? { ...lesson, content } : lesson, + ); - case DELETE_LESSON: - const lessonIdToDelete = action.payload; - // Find the index of the lesson to delete - const lessonIndex = state.lessons.findIndex(lesson => lesson._id === lessonIdToDelete); - - if (lessonIndex !== -1) { - // Create a new array without the deleted lesson - const updatedLessons = [ - ...state.lessons.slice(0, lessonIndex), - ...state.lessons.slice(lessonIndex + 1), - ]; - - return { - ...state, - lessons: updatedLessons, - }; - } - - return state; + return { + ...state, + lessons: updatedLessons, + }; + } + case DELETE_LESSON: { + const lessonIdToDelete = action.payload; + const updatedLessons = state.lessons.filter(lesson => lesson._id !== lessonIdToDelete); - case SET_LESSON: return { ...state, - lessons: state.lessons.map((lesson) => - lesson._id === action.payload._id ? action.payload : lesson - ), + lessons: updatedLessons, }; - case BM_LESSON_LIKES: - const updatedLesson = action.payload; - const updatedLessons = state.lessons.map(lesson => { - return lesson._id === updatedLesson._id ? updatedLesson : lesson; - }); - - return { - ...state, - lessons: updatedLessons, - }; + } + + case SET_LESSON: { + const updatedLessons = state.lessons.map(lesson => + lesson._id === action.payload._id ? action.payload : lesson, + ); - default: - return state; - } -} + return { + ...state, + lessons: updatedLessons, + }; + } + case BM_LESSON_LIKES: { + const updatedLesson = action.payload; + const updatedLessons = state.lessons.map(lesson => + lesson._id === updatedLesson._id ? updatedLesson : lesson, + ); + + return { + ...state, + lessons: updatedLessons, + }; + } + + default: { + return state; + } + } +}; - +export default lessonsReducer; diff --git a/src/reducers/bmdashboard/materialsReducer.js b/src/reducers/bmdashboard/materialsReducer.js index a9c08afea4..8726beecb7 100644 --- a/src/reducers/bmdashboard/materialsReducer.js +++ b/src/reducers/bmdashboard/materialsReducer.js @@ -1,96 +1,97 @@ +/* eslint-disable no-param-reassign */ import { - SET_MATERIALS, POST_UPDATE_MATERIAL_START_BULK, POST_UPDATE_MATERIAL_END_BULK, - RESET_UPDATE_MATERIAL_BULK, POST_UPDATE_MATERIAL_ERROR_BULK, POST_UPDATE_MATERIAL_START, POST_UPDATE_MATERIAL_END, - RESET_UPDATE_MATERIAL, POST_UPDATE_MATERIAL_ERROR -} from "constants/bmdashboard/materialsConstants" + SET_MATERIALS, + POST_UPDATE_MATERIAL_START_BULK, + POST_UPDATE_MATERIAL_END_BULK, + RESET_UPDATE_MATERIAL_BULK, + POST_UPDATE_MATERIAL_ERROR_BULK, + POST_UPDATE_MATERIAL_START, + POST_UPDATE_MATERIAL_END, + RESET_UPDATE_MATERIAL, + POST_UPDATE_MATERIAL_ERROR, +} from 'constants/bmdashboard/materialsConstants'; const defaultState = { materialslist: [], updateMaterials: { loading: false, result: null, - error: undefined + error: undefined, }, updateMaterialsBulk: { loading: false, result: null, - error: undefined - } -} + error: undefined, + }, +}; +// eslint-disable-next-line default-param-last export const materialsReducer = (materials = defaultState, action) => { switch (action.type) { - case SET_MATERIALS: - { - materials.materialslist = action.payload; - return { - ...materials, updateMaterials: { ...defaultState.updateMaterials }, - updateMaterialsBulk: { ...defaultState.updateMaterialsBulk } - } - } - case POST_UPDATE_MATERIAL_START: - { - const obj = { loading: true }; - materials.updateMaterials = obj; - return { ...materials } - } - case POST_UPDATE_MATERIAL_END: - { - const obj = { - result: action.payload, - loading: false, - error: false - } - materials.updateMaterials = obj; - return { ...materials } - } - case POST_UPDATE_MATERIAL_ERROR: - { - const obj = { - result: action.payload, - loading: false, - error: true - } - materials.updateMaterials = obj; - return { ...materials } - } - case RESET_UPDATE_MATERIAL: - { - const obj = { - loading: false, - result: null, - error: undefined - } - materials.updateMaterials = obj - return { ...materials } + case SET_MATERIALS: { + materials.materialslist = action.payload; + return { + ...materials, + updateMaterials: { ...defaultState.updateMaterials }, + updateMaterialsBulk: { ...defaultState.updateMaterialsBulk }, + }; + } + case POST_UPDATE_MATERIAL_START: { + const obj = { loading: true }; + materials.updateMaterials = obj; + return { ...materials }; + } + case POST_UPDATE_MATERIAL_END: { + const obj = { + result: action.payload, + loading: false, + error: false, + }; + materials.updateMaterials = obj; + return { ...materials }; + } + case POST_UPDATE_MATERIAL_ERROR: { + const obj = { + result: action.payload, + loading: false, + error: true, + }; + materials.updateMaterials = obj; + return { ...materials }; + } + case RESET_UPDATE_MATERIAL: { + const obj = { + loading: false, + result: null, + error: undefined, + }; + materials.updateMaterials = obj; + return { ...materials }; + } + case POST_UPDATE_MATERIAL_START_BULK: { + const obj = { loading: true }; + materials.updateMaterialsBulk = obj; + return { ...materials }; + } + case POST_UPDATE_MATERIAL_END_BULK: { + const obj = { result: action.payload, loading: false, error: false }; + materials.updateMaterialsBulk = obj; + return { ...materials }; + } - } - case POST_UPDATE_MATERIAL_START_BULK: - { - const obj = { loading: true } - materials.updateMaterialsBulk = obj; - return { ...materials } - } - case POST_UPDATE_MATERIAL_END_BULK: - { - const obj = { result: action.payload, loading: false, error: false } - materials.updateMaterialsBulk = obj; - return { ...materials } - } - - case POST_UPDATE_MATERIAL_ERROR_BULK: - { - const obj = { result: action.payload, loading: false, error: true } - materials.updateMaterialsBulk = obj; - return { ...materials } - } - case RESET_UPDATE_MATERIAL_BULK: - { - const obj = { loading: false, result: null, error: undefined } - materials.updateMaterialsBulk = obj; - return { ...materials } - } + case POST_UPDATE_MATERIAL_ERROR_BULK: { + const obj = { result: action.payload, loading: false, error: true }; + materials.updateMaterialsBulk = obj; + return { ...materials }; + } + case RESET_UPDATE_MATERIAL_BULK: { + const obj = { loading: false, result: null, error: undefined }; + materials.updateMaterialsBulk = obj; + return { ...materials }; + } default: return materials; } -} \ No newline at end of file +}; + +export default materialsReducer; diff --git a/src/reducers/bmdashboard/projectByIdReducer.js b/src/reducers/bmdashboard/projectByIdReducer.js index 1dd87b59b0..63d64c1b56 100644 --- a/src/reducers/bmdashboard/projectByIdReducer.js +++ b/src/reducers/bmdashboard/projectByIdReducer.js @@ -1,8 +1,11 @@ -import GET_BM_PROJECT_BY_ID from "constants/bmdashboard/projectConstants" +import GET_BM_PROJECT_BY_ID from 'constants/bmdashboard/projectConstants'; +// eslint-disable-next-line default-param-last export const bmProjectByIdReducer = (project = null, action) => { - if(action.type === GET_BM_PROJECT_BY_ID) { - return action.payload + if (action.type === GET_BM_PROJECT_BY_ID) { + return action.payload; } - return project -} + return project; +}; + +export default bmProjectByIdReducer; diff --git a/src/reducers/bmdashboard/projectReducer.js b/src/reducers/bmdashboard/projectReducer.js index 8be6076b82..0ca2757903 100644 --- a/src/reducers/bmdashboard/projectReducer.js +++ b/src/reducers/bmdashboard/projectReducer.js @@ -1,8 +1,11 @@ -import GET_BM_PROJECTS from "constants/bmdashboard/projectConstants" +import GET_BM_PROJECTS from 'constants/bmdashboard/projectConstants'; +// eslint-disable-next-line default-param-last export const bmProjectReducer = (materials = [], action) => { - if(action.type === GET_BM_PROJECTS) { - return action.payload + if (action.type === GET_BM_PROJECTS) { + return action.payload; } - return materials -} \ No newline at end of file + return materials; +}; + +export default bmProjectReducer; diff --git a/src/reducers/bmdashboard/reusablesReducer.js b/src/reducers/bmdashboard/reusablesReducer.js index 3e9fe68ae6..33357103b0 100644 --- a/src/reducers/bmdashboard/reusablesReducer.js +++ b/src/reducers/bmdashboard/reusablesReducer.js @@ -1,96 +1,97 @@ +/* eslint-disable no-param-reassign */ import { - SET_REUSABLES, POST_UPDATE_REUSABLE_START_BULK, POST_UPDATE_REUSABLE_END_BULK, - RESET_UPDATE_REUSABLE_BULK, POST_UPDATE_REUSABLE_ERROR_BULK, POST_UPDATE_REUSABLE_START, POST_UPDATE_REUSABLE_END, - RESET_UPDATE_REUSABLE, POST_UPDATE_REUSABLE_ERROR -} from "constants/bmdashboard/reusableConstants" + SET_REUSABLES, + POST_UPDATE_REUSABLE_START_BULK, + POST_UPDATE_REUSABLE_END_BULK, + RESET_UPDATE_REUSABLE_BULK, + POST_UPDATE_REUSABLE_ERROR_BULK, + POST_UPDATE_REUSABLE_START, + POST_UPDATE_REUSABLE_END, + RESET_UPDATE_REUSABLE, + POST_UPDATE_REUSABLE_ERROR, +} from 'constants/bmdashboard/reusableConstants'; const defaultState = { reusablesList: [], updateReusables: { loading: false, result: null, - error: undefined + error: undefined, }, updateReusablesBulk: { loading: false, result: null, - error: undefined - } -} + error: undefined, + }, +}; +// eslint-disable-next-line default-param-last export const reusablesReducer = (reusables = defaultState, action) => { switch (action.type) { - case SET_REUSABLES: - { - reusables.reusablesList = action.payload; - return { - ...reusables, updateReusables: { ...defaultState.updateReusables }, - updateReusablesBulk: { ...defaultState.updateReusablesBulk } - } - } - case POST_UPDATE_REUSABLE_START: - { - const obj = { loading: true }; - reusables.updateReusables = obj; - return { ...reusables } - } - case POST_UPDATE_REUSABLE_END: - { - const obj = { - result: action.payload, - loading: false, - error: false - } - reusables.updateReusables = obj; - return { ...reusables } - } - case POST_UPDATE_REUSABLE_ERROR: - { - const obj = { - result: action.payload, - loading: false, - error: true - } - reusables.updateReusables = obj; - return { ...reusables } - } - case RESET_UPDATE_REUSABLE: - { - const obj = { - loading: false, - result: null, - error: undefined - } - reusables.updateReusables = obj - return { ...reusables } + case SET_REUSABLES: { + reusables.reusablesList = action.payload; + return { + ...reusables, + updateReusables: { ...defaultState.updateReusables }, + updateReusablesBulk: { ...defaultState.updateReusablesBulk }, + }; + } + case POST_UPDATE_REUSABLE_START: { + const obj = { loading: true }; + reusables.updateReusables = obj; + return { ...reusables }; + } + case POST_UPDATE_REUSABLE_END: { + const obj = { + result: action.payload, + loading: false, + error: false, + }; + reusables.updateReusables = obj; + return { ...reusables }; + } + case POST_UPDATE_REUSABLE_ERROR: { + const obj = { + result: action.payload, + loading: false, + error: true, + }; + reusables.updateReusables = obj; + return { ...reusables }; + } + case RESET_UPDATE_REUSABLE: { + const obj = { + loading: false, + result: null, + error: undefined, + }; + reusables.updateReusables = obj; + return { ...reusables }; + } + case POST_UPDATE_REUSABLE_START_BULK: { + const obj = { loading: true }; + reusables.updateReusablesBulk = obj; + return { ...reusables }; + } + case POST_UPDATE_REUSABLE_END_BULK: { + const obj = { result: action.payload, loading: false, error: false }; + reusables.updateReusablesBulk = obj; + return { ...reusables }; + } - } - case POST_UPDATE_REUSABLE_START_BULK: - { - const obj = { loading: true } - reusables.updateReusablesBulk = obj; - return { ...reusables } - } - case POST_UPDATE_REUSABLE_END_BULK: - { - const obj = { result: action.payload, loading: false, error: false } - reusables.updateReusablesBulk = obj; - return { ...reusables } - } - - case POST_UPDATE_REUSABLE_ERROR_BULK: - { - const obj = { result: action.payload, loading: false, error: true } - reusables.updateReusablesBulk = obj; - return { ...reusables } - } - case RESET_UPDATE_REUSABLE_BULK: - { - const obj = { loading: false, result: null, error: undefined } - reusables.updateReusablesBulk = obj; - return { ...reusables } - } + case POST_UPDATE_REUSABLE_ERROR_BULK: { + const obj = { result: action.payload, loading: false, error: true }; + reusables.updateReusablesBulk = obj; + return { ...reusables }; + } + case RESET_UPDATE_REUSABLE_BULK: { + const obj = { loading: false, result: null, error: undefined }; + reusables.updateReusablesBulk = obj; + return { ...reusables }; + } default: return reusables; } -} \ No newline at end of file +}; + +export default reusablesReducer; diff --git a/src/reducers/dashboardReducer.js b/src/reducers/dashboardReducer.js index 7282c955e0..0027240185 100644 --- a/src/reducers/dashboardReducer.js +++ b/src/reducers/dashboardReducer.js @@ -4,9 +4,11 @@ const initialState = { taskCounts: {}, }; +// eslint-disable-next-line default-param-last const dashboardReducer = (state = initialState, action) => { switch (action.type) { - case INCREMENT_DASHBOARD_TASK_COUNT: + case INCREMENT_DASHBOARD_TASK_COUNT: { + // Wrap case block in braces to avoid scoping issues const { taskId } = action.payload; const previousCount = state.taskCounts[taskId] || 0; const newCount = previousCount + 1; @@ -17,9 +19,11 @@ const dashboardReducer = (state = initialState, action) => { [taskId]: newCount, }, }; - default: + } + default: { return state; + } } }; -export default dashboardReducer; \ No newline at end of file +export default dashboardReducer; diff --git a/src/reducers/errorsReducer.js b/src/reducers/errorsReducer.js index 4bf7e06d1b..56bf994ec2 100644 --- a/src/reducers/errorsReducer.js +++ b/src/reducers/errorsReducer.js @@ -2,6 +2,7 @@ import { GET_ERRORS, CLEAR_ERRORS } from '../constants/errors'; const initialState = {}; +// eslint-disable-next-line default-param-last export const errorsReducer = (state = initialState, action) => { switch (action.type) { case GET_ERRORS: @@ -12,3 +13,5 @@ export const errorsReducer = (state = initialState, action) => { return state; } }; + +export default errorsReducer; diff --git a/src/reducers/followUpReducer.js b/src/reducers/followUpReducer.js index ea20d5e478..90fd119994 100644 --- a/src/reducers/followUpReducer.js +++ b/src/reducers/followUpReducer.js @@ -1,10 +1,11 @@ -import * as types from './../constants/followUpConstants'; +import * as types from '../constants/followUpConstants'; const initialState = { followUps: {}, error: null, }; +// eslint-disable-next-line default-param-last export const followUpReducer = (state = initialState, action) => { switch (action.type) { case types.FETCH_ALL_FOLLOWUPS: @@ -28,3 +29,5 @@ export const followUpReducer = (state = initialState, action) => { return state; } }; + +export default followUpReducer; diff --git a/src/reducers/handleSuccessReducer.js b/src/reducers/handleSuccessReducer.js index 158a20578a..884ae783ab 100644 --- a/src/reducers/handleSuccessReducer.js +++ b/src/reducers/handleSuccessReducer.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line default-param-last export const handleSuccessReducer = (status = null, action) => { if (action.type === 'REQUEST_SUCCEEDED') { return action.payload; @@ -9,3 +10,5 @@ export const handleSuccessReducer = (status = null, action) => { return status; }; + +export default handleSuccessReducer; diff --git a/src/reducers/index.js b/src/reducers/index.js index e79174b9d8..a710befb47 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -1,22 +1,25 @@ -import { combineReducers } from 'redux'; import { teamMemberTasksReducer } from 'components/TeamMemberTasks/reducer'; import { taskEditSuggestionsReducer } from 'components/TaskEditSuggestions/reducer'; import { userProfileByIdReducer, userTaskByIdReducer } from './userProfileByIdReducer'; import { authReducer } from './authReducer'; -import { allUserProfilesBasicInfoReducer } from './allUserProfilesBasicInfoReducer'; -import { allUserProfilesReducer, changeUserPageStatusReducer, enableUserInfoEditReducer, updateUserInfoReducer } from './allUserProfilesReducer'; +import { allUserProfilesBasicInfoReducer } from './allUserProfilesBasicInfoReducer'; +import { + allUserProfilesReducer, + changeUserPageStatusReducer, + enableUserInfoEditReducer, +} from './allUserProfilesReducer'; import { leaderboardDataReducer, orgDataReducer } from './leaderboardDataReducer'; -import { weeklySummariesReducer } from './weeklySummariesReducer'; -import { weeklySummariesReportReducer } from './weeklySummariesReportReducer'; +import weeklySummariesReducer from './weeklySummariesReducer'; +import weeklySummariesReportReducer from './weeklySummariesReportReducer'; import { allProjectsReducer } from './allProjectsReducer'; import { projectReportReducer } from './projectReportReducer'; -import { userProjectsReducer } from './userProjectsReducer'; +import userProjectsReducer from './userProjectsReducer'; import { projectMembershipReducer } from './projectMembershipReducer'; import { allUserTeamsReducer } from './allTeamsReducer'; import { teamByIdReducer } from './teamByIdReducer'; import { errorsReducer } from './errorsReducer'; import { timeEntriesReducer } from './timeEntriesReducer'; -import { wbsReducer } from './wbsReducer'; +import wbsReducer from './wbsReducer'; import { taskReducer } from './allTasksReducer'; import { managingTeamsReducer } from './managingTeamsReducer'; import { teamUsersReducer } from './teamsTeamMembersReducer'; @@ -26,15 +29,14 @@ import { popupEditorReducer } from './popupEditorReducer'; import { roleReducer } from './roleReducer'; import { rolePresetReducer } from './rolePresetReducer'; import { ownerMessageReducer } from './ownerMessageReducer'; -import { warningsByUserIdReducer } from './warningsReducer'; +import warningsByUserIdReducer from './warningsReducer'; import { infoCollectionsReducer } from './informationReducer'; -import { weeklySummariesAIPromptReducer } from './weeklySummariesAIPromptReducer'; -import { mouseoverTextReducer } from './mouseoverTextReducer'; +import mouseoverTextReducer from './mouseoverTextReducer'; import notificationReducer from './notificationReducer'; -import { weeklySummaryRecipientsReducer } from "./weeklySummaryRecipientsReducer"; -import { followUpReducer } from "./followUpReducer"; +import weeklySummaryRecipientsReducer from './weeklySummaryRecipientsReducer'; +import { followUpReducer } from './followUpReducer'; import { BlueSquareEmailAssignment } from './blueSquareEmailBcc'; -import {userProjectsByUserNameReducer} from './userProjectsByUserNameReducer'; +import userProjectsByUserNameReducer from './userProjectsByUserNameReducer'; import { projectByIdReducer } from './projectByIdReducer'; // bm dashboard @@ -48,8 +50,8 @@ import { bmInvUnitReducer } from './bmdashboard/inventoryUnitReducer'; import { consumablesReducer } from './bmdashboard/consumablesReducer'; import { toolReducer } from './bmdashboard/toolReducer'; import { equipmentReducer } from './bmdashboard/equipmentReducer'; -import dashboardReducer from '../reducers/dashboardReducer'; -import { timeOffRequestsReducer } from "./timeOffRequestReducer"; +import dashboardReducer from './dashboardReducer'; +import { timeOffRequestsReducer } from './timeOffRequestReducer'; import { totalOrgSummaryReducer } from './totalOrgSummaryReducer'; import { allUsersTimeEntriesReducer } from './allUsersTimeEntriesReducer'; @@ -76,14 +78,14 @@ const localReducers = { ownerMessage: ownerMessageReducer, infoCollections: infoCollectionsReducer, mouseoverText: mouseoverTextReducer, - weeklySummaryRecipients:weeklySummaryRecipientsReducer, + weeklySummaryRecipients: weeklySummaryRecipientsReducer, notification: notificationReducer, - userFollowUp : followUpReducer, - userProjectsByUserNameReducer: userProjectsByUserNameReducer, - blueSquareEmailAssignment : BlueSquareEmailAssignment, + userFollowUp: followUpReducer, + userProjectsByUserNameReducer, + blueSquareEmailAssignment: BlueSquareEmailAssignment, totalOrgSummary: totalOrgSummaryReducer, allUsersTimeEntries: allUsersTimeEntriesReducer, - allUserProfilesBasicInfo : allUserProfilesBasicInfoReducer, + allUserProfilesBasicInfo: allUserProfilesBasicInfoReducer, projectById: projectByIdReducer, // bmdashboard @@ -99,12 +101,12 @@ const localReducers = { bmInvUnits: bmInvUnitReducer, bmConsumables: consumablesReducer, bmReusables: reusablesReducer, - dashboard: dashboardReducer + dashboard: dashboardReducer, }; const sessionReducers = { - userPagination:changeUserPageStatusReducer, - userProfileEdit:enableUserInfoEditReducer, + userPagination: changeUserPageStatusReducer, + userProfileEdit: enableUserInfoEditReducer, userProfile: userProfileByIdReducer, userTask: userTaskByIdReducer, leaderBoardData: leaderboardDataReducer, diff --git a/src/reducers/informationReducer.js b/src/reducers/informationReducer.js index 82ff927454..c796cc6d45 100644 --- a/src/reducers/informationReducer.js +++ b/src/reducers/informationReducer.js @@ -6,7 +6,7 @@ const initialState = { fetchError: null, }; -// eslint-disable-next-line import/prefer-default-export +// eslint-disable-next-line default-param-last export const infoCollectionsReducer = (state = initialState, action) => { switch (action.type) { case actions.FETCH_INFOS_BEGIN: @@ -30,12 +30,14 @@ export const infoCollectionsReducer = (state = initialState, action) => { fetchError: action.payload.error, }; case actions.ADD_INFO_SUCCESS: - return { - ...state, - infoCollections: [...state.infoCollections, action.payload.newInfo], - }; - + return { + ...state, + infoCollections: [...state.infoCollections, action.payload.newInfo], + }; + default: return state; } }; + +export default infoCollectionsReducer; diff --git a/src/reducers/leaderboardDataReducer.js b/src/reducers/leaderboardDataReducer.js index 5caac4c84d..843636eec4 100644 --- a/src/reducers/leaderboardDataReducer.js +++ b/src/reducers/leaderboardDataReducer.js @@ -1,3 +1,4 @@ +/* eslint-disable default-param-last */ export const leaderboardDataReducer = (leaderBoardData = [], action) => { if (action.type === 'GET_LEADERBOARD_DATA') { return action.payload; diff --git a/src/reducers/managingTeamsReducer.js b/src/reducers/managingTeamsReducer.js index 79277e49a2..6857a56e49 100644 --- a/src/reducers/managingTeamsReducer.js +++ b/src/reducers/managingTeamsReducer.js @@ -13,6 +13,7 @@ const updateObject = (oldObject, updatedProperties) => ({ ...updatedProperties, }); +// eslint-disable-next-line default-param-last export const managingTeamsReducer = (managingTeams = managingTeamsInitial, action) => { switch (action.type) { case FETCH_PROJECTS_START: @@ -25,9 +26,10 @@ export const managingTeamsReducer = (managingTeams = managingTeamsInitial, actio status: '200', }); case FETCH_TEAMS_ERROR: - console.error('managingTeamsReducer Error: ', action.payload); return { ...managingTeams, fetching: false, status: action.payload }; default: return managingTeams; } }; + +export default managingTeamsReducer; diff --git a/src/reducers/monthlyDashboardDataReducer.js b/src/reducers/monthlyDashboardDataReducer.js index 3fb2e03bd9..e41ad61cf7 100644 --- a/src/reducers/monthlyDashboardDataReducer.js +++ b/src/reducers/monthlyDashboardDataReducer.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line default-param-last export const monthlyDashboardDataReducer = (monthlyDashboardData = null, action) => { if (action.type === 'GET_MONTHLY_DASHBOARD_DATA') { return action.payload; @@ -5,3 +6,5 @@ export const monthlyDashboardDataReducer = (monthlyDashboardData = null, action) return monthlyDashboardData; }; + +export default monthlyDashboardDataReducer; diff --git a/src/reducers/mouseoverTextReducer.js b/src/reducers/mouseoverTextReducer.js index 1b6379b8a5..b4089231b3 100644 --- a/src/reducers/mouseoverTextReducer.js +++ b/src/reducers/mouseoverTextReducer.js @@ -1,20 +1,30 @@ -import * as types from './../constants/mouseoverTextConstants'; +import * as types from '../constants/mouseoverTextConstants'; const initialState = null; +// eslint-disable-next-line default-param-last export const mouseoverTextReducer = (state = initialState, action) => { switch (action.type) { - case types.GET_MOUSEOVER_TEXT: - const data = action.payload; - return data; + case types.GET_MOUSEOVER_TEXT: { + // Directly return the payload for GET_MOUSEOVER_TEXT + return action.payload; + } - case types.CREATE_MOUSEOVER_TEXT: + case types.CREATE_MOUSEOVER_TEXT: { + // Placeholder for creating mouseover text, if needed in the future return state; + } - case types.UPDATE_MOUSEOVER_TEXT: + case types.UPDATE_MOUSEOVER_TEXT: { + // Placeholder for updating mouseover text, if needed in the future return state; + } - default: + default: { + // Ensure the current state is returned by default return state; + } } }; + +export default mouseoverTextReducer; diff --git a/src/reducers/notificationReducer.js b/src/reducers/notificationReducer.js index c7ebeba5de..141154a652 100644 --- a/src/reducers/notificationReducer.js +++ b/src/reducers/notificationReducer.js @@ -8,96 +8,109 @@ const initialState = { error: null, }; +// eslint-disable-next-line default-param-last const notificationReducer = (state = initialState, action) => { - switch (action.type) { + // Handle request actions case actionTypes.FETCH_USER_NOTIFICATIONS_REQUEST: case actionTypes.FETCH_UNREAD_USER_NOTIFICATIONS_REQUEST: case actionTypes.FETCH_SENT_NOTIFICATIONS_REQUEST: case actionTypes.CREATE_NOTIFICATION_REQUEST: case actionTypes.DELETE_NOTIFICATION_REQUEST: - case actionTypes.MARK_NOTIFICATION_AS_READ_REQUEST: + case actionTypes.MARK_NOTIFICATION_AS_READ_REQUEST: { return { ...state, loading: true, error: null, }; + } - // Handle success and failure cases - + // Handle failure actions case actionTypes.FETCH_USER_NOTIFICATIONS_FAILURE: case actionTypes.FETCH_UNREAD_USER_NOTIFICATIONS_FAILURE: case actionTypes.FETCH_SENT_NOTIFICATIONS_FAILURE: case actionTypes.CREATE_NOTIFICATION_FAILURE: case actionTypes.DELETE_NOTIFICATION_FAILURE: - case actionTypes.MARK_NOTIFICATION_AS_READ_FAILURE: + case actionTypes.MARK_NOTIFICATION_AS_READ_FAILURE: { return { ...state, loading: false, error: action.payload, - }; + }; + } - case actionTypes.RESET_ERROR: + // Reset error state + case actionTypes.RESET_ERROR: { return { ...state, error: null, }; + } - case actionTypes.FETCH_USER_NOTIFICATIONS_SUCCESS: + // Handle success actions + case actionTypes.FETCH_USER_NOTIFICATIONS_SUCCESS: { return { ...state, notifications: action.payload, loading: false, error: null, }; + } - case actionTypes.FETCH_UNREAD_USER_NOTIFICATIONS_SUCCESS: + case actionTypes.FETCH_UNREAD_USER_NOTIFICATIONS_SUCCESS: { return { ...state, unreadNotifications: action.payload, loading: false, error: null, }; + } - // case actionTypes.FETCH_SENT_NOTIFICATIONS_SUCCESS: - // return { - // ...state, - // sentNotifications: action.payload, - // loading: false, - // error: null, - // }; + case actionTypes.FETCH_SENT_NOTIFICATIONS_SUCCESS: { + return { + ...state, + sentNotifications: action.payload, + loading: false, + error: null, + }; + } - // case actionTypes.CREATE_NOTIFICATION_SUCCESS: - // return { - // ...state, - // notifications: [...state.notifications, action.payload], - // loading: false, - // error: null, - // }; + case actionTypes.CREATE_NOTIFICATION_SUCCESS: { + return { + ...state, + notifications: [...state.notifications, action.payload], + loading: false, + error: null, + }; + } - // case actionTypes.DELETE_NOTIFICATION_SUCCESS: - // return { - // ...state, - // notifications: state.notifications.filter((notification) => notification.id !== action.payload), - // loading: false, - // error: null, - // }; + case actionTypes.DELETE_NOTIFICATION_SUCCESS: { + return { + ...state, + notifications: state.notifications.filter( + notification => notification.id !== action.payload, + ), + loading: false, + error: null, + }; + } - case actionTypes.MARK_NOTIFICATION_AS_READ_SUCCESS: - const { unreadNotifications } = state; - const updatedUnreadNotifications = unreadNotifications.filter((notification) => notification._id !== action.payload); + case actionTypes.MARK_NOTIFICATION_AS_READ_SUCCESS: { + const updatedUnreadNotifications = state.unreadNotifications.filter( + notification => notification._id !== action.payload, + ); return { ...state, - // remove the notification from unreadNotifications unreadNotifications: updatedUnreadNotifications, loading: false, error: null, }; + } - + // Default case default: return state; } }; -export default notificationReducer; \ No newline at end of file +export default notificationReducer; diff --git a/src/reducers/ownerMessageReducer.js b/src/reducers/ownerMessageReducer.js index f64cbbe3b4..12992eb38d 100644 --- a/src/reducers/ownerMessageReducer.js +++ b/src/reducers/ownerMessageReducer.js @@ -1,16 +1,19 @@ -import * as types from "../constants/ownerMessageConstants"; +import * as types from '../constants/ownerMessageConstants'; const initialState = { message: '', standardMessage: '', }; +// eslint-disable-next-line default-param-last export const ownerMessageReducer = (state = initialState, action) => { - switch(action.type) { + switch (action.type) { case types.UPDATE_OWNER_MESSAGE: return action.payload; - - default: + + default: return state; } -} \ No newline at end of file +}; + +export default ownerMessageReducer; diff --git a/src/reducers/popupEditorReducer.js b/src/reducers/popupEditorReducer.js index 2b3f622cac..f74daf7131 100644 --- a/src/reducers/popupEditorReducer.js +++ b/src/reducers/popupEditorReducer.js @@ -1,4 +1,4 @@ -import * as types from "../constants/popupEditorConstants"; +import * as types from '../constants/popupEditorConstants'; const allPopupEditorInital = { fetching: false, @@ -8,9 +8,10 @@ const allPopupEditorInital = { error: '', }; +// eslint-disable-next-line default-param-last export const popupEditorReducer = (allPopup = allPopupEditorInital, action) => { switch (action.type) { - case types.RECEIVE_POPUP: + case types.RECEIVE_POPUP: { return { ...allPopup, popupItems: action.popupItems, @@ -18,7 +19,8 @@ export const popupEditorReducer = (allPopup = allPopupEditorInital, action) => { fetching: false, error: 'none', }; - case types.CURRENT_POPUP: + } + case types.CURRENT_POPUP: { return { ...allPopup, currPopup: action.currPopup, @@ -26,6 +28,12 @@ export const popupEditorReducer = (allPopup = allPopupEditorInital, action) => { fetching: false, error: 'none', }; + } + default: { + // Explicit default case for clarity and extensibility + return allPopup; + } } - return allPopup; }; + +export default popupEditorReducer; diff --git a/src/reducers/projectByIdReducer.js b/src/reducers/projectByIdReducer.js index dd33ea859e..420abf18f3 100644 --- a/src/reducers/projectByIdReducer.js +++ b/src/reducers/projectByIdReducer.js @@ -1,8 +1,11 @@ import { GET_PROJECT_BY_ID } from '../constants/project'; +// eslint-disable-next-line default-param-last export const projectByIdReducer = (project = null, action) => { if (action.type === GET_PROJECT_BY_ID) { return action.payload; } return project; }; + +export default projectByIdReducer; diff --git a/src/reducers/projectMembershipReducer.js b/src/reducers/projectMembershipReducer.js index 3dade0d78a..d19649c880 100644 --- a/src/reducers/projectMembershipReducer.js +++ b/src/reducers/projectMembershipReducer.js @@ -1,4 +1,4 @@ -import * as types from "../constants/projectMembership"; +import * as types from '../constants/projectMembership'; const allMembershipInital = { projectName: '', @@ -9,13 +9,18 @@ const allMembershipInital = { error: '', }; +// eslint-disable-next-line default-param-last export const projectMembershipReducer = (allMembership = allMembershipInital, action) => { switch (action.type) { - case types.FETCH_MEMBERS_START: + case types.FETCH_MEMBERS_START: { return { ...allMembership, fetched: false, fetching: true, error: 'none' }; - case types.FETCH_MEMBERS_ERROR: + } + + case types.FETCH_MEMBERS_ERROR: { return { ...allMembership, fetched: true, fetching: false, error: action.err }; - case types.RECEIVE_MEMBERS: + } + + case types.RECEIVE_MEMBERS: { return { ...allMembership, members: action.members, @@ -23,11 +28,17 @@ export const projectMembershipReducer = (allMembership = allMembershipInital, ac fetching: false, error: 'none', }; - case types.FIND_USERS_START: + } + + case types.FIND_USERS_START: { return { ...allMembership, fetched: false, fetching: true, error: 'none' }; - case types.FIND_USERS_ERROR: + } + + case types.FIND_USERS_ERROR: { return { ...allMembership, fetched: true, fetching: false, error: action.err }; - case types.FOUND_USERS: + } + + case types.FOUND_USERS: { return { ...allMembership, foundUsers: action.users, @@ -35,29 +46,29 @@ export const projectMembershipReducer = (allMembership = allMembershipInital, ac fetching: false, error: 'none', }; - case types.ADD_NEW_MEMBER: + } + + case types.ADD_NEW_MEMBER: { return { ...allMembership, members: [action.member, ...allMembership.members] }; - case types.ADD_NEW_MEMBER_ERROR: + } + + case types.ADD_NEW_MEMBER_ERROR: { return { ...allMembership, fetched: true, fetching: false, error: action.err }; - case types.DELETE_MEMBER: - const indexMember = allMembership.members.findIndex(member => member._id === action.userId); - return { - ...allMembership, - members: [ - ...allMembership.members.slice(0, indexMember), - ...allMembership.members.slice(indexMember + 1), - ], - }; - case types.REMOVE_FOUND_USER: - const indexUser = allMembership.foundUsers.findIndex(user => user._id === action.userId); - return { - ...allMembership, - foundUsers: [ - ...allMembership.foundUsers.slice(0, indexUser), - ...allMembership.foundUsers.slice(indexUser + 1), - ], - }; + } + + case types.DELETE_MEMBER: { + const members = allMembership.members.filter(member => member._id !== action.userId); + return { ...allMembership, members }; + } + + case types.REMOVE_FOUND_USER: { + const foundUsers = allMembership.foundUsers.filter(user => user._id !== action.userId); + return { ...allMembership, foundUsers }; + } + default: return allMembership; } }; + +export default projectMembershipReducer; diff --git a/src/reducers/projectReportReducer.js b/src/reducers/projectReportReducer.js index 96983a4316..931c7b0db6 100644 --- a/src/reducers/projectReportReducer.js +++ b/src/reducers/projectReportReducer.js @@ -1,17 +1,23 @@ import { combineReducers } from 'redux'; -import { projectByIdReducer } from "./projectByIdReducer"; -import { GET_PROJECT_REPORT_BEGIN, GET_PROJECT_REPORT_END } from "../components/Reports/ProjectReport/actions"; +import { projectByIdReducer } from './projectByIdReducer'; +import { + GET_PROJECT_REPORT_BEGIN, + GET_PROJECT_REPORT_END, +} from '../components/Reports/ProjectReport/actions'; export const projectReportReducer = combineReducers({ project: projectByIdReducer, + // eslint-disable-next-line default-param-last isLoading: (state = false, action) => { switch (action.type) { case GET_PROJECT_REPORT_BEGIN: return true; case GET_PROJECT_REPORT_END: return false; - default: + default: return state; } - } + }, }); + +export default projectReportReducer; diff --git a/src/reducers/rolePresetReducer.js b/src/reducers/rolePresetReducer.js index 5fd0952cd8..7c8d49b274 100644 --- a/src/reducers/rolePresetReducer.js +++ b/src/reducers/rolePresetReducer.js @@ -1,33 +1,44 @@ -import * as types from "../constants/rolePermissionPresets"; +import * as types from '../constants/rolePermissionPresets'; const initialState = { presets: [], }; +// eslint-disable-next-line default-param-last export const rolePresetReducer = (state = initialState, action) => { switch (action.type) { - case types.RECEIVE_PRESETS: + case types.RECEIVE_PRESETS: { return { ...state, presets: action.presets }; + } - case types.ADD_NEW_PRESET: - const toAdd = state.presets; - toAdd.push(action.payload); - return { ...state, presets: toAdd }; + case types.ADD_NEW_PRESET: { + // Create a new array to ensure immutability + return { ...state, presets: [...state.presets, action.payload] }; + } - case types.UPDATE_PRESET: + case types.UPDATE_PRESET: { const presetUpdated = action.payload; - const indexPresetUpdated = state.presets.findIndex(preset => preset._id === presetUpdated._id); - const presetsCopy = state.presets; - - presetsCopy[indexPresetUpdated].presetName = presetUpdated.presetName; - - return { ...state, presets: presetsCopy }; - - case types.DELETE_PRESET: - const presetsFiltered = state.presets.filter(preset => preset._id != action.presetId); - return {...state, presets: presetsFiltered}; + const updatedPresets = state.presets.map(preset => { + if (preset._id === presetUpdated._id) { + return { + ...preset, + presetName: presetUpdated.presetName, + }; + } + return preset; + }); + return { ...state, presets: updatedPresets }; + } + + case types.DELETE_PRESET: { + // Filter creates a new array + const presetsFiltered = state.presets.filter(preset => preset._id !== action.presetId); + return { ...state, presets: presetsFiltered }; + } default: return state; } }; + +export default rolePresetReducer; diff --git a/src/reducers/roleReducer.js b/src/reducers/roleReducer.js index 0419851de0..c4c6ca26b0 100644 --- a/src/reducers/roleReducer.js +++ b/src/reducers/roleReducer.js @@ -1,35 +1,44 @@ -import * as types from "../constants/role"; +import * as types from '../constants/role'; const initialState = { roles: [], }; +// eslint-disable-next-line default-param-last export const roleReducer = (state = initialState, action) => { switch (action.type) { - case types.RECEIVE_ROLES: - const rolesSortByPermission = action.roles.sort( + case types.RECEIVE_ROLES: { + // Wrap in braces to fix lexical declaration issue + const rolesSortByPermission = [...action.roles].sort( (a, b) => b.permissions.length - a.permissions.length, ); return { ...state, roles: rolesSortByPermission }; + } - case types.ADD_NEW_ROLE: - const toAdd = state.roles; - toAdd.push(action.payload); - return { ...state, roles: toAdd }; + case types.ADD_NEW_ROLE: { + // Wrap in braces to fix lexical declaration issue + return { ...state, roles: [...state.roles, action.payload] }; + } - case types.UPDATE_ROLE: + case types.UPDATE_ROLE: { + // Wrap in braces to fix lexical declaration issue const roleUpdated = action.payload; - const indexRoleUpdated = state.roles.findIndex(role => role._id === roleUpdated.roleId); - const rolesCopy = state.roles; - - if (roleUpdated.roleName !== rolesCopy[indexRoleUpdated].roleName) { - rolesCopy[indexRoleUpdated].roleName = roleUpdated.roleName; - } - - rolesCopy[indexRoleUpdated].permissions = roleUpdated.permissions; - return { ...state, roles: rolesCopy }; + const updatedRoles = state.roles.map(role => { + if (role._id === roleUpdated.roleId) { + return { + ...role, + roleName: roleUpdated.roleName || role.roleName, + permissions: roleUpdated.permissions, + }; + } + return role; + }); + return { ...state, roles: updatedRoles }; + } default: return state; } }; + +export default roleReducer; diff --git a/src/reducers/teamByIdReducer.js b/src/reducers/teamByIdReducer.js index d2e55acba1..2ef8569a69 100644 --- a/src/reducers/teamByIdReducer.js +++ b/src/reducers/teamByIdReducer.js @@ -1,8 +1,9 @@ -import { GET_TEAM_BY_ID } from '../constants/team'; - +// eslint-disable-next-line default-param-last export const teamByIdReducer = (team = null, action) => { if (action.type === 'GET_TEAM_BY_ID') { return action.payload; } return team; }; + +export default teamByIdReducer; diff --git a/src/reducers/teamMembershipReducer.js b/src/reducers/teamMembershipReducer.js index 37020b5123..22d13f4930 100644 --- a/src/reducers/teamMembershipReducer.js +++ b/src/reducers/teamMembershipReducer.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line default-param-last export const teamMembershipReducer = (members = null, action) => { if (action.type === 'GET_TEAM_MEMBERSHIP') { return action.payload; @@ -5,3 +6,5 @@ export const teamMembershipReducer = (members = null, action) => { return members; }; + +export default teamMembershipReducer; diff --git a/src/reducers/teamsTeamMembersReducer.js b/src/reducers/teamsTeamMembersReducer.js index 98d31e250e..8dd497e9c4 100644 --- a/src/reducers/teamsTeamMembersReducer.js +++ b/src/reducers/teamsTeamMembersReducer.js @@ -12,6 +12,7 @@ export const updateObject = (oldObject, updatedProperties) => ({ ...updatedProperties, }); +// eslint-disable-next-line default-param-last export const teamUsersReducer = (teamMembers = teamUsersInitial, action) => { switch (action.type) { case types.RECEIVE_TEAM_USERS: diff --git a/src/reducers/themeReducer.js b/src/reducers/themeReducer.js index 9a951e3c78..bc921ff4a5 100644 --- a/src/reducers/themeReducer.js +++ b/src/reducers/themeReducer.js @@ -2,6 +2,7 @@ const initialState = { darkMode: false, }; +// eslint-disable-next-line default-param-last export const themeReducer = (state = initialState, action) => { switch (action.type) { case 'TOGGLE_THEME': @@ -13,3 +14,5 @@ export const themeReducer = (state = initialState, action) => { return state; } }; + +export default themeReducer; diff --git a/src/reducers/timeEntriesForSpecifiedPeriodReducer.js b/src/reducers/timeEntriesForSpecifiedPeriodReducer.js index e93cff9012..9077f9c2ed 100644 --- a/src/reducers/timeEntriesForSpecifiedPeriodReducer.js +++ b/src/reducers/timeEntriesForSpecifiedPeriodReducer.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line default-param-last export const timeEntriesForSpecifiedPeriodReducer = (timeEntries = null, action) => { if (action.type === 'GET_TIME_ENTRY_FOR_SPECIFIED_PERIOD') { return action.payload; @@ -5,3 +6,5 @@ export const timeEntriesForSpecifiedPeriodReducer = (timeEntries = null, action) return timeEntries; }; + +export default timeEntriesForSpecifiedPeriodReducer; diff --git a/src/reducers/timeEntriesReducer.js b/src/reducers/timeEntriesReducer.js index 3eafd6af85..1a130c7bfd 100644 --- a/src/reducers/timeEntriesReducer.js +++ b/src/reducers/timeEntriesReducer.js @@ -13,6 +13,7 @@ const initialState = { period: [], }; +// eslint-disable-next-line default-param-last export const timeEntriesReducer = (state = initialState, action) => { switch (action.type) { case GET_TIME_ENTRIES_WEEK: @@ -40,3 +41,5 @@ export const timeEntriesReducer = (state = initialState, action) => { return state; } }; + +export default timeEntriesReducer; diff --git a/src/reducers/timeOffRequestReducer.js b/src/reducers/timeOffRequestReducer.js index bb424d3c26..e30f0e1bbe 100644 --- a/src/reducers/timeOffRequestReducer.js +++ b/src/reducers/timeOffRequestReducer.js @@ -1,4 +1,4 @@ -import * as types from './../constants/timeOffRequestConstants'; +import * as types from '../constants/timeOffRequestConstants'; const initialState = { requests: {}, @@ -11,6 +11,7 @@ const initialState = { error: null, }; +// eslint-disable-next-line default-param-last export const timeOffRequestsReducer = (state = initialState, action) => { switch (action.type) { case types.FETCH_TIME_OFF_REQUESTS_SUCCESS: @@ -23,9 +24,12 @@ export const timeOffRequestsReducer = (state = initialState, action) => { data: {}, }, }; + case types.FETCH_TIME_OFF_REQUESTS_FAILURE: return { ...state, requests: {}, error: action.payload }; - case types.ADD_TIME_OF_REQUEST: + + case types.ADD_TIME_OF_REQUEST: { + // Enclosed in braces to fix the lexical declaration issue const key = action.payload.requestFor; const updatedKeyRequests = [...(state.requests[key] || []), action.payload]; return { @@ -35,7 +39,10 @@ export const timeOffRequestsReducer = (state = initialState, action) => { [key]: updatedKeyRequests, }, }; - case types.UPDATE_TIME_OF_REQUEST: + } + + case types.UPDATE_TIME_OF_REQUEST: { + // Enclosed in braces to fix the lexical declaration issue const id = action.payload.requestFor; return { ...state, @@ -52,7 +59,10 @@ export const timeOffRequestsReducer = (state = initialState, action) => { }), }, }; - case types.DELETE_TIME_OF_REQUEST: + } + + case types.DELETE_TIME_OF_REQUEST: { + // Enclosed in braces to fix the lexical declaration issue const { requestFor, _id } = action.payload; return { ...state, @@ -61,12 +71,16 @@ export const timeOffRequestsReducer = (state = initialState, action) => { [requestFor]: state.requests[requestFor].filter(request => request._id !== _id), }, }; + } + case types.ADD_IS_ON_TIME_OFF_REQUESTS: { return { ...state, onTimeOff: action.payload, error: null }; } + case types.ADD_GOING_ON_TIME_OFF_REQUESTS: { return { ...state, goingOnTimeOff: action.payload, error: null }; } + case types.TIME_OFF_REQUEST_DETAIL_MODAL_OPEN: { return { ...state, @@ -78,6 +92,7 @@ export const timeOffRequestsReducer = (state = initialState, action) => { error: null, }; } + case types.TIME_OFF_REQUEST_DETAIL_MODAL_CLOSE: { return { ...state, @@ -89,7 +104,10 @@ export const timeOffRequestsReducer = (state = initialState, action) => { error: null, }; } + default: return state; } }; + +export default timeOffRequestsReducer; diff --git a/src/reducers/totalOrgSummaryReducer.js b/src/reducers/totalOrgSummaryReducer.js index 46b5c4b31c..c46887c644 100644 --- a/src/reducers/totalOrgSummaryReducer.js +++ b/src/reducers/totalOrgSummaryReducer.js @@ -8,6 +8,7 @@ const initialState = { fetchingError: null, }; +// eslint-disable-next-line default-param-last export const totalOrgSummaryReducer = (state = initialState, action) => { switch (action.type) { case actions.FETCH_TOTAL_ORG_SUMMARY_BEGIN: @@ -30,7 +31,7 @@ export const totalOrgSummaryReducer = (state = initialState, action) => { loading: false, error: action.payload.error, }; - + case actions.FETCH_TOTAL_ORG_SUMMARY_DATA_SUCCESS: return { ...state, @@ -49,3 +50,5 @@ export const totalOrgSummaryReducer = (state = initialState, action) => { return state; } }; + +export default totalOrgSummaryReducer; diff --git a/src/reducers/userProfileByIdReducer.js b/src/reducers/userProfileByIdReducer.js index de1ef77457..a1022fe35d 100644 --- a/src/reducers/userProfileByIdReducer.js +++ b/src/reducers/userProfileByIdReducer.js @@ -14,6 +14,7 @@ export const updateObject = (oldObject, updatedProperties) => { }; }; +// eslint-disable-next-line default-param-last export const userProfileByIdReducer = (userProfile = initialUserProfileState, action) => { if (action.type === GET_USER_PROFILE) { return action.payload; @@ -30,6 +31,7 @@ export const userProfileByIdReducer = (userProfile = initialUserProfileState, ac return userProfile; }; +// eslint-disable-next-line default-param-last export const userTaskByIdReducer = (userTask = [], action) => { if (action.type === GET_USER_TASKS) { return action.payload; diff --git a/src/reducers/userProjectMembersReducer.js b/src/reducers/userProjectMembersReducer.js index 9755251ea6..531713424a 100644 --- a/src/reducers/userProjectMembersReducer.js +++ b/src/reducers/userProjectMembersReducer.js @@ -1,7 +1,10 @@ -export const userProjectMembersReducer = (projectMembers = null, action) => { +// eslint-disable-next-line default-param-last +const userProjectMembersReducer = (projectMembers = null, action) => { if (action.type === 'GET_USER_PROJECT_MEMBERS') { return action.payload; } return projectMembers; }; + +export default userProjectMembersReducer; diff --git a/src/reducers/userProjectsByUserNameReducer.js b/src/reducers/userProjectsByUserNameReducer.js index cd46c10c04..7da0d150f0 100644 --- a/src/reducers/userProjectsByUserNameReducer.js +++ b/src/reducers/userProjectsByUserNameReducer.js @@ -1,22 +1,26 @@ -import {GET_PROJECT_BY_USER_NAME, USER_NOT_FOUND_ERROR} from '../constants/userProfile'; +import { GET_PROJECT_BY_USER_NAME, USER_NOT_FOUND_ERROR } from '../constants/userProfile'; const initialUserProject = { projects: [], error: null, }; -export const userProjectsByUserNameReducer = (state = initialUserProject, action )=>{ +// eslint-disable-next-line default-param-last +const userProjectsByUserNameReducer = (state = initialUserProject, action) => { switch (action.type) { - case GET_PROJECT_BY_USER_NAME: - return { - ...state, - projects: action.payload - } - case USER_NOT_FOUND_ERROR : - return { - ...state, - error: action.payload - } - default: return state + case GET_PROJECT_BY_USER_NAME: + return { + ...state, + projects: action.payload, + }; + case USER_NOT_FOUND_ERROR: + return { + ...state, + error: action.payload, + }; + default: + return state; } -} \ No newline at end of file +}; + +export default userProjectsByUserNameReducer; diff --git a/src/reducers/userProjectsReducer.js b/src/reducers/userProjectsReducer.js index 4bd6c3e864..c3611166ef 100644 --- a/src/reducers/userProjectsReducer.js +++ b/src/reducers/userProjectsReducer.js @@ -5,7 +5,8 @@ const initialState = { wbs: [], }; -export const userProjectsReducer = (state = initialState, action) => { +// eslint-disable-next-line default-param-last +const userProjectsReducer = (state = initialState, action) => { switch (action.type) { case types.GET_USER_PROJECTS: return { @@ -16,3 +17,5 @@ export const userProjectsReducer = (state = initialState, action) => { return state; } }; + +export default userProjectsReducer; diff --git a/src/reducers/userTeamMembersReducer.js b/src/reducers/userTeamMembersReducer.js index d90210df01..8bc2f0320b 100644 --- a/src/reducers/userTeamMembersReducer.js +++ b/src/reducers/userTeamMembersReducer.js @@ -1,7 +1,10 @@ -export const userTeamMembersReducer = (teamMembers = null, action) => { +// eslint-disable-next-line default-param-last +const userTeamMembersReducer = (teamMembers = null, action) => { if (action.type === 'GET_USER_TEAM_MEMBERS') { return action.payload; } return teamMembers; }; + +export default userTeamMembersReducer; diff --git a/src/reducers/warningsReducer.js b/src/reducers/warningsReducer.js index f5ab5a828b..fea658ef61 100644 --- a/src/reducers/warningsReducer.js +++ b/src/reducers/warningsReducer.js @@ -7,7 +7,8 @@ import { EDIT_WARNING_DESCRIPTION, } from '../constants/warning'; -export const warningsByUserIdReducer = (state = [], action) => { +// eslint-disable-next-line default-param-last +const warningsByUserIdReducer = (state = [], action) => { switch (action.type) { case GET_WARNINGS_BY_USER_ID: return action.payload; @@ -31,3 +32,5 @@ export const warningsByUserIdReducer = (state = [], action) => { return state; } }; + +export default warningsByUserIdReducer; diff --git a/src/reducers/wbsReducer.js b/src/reducers/wbsReducer.js index 8b86aeb1b0..ad24a8dfc7 100644 --- a/src/reducers/wbsReducer.js +++ b/src/reducers/wbsReducer.js @@ -1,4 +1,4 @@ -import * as types from "../constants/WBS"; +import * as types from '../constants/WBS'; const allWBSInital = { fetching: false, @@ -7,12 +7,15 @@ const allWBSInital = { error: '', }; -export const wbsReducer = (allWBS = allWBSInital, action) => { +// eslint-disable-next-line default-param-last +const wbsReducer = (allWBS = allWBSInital, action) => { switch (action.type) { case types.FETCH_WBS_START: return { ...allWBS, fetched: false, fetching: true, error: 'none' }; + case types.FETCH_WBS_ERROR: return { ...allWBS, fetched: true, fetching: false, error: action.err }; + case types.RECEIVE_WBS: return { ...allWBS, @@ -21,17 +24,25 @@ export const wbsReducer = (allWBS = allWBSInital, action) => { fetching: false, error: 'none', }; + case types.ADD_NEW_WBS: return { ...allWBS, WBSItems: [action.wbs, ...allWBS.WBSItems] }; + case types.ADD_NEW_WBS_ERROR: return { ...allWBS, fetched: true, fetching: false, error: action.err }; - case types.DELETE_WBS: - const index = allWBS.WBSItems.findIndex(wbs => wbs._id == action.wbsId); + + case types.DELETE_WBS: { + // Wrap this block in braces to fix the lexical declaration issue + const index = allWBS.WBSItems.findIndex(wbs => wbs._id === action.wbsId); return { ...allWBS, WBSItems: [...allWBS.WBSItems.slice(0, index), ...allWBS.WBSItems.slice(index + 1)], }; + } + default: return allWBS; } }; + +export default wbsReducer; diff --git a/src/reducers/weeklyDashboardDataReducer.js b/src/reducers/weeklyDashboardDataReducer.js index 325865ee3e..9be2387aa1 100644 --- a/src/reducers/weeklyDashboardDataReducer.js +++ b/src/reducers/weeklyDashboardDataReducer.js @@ -1,7 +1,10 @@ -export const weeklyDashboardDataReducer = (weeklyDashboardData = null, action) => { +// eslint-disable-next-line default-param-last +const weeklyDashboardDataReducer = (weeklyDashboardData = null, action) => { if (action.type === 'GET_WEEKLY_DASHBOARD_DATA') { return action.payload; } return weeklyDashboardData; }; + +export default weeklyDashboardDataReducer; diff --git a/src/reducers/weeklySummariesAIPromptReducer.js b/src/reducers/weeklySummariesAIPromptReducer.js index 8e8c1880d1..801926c3d5 100644 --- a/src/reducers/weeklySummariesAIPromptReducer.js +++ b/src/reducers/weeklySummariesAIPromptReducer.js @@ -1,14 +1,17 @@ -const initialState = null +const initialState = null; -export const weeklySummariesAIPromptReducer = (dashboardData = initialState, action) => { +// eslint-disable-next-line default-param-last +const weeklySummariesAIPromptReducer = (dashboardData = initialState, action) => { switch (action.type) { case 'GET_AI_PROMPT_TEXT': - return action.payload + return action.payload; case 'UPDATE_AI_PROMPT_TEXT': - return dashboardData + return dashboardData; default: - return dashboardData + return dashboardData; } }; + +export default weeklySummariesAIPromptReducer; diff --git a/src/reducers/weeklySummariesReducer.js b/src/reducers/weeklySummariesReducer.js index 4fe9fec627..bdc20c6953 100644 --- a/src/reducers/weeklySummariesReducer.js +++ b/src/reducers/weeklySummariesReducer.js @@ -6,7 +6,8 @@ const initialState = { fetchError: null, }; -export const weeklySummariesReducer = (state = initialState, action) => { +// eslint-disable-next-line default-param-last +const weeklySummariesReducer = (state = initialState, action) => { switch (action.type) { case actions.FETCH_WEEKLY_SUMMARIES_BEGIN: return { @@ -33,3 +34,5 @@ export const weeklySummariesReducer = (state = initialState, action) => { return state; } }; + +export default weeklySummariesReducer; diff --git a/src/reducers/weeklySummariesReportReducer.js b/src/reducers/weeklySummariesReportReducer.js index 5bdcac5bd9..69016aad1f 100644 --- a/src/reducers/weeklySummariesReportReducer.js +++ b/src/reducers/weeklySummariesReportReducer.js @@ -6,7 +6,8 @@ const initialState = { error: null, }; -export const weeklySummariesReportReducer = (state = initialState, action) => { +// eslint-disable-next-line default-param-last +const weeklySummariesReportReducer = (state = initialState, action) => { switch (action.type) { case actions.FETCH_SUMMARIES_REPORT_BEGIN: return { @@ -29,17 +30,21 @@ export const weeklySummariesReportReducer = (state = initialState, action) => { error: action.payload.error, }; - case actions.UPDATE_SUMMARY_REPORT: + case actions.UPDATE_SUMMARY_REPORT: { + // Wrap this block in braces to fix the lexical declaration issue const { _id, updatedField } = action.payload; const newSummaries = [...state.summaries]; const summaryIndex = newSummaries.findIndex(summary => summary._id === _id); - newSummaries[summaryIndex] = { ...newSummaries[summaryIndex], ...updatedField } + newSummaries[summaryIndex] = { ...newSummaries[summaryIndex], ...updatedField }; return { ...state, summaries: newSummaries, }; + } default: return state; } }; + +export default weeklySummariesReportReducer; diff --git a/src/reducers/weeklySummaryRecipientsReducer.js b/src/reducers/weeklySummaryRecipientsReducer.js index 5acf363a78..8dcac40725 100644 --- a/src/reducers/weeklySummaryRecipientsReducer.js +++ b/src/reducers/weeklySummaryRecipientsReducer.js @@ -1,42 +1,42 @@ import * as actions from '../constants/weeklySummariesReport'; -import storage from 'redux-persist/lib/storage'; // defaults to localStorage for web -import { persistReducer } from 'redux-persist'; const initialState = { user: {}, recepientsArr: [], - err: null -} + err: null, +}; -export const weeklySummaryRecipientsReducer = (state = initialState, action) => { +// eslint-disable-next-line default-param-last +const weeklySummaryRecipientsReducer = (state = initialState, action) => { switch (action.type) { - case actions.DELETE_WEEKLY_SUMMARIES_RECIPIENTS: return { ...state, - recepientsArr: state.recepientsArr.filter((elem) => elem._id !== action.payload.userid) - } + recepientsArr: state.recepientsArr.filter(elem => elem._id !== action.payload.userid), + }; case actions.AUTHORIZE_WEEKLY_SUMMARY_REPORTS: return { ...state, - passwordMatch: action.payload - } + passwordMatch: action.payload, + }; case actions.AUTHORIZE_WEEKLYSUMMARIES_REPORTS_ERROR: return { ...state, - passwordMatchErr: action.payload - } + passwordMatchErr: action.payload, + }; case actions.GET_SUMMARY_RECIPIENTS: return { ...state, - recepientsArr: action.recepientsArr - } + recepientsArr: action.recepientsArr, + }; case actions.GET_SUMMARY_RECIPIENTS_ERROR: return { ...state, - getRecepientsErr: action.payload.err - } + getRecepientsErr: action.payload.err, + }; default: return state; } -} \ No newline at end of file +}; + +export default weeklySummaryRecipientsReducer; From dd3c5797b1504905f2ff30b5c3c769d9ac20f4d7 Mon Sep 17 00:00:00 2001 From: Samarth Bhadane Date: Sat, 11 Jan 2025 08:33:08 -0800 Subject: [PATCH 2/2] Fixed Linting Issues --- src/reducers/weeklyDashboardDataReducer.js | 2 +- src/reducers/weeklySummariesReducer.js | 2 +- src/reducers/weeklySummariesReportReducer.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/reducers/weeklyDashboardDataReducer.js b/src/reducers/weeklyDashboardDataReducer.js index 9be2387aa1..397209f87d 100644 --- a/src/reducers/weeklyDashboardDataReducer.js +++ b/src/reducers/weeklyDashboardDataReducer.js @@ -1,5 +1,5 @@ // eslint-disable-next-line default-param-last -const weeklyDashboardDataReducer = (weeklyDashboardData = null, action) => { +export const weeklyDashboardDataReducer = (weeklyDashboardData = null, action) => { if (action.type === 'GET_WEEKLY_DASHBOARD_DATA') { return action.payload; } diff --git a/src/reducers/weeklySummariesReducer.js b/src/reducers/weeklySummariesReducer.js index bdc20c6953..39506967e8 100644 --- a/src/reducers/weeklySummariesReducer.js +++ b/src/reducers/weeklySummariesReducer.js @@ -7,7 +7,7 @@ const initialState = { }; // eslint-disable-next-line default-param-last -const weeklySummariesReducer = (state = initialState, action) => { +export const weeklySummariesReducer = (state = initialState, action) => { switch (action.type) { case actions.FETCH_WEEKLY_SUMMARIES_BEGIN: return { diff --git a/src/reducers/weeklySummariesReportReducer.js b/src/reducers/weeklySummariesReportReducer.js index 69016aad1f..50a1a7aa33 100644 --- a/src/reducers/weeklySummariesReportReducer.js +++ b/src/reducers/weeklySummariesReportReducer.js @@ -7,7 +7,7 @@ const initialState = { }; // eslint-disable-next-line default-param-last -const weeklySummariesReportReducer = (state = initialState, action) => { +export const weeklySummariesReportReducer = (state = initialState, action) => { switch (action.type) { case actions.FETCH_SUMMARIES_REPORT_BEGIN: return {