Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
sickelap committed Nov 5, 2023
1 parent 67b74c5 commit 1b6eecb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
35 changes: 15 additions & 20 deletions src/components/modals/ModalUserEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useManageUpdateUserMutation, useSignUpMutation } from "../../api_client
import type { DirTree } from "../../api_client/dir-tree";
import { useLazyFetchDirsQuery } from "../../api_client/dir-tree";
import { useAppDispatch, useAppSelector } from "../../store/store";
import { IUser } from "../../store/user/user.zod";
import { EMAIL_REGEX, mergeDirTree } from "../../util/util";
import { PasswordEntry } from "../settings/PasswordEntry";

Expand Down Expand Up @@ -66,30 +67,30 @@ export function ModalUserEdit(props: Props) {
const [updateUser] = useManageUpdateUserMutation();
const [fetchDirectoryTree, { data: directoryTree }] = useLazyFetchDirsQuery();

const validateUsername = username => {
let error = null;
const validateUsername = (username: string) => {
let error = "";
if (!username) {
error = t("modaluseredit.errorusernamecannotbeblank");
} else if (userList && userList.results) {
userList.results.every(user => {
} else if (userList?.results) {
userList.results.every((user: IUser) => {
if (user.username.toLowerCase() === username.toLowerCase() && user.id !== userToEdit.id) {
error = t("modaluseredit.errorusernameexists");
return false;
}
return true;
});
}
return error;
return error || null;
};

const validateEmail = email => {
const validateEmail = (email: string) => {
if (email && !EMAIL_REGEX.test(email)) {
return t("modaluseredit.errorinvalidemail");
}
return null;
};

const validatePath = path => {
const validatePath = (path: string) => {
if (firstTimeSetup && !path) {
return t("modalscandirectoryedit.mustspecifypath");
}
Expand Down Expand Up @@ -118,7 +119,7 @@ export function ModalUserEdit(props: Props) {
});

useEffect(() => {
if (auth.access && auth.access.is_admin) {
if (auth?.access?.is_admin) {
fetchDirectoryTree("");
}
}, [auth.access, dispatch]);
Expand Down Expand Up @@ -161,7 +162,7 @@ export function ModalUserEdit(props: Props) {
}
}, [form.values.scan_directory]);

const nodeClicked = (event, rowInfo) => {
const nodeClicked = (event: Event, rowInfo: any) => {
if (inputRef.current) {
const path = rowInfo.node.absolute_path;
inputRef.current.value = path;
Expand Down Expand Up @@ -318,19 +319,13 @@ export function ModalUserEdit(props: Props) {
canDrag={() => false}
canDrop={() => false}
treeData={treeData}
onChange={changedTreeData => setTreeData(changedTreeData)}
onChange={setTreeData}
theme={FileExplorerTheme}
isVirtualized={false}
generateNodeProps={rowInfo => {
const nodeProps = {
onClick: event => nodeClicked(event, rowInfo),
};
if (selectedNodeId === rowInfo.node.id) {
// @ts-ignore
nodeProps.className = "selected-node";
}
return nodeProps;
}}
generateNodeProps={(rowInfo: any) => ({
onClick: (event: Event) => nodeClicked(event, rowInfo),
className: selectedNodeId === rowInfo.node.id ? "selected-node" : undefined,
})}
/>
</div>
</>
Expand Down
3 changes: 2 additions & 1 deletion src/components/settings/date-time-settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createStyles } from "@mantine/core";
import type { TFunction } from "i18next";
import React from "react";

import type { DateTimeRule } from "./date-time.zod";
Expand Down Expand Up @@ -35,7 +36,7 @@ export const useDateTimeSettingsStyles = createStyles(theme => ({
},
}));

export function getRuleExtraInfo(rule: DateTimeRule, t: (s: string, o: Object) => string) {
export function getRuleExtraInfo(rule: DateTimeRule, t: TFunction<"translation", undefined>) {
const ignoredProps = ["name", "id", "rule_type", "transform_tz", "is_default"];
return (
<>
Expand Down

0 comments on commit 1b6eecb

Please sign in to comment.