diff options
author | eug-vs <eug-vs@keemail.me> | 2020-03-21 14:17:58 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-03-21 14:17:58 +0300 |
commit | 550f00b93c03a9ad98ef9bb1197c0fbfd5b1e572 (patch) | |
tree | 28408ad5330ae98da60fea9778ebdf10a28893d1 | |
parent | 2d976f7d3468ba5f49bb54351b47b3cad494d7ba (diff) | |
download | chrono-cube-ui-550f00b93c03a9ad98ef9bb1197c0fbfd5b1e572.tar.gz |
chore!: migrate index.js -> index.tsx
-rw-r--r-- | src/index.tsx (renamed from src/index.js) | 22 | ||||
-rw-r--r-- | src/react-app-env.d.ts | 1 | ||||
-rw-r--r-- | tsconfig.json | 25 |
3 files changed, 39 insertions, 9 deletions
diff --git a/src/index.js b/src/index.tsx index 49c66e7..eb43b7e 100644 --- a/src/index.js +++ b/src/index.tsx @@ -20,11 +20,14 @@ import GitHubIcon from '@material-ui/icons/GitHub'; import { get } from './requests'; - -const App = () => { - - const [page, setPage] = useState('app'); - const [user, setUser] = useState({ username: 'anonymous', id: null }); +interface User { + username: string; + id: number | null; +} + +const App: React.FC = () => { + const [page, setPage] = useState<string>('app'); + const [user, setUser] = useState<User>({ username: 'anonymous', id: null }); const [recentSolutions, setRecentSolutions] = useState([]); const headerContents = { @@ -35,15 +38,15 @@ const App = () => { }; useEffect(() => { - const userId = +localStorage.getItem('userId'); + const userId = localStorage.getItem('userId'); if (userId) { get('users/').then(response => { - setUser(response.data.filter(user => user.id === +userId)[0]); + setUser(response.data.filter((user: User) => user.id === +userId)[0]); }); } }, []); - const Page = ({ page }) => { + const Page: React.FC<{ page: string }> = ({ page }) => { switch (page) { case 'app': return ( @@ -73,7 +76,8 @@ const App = () => { <BenzinThemeProvider> <Header logo={{ - title: 'ChronoCube' + title: 'ChronoCube', + icon: null }} contents={headerContents} page={page} diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts new file mode 100644 index 0000000..6431bc5 --- /dev/null +++ b/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// <reference types="react-scripts" /> diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f2850b7 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react" + }, + "include": [ + "src" + ] +} |