الملفات
back_end_oudelaa/oudelaa_dashboard/lib/api/auth.ts
boutmoun123 8863f61d00
فشلت بعض الفحوصات
Deploy To Ghaymah / deploy (push) Has been cancelled
Add Oudelaa dashboard API integration
2026-05-25 20:36:52 +03:00

35 أسطر
1.1 KiB
TypeScript

import { apiEndpoints } from "@/lib/api/endpoints";
import { fetchWithAuth } from "@/lib/auth/client";
import type { LoginResponse, SessionsResponse, SuccessMessage } from "@/types/api";
export async function loginDashboardUser(email: string, password: string) {
return fetchWithAuth<LoginResponse>(apiEndpoints.auth.login, {
method: "POST",
body: JSON.stringify({ email, password }),
});
}
export async function refreshDashboardUser(refreshToken: string) {
return fetchWithAuth<LoginResponse>(apiEndpoints.auth.refresh, {
method: "POST",
body: JSON.stringify({ refreshToken }),
});
}
export async function logoutDashboardUser(refreshToken: string) {
return fetchWithAuth<SuccessMessage>(apiEndpoints.auth.logout, {
method: "POST",
body: JSON.stringify({ refreshToken }),
});
}
export async function listSuperAdminSessions() {
return fetchWithAuth<SessionsResponse>(apiEndpoints.auth.superAdminSessions);
}
export async function revokeSuperAdminSession(sessionId: string) {
return fetchWithAuth<SuccessMessage>(apiEndpoints.auth.revokeSuperAdminSession(sessionId), {
method: "POST",
});
}