mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 01:05:40 +00:00
Add eslint rule and fix as many issues as possible
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useState } from 'react';
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
interface UsePopUpProps {
|
||||
name: Readonly<string>;
|
||||
@@ -11,7 +11,7 @@ interface UsePopUpProps {
|
||||
* SIDENOTE: On inputting give it as const and not string with (as const)
|
||||
*/
|
||||
type UsePopUpState<T extends Readonly<string[]> | UsePopUpProps[]> = {
|
||||
[P in T extends UsePopUpProps[] ? T[number]['name'] : T[number]]: {
|
||||
[P in T extends UsePopUpProps[] ? T[number]["name"] : T[number]]: {
|
||||
isOpen: boolean;
|
||||
data?: unknown;
|
||||
};
|
||||
@@ -35,7 +35,7 @@ export const usePopUp = <T extends Readonly<string[]> | UsePopUpProps[]>(
|
||||
const [popUp, setPopUp] = useState<UsePopUpState<T>>(
|
||||
Object.fromEntries(
|
||||
popUpNames.map((popUpName) =>
|
||||
typeof popUpName === 'string'
|
||||
typeof popUpName === "string"
|
||||
? [popUpName, { isOpen: false }]
|
||||
: [popUpName.name, { isOpen: popUpName.isOpen }]
|
||||
) // convert into an array of [[popUpName,state]] then into Object
|
||||
@@ -53,7 +53,7 @@ export const usePopUp = <T extends Readonly<string[]> | UsePopUpProps[]>(
|
||||
const handlePopUpToggle = useCallback((popUpName: keyof UsePopUpState<T>, state?: boolean) => {
|
||||
setPopUp((oldState) => ({
|
||||
...oldState,
|
||||
[popUpName]: { isOpen: typeof state === 'undefined' ? !oldState[popUpName].isOpen : state }
|
||||
[popUpName]: { isOpen: typeof state === "undefined" ? !oldState[popUpName].isOpen : state }
|
||||
}));
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user