small aditions

This commit is contained in:
DavidK004 2025-12-17 15:30:27 +01:00
parent e50b99641c
commit f9073af330
5 changed files with 23 additions and 0 deletions

13
src/api/users.ts Normal file
View File

@ -0,0 +1,13 @@
import axiosInstance from "./axiosInstance";
export const getAllUsers = async (page: number) => {
const res = await axiosInstance.get("/api/users", {
params: { page },
});
return res.data;
};
export const getUserById = async (id: number) => {
const res = await axiosInstance.get(`api/users/${id}`);
return res.data;
};

View File

@ -9,6 +9,7 @@ export const useLogin = () => {
onSuccess: (data) => {
localStorage.setItem("access_token", data.token);
toast.success("Logged In!");
},
onError: (err: any) => {

View File

View File

@ -0,0 +1,8 @@
import { useQuery } from "@tanstack/react-query";
import { getAllUsers } from "../../api/users";
export const useUsers = (page: number) =>
useQuery({
queryKey: ["users"],
queryFn: () => getAllUsers(page),
});

View File

@ -16,6 +16,7 @@ const ProfilePage = () => {
}
}, []);
return (
<Container>
<Box sx={{ padding: 4, maxWidth: 360 }}>