Skip to content

Commit

Permalink
feat: Move Security to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
mman committed Oct 15, 2024
1 parent ecb299c commit 7778e87
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import {
} from "@coreui/react"

import { usePostSecurity } from "../../hooks/useAdminApi"
import {
useFormValidation,
extractParameterNameAndValue,
} from "../../hooks/useFormValidation"
import { useFormValidation, extractParameterNameAndValue } from "../../hooks/useFormValidation"

interface SecurityState {
username: string
password: string
password1: string
}

type SecurityStateKeys = keyof SecurityState

function Security() {
const [state, setState] = useState({
Expand All @@ -36,9 +41,11 @@ function Security() {
)
})

function handleFormInputChange(event) {
function handleFormInputChange(event: React.ChangeEvent<HTMLInputElement>) {
const clone = { ...state }
const [name, value] = extractParameterNameAndValue(event)
const [name, value] = extractParameterNameAndValue<SecurityStateKeys>(event)
// TODO: fix this
// @ts-expect-error
clone[name] = value
setState(clone)
}
Expand Down

0 comments on commit 7778e87

Please sign in to comment.