mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-10-01 04:43:13 +00:00
29 lines
652 B
TypeScript
29 lines
652 B
TypeScript
|
|
import apiClient from './client';
|
||
|
|
|
||
|
|
export interface AuthUser {
|
||
|
|
id: string;
|
||
|
|
email: string;
|
||
|
|
displayName: string;
|
||
|
|
role: 'Dispatcher' | 'Admin' | 'SysAdmin';
|
||
|
|
token: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface UserProfile {
|
||
|
|
id: string;
|
||
|
|
email: string;
|
||
|
|
displayName: string;
|
||
|
|
role: 'Dispatcher' | 'Admin' | 'SysAdmin';
|
||
|
|
}
|
||
|
|
|
||
|
|
export const authApi = {
|
||
|
|
exchangeCode: async (code: string, redirectUri: string): Promise<AuthUser> => {
|
||
|
|
const res = await apiClient.post('/auth/callback', { code, redirectUri });
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
getMe: async (): Promise<UserProfile> => {
|
||
|
|
const res = await apiClient.get('/users/me');
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
};
|