Enhance authentication input fields with autocomplete attributes and refactor API registration and login methods for improved response handling
This commit is contained in:
@@ -116,11 +116,11 @@ function AuthScreen({ onAuth }: { onAuth: (auth: AuthState) => void }) {
|
||||
)}
|
||||
<label>
|
||||
Email
|
||||
<input type="email" value={email} onChange={(event) => setEmail(event.target.value)} />
|
||||
<input type="email" autoComplete="username" value={email} onChange={(event) => setEmail(event.target.value)} />
|
||||
</label>
|
||||
<label>
|
||||
Пароль
|
||||
<input type="password" value={password} onChange={(event) => setPassword(event.target.value)} />
|
||||
<input type="password" autoComplete={mode === "register" ? "new-password" : "current-password"} value={password} onChange={(event) => setPassword(event.target.value)} />
|
||||
</label>
|
||||
{error && <p className="error">{error}</p>}
|
||||
<button className="primary" disabled={mutation.isPending}>
|
||||
|
||||
+6
-4
@@ -25,11 +25,13 @@ async function request<T>(path: string, options: RequestInit = {}, token?: strin
|
||||
}
|
||||
|
||||
export const api = {
|
||||
register(payload: { email: string; password: string; display_name: string }) {
|
||||
return request<AuthState>("/auth/register", { method: "POST", body: JSON.stringify(payload) });
|
||||
async register(payload: { email: string; password: string; display_name: string }): Promise<AuthState> {
|
||||
const raw = await request<{ access_token: string; user: User }>("/auth/register", { method: "POST", body: JSON.stringify(payload) });
|
||||
return { accessToken: raw.access_token, user: raw.user };
|
||||
},
|
||||
login(payload: { email: string; password: string }) {
|
||||
return request<AuthState>("/auth/login", { method: "POST", body: JSON.stringify(payload) });
|
||||
async login(payload: { email: string; password: string }): Promise<AuthState> {
|
||||
const raw = await request<{ access_token: string; user: User }>("/auth/login", { method: "POST", body: JSON.stringify(payload) });
|
||||
return { accessToken: raw.access_token, user: raw.user };
|
||||
},
|
||||
me(token: string) {
|
||||
return request<User>("/me", {}, token);
|
||||
|
||||
@@ -180,11 +180,14 @@ async def progression(
|
||||
kind: Annotated[str, Query(pattern="^(exercise|equipment)$")] = "exercise",
|
||||
entity_id: str | None = None,
|
||||
) -> Any:
|
||||
p: dict[str, Any] = {"kind": kind}
|
||||
if entity_id is not None:
|
||||
p["entity_id"] = entity_id
|
||||
return await logic_request(
|
||||
"GET",
|
||||
"/internal/analytics/progression",
|
||||
user,
|
||||
params={"kind": kind, "entity_id": entity_id},
|
||||
params=p,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -351,8 +351,8 @@ def recalculate_workout_calories(db: Session, workout_id: uuid.UUID) -> None:
|
||||
def get_progression(
|
||||
db: Db,
|
||||
user_id: CurrentUserId,
|
||||
kind: str = Query(pattern="^(exercise|equipment)$"),
|
||||
entity_id: uuid.UUID | None = None,
|
||||
kind: Annotated[str, Query(pattern="^(exercise|equipment)$")],
|
||||
entity_id: Annotated[uuid.UUID | None, Query()] = None,
|
||||
) -> ProgressionRead:
|
||||
statement = (
|
||||
select(Workout.started_at, WorkoutSet.weight, WorkoutSet.reps)
|
||||
|
||||
Reference in New Issue
Block a user