feat(AdminPage): add support for UserInputType in handleNewUser function to improve type safety and prevent potential errors

fix(UserInputType): make is_active and is_superuser optional in UserInputType to allow for flexibility in user input
This commit is contained in:
anovazzi1 2023-08-15 18:04:10 -03:00
commit 85add46761
2 changed files with 4 additions and 3 deletions

View file

@ -25,6 +25,7 @@ import {
} from "../../controllers/API";
import ConfirmationModal from "../../modals/ConfirmationModal";
import UserManagementModal from "../../modals/UserManagementModal";
import { UserInputType } from "../../types/components";
export default function AdminPage() {
const [inputValue, setInputValue] = useState("");
@ -164,7 +165,7 @@ export default function AdminPage() {
});
}
function handleNewUser(user) {
function handleNewUser(user: UserInputType) {
addUser(user)
.then((res) => {
resetFilter();

View file

@ -230,6 +230,6 @@ export type loginInputStateType = {
export type UserInputType = {
username: string;
password: string;
is_active: boolean;
is_superuser: boolean;
is_active?: boolean;
is_superuser?: boolean;
};