changed project struture.
Also addded a functional JWT token service. Also added user react frontend
This commit is contained in:
29
frontend_admin/src/utils/useUsers.ts
Normal file
29
frontend_admin/src/utils/useUsers.ts
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user