NeoScan_Radiologist/app/modules/Auth/services/authAPI.ts
2025-08-14 20:16:03 +05:30

69 lines
2.4 KiB
TypeScript

/*
* File: authAPI.ts
* Description: API service for authentication using apisauce
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/
import { create } from 'apisauce';
import { API_CONFIG } from '../../../shared/utils/constants';
import { buildHeaders } from '../../../shared/utils/api';
const api = create({
baseURL: API_CONFIG.BASE_URL, // TODO: Replace with actual endpoint
});
/**
* login - authenticates user with email and password
*/
export const authAPI = {
login: (email: string, password: string,platform:string) => api.post('/api/auth/auth/login', { email, password,platform },buildHeaders()),
//fetch hospital list
gethospitals: () => api.get('/api/hospitals/hospitals/app_user/hospitals', {},buildHeaders()),
//user signup
signup: (formData:any) => api.post('/api/auth/auth/admin/create-user-fromapp', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
}),
//validate email
validatemail: (payload:{email:string}) => api.post('/api/auth/auth/check-email', payload,buildHeaders()),
//change password
changepassword: (payload:{password:string,token:string | undefined}) => api.post('/api/auth/onboarding/change-password', {password:payload.password},buildHeaders({token:payload.token})),
//validate username
validateusername: (username:string|undefined) => api.post('/api/auth/auth/check-username', {username},buildHeaders()),
//upload document for onboarding
uploadDocument: (formData:any, token:string | undefined) => api.post('/api/auth/onboarding/upload-id-photo', formData, {
headers: {
'Content-Type': 'multipart/form-data',
...(token && { 'Authorization': `Bearer ${token}` }),
},
}),
// Update user profile
updateUserProfile: (userId: string, profileData: {
first_name: string;
last_name: string;
}, token: string) => api.put(
`/api/auth/auth/admin/users/self/${userId}`,
profileData,
buildHeaders({ token })
),
// Change password (admin endpoint)
changePassword: (userId: string, passwordData: {
password: string;
}, token: string) => api.put(
`/api/auth/auth/admin/users/self/${userId}`,
passwordData,
buildHeaders({ token })
),
// Add more endpoints as needed
};
/*
* End of File: authAPI.ts
* Design & Developed by Tech4Biz Solutions
* Copyright (c) Spurrin Innovations. All rights reserved.
*/