changed project struture.

Also addded a functional JWT token service.

Also added user react frontend
This commit is contained in:
2025-07-23 11:59:59 +02:00
parent 2b4b554c24
commit d552f40c2d
52 changed files with 3807 additions and 31 deletions

View File

@@ -0,0 +1,12 @@
import Cookies from "js-cookie";
export const greeting = () => {
return Cookies.get("name") ?? "Login";
};
export const logout = () => {
Cookies.remove("name");
Cookies.remove("token");
localStorage.removeItem("users");
window.location.reload();
};

View File

@@ -0,0 +1,29 @@
import { useState, useEffect } from "react";
export interface User {
id: number;
username: string;
first_name: string;
last_name: string;
email: string;
password: string;
created: string;
}
export function useUsers(): User[] {
const [users, setUsers] = useState<User[]>([]);
useEffect(() => {
const data = localStorage.getItem("users");
if (data) {
try {
const parsed = JSON.parse(data);
setUsers(parsed.result || []);
} catch {
setUsers([]);
}
}
}, []);
return users;
}