mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-10-07 16:18:57 +00:00
34 lines
859 B
TypeScript
34 lines
859 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;
|
||
|
|
},
|
||
|
|
|
||
|
|
devLogin: async (email: string, displayName: string, role: string): Promise<AuthUser> => {
|
||
|
|
const res = await apiClient.post('/auth/dev-login', { email, displayName, role });
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
getMe: async (): Promise<UserProfile> => {
|
||
|
|
const res = await apiClient.get('/users/me');
|
||
|
|
return res.data;
|
||
|
|
},
|
||
|
|
};
|