diff --git a/src/@types/events.ts b/src/@types/events.ts new file mode 100644 index 0000000..e04edf3 --- /dev/null +++ b/src/@types/events.ts @@ -0,0 +1,3 @@ +import { FormEvent } from 'react' + +export interface TypeForm extends FormEvent {} diff --git a/src/routes/Fetch.tsx b/src/routes/Fetch.tsx index 1b20405..f77cd1d 100644 --- a/src/routes/Fetch.tsx +++ b/src/routes/Fetch.tsx @@ -1,16 +1,17 @@ -import React, { useState, FormEvent, useEffect, Fragment } from 'react' +import React, { useState, useEffect, Fragment } from 'react' import { fetchAndSet, isCodeFF } from '../control' import { Input } from '../view/Input' import { saveToken } from '../utils' import { Redirect } from 'react-router-dom' +import { TypeForm } from '../@types/events' interface FormElements extends HTMLFormElement { student_no: HTMLInputElement student_pw: HTMLInputElement } -interface FormTarget extends FormEvent { +interface FormTarget extends TypeForm { target: FormElements } @@ -34,7 +35,7 @@ const App = () => {

학번 및 비밀번호를 입력해주세요!

- +
diff --git a/src/routes/Login.tsx b/src/routes/Login.tsx index 2b738cb..8439fc8 100644 --- a/src/routes/Login.tsx +++ b/src/routes/Login.tsx @@ -1,15 +1,22 @@ -import React, { FormEvent, useState, Fragment } from 'react' +import React, { useState, Fragment } from 'react' import { Input } from '../view/Input' import { submitID } from '../control' +import { TypeForm } from '../@types/events' + +interface FormElements extends HTMLFormElement { + mailid: HTMLInputElement +} + +interface FormTarget extends TypeForm { + target: FormElements +} const App: React.FC = () => { const [flag, setFlag] = useState() - const onSubmit = async (event: FormEvent) => { + const onSubmit = async (event: FormTarget) => { event.preventDefault() - // @ts-ignore - const { value }: { value: string } = event.target[0] - setFlag(await submitID(value)) + setFlag(await submitID(event.target.mailid.value)) } return (