first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import {useMutation} from '@tanstack/react-query';
import {BackendResponse} from '@common/http/backend-response/backend-response';
import {apiClient} from '@common/http/query-client';
import {showHttpErrorToast} from '@common/utils/http/show-http-error-toast';
interface Response extends BackendResponse {}
interface Payload {
password: string;
}
export function useLogoutOtherSessions() {
return useMutation({
mutationFn: (payload: Payload) => logoutOther(payload),
onError: r => showHttpErrorToast(r),
});
}
function logoutOther(payload: Payload): Promise<Response> {
return apiClient
.post('user-sessions/logout-other', payload)
.then(response => response.data);
}

View File

@@ -0,0 +1,34 @@
import {useQuery} from '@tanstack/react-query';
import {apiClient} from '@common/http/query-client';
import {BackendResponse} from '@common/http/backend-response/backend-response';
export interface ActiveSession {
id: string;
platform?: string;
device_type?: 'mobile' | 'tablet' | 'desktop';
browser?: string;
country?: string;
city?: string;
ip_address?: string;
token?: string;
is_current_device: boolean;
last_active: string;
created_at: string;
}
interface Response extends BackendResponse {
sessions: ActiveSession[];
}
export function useUserSessions() {
return useQuery({
queryKey: ['user-sessions'],
queryFn: () => fetchUserSessions(),
});
}
function fetchUserSessions() {
return apiClient
.get<Response>(`user-sessions`)
.then(response => response.data);
}