apply suggestions
continuous-integration/drone/push Build is failing Details

maxime 1 year ago
parent 8fc8aa6917
commit 6eacfc1ae2

@ -1,2 +1 @@
VITE_API_ENDPOINT=http://localhost:5254 VITE_API_ENDPOINT=https://iqball.maxou.dev/api/dotnet-master
VITE_BASE=

@ -5,6 +5,8 @@ module.exports = {
"eslint:recommended", "eslint:recommended",
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended", "plugin:react-hooks/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
], ],
ignorePatterns: ["dist", ".eslintrc.cjs"], ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser", parser: "@typescript-eslint/parser",

@ -6,4 +6,4 @@ export const API = import.meta.env.VITE_API_ENDPOINT
/** /**
* This constant defines the base app's endpoint. * This constant defines the base app's endpoint.
*/ */
export const BASE = import.meta.env.VITE_BASE export const BASE = import.meta.env.BASE_URL.slice(0, import.meta.env.BASE_URL.length - 1)

@ -1,9 +1,6 @@
import { API, BASE } from "./Constants" import { API } from "./Constants"
import { getSession, saveSession, Session } from "./api/session.ts" import { getSession, saveSession, Session } from "./api/session.ts"
import { redirect } from "react-router-dom"
export function redirect(url: string) {
location.pathname = BASE + url
}
export async function fetchAPI( export async function fetchAPI(
url: string, url: string,

@ -99,20 +99,23 @@ interface EditorPageProps {
} }
export default function EditorPage({ guestMode }: EditorPageProps) { export default function EditorPage({ guestMode }: EditorPageProps) {
const [tactic, setTactic] = useState<TacticDto>() const [tactic, setTactic] = useState<TacticDto | null>(() => {
const { tacticId: idStr } = useParams()
const id = guestMode ? -1 : parseInt(idStr!)
useEffect(() => {
if (guestMode) { if (guestMode) {
setTactic({ return {
id: -1, id: -1,
courtType: "PLAIN", courtType: "PLAIN",
content: '{"components": []}', content: '{"components": []}',
name: DEFAULT_TACTIC_NAME, name: DEFAULT_TACTIC_NAME,
}
}
return null;
}) })
const { tacticId: idStr } = useParams()
const id = guestMode ? -1 : parseInt(idStr!)
useEffect(() => {
if (guestMode)
return return
}
async function initialize() { async function initialize() {
const infoResponse = fetchAPIGet(`tactics/${id}`) const infoResponse = fetchAPIGet(`tactics/${id}`)

@ -1,11 +1,11 @@
import "../style/home/home.css" import "../style/home/home.css"
// import AccountSvg from "../assets/account.svg?react"
import { BASE } from "../Constants" import { BASE } from "../Constants"
import { getSession } from "../api/session.ts" import { getSession } from "../api/session.ts"
import { fetchAPIGet, redirect } from "../Fetcher.ts" import { redirect } from "react-router-dom"
import { useLayoutEffect, useState } from "react" import { useLayoutEffect, useState } from "react"
import { User } from "../model/User.ts" import { User } from "../model/User.ts"
import { fetchAPIGet } from "../Fetcher.ts"
interface Tactic { interface Tactic {
id: number id: number

@ -1,21 +1,21 @@
import { FormEvent, useRef, useState } from "react" import { FormEvent, useRef, useState } from "react"
import { BASE } from "../Constants.ts" import { BASE } from "../Constants.ts"
import { fetchAPI, redirect } from "../Fetcher.ts" import { fetchAPI } from "../Fetcher.ts"
import { Failure } from "../api/failure.ts" import { Failure } from "../api/failure.ts"
import { getSession, saveSession } from "../api/session.ts" import { getSession, saveSession } from "../api/session.ts"
import "../style/form.css" import "../style/form.css"
import { redirect } from "react-router-dom"
export default function LoginApp() { export default function LoginApp() {
const [errors, setErrors] = useState<Failure[]>([]) const [errors, setErrors] = useState<Failure[]>([])
const emailRef = useRef<HTMLInputElement>(null)
const passwordRef = useRef<HTMLInputElement>(null)
async function handleSubmit(e: FormEvent) { async function handleSubmit(e: FormEvent) {
e.preventDefault() e.preventDefault()
const email = emailRef.current!.value const { email, password } = Object.fromEntries(
const password = passwordRef.current!.value new FormData(e.target as HTMLFormElement),
)
const response = await fetchAPI( const response = await fetchAPI(
"auth/token", "auth/token",
@ -38,7 +38,7 @@ export default function LoginApp() {
{ {
type: "Non autorisé", type: "Non autorisé",
messages: [ messages: [
"L'adresse email ou le mot de passe sont invalide.", "L'adresse email ou le mot de passe sont invalides.",
], ],
}, },
]) ])
@ -81,7 +81,6 @@ export default function LoginApp() {
<div className="form-group"> <div className="form-group">
<label htmlFor="email">Email :</label> <label htmlFor="email">Email :</label>
<input <input
ref={emailRef}
type="text" type="text"
id="email" id="email"
name="email" name="email"
@ -90,7 +89,6 @@ export default function LoginApp() {
<label htmlFor="password">Mot de passe :</label> <label htmlFor="password">Mot de passe :</label>
<input <input
ref={passwordRef}
type="password" type="password"
id="password" id="password"
name="password" name="password"

@ -2,22 +2,22 @@
// import "../style/visualizer.css" // import "../style/visualizer.css"
// import Court from "../assets/court/full_court.svg" // import Court from "../assets/court/full_court.svg"
// //
// // export default function Visualizer({ id, name }: { id: number; name: string }) { // export default function Visualizer({ id, name }: { id: number; name: string }) {
// // const [style, setStyle] = useState<CSSProperties>({}) // const [style, setStyle] = useState<CSSProperties>({})
// // //
// // return ( // return (
// // <div id="main"> // <div id="main">
// // <div id="topbar"> // <div id="topbar">
// // <h1>{name}</h1> // <h1>{name}</h1>
// // </div> // </div>
// // <div id="court-container"> // <div id="court-container">
// // <img // <img
// // id="court" // id="court"
// // src={Court} // src={Court}
// // style={style} // style={style}
// // alt="Basketball Court" // alt="Basketball Court"
// // /> // />
// // </div> // </div>
// // </div> // </div>
// // ) // )
// // } // }

@ -1,8 +1,9 @@
import AccountSvg from "../../assets/account.svg?react" import AccountSvg from "../../assets/account.svg?react"
import "../../style/template/header.css" import "../../style/template/header.css"
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import { fetchAPIGet, redirect } from "../../Fetcher.ts" import { fetchAPIGet } from "../../Fetcher.ts"
import { getSession, saveSession } from "../../api/session.ts" import { getSession, saveSession } from "../../api/session.ts"
import { redirect } from "react-router-dom"
export function Header() { export function Header() {
const session = getSession() const session = getSession()

@ -13,8 +13,6 @@ export default defineConfig({
cssInjectedByJsPlugin({ cssInjectedByJsPlugin({
relativeCSSInjection: true, relativeCSSInjection: true,
}), }),
svgr({ svgr(),
include: "**/*.svg?react",
}),
], ],
}) })

Loading…
Cancel
Save