-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #335 from calisio/main
fix: fixes all linting warnings
- Loading branch information
Showing
103 changed files
with
6,622 additions
and
6,251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:react-hooks/recommended", | ||
], | ||
ignorePatterns: ["dist", ".eslintrc.cjs"], | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["react-refresh"], | ||
rules: { | ||
"react-refresh/only-export-components": [ | ||
"warn", | ||
{ allowConstantExport: true }, | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended' | ||
], | ||
}, | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true } | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"trailingComma": "none", | ||
"tabWidth": 4, | ||
"semi": true, | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>UnlockEd</title> | ||
<link href="/fonts/fonts.css" rel="stylesheet" type="text/css" /> | ||
</head> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>UnlockEd</title> | ||
<link href="/fonts/fonts.css" rel="stylesheet" type="text/css" /> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
{ | ||
"name": "unlockedv2", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"proxy": "http://localhost:8080", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"lint-staged": "oxlint src", | ||
"preview": "vite preview", | ||
"prepare": "cd .. && husky frontend/.husky" | ||
}, | ||
"dependencies": { | ||
"autoprefixer": "^10.4.19", | ||
"axios": "^1.6.8", | ||
"daisyui": "^4.10.5", | ||
"oxlint": "^0.3.2", | ||
"postcss": "^8.4.38", | ||
"prettier": "^3.2.5", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-hook-form": "^7.51.3", | ||
"react-router-dom": "^6.23.0", | ||
"recharts": "^2.12.7", | ||
"swr": "^2.2.5", | ||
"tailwindcss": "^3.4.3", | ||
"usehooks-ts": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"@heroicons/react": "^2.0.18", | ||
"@tailwindcss/forms": "^0.5.3", | ||
"@tailwindcss/typography": "^0.5.10", | ||
"@types/react": "^18.2.66", | ||
"@types/react-dom": "^18.2.22", | ||
"@typescript-eslint/eslint-plugin": "^7.2.0", | ||
"@typescript-eslint/parser": "^7.2.0", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.6", | ||
"husky": "^9.0.11", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.2.0" | ||
}, | ||
"lint-staged": { | ||
"**/*.{js,tsx,ts,css,md}": "prettier --write" | ||
} | ||
"name": "unlockedv2", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"proxy": "http://localhost:8080", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"lint-staged": "oxlint src", | ||
"preview": "vite preview", | ||
"prepare": "cd .. && husky frontend/.husky" | ||
}, | ||
"dependencies": { | ||
"autoprefixer": "^10.4.19", | ||
"axios": "^1.6.8", | ||
"daisyui": "^4.10.5", | ||
"oxlint": "^0.3.2", | ||
"postcss": "^8.4.38", | ||
"prettier": "^3.2.5", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-hook-form": "^7.51.3", | ||
"react-router-dom": "^6.23.0", | ||
"recharts": "^2.12.7", | ||
"swr": "^2.2.5", | ||
"tailwindcss": "^3.4.3", | ||
"usehooks-ts": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"@heroicons/react": "^2.0.18", | ||
"@tailwindcss/forms": "^0.5.3", | ||
"@tailwindcss/typography": "^0.5.10", | ||
"@types/react": "^18.2.66", | ||
"@types/react-dom": "^18.2.22", | ||
"@typescript-eslint/eslint-plugin": "^7.2.0", | ||
"@typescript-eslint/parser": "^7.2.0", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-refresh": "^0.4.6", | ||
"husky": "^9.0.11", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.2.0" | ||
}, | ||
"lint-staged": { | ||
"**/*.{js,tsx,ts,css,md}": "prettier --write" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,81 @@ | ||
import "@/bootstrap"; | ||
import '@/bootstrap'; | ||
import React, { | ||
createContext, | ||
useContext, | ||
useEffect, | ||
useState, | ||
Dispatch, | ||
SetStateAction, | ||
} from "react"; | ||
import { User } from "./types"; | ||
import axios from "axios"; | ||
createContext, | ||
useContext, | ||
useEffect, | ||
useState, | ||
Dispatch, | ||
SetStateAction | ||
} from 'react'; | ||
import { User } from './types'; | ||
import axios from 'axios'; | ||
|
||
interface AuthContextType { | ||
user: User | null; | ||
setUser: Dispatch<SetStateAction<User | null>>; | ||
user: User | null; | ||
setUser: Dispatch<SetStateAction<User | null>>; | ||
} | ||
|
||
const AuthContext = createContext<AuthContextType | null>(null); | ||
|
||
export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ | ||
children, | ||
children | ||
}) => { | ||
const [user, setUser] = useState<User | null>(null); | ||
const [loading, setLoading] = useState(true); | ||
useEffect(() => { | ||
const fetchUser = async () => { | ||
try { | ||
const response = await axios.get(`/api/auth`); | ||
setUser(response.data); | ||
} catch (error) { | ||
console.log("Authentication check failed", error); | ||
setUser(null); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
fetchUser(); | ||
}, []); | ||
const [user, setUser] = useState<User | null>(null); | ||
const [loading, setLoading] = useState(true); | ||
useEffect(() => { | ||
const fetchUser = async () => { | ||
try { | ||
const response = await axios.get(`/api/auth`); | ||
setUser(response.data); | ||
} catch (error) { | ||
console.log('Authentication check failed', error); | ||
setUser(null); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
fetchUser(); | ||
}, []); | ||
|
||
if (loading) { | ||
return <div>Loading...</div>; | ||
} | ||
if (!user) { | ||
return null; | ||
} else if ( | ||
user.password_reset === true && | ||
window.location.pathname !== "/reset-password" | ||
) { | ||
window.location.href = "/reset-password"; | ||
return null; | ||
} | ||
return ( | ||
<AuthContext.Provider value={{ user, setUser }}> | ||
{children} | ||
</AuthContext.Provider> | ||
); | ||
if (loading) { | ||
return <div>Loading...</div>; | ||
} | ||
if (!user) { | ||
return null; | ||
} else if ( | ||
user.password_reset === true && | ||
window.location.pathname !== '/reset-password' | ||
) { | ||
window.location.href = '/reset-password'; | ||
return null; | ||
} | ||
return ( | ||
<AuthContext.Provider value={{ user, setUser }}> | ||
{children} | ||
</AuthContext.Provider> | ||
); | ||
}; | ||
|
||
export const useAuth = () => { | ||
const context = useContext(AuthContext); | ||
if (!context) { | ||
throw new Error("useAuth must be used within an AuthProvider"); | ||
} | ||
return context; | ||
const context = useContext(AuthContext); | ||
if (!context) { | ||
throw new Error('useAuth must be used within an AuthProvider'); | ||
} | ||
return context; | ||
}; | ||
|
||
export const handleLogout = async () => { | ||
try { | ||
await axios.post("/api/logout"); | ||
const logout_response = await axios.get("/self-service/logout/browser"); | ||
if (logout_response.data.logout_url) { | ||
window.location.href = logout_response.data.logout_url; | ||
} else { | ||
console.log("Logout failed", logout_response); | ||
window.location.href = "/self-service/login/browser"; | ||
try { | ||
await axios.post('/api/logout'); | ||
const logout_response = await axios.get('/self-service/logout/browser'); | ||
if (logout_response.data.logout_url) { | ||
window.location.href = logout_response.data.logout_url; | ||
} else { | ||
console.log('Logout failed', logout_response); | ||
window.location.href = '/self-service/login/browser'; | ||
} | ||
} catch (error) { | ||
window.location.href = '/login'; | ||
console.log('Logout failed', error); | ||
} | ||
} catch (error) { | ||
window.location.href = "/login"; | ||
console.log("Logout failed", error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { HTMLAttributes } from "react"; | ||
import { HTMLAttributes } from 'react'; | ||
|
||
export default function ApplicationLogo(props: HTMLAttributes<HTMLElement>) { | ||
return <img {...props} src="/ul-logo.png" />; | ||
return <img {...props} src="/ul-logo.png" />; | ||
} |
Oops, something went wrong.