login time
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user