More typing
This commit is contained in:
@@ -2,6 +2,7 @@ import { useLocalStorage } from '@mantine/hooks';
|
||||
import { appTheme } from 'contexts';
|
||||
import { useAtom } from 'jotai';
|
||||
import { useState } from 'react';
|
||||
import type { Theme } from 'types';
|
||||
import { useMutationAPI } from './useAPI';
|
||||
|
||||
export function useCommonHooks() {
|
||||
@@ -80,17 +81,17 @@ export function useCommonHooks() {
|
||||
'i',
|
||||
); // fragment locator
|
||||
|
||||
const reorder = (list: any, startIndex: any, endIndex: any) => {
|
||||
const reorder = (list: any, startIndex: number, endIndex: number) => {
|
||||
const result = Array.from(list);
|
||||
const [removed]: any = result.splice(startIndex, 1);
|
||||
result.splice(endIndex, 0, removed);
|
||||
return result;
|
||||
};
|
||||
|
||||
const handleThemeChange = (themes: any, save: any) => {
|
||||
const handleThemeChange = (themes: Theme[], save: boolean) => {
|
||||
const enabled = themes
|
||||
.filter((t: any) => t.randomEnabled)
|
||||
.filter((t: any) => t.name !== theme.name);
|
||||
.filter((t: Theme) => t.randomEnabled)
|
||||
.filter((t: Theme) => t.name !== theme.name);
|
||||
if (enabled.length === 0) {
|
||||
setTheme(themes[0]);
|
||||
save && setThemeName(themes[0].name);
|
||||
@@ -105,11 +106,11 @@ export function useCommonHooks() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = (item: any, endpoint: any) => {
|
||||
const handleDelete = (item: any, endpoint: string) => {
|
||||
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: item });
|
||||
};
|
||||
|
||||
function fixDigits(k: any) {
|
||||
function fixDigits(k: number) {
|
||||
if (k < 10) {
|
||||
return `0${k}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user