Skip to content

Commit

Permalink
Merge pull request #39 from AntaresSimulatorTeam/fix/sonar_errors
Browse files Browse the repository at this point in the history
fix: fix sonar errors
  • Loading branch information
melazaar authored Jan 29, 2025
2 parents 5aca5dc + d9626af commit 6070eaa
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/hooks/test/useHandlePinnedProjectList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
usePinnedProjectDispatch,
} from '@/store/contexts/ProjectContext';
import { fetchPinnedProjects, pinProject } from '@/shared/services/pinnedProjectService.ts';
import React from 'react';
import { PINNED_PROJECT_ACTION } from '@/shared/enum/project.ts';
import { v4 as uuidv4 } from 'uuid';
import { notifyToast } from '@/shared/notification/notification.tsx';
Expand Down Expand Up @@ -110,7 +109,6 @@ describe('useHandlePinnedProjectList', () => {
expectTypeOf(result.current.handlePinProject).toBeFunction();
expect(fetchPinnedProjects).toHaveBeenCalledTimes(1);
expect(fetchPinnedProjects).toHaveBeenCalledWith('me00247');
expect(fetchPinnedProjects).toHaveReturned(mockProjectsApiResponse);
expect(mockUsePinnedProjectDispatch).toHaveBeenCalledTimes(1);
expect(mockDispatch).toHaveBeenCalledTimes(1);
expect(mockDispatch).toHaveBeenCalledWith({
Expand Down Expand Up @@ -152,7 +150,6 @@ describe('useHandlePinnedProjectList', () => {

await waitFor(() => {
expect(pinProject).toHaveBeenCalledWith('me00247');
expect(pinProject).toHaveReturned(mockPinProjectResponse);
expect(mockDispatch).toHaveBeenCalledTimes(1);
expect(mockDispatch).toHaveBeenCalledWith({
type: PINNED_PROJECT_ACTION.ADD_ITEM,
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useFetchProjectList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useFetchProjectList = (
const [count, setCount] = useState(0);

const fetchProjects = useCallback(
async (searchTerm, current, intervalSize) => {
async (searchTerm: string, current: number, intervalSize: number) => {
fetchProjectFromSearchTerm(searchTerm, current, intervalSize)
.then((json) => {
setProjects(json.content);
Expand Down
6 changes: 3 additions & 3 deletions src/pages/pegase/projects/ProjectContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ProjectContent = ({ shouldRefetchProjectList }: ProjectContentProps) => {
const { t } = useTranslation();
const intervalSize = 9;
const userName = 'mouad'; // Replace with actual user name
const [searchTerm, setSearchTerm] = useState<string | undefined>('');
const [searchTerm, setSearchTerm] = useState<string>('');
const [activeChip, setActiveChip] = useState<boolean | null>(false);
const [current, setCurrent] = useState(0);
const { projects, count, refetch } = useFetchProjectList(
Expand All @@ -43,7 +43,7 @@ const ProjectContent = ({ shouldRefetchProjectList }: ProjectContentProps) => {
const dispatch = usePinnedProjectDispatch();

const searchProject = (value?: string | undefined) => {
setSearchTerm(value);
value && setSearchTerm(value);
};

const handleChipClick = () => {
Expand All @@ -62,7 +62,7 @@ const ProjectContent = ({ shouldRefetchProjectList }: ProjectContentProps) => {
type: PINNED_PROJECT_ACTION.REMOVE_ITEM,
payload: projectId,
} as PinnedProjectActionType);
await refetch(); // Actualiser les projets après suppression
await refetch(searchTerm, current, intervalSize); // Actualiser les projets après suppression
};

const handleCardClick = (projectId: string, projectName: string) => {
Expand Down
8 changes: 4 additions & 4 deletions src/shared/services/projectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export const fetchProjectsFromPartialName = async (query: string): Promise<strin
/**
* Retrieve a list of project from a user name
*
* @param searchTerm
* @param current
* @param intervalSize
* @param {string} searchTerm
* @param {number} current
* @param {number} intervalSize
*/
export const fetchProjectFromSearchTerm = async (searchTerm, current, intervalSize) => {
export const fetchProjectFromSearchTerm = async (searchTerm: string, current: number, intervalSize: number) => {
const response = await fetch(
`${PROJECT_SEARCH_ENDPOINT}?page=${current + 1}&size=${intervalSize}&search=${searchTerm || ''}`,
);
Expand Down
Loading

0 comments on commit 6070eaa

Please sign in to comment.