login time

This commit is contained in:
Sone
2025-11-05 20:11:34 +01:00
parent b43aec6b9a
commit fdcc42007a
21 changed files with 1363 additions and 843 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ export const getApiUrl = () => {
if (!isDev) return prodUrl;
if (Platform.OS === "web") {
return process.env.EXPO_PUBLIC_BACKEND_URL;
return process.env.EXPO_PUBLIC_BACKEND_URL || "http://localhost:5000/api";
}
try {
+28
View File
@@ -26,6 +26,16 @@ export type UserLoginLog = {
email: string;
lastLoginAt: string | Date;
activity: string;
status?: "SUCCESS" | "FAILURE";
failureReason?:
| "MISSING_CREDENTIALS"
| "INVALID_CREDENTIALS"
| "WRONG_PASSWORD"
| "ACCOUNT_LOCKED"
| "NOT_ACTIVATED"
| "NOT_ALLOWED"
| "UNKNOWN"
| null;
};
const normalizeSortDir = (dir?: TableSortDirection) => {
@@ -82,6 +92,23 @@ export const usersApi = baseApi.injectEndpoints({
providesTags: ["UserLogs"],
}),
getUserLogsById: builder.query<
{ items: UserLoginLog[]; total: number; page: number; limit: number },
{ userId: string; page?: number; limit?: number }
>({
query: ({ userId, page, limit }) => ({
url: `/users/${userId}/logs`,
params: {
...(page !== undefined && { page }),
...(limit !== undefined && { limit }),
},
}),
providesTags: (_res, _err, { userId }) => [
"UserLogs",
{ type: "UserLogs", id: userId } as any,
],
}),
getUsers: builder.query<PaginatedUsers, UsersQueryParams | undefined>({
query: (params) => ({ url: "/users", params: buildUserParams(params) }),
providesTags: (result) => [
@@ -139,6 +166,7 @@ export const usersApi = baseApi.injectEndpoints({
export const {
useGetUserLogsQuery,
useGetUserLogsByIdQuery,
useGetUsersQuery,
useGetUserByIdQuery,
useDeleteUserMutation,