Skip to content

Commit

Permalink
types:fix type
Browse files Browse the repository at this point in the history
Signed-off-by: capyq <quentin.capy@rte-france.com>
  • Loading branch information
capyq committed Oct 17, 2024
1 parent 3ee4bc9 commit e6e7fea
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup/dist/yup';
import { createContingencyList } from '../../../../utils/rest-api';
import { FunctionComponent, SyntheticEvent } from 'react';
import { FunctionComponent } from 'react';
import ContingencyListCreationForm from './contingency-list-creation-form';
import {
ContingencyListFormData,
Expand Down Expand Up @@ -47,7 +47,7 @@ const schema = yup.object().shape({
const emptyFormData = getContingencyListEmptyFormData();

interface ContingencyListCreationDialogProps {
onClose: (event?: SyntheticEvent) => void;
onClose: () => void;
open: boolean;
titleId: string;
}
Expand Down Expand Up @@ -75,9 +75,9 @@ const ContingencyListCreationDialog: FunctionComponent<ContingencyListCreationDi
const nameError = errors[FieldConstants.NAME];
const isValidating = errors.root?.isValidating;

const closeAndClear = (event?: SyntheticEvent) => {
const closeAndClear = () => {
reset(emptyFormData);
onClose(event);
onClose();
};

const onSubmit = (data: ContingencyListFormDataWithRequiredCriteria) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup/dist/yup';

import { FunctionComponent, SyntheticEvent, useEffect, useState } from 'react';
import { FunctionComponent, useEffect, useState } from 'react';
import {
CriteriaBasedData,
getContingencyListEmptyFormData,
Expand Down Expand Up @@ -48,7 +48,7 @@ interface CriteriaBasedEditionDialogProps {
contingencyListId: string;
contingencyListType: string;
open: boolean;
onClose: (event?: SyntheticEvent) => void;
onClose: () => void;
titleId: string;
name: string;
broadcastChannel: BroadcastChannel;
Expand Down Expand Up @@ -98,9 +98,9 @@ const CriteriaBasedEditionDialog: FunctionComponent<CriteriaBasedEditionDialogPr
.finally(() => setIsFetching(false));
}, [contingencyListId, contingencyListType, name, reset, snackError]);

const closeAndClear = (event?: SyntheticEvent) => {
const closeAndClear = () => {
reset(emptyFormData());
onClose(event);
onClose();
};

const editContingencyList = (contingencyListId: string, contingencyList: CriteriaBasedEditionFormData) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup/dist/yup';

import { FunctionComponent, SyntheticEvent, useEffect, useState } from 'react';
import { FunctionComponent, useEffect, useState } from 'react';
import {
getContingencyListEmptyFormData,
getExplicitNamingFormDataFromFetchedElement,
Expand Down Expand Up @@ -49,7 +49,7 @@ interface ExplicitNamingEditionDialogProps {
contingencyListId: string;
contingencyListType: string;
open: boolean;
onClose: (event?: SyntheticEvent) => void;
onClose: () => void;
titleId: string;
name: string;
broadcastChannel: BroadcastChannel;
Expand Down Expand Up @@ -98,9 +98,9 @@ const ExplicitNamingEditionDialog: FunctionComponent<ExplicitNamingEditionDialog
.finally(() => setIsFetching(false));
}, [contingencyListId, contingencyListType, name, reset, snackError]);

const closeAndClear = (event?: SyntheticEvent) => {
const closeAndClear = () => {
reset(emptyFormData());
onClose(event);
onClose();
};

const editContingencyList = (contingencyListId: string, contingencyList: ExplicitNamingEditionFormData) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup/dist/yup';

import React, { FunctionComponent, SyntheticEvent, useEffect, useState } from 'react';
import { FunctionComponent, useEffect, useState } from 'react';
import { getContingencyListEmptyFormData, getScriptFormDataFromFetchedElement } from '../../contingency-list-utils';
import { getContingencyList, saveScriptContingencyList } from 'utils/rest-api';
import ScriptEditionForm from './script-edition-form';
Expand All @@ -41,7 +41,7 @@ interface ScriptEditionDialogProps {
contingencyListId: string;
contingencyListType: string;
open: boolean;
onClose: (event?: React.SyntheticEvent) => void;
onClose: () => void;
titleId: string;
name: string;
broadcastChannel: BroadcastChannel;
Expand Down Expand Up @@ -92,9 +92,9 @@ const ScriptEditionDialog: FunctionComponent<ScriptEditionDialogProps> = ({
.finally(() => setIsFetching(false));
}, [contingencyListId, contingencyListType, name, reset, snackError]);

const closeAndClear = (event?: SyntheticEvent) => {
const closeAndClear = () => {
reset(emptyFormData());
onClose(event);
onClose();
};

const editContingencyList = (contingencyListId: string, contingencyList: ScriptEditionFormData) => {
Expand Down
8 changes: 2 additions & 6 deletions src/components/dialogs/copy-to-script-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const emptyFormData = {
interface CopyToScriptDialogProps {
id: string;
open: boolean;
onClose: (...args: any[]) => void;
onClose: () => void;
onValidate: (...args: any[]) => void;
currentName: string;
title: string;
Expand Down Expand Up @@ -82,10 +82,6 @@ const CopyToScriptDialog: React.FunctionComponent<CopyToScriptDialogProps> = ({
onValidate(id, data[FieldConstants.NAME]);
};

const handleClose = () => {
onClose();
};

const handleGenerateNameError = useCallback(() => {
return handleError(
intl.formatMessage(
Expand Down Expand Up @@ -117,7 +113,7 @@ const CopyToScriptDialog: React.FunctionComponent<CopyToScriptDialogProps> = ({
return (
<CustomMuiDialog
open={open}
onClose={handleClose}
onClose={onClose}
onSave={onSubmit}
formSchema={schema}
formMethods={methods}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface IFormData {
}

interface CreateCaseDialogProps {
onClose: (e?: unknown, nextSelectedDirectoryId?: string | null) => void;
onClose: () => void;
open: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/dialogs/create-directory-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { FunctionComponent } from 'react';

interface CreateDirectoryDialogProps {
open: boolean;
onClose: (e?: unknown, nextSelectedDirectoryId?: string | null) => void;
onClose: () => void;
onClick: (newName: string) => void;
title: string;
parentDirectory?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function formatCaseImportParameters(params: Parameter[]): Parameter[] {

interface CreateStudyDialogProps {
open: boolean;
onClose: (e?: unknown, nextSelectedDirectoryId?: string | null) => void;
onClose: () => void;
providedExistingCase?: ElementAttributes;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/dialogs/delete-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { CancelButton, ElementAttributes, OverflowableText } from '@gridsuite/co

interface DeleteDialogProps {
open: boolean;
onClose: (e?: unknown, nextSelectedDirectoryId?: string | null) => void;
onClose: () => void;
onClick: () => void;
items: ElementAttributes[];
multipleDeleteFormatMessageId: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialogs/rename-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { AppState } from 'redux/reducer';

interface RenameDialogProps {
open: boolean;
onClose: (e?: unknown, nextSelectedDirectoryId?: string | null) => void;
onClose: () => void;
onClick: (newName: string) => void;
title: string;
message: string;
Expand Down
27 changes: 16 additions & 11 deletions src/components/menus/directory-tree-contextual-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { AppState } from 'redux/reducer';
interface DirectoryTreeContextualMenuProps {
directory: ElementAttributes | null;
open: boolean;
onClose: (e: unknown, nextSelectedDirectoryId?: string | null) => void;
onClose: (nextSelectedDirectoryId?: string | null) => void;
openDialog: string;
setOpenDialog: (dialogId: string) => void;
restrictMenuItems: boolean;
Expand All @@ -72,8 +72,8 @@ const DirectoryTreeContextualMenu: React.FC<DirectoryTreeContextualMenuProps> =
};

const handleCloseDialog = useCallback(
(e: unknown, nextSelectedDirectoryId: string | null = null) => {
onClose(e, nextSelectedDirectoryId);
(nextSelectedDirectoryId: string | null = null) => {
onClose(nextSelectedDirectoryId);
setOpenDialog(DialogsId.NONE);
setHideMenu(false);
setDeleteError('');
Expand All @@ -83,7 +83,7 @@ const DirectoryTreeContextualMenu: React.FC<DirectoryTreeContextualMenuProps> =

const [renameCB, renameState] = useDeferredFetch(
renameElement,
() => handleCloseDialog(null, null),
() => handleCloseDialog(),
(HTTPStatusCode: number) => {
if (HTTPStatusCode === 403) {
return intl.formatMessage({ id: 'renameDirectoryError' });
Expand All @@ -94,12 +94,12 @@ const DirectoryTreeContextualMenu: React.FC<DirectoryTreeContextualMenuProps> =
);

const [insertDirectoryCB, insertDirectoryState] = useDeferredFetch(insertDirectory, (response: ElementAttributes) =>
handleCloseDialog(null, response?.elementUuid)
handleCloseDialog(response?.elementUuid)
);

const [insertRootDirectoryCB, insertRootDirectoryState] = useDeferredFetch(
insertRootDirectory,
(response: ElementAttributes) => handleCloseDialog(null, response?.elementUuid)
(response: ElementAttributes) => handleCloseDialog(response?.elementUuid)
);

const selectionForCopy = useSelector((state: AppState) => state.selectionForCopy);
Expand Down Expand Up @@ -128,7 +128,7 @@ const DirectoryTreeContextualMenu: React.FC<DirectoryTreeContextualMenuProps> =
function pasteElement(directoryUuid: string, selectionForCopy: any) {
if (!selectionForCopy.sourceItemUuid) {
handleError(intl.formatMessage({ id: 'elementPasteFailed404' }));
handleCloseDialog(null);
handleCloseDialog();
} else {
console.info('Pasting element %s into directory %s', selectionForCopy.nameItem, directoryUuid);

Expand Down Expand Up @@ -183,7 +183,7 @@ const DirectoryTreeContextualMenu: React.FC<DirectoryTreeContextualMenuProps> =
);
}

handleCloseDialog(null);
handleCloseDialog();
}
}

Expand All @@ -192,7 +192,7 @@ const DirectoryTreeContextualMenu: React.FC<DirectoryTreeContextualMenuProps> =
(elementsUuid: string) => {
setDeleteError('');
deleteElement(elementsUuid)
.then(() => handleCloseDialog(null, directory?.parentUuid))
.then(() => handleCloseDialog(directory?.parentUuid))
.catch((error: any) => {
//show the error message and don't close the dialog
setDeleteError(error.message);
Expand Down Expand Up @@ -377,7 +377,7 @@ const DirectoryTreeContextualMenu: React.FC<DirectoryTreeContextualMenuProps> =
return (
<FilterCreationDialog
open={true}
onClose={handleCloseDialog}
onClose={() => handleCloseDialog()}
activeDirectory={activeDirectory}
elementExists={elementExists}
language={languageLocal}
Expand All @@ -392,7 +392,12 @@ const DirectoryTreeContextualMenu: React.FC<DirectoryTreeContextualMenuProps> =
return (
<>
{open && (
<CommonContextualMenu {...others} menuItems={buildMenu()} open={open && !hideMenu} onClose={onClose} />
<CommonContextualMenu
{...others}
menuItems={buildMenu()}
open={open && !hideMenu}
onClose={() => onClose()}
/>
)}
{renderDialog()}
</>
Expand Down

0 comments on commit e6e7fea

Please sign in to comment.