refactor: pecah lib/api.ts dan constants/Styles.ts per domain
- lib/api.ts (879 baris) → 13 file di lib/api/ per domain - constants/Styles.ts (1.275 baris) → 10 file di constants/styles/ per domain - tambah docs/FILE-HEALTH.md dan referensinya ke CLAUDE.md - kedua file lama tetap sebagai re-export — zero breaking changes
This commit is contained in:
42
lib/api/user.api.ts
Normal file
42
lib/api/user.api.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import api from './client';
|
||||
|
||||
export const apiGetProfile = async ({ id }: { id: string }) => {
|
||||
const response = await api.get(`mobile/user/${id}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiEditProfile = async (data: FormData) => {
|
||||
const response = await api.put(`/mobile/user/profile`, data, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiGetUser = async ({ user, active, search, group, page }: { user: string, active: string, search: string, group?: string, page?: number }) => {
|
||||
const response = await api.get(`mobile/user?user=${user}&active=${active}&group=${group}&search=${search}&page=${page}`);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiCreateUser = async ({ data }: { data: FormData }) => {
|
||||
const response = await api.post('/mobile/user', data, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const apiDeleteUser = async (data: { user: string, isActive: boolean }, id: string) => {
|
||||
const response = await api.delete(`mobile/user/${id}`, { data })
|
||||
return response.data
|
||||
};
|
||||
|
||||
export const apiToggleApprover = async (data: { user: string, isApprover: boolean }, id: string) => {
|
||||
const response = await api.patch(`mobile/user/${id}`, data)
|
||||
return response.data
|
||||
};
|
||||
|
||||
export const apiEditUser = async (data: FormData, id: string) => {
|
||||
const response = await api.put(`/mobile/user/${id}`, data, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
})
|
||||
return response.data;
|
||||
};
|
||||
Reference in New Issue
Block a user