diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..c0a45b6 Binary files /dev/null and b/bun.lockb differ diff --git a/config-overrides.js b/config-overrides.js new file mode 100644 index 0000000..a1cdbc4 --- /dev/null +++ b/config-overrides.js @@ -0,0 +1,9 @@ +module.exports = function override(webpackConfig) { + webpackConfig.module.rules.push({ + test: /\.mjs$/, + include: /node_modules/, + type: 'javascript/auto', + }) + + return webpackConfig +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..33ec6ce --- /dev/null +++ b/index.html @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + Games Database + + + + + +
+ + + + diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..8627da4 --- /dev/null +++ b/notes.txt @@ -0,0 +1,3 @@ +Include somewhere with image on error page. Probably in video alt. + +Image by Alexander Antropov from Pixabay \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ea09056 --- /dev/null +++ b/package.json @@ -0,0 +1,76 @@ +{ + "name": "games-database-client", + "version": "0.1.0", + "private": true, + "dependencies": { + "@chakra-ui/icons": "^2.1.1", + "@chakra-ui/react": "^2.8.2", + "@emotion/react": "^11.11.1", + "@emotion/styled": "^11.11.0", + "@hookstate/core": "^4.0.1", + "@hookstate/localstored": "^4.0.2", + "axios": "^1.5.0", + "bson-objectid": "^2.0.4", + "chakra-react-select": "^4.7.2", + "chakra-ui-contextmenu": "^1.0.5", + "framer-motion": "^10.16.4", + "interweave": "^13.1.0", + "jodit-react": "^1.3.39", + "js-base64": "^3.7.5", + "react": "^18.2.0", + "react-device-detect": "^2.2.3", + "react-dom": "^18.2.0", + "react-hook-form": "^7.48.2", + "react-icons": "^4.11.0", + "react-rating": "^2.0.5", + "react-responsive-carousel": "^3.2.23", + "react-router-dom": "^5.3.4", + "react-select": "^5.7.4", + "react-toastify": "^9.1.3", + "web-vitals": "^3.4.0" + }, + "scripts": { + "start": "bunx --bun vite", + "buildProject": "bunx --bun vite build", + "serve": "vite preview", + "serveprod": "serve ./dist/index.html" + }, + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ] + }, + "resolutions": { + "@types/react": "18.2.21", + "@types/react-dom": "18.2.7" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + }, + "devDependencies": { + "@chakra-ui/cli": "^2.4.1", + "@hookstate/devtools": "^4.0.1", + "@testing-library/jest-dom": "^6.1.3", + "@testing-library/react": "^14.0.0", + "@testing-library/user-event": "^14.4.3", + "@types/jest": "^29.5.4", + "@types/node": "^20.6.0", + "@types/react": "^18.2.21", + "@types/react-dom": "^18.2.7", + "@types/react-router-dom": "^5.3.3", + "@types/react-table": "^7.7.15", + "@vitejs/plugin-react": "^4.0.4", + "typescript": "^5.2.2", + "vite": "^4.4.9" + } +} diff --git a/public/assets/Logo.svg b/public/assets/Logo.svg new file mode 100644 index 0000000..3a14d3e --- /dev/null +++ b/public/assets/Logo.svg @@ -0,0 +1,51 @@ + + + + + + + diff --git a/public/assets/SteamAndDeckLogo.svg b/public/assets/SteamAndDeckLogo.svg new file mode 100644 index 0000000..4fd83d3 --- /dev/null +++ b/public/assets/SteamAndDeckLogo.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..f9fadb4 Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..7d3bb95 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "Games Database", + "name": "Games Database", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..696bf08 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.js.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/src/@types/game.ts b/src/@types/game.ts new file mode 100644 index 0000000..02d1a97 --- /dev/null +++ b/src/@types/game.ts @@ -0,0 +1,3 @@ +export type RecursivePartial = { + [P in keyof T]?: RecursivePartial; +}; \ No newline at end of file diff --git a/src/App.test.tsx b/src/App.test.tsx new file mode 100644 index 0000000..2a68616 --- /dev/null +++ b/src/App.test.tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import App from './App'; + +test('renders learn react link', () => { + render(); + const linkElement = screen.getByText(/learn react/i); + expect(linkElement).toBeInTheDocument(); +}); diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..fc7db19 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,112 @@ +import React, { useEffect } from 'react' +import GameDashboard from './components/GamesDashboard' +import { Redirect, Route, Switch, useLocation } from 'react-router-dom' +import Header from './components/Header' +import Home from './components/Home' +import GameDetails from './components/GameDetails' +import GameForm from './components/GameForm' +import NotFound from './errors/NotFound' +import TestErrors from './errors/TestError' +import Footer from './components/Footer' +import LoginForm from './components/authComponents/LoginForm' +import { + setAppLoaded, + getUser, + appLoadedState, + loggedInState, loadedPreferences, +} from './stateManagement/userState' +import {useHookstate} from '@hookstate/core' +import { ToastContainer } from 'react-toastify' +import NoGames from './components/NoGames' +import CreateUser from './components/userComponents/CreateUser' +import LoadingModal from './components/LoadingModal' +import SomethingWentWrong from './errors/SomethingWentWrong' +import ForgotPassword from './components/authComponents/ForgotPassword' +import ResetPassword from './components/authComponents/ResetPassword' +import UserProfile from './components/userComponents/UserProfile' +import EditUser from './components/userComponents/EditUser' +import {Box, useColorMode} from "@chakra-ui/react"; + +function App() { + const location = useLocation() + const appLoaded = useHookstate(appLoadedState) + const appLoad = appLoaded.get() + const isLoggedIn = useHookstate(loggedInState) + const loggedIn = isLoggedIn.get() + const originalToken = window.localStorage.getItem('jwt') + const { colorMode, toggleColorMode } = useColorMode() + + useEffect(() => { + if (originalToken) getUser(originalToken).finally(() => setAppLoaded(true)) + else setAppLoaded(false) + }, [originalToken]) + + if (!appLoad) + + useEffect(() => { + if(loadedPreferences.get().theme !== colorMode) { + localStorage.removeItem('chakra-ui-color-mode') + toggleColorMode() + } + }, [loadedPreferences.get().theme]); + + // noinspection SpellCheckingInspection + return ( + <> + + {loggedIn ?
: ''} + + {loggedIn ? : } + + + {/**/} + + } + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {loggedIn ?